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>
56 #define HWCAP_PPC_VSX (1U << 7)
57 #define HWCAP_PPC_ALTIVEC (1U << 28)
58 #define HWCAP2_PPC_ARCH_2_07 (1U << 31)
69 extern struct ExecIFace *IExec;
71 IExec->GetCPUInfoTags(GCIT_VectorUnit, &
result, TAG_DONE);
72 if (
result == VECTORTYPE_ALTIVEC)
75 #elif HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
89 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
90 #if defined(__NetBSD__) || defined(__OpenBSD__)
91 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
93 int sels[2] = {CTL_HW, HW_VECTORUNIT};
96 size_t len =
sizeof(has_vu);
99 err = sysctl(sels, 2, &has_vu, &
len,
NULL, 0);
104 #elif defined(__linux__)
108 int fd = open(
"/proc/self/auxv", O_RDONLY);
109 unsigned long buf[64] = { 0 };
115 while ((count =
read(fd, buf,
sizeof(buf))) > 0) {
116 for (
i = 0;
i < count /
sizeof(*buf);
i += 2) {
117 if (buf[
i] == AT_NULL)
137 #elif CONFIG_RUNTIME_CPUDETECT && defined(__linux__)
138 #define PVR_G4_7400 0x000C
139 #define PVR_G5_970 0x0039
140 #define PVR_G5_970FX 0x003C
141 #define PVR_G5_970MP 0x0044
142 #define PVR_G5_970GX 0x0045
143 #define PVR_POWER6 0x003E
144 #define PVR_POWER7 0x003F
145 #define PVR_POWER8 0x004B
146 #define PVR_CELL_PPU 0x0070
150 __asm__ volatile(
"mfspr %0, 287" :
"=r" (proc_ver));
152 if (proc_ver & 0x8000 ||
153 proc_ver == PVR_G4_7400 ||
154 proc_ver == PVR_G5_970 ||
155 proc_ver == PVR_G5_970FX ||
156 proc_ver == PVR_G5_970MP ||
157 proc_ver == PVR_G5_970GX ||
158 proc_ver == PVR_POWER6 ||
159 proc_ver == PVR_POWER7 ||
160 proc_ver == PVR_POWER8 ||
161 proc_ver == PVR_CELL_PPU)
163 if (proc_ver == PVR_POWER7 ||
164 proc_ver == PVR_POWER8)
166 if (proc_ver == PVR_POWER8)