From 1451d1dc688d03a7e38dbf7df3ff3a2abcd7fee4 Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 17 Apr 2014 21:17:11 +0000 Subject: [PATCH] Get rid of MS Visual C compiler and Intel C compiler specific defines. --- lib/libcrypto/aes/aes_locl.h | 10 +- lib/libcrypto/aes/aes_x86core.c | 4 +- lib/libcrypto/bn/bn_lcl.h | 9 -- lib/libcrypto/camellia/camellia.c | 12 +- lib/libcrypto/cast/cast_lcl.h | 4 - lib/libcrypto/des/des_locl.h | 4 +- lib/libcrypto/engine/eng_padlock.c | 133 +-------------------- lib/libcrypto/modes/modes_lcl.h | 12 -- lib/libcrypto/rc2/rc2_skey.c | 8 -- lib/libcrypto/rc5/rc5_locl.h | 5 +- lib/libcrypto/rsa/rsa_pss.c | 8 -- lib/libcrypto/sha/sha512.c | 30 ----- lib/libcrypto/whrlpool/wp_block.c | 7 +- lib/libssl/src/crypto/aes/aes_locl.h | 10 +- lib/libssl/src/crypto/aes/aes_x86core.c | 4 +- lib/libssl/src/crypto/bn/bn_lcl.h | 9 -- lib/libssl/src/crypto/camellia/camellia.c | 12 +- lib/libssl/src/crypto/cast/cast_lcl.h | 4 - lib/libssl/src/crypto/des/des_locl.h | 4 +- lib/libssl/src/crypto/engine/eng_padlock.c | 133 +-------------------- lib/libssl/src/crypto/modes/modes_lcl.h | 12 -- lib/libssl/src/crypto/rc2/rc2_skey.c | 8 -- lib/libssl/src/crypto/rc5/rc5_locl.h | 5 +- lib/libssl/src/crypto/rsa/rsa_pss.c | 8 -- lib/libssl/src/crypto/sha/sha512.c | 30 ----- lib/libssl/src/crypto/whrlpool/wp_block.c | 7 +- 26 files changed, 16 insertions(+), 476 deletions(-) diff --git a/lib/libcrypto/aes/aes_locl.h b/lib/libcrypto/aes/aes_locl.h index 054b442d416..1d0e86331e4 100644 --- a/lib/libcrypto/aes/aes_locl.h +++ b/lib/libcrypto/aes/aes_locl.h @@ -62,14 +62,8 @@ #include #include -#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) -# define GETU32(p) SWAP(*((u32 *)(p))) -# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } -#else -# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) -# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } -#endif +#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) +#define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } #ifdef AES_LONG typedef unsigned long u32; diff --git a/lib/libcrypto/aes/aes_x86core.c b/lib/libcrypto/aes/aes_x86core.c index c5d17b31277..295ea22bb46 100644 --- a/lib/libcrypto/aes/aes_x86core.c +++ b/lib/libcrypto/aes/aes_x86core.c @@ -91,9 +91,7 @@ typedef unsigned long long u64; #endif #undef ROTATE -#if defined(_MSC_VER) || defined(__ICC) -# define ROTATE(a,n) _lrotl(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 +#if defined(__GNUC__) && __GNUC__>=2 # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ( \ diff --git a/lib/libcrypto/bn/bn_lcl.h b/lib/libcrypto/bn/bn_lcl.h index 9194e86b399..1208deb3cfa 100644 --- a/lib/libcrypto/bn/bn_lcl.h +++ b/lib/libcrypto/bn/bn_lcl.h @@ -271,15 +271,6 @@ extern "C" { : "a"(a),"g"(b) \ : "cc"); # endif -# elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT) -# if defined(_MSC_VER) && _MSC_VER>=1400 - unsigned __int64 __umulh (unsigned __int64 a,unsigned __int64 b); - unsigned __int64 _umul128 (unsigned __int64 a,unsigned __int64 b, - unsigned __int64 *h); -# pragma intrinsic(__umulh,_umul128) -# define BN_UMULT_HIGH(a,b) __umulh((a),(b)) -# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high))) -# endif # elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) # if defined(__GNUC__) && __GNUC__>=2 # if __GNUC__>=4 && __GNUC_MINOR__>=4 /* "h" constraint is no more since 4.4 */ diff --git a/lib/libcrypto/camellia/camellia.c b/lib/libcrypto/camellia/camellia.c index 75fc8991c08..da708bdf610 100644 --- a/lib/libcrypto/camellia/camellia.c +++ b/lib/libcrypto/camellia/camellia.c @@ -88,17 +88,7 @@ /* 32-bit rotations */ #if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define RightRotate(x, s) _lrotr(x, s) -# define LeftRotate(x, s) _lrotl(x, s) -# if _MSC_VER >= 1400 -# define SWAP(x) _byteswap_ulong(x) -# else -# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) -# endif -# define GETU32(p) SWAP(*((u32 *)(p))) -# define PUTU32(p,v) (*((u32 *)(p)) = SWAP((v))) -# elif defined(__GNUC__) && __GNUC__>=2 +# if defined(__GNUC__) && __GNUC__>=2 # if defined(__i386) || defined(__x86_64) # define RightRotate(x,s) ({u32 ret; asm ("rorl %1,%0":"=r"(ret):"I"(s),"0"(x):"cc"); ret; }) # define LeftRotate(x,s) ({u32 ret; asm ("roll %1,%0":"=r"(ret):"I"(s),"0"(x):"cc"); ret; }) diff --git a/lib/libcrypto/cast/cast_lcl.h b/lib/libcrypto/cast/cast_lcl.h index e756021a33d..cf0ca9e607b 100644 --- a/lib/libcrypto/cast/cast_lcl.h +++ b/lib/libcrypto/cast/cast_lcl.h @@ -152,11 +152,7 @@ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) -#define ROTL(a,n) (_lrotl(a,n)) -#else #define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) -#endif #define C_M 0x3fc #define C_0 22L diff --git a/lib/libcrypto/des/des_locl.h b/lib/libcrypto/des/des_locl.h index cf7811041ef..bbae457377e 100644 --- a/lib/libcrypto/des/des_locl.h +++ b/lib/libcrypto/des/des_locl.h @@ -152,9 +152,7 @@ } \ } -#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC) -#define ROTATE(a,n) (_lrotr(a,n)) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +#if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ("rorl %1,%0" \ diff --git a/lib/libcrypto/engine/eng_padlock.c b/lib/libcrypto/engine/eng_padlock.c index d1fc8d93151..d5d9a16bf24 100644 --- a/lib/libcrypto/engine/eng_padlock.c +++ b/lib/libcrypto/engine/eng_padlock.c @@ -101,8 +101,7 @@ compiler choice is limited to GCC and Microsoft C. */ #undef COMPILE_HW_PADLOCK #if !defined(I386_ONLY) && !defined(OPENSSL_NO_INLINE_ASM) -# if (defined(__GNUC__) && (defined(__i386__) || defined(__i386))) || \ - (defined(_MSC_VER) && defined(_M_IX86)) +# if (defined(__GNUC__) && (defined(__i386__) || defined(__i386))) # define COMPILE_HW_PADLOCK # endif #endif @@ -499,136 +498,6 @@ padlock_memcpy(void *dst,const void *src,size_t n) return dst; } - -#elif defined(_MSC_VER) -/* - * Unlike GCC these are real functions. In order to minimize impact - * on performance we adhere to __fastcall calling convention in - * order to get two first arguments passed through %ecx and %edx. - * Which kind of suits very well, as instructions in question use - * both %ecx and %edx as input:-) - */ -#define REP_XCRYPT(code) \ - _asm _emit 0xf3 \ - _asm _emit 0x0f _asm _emit 0xa7 \ - _asm _emit code - -/* BIG FAT WARNING: - * The offsets used with 'lea' instructions - * describe items of the 'padlock_cipher_data' - * structure. - */ -#define PADLOCK_XCRYPT_ASM(name,code) \ -static void * __fastcall \ - name (size_t cnt, void *cdata, \ - void *outp, const void *inp) \ -{ _asm mov eax,edx \ - _asm lea edx,[eax+16] \ - _asm lea ebx,[eax+32] \ - _asm mov edi,outp \ - _asm mov esi,inp \ - REP_XCRYPT(code) \ -} - -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ecb,0xc8) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cbc,0xd0) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cfb,0xe0) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ofb,0xe8) - -static int __fastcall -padlock_xstore(void *outp,unsigned int code) -{ _asm mov edi,ecx - _asm _emit 0x0f _asm _emit 0xa7 _asm _emit 0xc0 -} - -static void __fastcall -padlock_reload_key(void) -{ _asm pushfd _asm popfd } - -static void __fastcall -padlock_verify_context(void *cdata) -{ _asm { - pushfd - bt DWORD PTR[esp],30 - jnc skip - cmp ecx,padlock_saved_context - je skip - popfd - sub esp,4 - skip: add esp,4 - mov padlock_saved_context,ecx - } -} - -static int -padlock_available(void) -{ _asm { - pushfd - pop eax - mov ecx,eax - xor eax,1<<21 - push eax - popfd - pushfd - pop eax - xor eax,ecx - bt eax,21 - jnc noluck - mov eax,0 - cpuid - xor eax,eax - cmp ebx,'tneC' - jne noluck - cmp edx,'Hrua' - jne noluck - cmp ecx,'slua' - jne noluck - mov eax,0xC0000000 - cpuid - mov edx,eax - xor eax,eax - cmp edx,0xC0000001 - jb noluck - mov eax,0xC0000001 - cpuid - xor eax,eax - bt edx,6 - jnc skip_a - bt edx,7 - jnc skip_a - mov padlock_use_ace,1 - inc eax - skip_a: bt edx,2 - jnc skip_r - bt edx,3 - jnc skip_r - mov padlock_use_rng,1 - inc eax - skip_r: - noluck: - } -} - -static void __fastcall -padlock_bswapl(void *key) -{ _asm { - pushfd - cld - mov esi,ecx - mov edi,ecx - mov ecx,60 - up: lodsd - bswap eax - stosd - loop up - popfd - } -} - -/* MS actually specifies status of Direction Flag and compiler even - * manages to compile following as 'rep movsd' all by itself... - */ -#define padlock_memcpy(o,i,n) ((unsigned char *)memcpy((o),(i),(n)&~3U)) #endif /* ===== AES encryption/decryption ===== */ diff --git a/lib/libcrypto/modes/modes_lcl.h b/lib/libcrypto/modes/modes_lcl.h index 9d83e128444..b32c1b43c5d 100644 --- a/lib/libcrypto/modes/modes_lcl.h +++ b/lib/libcrypto/modes/modes_lcl.h @@ -60,18 +60,6 @@ typedef unsigned char u8; : "=r"(ret) : "r"((u32)(x))); \ ret; }) # endif -#elif defined(_MSC_VER) -# if _MSC_VER>=1300 -# pragma intrinsic(_byteswap_uint64,_byteswap_ulong) -# define BSWAP8(x) _byteswap_uint64((u64)(x)) -# define BSWAP4(x) _byteswap_ulong((u32)(x)) -# elif defined(_M_IX86) - __inline u32 _bswap4(u32 val) { - _asm mov eax,val - _asm bswap eax - } -# define BSWAP4(x) _bswap4(x) -# endif #endif #endif diff --git a/lib/libcrypto/rc2/rc2_skey.c b/lib/libcrypto/rc2/rc2_skey.c index 26b8dd63f69..56e47845a4f 100644 --- a/lib/libcrypto/rc2/rc2_skey.c +++ b/lib/libcrypto/rc2/rc2_skey.c @@ -85,10 +85,6 @@ static const unsigned char key_table[256]={ 0xfe,0x7f,0xc1,0xad, }; -#if defined(_MSC_VER) && defined(_ARM_) -#pragma optimize("g",off) -#endif - /* It has come to my attention that there are 2 versions of the RC2 * key schedule. One which is normal, and anther which has a hook to * use a reduced key length. @@ -140,7 +136,3 @@ void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits) for (i=127; i>=0; i-=2) *(ki--)=((k[i]<<8)|k[i-1])&0xffff; } - -#if defined(_MSC_VER) -#pragma optimize("",on) -#endif diff --git a/lib/libcrypto/rc5/rc5_locl.h b/lib/libcrypto/rc5/rc5_locl.h index d337f73fad9..314ce8909ac 100644 --- a/lib/libcrypto/rc5/rc5_locl.h +++ b/lib/libcrypto/rc5/rc5_locl.h @@ -146,10 +146,7 @@ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC) -#define ROTATE_l32(a,n) _lrotl(a,n) -#define ROTATE_r32(a,n) _lrotr(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +#if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE_l32(a,n) ({ register unsigned int ret; \ asm ("roll %%cl,%0" \ diff --git a/lib/libcrypto/rsa/rsa_pss.c b/lib/libcrypto/rsa/rsa_pss.c index 75e8c185335..bd2fde07d43 100644 --- a/lib/libcrypto/rsa/rsa_pss.c +++ b/lib/libcrypto/rsa/rsa_pss.c @@ -66,10 +66,6 @@ static const unsigned char zeroes[] = {0,0,0,0,0,0,0,0}; -#if defined(_MSC_VER) && defined(_ARM_) -#pragma optimize("g", off) -#endif - int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, const unsigned char *EM, int sLen) { @@ -294,7 +290,3 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, return ret; } - -#if defined(_MSC_VER) -#pragma optimize("",on) -#endif diff --git a/lib/libcrypto/sha/sha512.c b/lib/libcrypto/sha/sha512.c index 32bfecbf9bf..c92f18e418c 100644 --- a/lib/libcrypto/sha/sha512.c +++ b/lib/libcrypto/sha/sha512.c @@ -346,36 +346,6 @@ static const SHA_LONG64 K512[80] = { : "=r"(ret) \ : "r"(a),"K"(n)); ret; }) # endif -# elif defined(_MSC_VER) -# if defined(_WIN64) /* applies to both IA-64 and AMD64 */ -# pragma intrinsic(_rotr64) -# define ROTR(a,n) _rotr64((a),n) -# endif -# if defined(_M_IX86) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(I386_ONLY) - static SHA_LONG64 __fastcall __pull64be(const void *x) - { _asm mov edx, [ecx + 0] - _asm mov eax, [ecx + 4] - _asm xchg dh,dl - _asm xchg ah,al - _asm rol edx,16 - _asm rol eax,16 - _asm xchg dh,dl - _asm xchg ah,al - } -# else - static SHA_LONG64 __fastcall __pull64be(const void *x) - { _asm mov edx, [ecx + 0] - _asm mov eax, [ecx + 4] - _asm bswap edx - _asm bswap eax - } -# endif -# define PULL64(x) __pull64be(&(x)) -# if _MSC_VER<=1200 -# pragma inline_depth(0) -# endif -# endif # endif #endif diff --git a/lib/libcrypto/whrlpool/wp_block.c b/lib/libcrypto/whrlpool/wp_block.c index ce977083add..fadad01401d 100644 --- a/lib/libcrypto/whrlpool/wp_block.c +++ b/lib/libcrypto/whrlpool/wp_block.c @@ -77,12 +77,7 @@ typedef unsigned long long u64; #endif #undef ROTATE -#if defined(_MSC_VER) -# if defined(_WIN64) /* applies to both IA-64 and AMD64 */ -# pragma intrinsic(_rotl64) -# define ROTATE(a,n) _rotl64((a),n) -# endif -#elif defined(__GNUC__) && __GNUC__>=2 +#if defined(__GNUC__) && __GNUC__>=2 # if defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) diff --git a/lib/libssl/src/crypto/aes/aes_locl.h b/lib/libssl/src/crypto/aes/aes_locl.h index 054b442d416..1d0e86331e4 100644 --- a/lib/libssl/src/crypto/aes/aes_locl.h +++ b/lib/libssl/src/crypto/aes/aes_locl.h @@ -62,14 +62,8 @@ #include #include -#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) -# define GETU32(p) SWAP(*((u32 *)(p))) -# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } -#else -# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) -# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } -#endif +#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) +#define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } #ifdef AES_LONG typedef unsigned long u32; diff --git a/lib/libssl/src/crypto/aes/aes_x86core.c b/lib/libssl/src/crypto/aes/aes_x86core.c index c5d17b31277..295ea22bb46 100644 --- a/lib/libssl/src/crypto/aes/aes_x86core.c +++ b/lib/libssl/src/crypto/aes/aes_x86core.c @@ -91,9 +91,7 @@ typedef unsigned long long u64; #endif #undef ROTATE -#if defined(_MSC_VER) || defined(__ICC) -# define ROTATE(a,n) _lrotl(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 +#if defined(__GNUC__) && __GNUC__>=2 # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ( \ diff --git a/lib/libssl/src/crypto/bn/bn_lcl.h b/lib/libssl/src/crypto/bn/bn_lcl.h index 9194e86b399..1208deb3cfa 100644 --- a/lib/libssl/src/crypto/bn/bn_lcl.h +++ b/lib/libssl/src/crypto/bn/bn_lcl.h @@ -271,15 +271,6 @@ extern "C" { : "a"(a),"g"(b) \ : "cc"); # endif -# elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT) -# if defined(_MSC_VER) && _MSC_VER>=1400 - unsigned __int64 __umulh (unsigned __int64 a,unsigned __int64 b); - unsigned __int64 _umul128 (unsigned __int64 a,unsigned __int64 b, - unsigned __int64 *h); -# pragma intrinsic(__umulh,_umul128) -# define BN_UMULT_HIGH(a,b) __umulh((a),(b)) -# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high))) -# endif # elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) # if defined(__GNUC__) && __GNUC__>=2 # if __GNUC__>=4 && __GNUC_MINOR__>=4 /* "h" constraint is no more since 4.4 */ diff --git a/lib/libssl/src/crypto/camellia/camellia.c b/lib/libssl/src/crypto/camellia/camellia.c index 75fc8991c08..da708bdf610 100644 --- a/lib/libssl/src/crypto/camellia/camellia.c +++ b/lib/libssl/src/crypto/camellia/camellia.c @@ -88,17 +88,7 @@ /* 32-bit rotations */ #if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define RightRotate(x, s) _lrotr(x, s) -# define LeftRotate(x, s) _lrotl(x, s) -# if _MSC_VER >= 1400 -# define SWAP(x) _byteswap_ulong(x) -# else -# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) -# endif -# define GETU32(p) SWAP(*((u32 *)(p))) -# define PUTU32(p,v) (*((u32 *)(p)) = SWAP((v))) -# elif defined(__GNUC__) && __GNUC__>=2 +# if defined(__GNUC__) && __GNUC__>=2 # if defined(__i386) || defined(__x86_64) # define RightRotate(x,s) ({u32 ret; asm ("rorl %1,%0":"=r"(ret):"I"(s),"0"(x):"cc"); ret; }) # define LeftRotate(x,s) ({u32 ret; asm ("roll %1,%0":"=r"(ret):"I"(s),"0"(x):"cc"); ret; }) diff --git a/lib/libssl/src/crypto/cast/cast_lcl.h b/lib/libssl/src/crypto/cast/cast_lcl.h index e756021a33d..cf0ca9e607b 100644 --- a/lib/libssl/src/crypto/cast/cast_lcl.h +++ b/lib/libssl/src/crypto/cast/cast_lcl.h @@ -152,11 +152,7 @@ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) -#define ROTL(a,n) (_lrotl(a,n)) -#else #define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) -#endif #define C_M 0x3fc #define C_0 22L diff --git a/lib/libssl/src/crypto/des/des_locl.h b/lib/libssl/src/crypto/des/des_locl.h index cf7811041ef..bbae457377e 100644 --- a/lib/libssl/src/crypto/des/des_locl.h +++ b/lib/libssl/src/crypto/des/des_locl.h @@ -152,9 +152,7 @@ } \ } -#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC) -#define ROTATE(a,n) (_lrotr(a,n)) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +#if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ register unsigned int ret; \ asm ("rorl %1,%0" \ diff --git a/lib/libssl/src/crypto/engine/eng_padlock.c b/lib/libssl/src/crypto/engine/eng_padlock.c index d1fc8d93151..d5d9a16bf24 100644 --- a/lib/libssl/src/crypto/engine/eng_padlock.c +++ b/lib/libssl/src/crypto/engine/eng_padlock.c @@ -101,8 +101,7 @@ compiler choice is limited to GCC and Microsoft C. */ #undef COMPILE_HW_PADLOCK #if !defined(I386_ONLY) && !defined(OPENSSL_NO_INLINE_ASM) -# if (defined(__GNUC__) && (defined(__i386__) || defined(__i386))) || \ - (defined(_MSC_VER) && defined(_M_IX86)) +# if (defined(__GNUC__) && (defined(__i386__) || defined(__i386))) # define COMPILE_HW_PADLOCK # endif #endif @@ -499,136 +498,6 @@ padlock_memcpy(void *dst,const void *src,size_t n) return dst; } - -#elif defined(_MSC_VER) -/* - * Unlike GCC these are real functions. In order to minimize impact - * on performance we adhere to __fastcall calling convention in - * order to get two first arguments passed through %ecx and %edx. - * Which kind of suits very well, as instructions in question use - * both %ecx and %edx as input:-) - */ -#define REP_XCRYPT(code) \ - _asm _emit 0xf3 \ - _asm _emit 0x0f _asm _emit 0xa7 \ - _asm _emit code - -/* BIG FAT WARNING: - * The offsets used with 'lea' instructions - * describe items of the 'padlock_cipher_data' - * structure. - */ -#define PADLOCK_XCRYPT_ASM(name,code) \ -static void * __fastcall \ - name (size_t cnt, void *cdata, \ - void *outp, const void *inp) \ -{ _asm mov eax,edx \ - _asm lea edx,[eax+16] \ - _asm lea ebx,[eax+32] \ - _asm mov edi,outp \ - _asm mov esi,inp \ - REP_XCRYPT(code) \ -} - -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ecb,0xc8) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cbc,0xd0) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_cfb,0xe0) -PADLOCK_XCRYPT_ASM(padlock_xcrypt_ofb,0xe8) - -static int __fastcall -padlock_xstore(void *outp,unsigned int code) -{ _asm mov edi,ecx - _asm _emit 0x0f _asm _emit 0xa7 _asm _emit 0xc0 -} - -static void __fastcall -padlock_reload_key(void) -{ _asm pushfd _asm popfd } - -static void __fastcall -padlock_verify_context(void *cdata) -{ _asm { - pushfd - bt DWORD PTR[esp],30 - jnc skip - cmp ecx,padlock_saved_context - je skip - popfd - sub esp,4 - skip: add esp,4 - mov padlock_saved_context,ecx - } -} - -static int -padlock_available(void) -{ _asm { - pushfd - pop eax - mov ecx,eax - xor eax,1<<21 - push eax - popfd - pushfd - pop eax - xor eax,ecx - bt eax,21 - jnc noluck - mov eax,0 - cpuid - xor eax,eax - cmp ebx,'tneC' - jne noluck - cmp edx,'Hrua' - jne noluck - cmp ecx,'slua' - jne noluck - mov eax,0xC0000000 - cpuid - mov edx,eax - xor eax,eax - cmp edx,0xC0000001 - jb noluck - mov eax,0xC0000001 - cpuid - xor eax,eax - bt edx,6 - jnc skip_a - bt edx,7 - jnc skip_a - mov padlock_use_ace,1 - inc eax - skip_a: bt edx,2 - jnc skip_r - bt edx,3 - jnc skip_r - mov padlock_use_rng,1 - inc eax - skip_r: - noluck: - } -} - -static void __fastcall -padlock_bswapl(void *key) -{ _asm { - pushfd - cld - mov esi,ecx - mov edi,ecx - mov ecx,60 - up: lodsd - bswap eax - stosd - loop up - popfd - } -} - -/* MS actually specifies status of Direction Flag and compiler even - * manages to compile following as 'rep movsd' all by itself... - */ -#define padlock_memcpy(o,i,n) ((unsigned char *)memcpy((o),(i),(n)&~3U)) #endif /* ===== AES encryption/decryption ===== */ diff --git a/lib/libssl/src/crypto/modes/modes_lcl.h b/lib/libssl/src/crypto/modes/modes_lcl.h index 9d83e128444..b32c1b43c5d 100644 --- a/lib/libssl/src/crypto/modes/modes_lcl.h +++ b/lib/libssl/src/crypto/modes/modes_lcl.h @@ -60,18 +60,6 @@ typedef unsigned char u8; : "=r"(ret) : "r"((u32)(x))); \ ret; }) # endif -#elif defined(_MSC_VER) -# if _MSC_VER>=1300 -# pragma intrinsic(_byteswap_uint64,_byteswap_ulong) -# define BSWAP8(x) _byteswap_uint64((u64)(x)) -# define BSWAP4(x) _byteswap_ulong((u32)(x)) -# elif defined(_M_IX86) - __inline u32 _bswap4(u32 val) { - _asm mov eax,val - _asm bswap eax - } -# define BSWAP4(x) _bswap4(x) -# endif #endif #endif diff --git a/lib/libssl/src/crypto/rc2/rc2_skey.c b/lib/libssl/src/crypto/rc2/rc2_skey.c index 26b8dd63f69..56e47845a4f 100644 --- a/lib/libssl/src/crypto/rc2/rc2_skey.c +++ b/lib/libssl/src/crypto/rc2/rc2_skey.c @@ -85,10 +85,6 @@ static const unsigned char key_table[256]={ 0xfe,0x7f,0xc1,0xad, }; -#if defined(_MSC_VER) && defined(_ARM_) -#pragma optimize("g",off) -#endif - /* It has come to my attention that there are 2 versions of the RC2 * key schedule. One which is normal, and anther which has a hook to * use a reduced key length. @@ -140,7 +136,3 @@ void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits) for (i=127; i>=0; i-=2) *(ki--)=((k[i]<<8)|k[i-1])&0xffff; } - -#if defined(_MSC_VER) -#pragma optimize("",on) -#endif diff --git a/lib/libssl/src/crypto/rc5/rc5_locl.h b/lib/libssl/src/crypto/rc5/rc5_locl.h index d337f73fad9..314ce8909ac 100644 --- a/lib/libssl/src/crypto/rc5/rc5_locl.h +++ b/lib/libssl/src/crypto/rc5/rc5_locl.h @@ -146,10 +146,7 @@ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC) -#define ROTATE_l32(a,n) _lrotl(a,n) -#define ROTATE_r32(a,n) _lrotr(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +#if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) # define ROTATE_l32(a,n) ({ register unsigned int ret; \ asm ("roll %%cl,%0" \ diff --git a/lib/libssl/src/crypto/rsa/rsa_pss.c b/lib/libssl/src/crypto/rsa/rsa_pss.c index 75e8c185335..bd2fde07d43 100644 --- a/lib/libssl/src/crypto/rsa/rsa_pss.c +++ b/lib/libssl/src/crypto/rsa/rsa_pss.c @@ -66,10 +66,6 @@ static const unsigned char zeroes[] = {0,0,0,0,0,0,0,0}; -#if defined(_MSC_VER) && defined(_ARM_) -#pragma optimize("g", off) -#endif - int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, const unsigned char *EM, int sLen) { @@ -294,7 +290,3 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, return ret; } - -#if defined(_MSC_VER) -#pragma optimize("",on) -#endif diff --git a/lib/libssl/src/crypto/sha/sha512.c b/lib/libssl/src/crypto/sha/sha512.c index 32bfecbf9bf..c92f18e418c 100644 --- a/lib/libssl/src/crypto/sha/sha512.c +++ b/lib/libssl/src/crypto/sha/sha512.c @@ -346,36 +346,6 @@ static const SHA_LONG64 K512[80] = { : "=r"(ret) \ : "r"(a),"K"(n)); ret; }) # endif -# elif defined(_MSC_VER) -# if defined(_WIN64) /* applies to both IA-64 and AMD64 */ -# pragma intrinsic(_rotr64) -# define ROTR(a,n) _rotr64((a),n) -# endif -# if defined(_M_IX86) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(I386_ONLY) - static SHA_LONG64 __fastcall __pull64be(const void *x) - { _asm mov edx, [ecx + 0] - _asm mov eax, [ecx + 4] - _asm xchg dh,dl - _asm xchg ah,al - _asm rol edx,16 - _asm rol eax,16 - _asm xchg dh,dl - _asm xchg ah,al - } -# else - static SHA_LONG64 __fastcall __pull64be(const void *x) - { _asm mov edx, [ecx + 0] - _asm mov eax, [ecx + 4] - _asm bswap edx - _asm bswap eax - } -# endif -# define PULL64(x) __pull64be(&(x)) -# if _MSC_VER<=1200 -# pragma inline_depth(0) -# endif -# endif # endif #endif diff --git a/lib/libssl/src/crypto/whrlpool/wp_block.c b/lib/libssl/src/crypto/whrlpool/wp_block.c index ce977083add..fadad01401d 100644 --- a/lib/libssl/src/crypto/whrlpool/wp_block.c +++ b/lib/libssl/src/crypto/whrlpool/wp_block.c @@ -77,12 +77,7 @@ typedef unsigned long long u64; #endif #undef ROTATE -#if defined(_MSC_VER) -# if defined(_WIN64) /* applies to both IA-64 and AMD64 */ -# pragma intrinsic(_rotl64) -# define ROTATE(a,n) _rotl64((a),n) -# endif -#elif defined(__GNUC__) && __GNUC__>=2 +#if defined(__GNUC__) && __GNUC__>=2 # if defined(__x86_64) || defined(__x86_64__) # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) -- 2.20.1