Here are my latest thoughts on what the run-time test for NEON should probably look like.
Previous proposals used two static variables instead of just one, but I think that would be less thread-safe. The variable "cached" is used in only two places, so, provided the access to it is atomic, the code has a good chance of being thread-safe even if compiled with -O0. (I don't think "volatile" would be helpful here.) #ifdef HAVE_NEON #ifdef __linux__ #ifdef __aarch64__ /* HWCAP_ASIMD is defined in <asm/hwcap.h> but not included by <sys/auxv.h>. Since all current AArch64 implementations have NEON/ASIMD it is probably better to return 1 than include a header file which is not intended for use by user programs. */ int have_neon(void) { return 1; } #else #include <sys/auxv.h> int have_neon(void) { static int cached = 2; int ret; /* This should be thread-safe in all reasonable circumstances. */ ret = cached; if (ret == 2) { ret = !!(getauxval(AT_HWCAP) & HWCAP_ARM_NEON); cached = ret; } return ret; } #endif #else #error Please implement a run-time test for NEON/ASIMD for your platform. #endif #endif -- To UNSUBSCRIBE, email to debian-arm-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/CAHDciUdc3E7NsoYtWrSZpqVRJbSeEE2cExK2=g42bxj8xaj...@mail.gmail.com