patch-simd_jsimd_powerpc_c 914 B

123456789101112131415161718192021222324252627282930313233
  1. $OpenBSD: patch-simd_jsimd_powerpc_c,v 1.1 2016/12/03 11:22:50 landry Exp $
  2. Detect Altivec support on ppc.
  3. --- simd/jsimd_powerpc.c.orig Wed Sep 21 01:36:59 2016
  4. +++ simd/jsimd_powerpc.c Fri Dec 2 19:23:14 2016
  5. @@ -26,6 +26,12 @@
  6. #include <string.h>
  7. #include <ctype.h>
  8. +#if defined(__OpenBSD__)
  9. +#include <sys/param.h>
  10. +#include <sys/sysctl.h>
  11. +#include <machine/cpu.h>
  12. +#endif
  13. +
  14. static unsigned int simd_support = ~0;
  15. #if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
  16. @@ -116,6 +122,12 @@ init_simd (void)
  17. if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
  18. break;
  19. }
  20. +#elif defined(__OpenBSD__)
  21. + int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
  22. + int altivec;
  23. + size_t len = sizeof(altivec);
  24. + if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0)
  25. + simd_support |= JSIMD_ALTIVEC;
  26. #endif
  27. /* Force different settings through environment variables */