summaryrefslogtreecommitdiff
path: root/crypto/ppccap.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2017-04-01 15:28:28 +0200
committerAndy Polyakov <appro@openssl.org>2017-04-02 20:45:59 +0200
commit0bd93bbe4ae60e5f318b298bfe617e468a7b71d0 (patch)
tree5060765563100fa73d08a7784178e3fe2de873a9 /crypto/ppccap.c
parentd83112b7fd3b0e751f8a5947e5a93db1cbbe86dc (diff)
downloadopenssl-new-0bd93bbe4ae60e5f318b298bfe617e468a7b71d0.tar.gz
crypto/ppccap.c: SIGILL-free processor capabilities detection on MacOS X.
It seems to be problematic to probe processor capabilities with SIGILL on MacOS X. The problem should be limited to cases when application code is debugged, but crashes were reported even during normal execution... Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/ppccap.c')
-rw-r--r--crypto/ppccap.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/ppccap.c b/crypto/ppccap.c
index b2b898e797..2f7cd8e6e7 100644
--- a/crypto/ppccap.c
+++ b/crypto/ppccap.c
@@ -22,6 +22,10 @@
# define __power_set(a) (_system_configuration.implementation & (a))
# endif
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+# include <sys/types.h>
+# include <sys/sysctl.h>
+#endif
#include <openssl/crypto.h>
#include <openssl/bn.h>
@@ -240,6 +244,28 @@ void OPENSSL_cpuid_setup(void)
# endif
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+ OPENSSL_ppccap_P |= PPC_FPU;
+
+ {
+ int val;
+ size_t len = sizeof(val);
+
+ if (sysctlbyname("hw.optional.64bitops", &val, &len, NULL, 0) == 0) {
+ if (val)
+ OPENSSL_ppccap_P |= PPC_FPU64;
+ }
+
+ len = sizeof(val);
+ if (sysctlbyname("hw.optional.altivec", &val, &len, NULL, 0) == 0) {
+ if (val)
+ OPENSSL_ppccap_P |= PPC_ALTIVEC;
+ }
+
+ return;
+ }
+#endif
+
if (getauxval != NULL) {
unsigned long hwcap = getauxval(HWCAP);