22 #include <sys/sysctl.h>
23 #elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
25 #include <machine/cpu.h>
28 #elif defined(__linux__)
29 #include <asm/cputable.h>
30 #include <linux/auxvec.h>
35 #elif defined(__NetBSD__) || defined(__OpenBSD__)
36 #include <sys/types.h>
37 #include <sys/sysctl.h>
38 #include <machine/cpu.h>
39 #elif defined(__AMIGAOS4__)
40 #include <exec/exec.h>
41 #include <interfaces/exec.h>
42 #include <proto/exec.h>
58 extern struct ExecIFace *IExec;
60 IExec->GetCPUInfoTags(GCIT_VectorUnit, &
result, TAG_DONE);
61 if (
result == VECTORTYPE_ALTIVEC)
64 #elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
68 #ifdef PPC_FEATURE2_ARCH_2_07
72 if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
74 #ifdef PPC_FEATURE_HAS_VSX
75 if (hwcap & PPC_FEATURE_HAS_VSX)
78 #ifdef PPC_FEATURE2_ARCH_2_07
79 if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
84 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
85 #if defined(__NetBSD__) || defined(__OpenBSD__)
86 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
88 int sels[2] = {CTL_HW, HW_VECTORUNIT};
91 size_t len =
sizeof(has_vu);
94 err = sysctl(sels, 2, &has_vu, &
len,
NULL, 0);
99 #elif defined(__linux__)
103 int fd = open(
"/proc/self/auxv", O_RDONLY);
104 unsigned long buf[64] = { 0 };
110 while ((count =
read(fd, buf,
sizeof(buf))) > 0) {
111 for (
i = 0;
i < count /
sizeof(*buf);
i += 2) {
112 if (buf[
i] == AT_NULL)
114 if (buf[
i] == AT_HWCAP) {
115 if (buf[
i + 1] & PPC_FEATURE_HAS_ALTIVEC)
117 #ifdef PPC_FEATURE_HAS_VSX
118 if (buf[
i + 1] & PPC_FEATURE_HAS_VSX)
125 else if (buf[
i] == AT_HWCAP2) {
126 #ifdef PPC_FEATURE2_ARCH_2_07
127 if (buf[
i + 1] & PPC_FEATURE2_ARCH_2_07)
138 #elif CONFIG_RUNTIME_CPUDETECT && defined(__linux__)
139 #define PVR_G4_7400 0x000C
140 #define PVR_G5_970 0x0039
141 #define PVR_G5_970FX 0x003C
142 #define PVR_G5_970MP 0x0044
143 #define PVR_G5_970GX 0x0045
144 #define PVR_POWER6 0x003E
145 #define PVR_POWER7 0x003F
146 #define PVR_POWER8 0x004B
147 #define PVR_CELL_PPU 0x0070
151 __asm__ volatile(
"mfspr %0, 287" :
"=r" (proc_ver));
153 if (proc_ver & 0x8000 ||
154 proc_ver == PVR_G4_7400 ||
155 proc_ver == PVR_G5_970 ||
156 proc_ver == PVR_G5_970FX ||
157 proc_ver == PVR_G5_970MP ||
158 proc_ver == PVR_G5_970GX ||
159 proc_ver == PVR_POWER6 ||
160 proc_ver == PVR_POWER7 ||
161 proc_ver == PVR_POWER8 ||
162 proc_ver == PVR_CELL_PPU)
164 if (proc_ver == PVR_POWER7 ||
165 proc_ver == PVR_POWER8)
167 if (proc_ver == PVR_POWER8)