Bug#767138: libfftw3 SIGILL on armhf

Edmund Grimley Evans edmund.grimley.evans at gmail.com
Thu Nov 20 10:58:08 UTC 2014


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



More information about the debian-science-maintainers mailing list