X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fppccap.c;h=13c2ca51627cba83a1a86a9e7cab85979b1b6724;hp=531f1b3be84005d74075e0445b198f42da13b87d;hb=0e716d9207e00c9d967492b3b8bb89efad16bd06;hpb=78c3e20579d3baa159c8b51b59d415b6e521614b diff --git a/crypto/ppccap.c b/crypto/ppccap.c index 531f1b3be8..13c2ca5162 100644 --- a/crypto/ppccap.c +++ b/crypto/ppccap.c @@ -4,16 +4,15 @@ #include #include #include -#ifdef __linux +#if defined(__linux) || defined(_AIX) #include #endif #include #include -#define PPC_FPU64 (1<<0) -#define PPC_ALTIVEC (1<<1) +#include "ppc_arch.h" -static int OPENSSL_ppccap_P = 0; +unsigned int OPENSSL_ppccap_P = 0; static sigset_t all_masked; @@ -25,7 +24,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U if (sizeof(size_t)==4) { -#if (defined(__APPLE__) && defined(__MACH__)) +#if 1 || (defined(__APPLE__) && defined(__MACH__)) if (num>=8 && (num&3)==0 && (OPENSSL_ppccap_P&PPC_FPU64)) return bn_mul_mont_fpu64(rp,ap,bp,np,n0,num); #else @@ -53,11 +52,28 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U } #endif +void sha256_block_p8(void *ctx,const void *inp,size_t len); +void sha256_block_ppc(void *ctx,const void *inp,size_t len); +void sha256_block_data_order(void *ctx,const void *inp,size_t len) + { + OPENSSL_ppccap_P&PPC_CRYPTO207? sha256_block_p8(ctx,inp,len): + sha256_block_ppc(ctx,inp,len); + } + +void sha512_block_p8(void *ctx,const void *inp,size_t len); +void sha512_block_ppc(void *ctx,const void *inp,size_t len); +void sha512_block_data_order(void *ctx,const void *inp,size_t len) + { + OPENSSL_ppccap_P&PPC_CRYPTO207? sha512_block_p8(ctx,inp,len): + sha512_block_ppc(ctx,inp,len); + } + static sigjmp_buf ill_jmp; static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); } void OPENSSL_ppc64_probe(void); void OPENSSL_altivec_probe(void); +void OPENSSL_crypto207_probe(void); void OPENSSL_cpuid_setup(void) { @@ -88,12 +104,14 @@ void OPENSSL_cpuid_setup(void) OPENSSL_ppccap_P = 0; #if defined(_AIX) - if (sizeof(size_t)==4 + if (sizeof(size_t)==4) + { + struct utsname uts; # if defined(_SC_AIX_KERNEL_BITMODE) - && sysconf(_SC_AIX_KERNEL_BITMODE)!=64 + if (sysconf(_SC_AIX_KERNEL_BITMODE)!=64) return; # endif - ) - return; + if (uname(&uts)!=0 || atoi(uts.version)<6) return; + } #endif memset(&ill_act,0,sizeof(ill_act)); @@ -126,6 +144,11 @@ void OPENSSL_cpuid_setup(void) { OPENSSL_altivec_probe(); OPENSSL_ppccap_P |= PPC_ALTIVEC; + if (sigsetjmp(ill_jmp,1) == 0) + { + OPENSSL_crypto207_probe(); + OPENSSL_ppccap_P |= PPC_CRYPTO207; + } } sigaction (SIGILL,&ill_oact,NULL);