cannam@95: /* cannam@95: * Copyright (c) 2003, 2007-11 Matteo Frigo cannam@95: * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology cannam@95: * cannam@95: * This program is free software; you can redistribute it and/or modify cannam@95: * it under the terms of the GNU General Public License as published by cannam@95: * the Free Software Foundation; either version 2 of the License, or cannam@95: * (at your option) any later version. cannam@95: * cannam@95: * This program is distributed in the hope that it will be useful, cannam@95: * but WITHOUT ANY WARRANTY; without even the implied warranty of cannam@95: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@95: * GNU General Public License for more details. cannam@95: * cannam@95: * You should have received a copy of the GNU General Public License cannam@95: * along with this program; if not, write to the Free Software cannam@95: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA cannam@95: * cannam@95: */ cannam@95: cannam@95: cannam@95: #include "ifftw.h" cannam@95: cannam@95: #if HAVE_NEON cannam@95: cannam@95: /* check for an environment where signals are known to work */ cannam@95: #if defined(unix) || defined(linux) cannam@95: # include cannam@95: # include cannam@95: cannam@95: static jmp_buf jb; cannam@95: cannam@95: static void sighandler(int x) cannam@95: { cannam@95: UNUSED(x); cannam@95: longjmp(jb, 1); cannam@95: } cannam@95: cannam@95: static int really_have_neon(void) cannam@95: { cannam@95: void (*oldsig)(int); cannam@95: oldsig = signal(SIGILL, sighandler); cannam@95: if (setjmp(jb)) { cannam@95: signal(SIGILL, oldsig); cannam@95: return 0; cannam@95: } else { cannam@95: /* paranoia: encode the instruction in binary because the cannam@95: assembler may not recognize it without -mfpu=neon */ cannam@95: /*asm volatile ("vand q0, q0, q0");*/ cannam@95: asm volatile (".long 0xf2000150"); cannam@95: signal(SIGILL, oldsig); cannam@95: return 1; cannam@95: } cannam@95: } cannam@95: cannam@95: extern void X(check_alignment_of_sse2_pm)(void); cannam@95: cannam@95: int X(have_simd_neon)(void) cannam@95: { cannam@95: static int init = 0, res; cannam@95: cannam@95: if (!init) { cannam@95: res = really_have_neon(); cannam@95: init = 1; cannam@95: } cannam@95: return res; cannam@95: } cannam@95: cannam@95: cannam@95: #else cannam@95: /* don't know how to autodetect NEON; assume it is present */ cannam@95: int X(have_simd_neon)(void) cannam@95: { cannam@95: return 1; cannam@95: } cannam@95: #endif cannam@95: cannam@95: #endif