diff options
author | Andy Polyakov <appro@openssl.org> | 2004-08-29 16:36:05 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2004-08-29 16:36:05 +0000 |
commit | 2b247cf81fbc320a313f952e2ea39cf63aa21010 (patch) | |
tree | d81b7181197eb2360ef8048ca9b488eff54b6e0f /crypto | |
parent | 746fc2526ffc17d57a5fb87568d01400cbcf62fd (diff) | |
download | openssl-new-2b247cf81fbc320a313f952e2ea39cf63aa21010.tar.gz |
OPENSSL_ia32cap final touches. Note that OPENSSL_ia32cap is no longer a
symbol, but a macro expanded as (*(OPENSSL_ia32cap_loc())). The latter
is the only one to be exported to application.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/asm/bn-586.pl | 6 | ||||
-rw-r--r-- | crypto/cryptlib.c | 14 | ||||
-rw-r--r-- | crypto/cryptlib.h | 3 | ||||
-rw-r--r-- | crypto/crypto.h | 3 | ||||
-rw-r--r-- | crypto/evp/c_all.c | 1 | ||||
-rw-r--r-- | crypto/sha/sha512.c | 7 | ||||
-rw-r--r-- | crypto/sha/sha512t.c | 8 | ||||
-rw-r--r-- | crypto/x86cpuid.pl | 8 |
8 files changed, 30 insertions, 20 deletions
diff --git a/crypto/bn/asm/bn-586.pl b/crypto/bn/asm/bn-586.pl index 0415015f65..26c2685a72 100644 --- a/crypto/bn/asm/bn-586.pl +++ b/crypto/bn/asm/bn-586.pl @@ -8,6 +8,8 @@ require "x86asm.pl"; $sse2=0; for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } +&external_label("OPENSSL_ia32cap_P") if ($sse2); + &bn_mul_add_words("bn_mul_add_words"); &bn_mul_words("bn_mul_words"); &bn_sqr_words("bn_sqr_words"); @@ -22,7 +24,7 @@ sub bn_mul_add_words { local($name)=@_; - &function_begin($name,""); + &function_begin($name,$sse2?"EXTRN\t_OPENSSL_ia32cap_P:DWORD":""); &comment(""); $Low="eax"; @@ -46,7 +48,7 @@ sub bn_mul_add_words &jz(&label("maw_finish")); if ($sse2) { - &picmeup("eax","OPENSSL_ia32cap"); + &picmeup("eax","OPENSSL_ia32cap_P"); &bt(&DWP(0,"eax"),26); &jnc(&label("maw_loop")); diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 419d37ca5d..517678dbd4 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -541,23 +541,23 @@ const char *CRYPTO_get_lock_name(int type) #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) -unsigned long OPENSSL_ia32cap=0; -unsigned long *OPENSSL_ia32cap_loc() { return &OPENSSL_ia32cap; } +unsigned long OPENSSL_ia32cap_P=0; +unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; } #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY) #define OPENSSL_CPUID_SETUP -void OPENSSL_cpuid_setup() +void OPENSSL_cpuid_setup(void) { static int trigger=0; - unsigned long OPENSSL_ia32_cpuid(); + unsigned long OPENSSL_ia32_cpuid(void); char *env; if (trigger) return; trigger=1; if ((env=getenv("OPENSSL_ia32cap"))) - OPENSSL_ia32cap = strtoul(env,NULL,0)|(1<<10); + OPENSSL_ia32cap_P = strtoul(env,NULL,0)|(1<<10); else - OPENSSL_ia32cap = OPENSSL_ia32_cpuid()|(1<<10); + OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid()|(1<<10); /* * |(1<<10) sets a reserved bit to signal that variable * was initialized already... This is to avoid interference @@ -568,7 +568,7 @@ void OPENSSL_cpuid_setup() #endif #if !defined(OPENSSL_CPUID_SETUP) -void OPENSSL_cpuid_setup() {} +void OPENSSL_cpuid_setup(void) {} #endif #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_DLL) diff --git a/crypto/cryptlib.h b/crypto/cryptlib.h index 0d6b9d59f0..8b0add7e20 100644 --- a/crypto/cryptlib.h +++ b/crypto/cryptlib.h @@ -93,6 +93,9 @@ extern "C" { #define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) #define HEX_SIZE(type) (sizeof(type)*2) +void OPENSSL_cpuid_setup(void); +extern unsigned long OPENSSL_ia32cap_P; + #ifdef __cplusplus } #endif diff --git a/crypto/crypto.h b/crypto/crypto.h index 9edb24dc6d..a1bd005c3a 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -541,6 +541,9 @@ void ERR_load_CRYPTO_strings(void); /* Reason codes. */ #define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 +unsigned long *OPENSSL_ia32cap_loc(void); +#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) + #ifdef __cplusplus } #endif diff --git a/crypto/evp/c_all.c b/crypto/evp/c_all.c index c6a3315e64..a5da52e62d 100644 --- a/crypto/evp/c_all.c +++ b/crypto/evp/c_all.c @@ -79,7 +79,6 @@ void OPENSSL_add_all_algorithms_noconf(void) * only on IA-32, but we reserve the option for all * platforms... */ - void OPENSSL_cpuid_setup(); OPENSSL_cpuid_setup(); OpenSSL_add_all_ciphers(); OpenSSL_add_all_digests(); diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c index bd1a125485..c84bd5addf 100644 --- a/crypto/sha/sha512.c +++ b/crypto/sha/sha512.c @@ -48,6 +48,8 @@ #include <openssl/sha.h> #include <openssl/opensslv.h> +#include "cryptlib.h" + const char *SHA512_version="SHA-512" OPENSSL_VERSION_PTEXT; #if defined(_M_IX86) || defined(_M_AMD64) || defined(__i386) || defined(__x86_64) @@ -347,9 +349,8 @@ static const SHA_LONG64 K512[80] = { #if defined(OPENSSL_IA32_SSE2) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY) #define GO_FOR_SSE2(ctx,in,num) do { \ - extern int OPENSSL_ia32cap; \ - void sha512_block_sse2(void *,const void *,size_t); \ - if (!(OPENSSL_ia32cap & (1<<26))) break; \ + void sha512_block_sse2(void *,const void *,size_t); \ + if (!(OPENSSL_ia32cap_P & (1<<26))) break; \ sha512_block_sse2(ctx->h,in,num); return; \ } while (0) #endif diff --git a/crypto/sha/sha512t.c b/crypto/sha/sha512t.c index 96a71efb8e..7385469bee 100644 --- a/crypto/sha/sha512t.c +++ b/crypto/sha/sha512t.c @@ -9,6 +9,7 @@ #include <openssl/sha.h> #include <openssl/evp.h> +#include <openssl/crypto.h> unsigned char app_c1[SHA512_DIGEST_LENGTH] = { 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba, @@ -70,11 +71,12 @@ int main () EVP_MD_CTX evp; #ifdef OPENSSL_IA32_SSE2 - { extern int OPENSSL_ia32cap; - char *env; + /* Alternative to this is to call OpenSSL_add_all_algorithms... + * The below code is retained exclusively for debugging purposes. */ + { char *env; if ((env=getenv("OPENSSL_ia32cap"))) - OPENSSL_ia32cap = strtol (env,NULL,0); + OPENSSL_ia32cap = strtoul (env,NULL,0); } #endif diff --git a/crypto/x86cpuid.pl b/crypto/x86cpuid.pl index 85fbef7417..da3e5bcaca 100644 --- a/crypto/x86cpuid.pl +++ b/crypto/x86cpuid.pl @@ -25,12 +25,12 @@ require "x86asm.pl"; &mov ("edx","ecx"); &function_end("OPENSSL_ia32_cpuid"); -&external_label("OPENSSL_ia32cap"); +&external_label("OPENSSL_ia32cap_P"); -&function_begin_B("OPENSSL_rdtsc"); +&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD"); &xor ("eax","eax"); &xor ("edx","edx"); - &picmeup("ecx","OPENSSL_ia32cap"); + &picmeup("ecx","OPENSSL_ia32cap_P"); &bt (&DWP(0,"ecx"),4); &jnc (&label("notsc")); &rdtsc (); @@ -38,6 +38,6 @@ require "x86asm.pl"; &ret (); &function_end_B("OPENSSL_rdtsc"); -&initseg("OPENSSL_cpuid_setup") if ($main'elf); +&initseg("OPENSSL_cpuid_setup"); &asm_finish(); |