diff options
author | unknown <svoj@mysql.com> | 2005-06-16 16:35:09 +0500 |
---|---|---|
committer | unknown <svoj@mysql.com> | 2005-06-16 16:35:09 +0500 |
commit | 0dabdf15a7f8d75eddc11f53f8ef87de3783b72d (patch) | |
tree | c92c38ffa34a246fd7cbc247a2d6dc5f7628263e /extra/yassl/taocrypt/src/integer.cpp | |
parent | fc465d1497ce598d07ec75eeaafc7ca84b578ee6 (diff) | |
download | mariadb-git-0dabdf15a7f8d75eddc11f53f8ef87de3783b72d.tar.gz |
WL#2286 - Compile MySQL w/YASSL support
Merge with latest yaSSL.
extra/yassl/include/lock.hpp:
Merge with latest yaSSL.
extra/yassl/include/socket_wrapper.hpp:
Merge with latest yaSSL.
extra/yassl/mySTL/helpers.hpp:
Merge with latest yaSSL.
extra/yassl/src/lock.cpp:
Merge with latest yaSSL.
extra/yassl/src/log.cpp:
Merge with latest yaSSL.
extra/yassl/src/socket_wrapper.cpp:
Merge with latest yaSSL.
extra/yassl/src/ssl.cpp:
Merge with latest yaSSL.
extra/yassl/src/timer.cpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/include/misc.hpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/include/random.hpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/include/types.hpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/src/asn.cpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/src/integer.cpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/src/misc.cpp:
Merge with latest yaSSL.
extra/yassl/taocrypt/src/random.cpp:
Merge with latest yaSSL.
Diffstat (limited to 'extra/yassl/taocrypt/src/integer.cpp')
-rw-r--r-- | extra/yassl/taocrypt/src/integer.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 0f06b9805dd..ebfefb027b3 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -23,6 +23,7 @@ /* based on Wei Dai's integer.cpp from CryptoPP */ +#include "runtime.hpp" #include "integer.hpp" #include "modarith.hpp" #include "asn.hpp" @@ -34,6 +35,21 @@ #endif +#if defined(_MSC_VER) && defined(_WIN64) // 64 bit X overflow intrinsic + #ifdef __ia64__ + #define myUMULH __UMULH + #elif __x86_64__ + #define myUMULH __umulh + #else + #error unknown 64bit windows + #endif + +extern "C" word myUMULH(word, word); + +#pragma intrinsic (myUMULH) +#endif + + #ifdef SSE2_INTRINSICS_AVAILABLE #ifdef __GNUC__ #include <xmmintrin.h> @@ -73,16 +89,15 @@ CPP_TYPENAME AllocatorBase<T>::pointer AlignedAllocator<T>::allocate( { void* p; #ifdef TAOCRYPT_MM_MALLOC_AVAILABLE - while (!(p = _mm_malloc(sizeof(T)*n, 16))) + p = _mm_malloc(sizeof(T)*n, 16); #elif defined(TAOCRYPT_MEMALIGN_AVAILABLE) - while (!(p = memalign(16, sizeof(T)*n))) + p = memalign(16, sizeof(T)*n); #elif defined(TAOCRYPT_MALLOC_ALIGNMENT_IS_16) - while (!(p = malloc(sizeof(T)*n))) + p = malloc(sizeof(T)*n); #else - while (!(p = (byte *)malloc(sizeof(T)*n + 8))) + p = (byte *)malloc(sizeof(T)*n + 8); // assume malloc alignment is at least 8 #endif - CallNewHandler(); #ifdef TAOCRYPT_NO_ALIGNED_ALLOC assert(m_pBlock == 0); @@ -156,8 +171,14 @@ DWord() {} static DWord Multiply(word a, word b) { DWord r; + #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE r.whole_ = (dword)a * b; + + #elif defined(_MSC_VER) + r.halfs_.low = a*b; + r.halfs_.high = myUMULH(a,b); + #elif defined(__alpha__) r.halfs_.low = a*b; #ifdef __GNUC__ @@ -166,22 +187,27 @@ DWord() {} #elif defined(__DECCXX) r.halfs_.high = asm("umulh %a0, %a1, %v0", a, b); #else - #error can not implement multiply overflow + #error unknown alpha compiler #endif + #elif defined(__ia64__) r.halfs_.low = a*b; __asm__("xmpy.hu %0=%1,%2" : "=f" (r.halfs_.high) : "f" (a), "f" (b)); + #elif defined(_ARCH_PPC64) r.halfs_.low = a*b; __asm__("mulhdu %0,%1,%2" : "=r" (r.halfs_.high) : "r" (a), "r" (b) : "cc"); + #elif defined(__x86_64__) __asm__("mulq %3" : "=d" (r.halfs_.high), "=a" (r.halfs_.low) : "a" (a), "rm" (b) : "cc"); + #elif defined(__mips64) __asm__("dmultu %2,%3" : "=h" (r.halfs_.high), "=l" (r.halfs_.low) : "r" (a), "r" (b)); + #elif defined(_M_IX86) // for testing word64 t = (word64)a * b; @@ -190,6 +216,7 @@ DWord() {} #else #error can not implement DWord #endif + return r; } @@ -3936,5 +3963,6 @@ template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*); template word DivideThreeWordsByTwo<word, DWord>(word*, word, word, DWord*); #endif + } // namespace |