mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
DRYer
This commit is contained in:
@@ -119,12 +119,13 @@ init_simd(void *x) {
|
|||||||
PyObject *module = (PyObject*)x;
|
PyObject *module = (PyObject*)x;
|
||||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||||
#define A(x, val) { Py_INCREF(Py_##val); if (0 != PyModule_AddObject(module, #x, Py_##val)) return false; }
|
#define A(x, val) { Py_INCREF(Py_##val); if (0 != PyModule_AddObject(module, #x, Py_##val)) return false; }
|
||||||
|
#define do_check() has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2") != 0;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#ifdef __arm64__
|
#ifdef __arm64__
|
||||||
// simde takes care of NEON on Apple Silicon
|
// simde takes care of NEON on Apple Silicon
|
||||||
has_sse4_2 = true; has_avx2 = true;
|
has_sse4_2 = true; has_avx2 = true;
|
||||||
#else
|
#else
|
||||||
has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2") != 0;
|
do_check();
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
@@ -132,9 +133,10 @@ init_simd(void *x) {
|
|||||||
// basic AVX2 and SSE4.2 intrinsics, so hopefully they work on ARM
|
// basic AVX2 and SSE4.2 intrinsics, so hopefully they work on ARM
|
||||||
has_sse4_2 = true; has_avx2 = true;
|
has_sse4_2 = true; has_avx2 = true;
|
||||||
#else
|
#else
|
||||||
has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2") != 0;
|
do_check();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#undef do_check
|
||||||
if (has_avx2) {
|
if (has_avx2) {
|
||||||
A(has_avx2, True);
|
A(has_avx2, True);
|
||||||
find_either_of_two_bytes_impl = find_either_of_two_bytes_256;
|
find_either_of_two_bytes_impl = find_either_of_two_bytes_256;
|
||||||
|
|||||||
Reference in New Issue
Block a user