aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-11-28 14:30:45 +0000
committerlloyd <[email protected]>2011-11-28 14:30:45 +0000
commit173a01fc66a9b7d76903e5134fc15d1bb3cb276c (patch)
tree067b6de5cf3c29d3f4620efeaecc673e5d6ebbe1
parent2f2581bf38f7c4c5618aec5012a33c02fed9a978 (diff)
Add AltiVec detection on OpenBSD, contributed by Brad Smith in PR 162
-rw-r--r--doc/log.txt2
-rw-r--r--src/utils/cpuid.cpp16
2 files changed, 17 insertions, 1 deletions
diff --git a/doc/log.txt b/doc/log.txt
index d82f47157..dfc49d90c 100644
--- a/doc/log.txt
+++ b/doc/log.txt
@@ -21,6 +21,8 @@ Version 1.10.2, Not Yet Released
* Add AltiVec detection for IBM POWER7 processors.
+* Add AltiVec detection for OpenBSD, contributed by Brad Smith (PR 162)
+
* Don't set a soname on OpenBSD, as it doesn't support it (PR 158)
* Fix a configure.py incompatability with the subprocess module
diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp
index c5710d689..f6581f09c 100644
--- a/src/utils/cpuid.cpp
+++ b/src/utils/cpuid.cpp
@@ -10,10 +10,20 @@
#include <botan/get_byte.h>
#include <botan/mem_ops.h>
+#if defined(BOTAN_TARGET_CPU_IS_PPC_FAMILY)
+
#if defined(BOTAN_TARGET_OS_IS_DARWIN)
#include <sys/sysctl.h>
#endif
+#if defined(BOTAN_TARGET_OS_IS_OPENBSD)
+ #include <sys/param.h>
+ #include <sys/sysctl.h>
+ #include <machine/cpu.h>
+#endif
+
+#endif
+
#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY)
#if defined(BOTAN_BUILD_COMPILER_IS_MSVC)
@@ -106,10 +116,14 @@ u32bit get_x86_cache_line_size()
bool altivec_check_sysctl()
{
-#if defined(BOTAN_TARGET_OS_IS_DARWIN)
+#if defined(BOTAN_TARGET_OS_IS_DARWIN) || defined(BOTAN_TARGET_OS_IS_OPENBSD)
+#if defined(BOTAN_TARGET_OS_IS_OPENBSD)
+ int sels[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+#else
// From Apple's docs
int sels[2] = { CTL_HW, HW_VECTORUNIT };
+#endif
int vector_type = 0;
size_t length = sizeof(vector_type);
int error = sysctl(sels, 2, &vector_type, &length, NULL, 0);