diff options
author | Andy Polyakov <appro@openssl.org> | 2017-04-02 22:00:15 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2017-04-04 23:10:41 +0200 |
commit | a91bfe2f55892f625d5a30171efa0fdfd2814abe (patch) | |
tree | 2f98e6d4adbe988fec163a305d24d00ea882732d /crypto/ppccap.c | |
parent | 3f524f77bc2de6deba582997a72200a41aef9fcf (diff) |
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...
[backport of 0bd93bbe4ae60e5f318b298bfe617e468a7b71d0]
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/ppccap.c')
-rw-r--r-- | crypto/ppccap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/ppccap.c b/crypto/ppccap.c index 74af4732b5..60566b1a5f 100644 --- a/crypto/ppccap.c +++ b/crypto/ppccap.c @@ -7,6 +7,10 @@ #if defined(__linux) || defined(_AIX) # include <sys/utsname.h> #endif +#if defined(__APPLE__) && defined(__MACH__) +# include <sys/types.h> +# include <sys/sysctl.h> +#endif #include <openssl/crypto.h> #include <openssl/bn.h> @@ -123,6 +127,26 @@ void OPENSSL_cpuid_setup(void) } #endif +#if defined(__APPLE__) && defined(__MACH__) + { + 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 + memset(&ill_act, 0, sizeof(ill_act)); ill_act.sa_handler = ill_handler; ill_act.sa_mask = all_masked; |