Mercurial > hg > sv-dependency-builds
annotate src/fftw-3.3.5/simd-support/vsx.c @ 127:7867fa7e1b6b
Current fftw source
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 18 Oct 2016 13:40:26 +0100 |
parents | |
children |
rev | line source |
---|---|
cannam@127 | 1 /* |
cannam@127 | 2 * Copyright (c) 2003, 2007-14 Matteo Frigo |
cannam@127 | 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology |
cannam@127 | 4 * |
cannam@127 | 5 * VSX SIMD implementation added 2015 Erik Lindahl. |
cannam@127 | 6 * Erik Lindahl places his modifications in the public domain. |
cannam@127 | 7 * |
cannam@127 | 8 * This program is free software; you can redistribute it and/or modify |
cannam@127 | 9 * it under the terms of the GNU General Public License as published by |
cannam@127 | 10 * the Free Software Foundation; either version 2 of the License, or |
cannam@127 | 11 * (at your option) any later version. |
cannam@127 | 12 * |
cannam@127 | 13 * This program is distributed in the hope that it will be useful, |
cannam@127 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
cannam@127 | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cannam@127 | 16 * GNU General Public License for more details. |
cannam@127 | 17 * |
cannam@127 | 18 * You should have received a copy of the GNU General Public License |
cannam@127 | 19 * along with this program; if not, write to the Free Software |
cannam@127 | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
cannam@127 | 21 * |
cannam@127 | 22 */ |
cannam@127 | 23 |
cannam@127 | 24 |
cannam@127 | 25 #include "ifftw.h" |
cannam@127 | 26 |
cannam@127 | 27 #if HAVE_VSX |
cannam@127 | 28 |
cannam@127 | 29 #if HAVE_SYS_SYSCTL_H |
cannam@127 | 30 # include <sys/sysctl.h> |
cannam@127 | 31 #endif |
cannam@127 | 32 |
cannam@127 | 33 #include <signal.h> |
cannam@127 | 34 #include <setjmp.h> |
cannam@127 | 35 |
cannam@127 | 36 static jmp_buf jb; |
cannam@127 | 37 |
cannam@127 | 38 static void sighandler(int x) |
cannam@127 | 39 { |
cannam@127 | 40 longjmp(jb, 1); |
cannam@127 | 41 } |
cannam@127 | 42 |
cannam@127 | 43 static int really_have_vsx(void) |
cannam@127 | 44 { |
cannam@127 | 45 void (*oldsig)(int); |
cannam@127 | 46 oldsig = signal(SIGILL, sighandler); |
cannam@127 | 47 if (setjmp(jb)) { |
cannam@127 | 48 signal(SIGILL, oldsig); |
cannam@127 | 49 return 0; |
cannam@127 | 50 } else { |
cannam@127 | 51 float mem[2]; |
cannam@127 | 52 __asm__ __volatile__ ("stxsdx 0,0,%0" :: "r" (mem) : "memory" ); |
cannam@127 | 53 signal(SIGILL, oldsig); |
cannam@127 | 54 return 1; |
cannam@127 | 55 } |
cannam@127 | 56 return 0; |
cannam@127 | 57 } |
cannam@127 | 58 |
cannam@127 | 59 int X(have_simd_vsx)(void) |
cannam@127 | 60 { |
cannam@127 | 61 static int init = 0, res; |
cannam@127 | 62 if (!init) { |
cannam@127 | 63 res = really_have_vsx(); |
cannam@127 | 64 init = 1; |
cannam@127 | 65 } |
cannam@127 | 66 return res; |
cannam@127 | 67 } |
cannam@127 | 68 |
cannam@127 | 69 #endif |