22 #include <sys/sysctl.h> 
   23 #elif defined(__linux__) 
   24 #include <asm/cputable.h> 
   25 #include <linux/auxvec.h> 
   30 #elif defined(__NetBSD__) || defined(__OpenBSD__) 
   31 #include <sys/types.h> 
   32 #include <sys/sysctl.h> 
   33 #include <machine/cpu.h> 
   34 #elif defined(__AMIGAOS4__) 
   35 #include <exec/exec.h> 
   36 #include <interfaces/exec.h> 
   37 #include <proto/exec.h> 
   53     extern struct ExecIFace *IExec;
 
   55     IExec->GetCPUInfoTags(GCIT_VectorUnit, &
result, TAG_DONE);
 
   56     if (
result == VECTORTYPE_ALTIVEC)
 
   59 #elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) 
   60 #if defined(__NetBSD__) || defined(__OpenBSD__) 
   61     int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
 
   63     int sels[2] = {CTL_HW, HW_VECTORUNIT};
 
   66     size_t len = 
sizeof(has_vu);
 
   69     err = sysctl(sels, 2, &has_vu, &
len, 
NULL, 0);
 
   74 #elif defined(__linux__) 
   78     int fd = open(
"/proc/self/auxv", O_RDONLY);
 
   79     unsigned long buf[64] = { 0 };
 
   85     while ((count = 
read(fd, buf, 
sizeof(buf))) > 0) {
 
   86         for (
i = 0; 
i < count / 
sizeof(*buf); 
i += 2) {
 
   87             if (buf[
i] == AT_NULL)
 
   89             if (buf[
i] == AT_HWCAP) {
 
   90                 if (buf[
i + 1] & PPC_FEATURE_HAS_ALTIVEC)
 
   92 #ifdef PPC_FEATURE_HAS_VSX 
   93                 if (buf[
i + 1] & PPC_FEATURE_HAS_VSX)
 
  100             else if (buf[
i] == AT_HWCAP2) {
 
  101 #ifdef PPC_FEATURE2_ARCH_2_07 
  102                 if (buf[
i + 1] & PPC_FEATURE2_ARCH_2_07)
 
  113 #elif CONFIG_RUNTIME_CPUDETECT && defined(__linux__) 
  114 #define PVR_G4_7400  0x000C 
  115 #define PVR_G5_970   0x0039 
  116 #define PVR_G5_970FX 0x003C 
  117 #define PVR_G5_970MP 0x0044 
  118 #define PVR_G5_970GX 0x0045 
  119 #define PVR_POWER6   0x003E 
  120 #define PVR_POWER7   0x003F 
  121 #define PVR_POWER8   0x004B 
  122 #define PVR_CELL_PPU 0x0070 
  126     __asm__ volatile(
"mfspr %0, 287" : 
"=r" (proc_ver));
 
  128     if (proc_ver  & 0x8000 ||
 
  129         proc_ver == PVR_G4_7400  ||
 
  130         proc_ver == PVR_G5_970   ||
 
  131         proc_ver == PVR_G5_970FX ||
 
  132         proc_ver == PVR_G5_970MP ||
 
  133         proc_ver == PVR_G5_970GX ||
 
  134         proc_ver == PVR_POWER6   ||
 
  135         proc_ver == PVR_POWER7   ||
 
  136         proc_ver == PVR_POWER8   ||
 
  137         proc_ver == PVR_CELL_PPU)
 
  139     if (proc_ver == PVR_POWER7 ||
 
  140         proc_ver == PVR_POWER8)
 
  142     if (proc_ver == PVR_POWER8)