2
* Copyright (c) 2003, 2006 Matteo Frigo
3
* Copyright (c) 2003, 2006 Massachusetts Institute of Technology
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/* $Id: altivec.c,v 1.14 2006-01-05 03:04:27 stevenj Exp $ */
29
#include <sys/sysctl.h>
32
#if HAVE_SYS_SYSCTL_H && HAVE_SYSCTL && defined(CTL_HW) && defined(HW_VECTORUNIT)
34
static int really_have_altivec(void)
39
mib[1] = HW_VECTORUNIT;
40
len = sizeof(altivecp);
41
sysctl(mib, 2, &altivecp, &len, NULL, 0);
44
#else /* HAVE_SYS_SYSCTL_H etc. */
51
static void sighandler(int x)
56
static int really_have_altivec(void)
59
oldsig = signal(SIGILL, sighandler);
61
signal(SIGILL, oldsig);
64
__asm__ __volatile__ (".long 0x10000484"); /* vor 0,0,0 */
65
signal(SIGILL, oldsig);
74
static int init = 0, res;
76
res = really_have_altivec();