X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gosthash2012.c;h=9548bfb5492318313b83e631256479bbc4d43cc8;hb=3b31dea89630ecd3f741171ed3e1d4259adabf0e;hp=d6cde2154a7143371057a530473c057c3f2dbed9;hpb=b3dd924c96575efc13392530295e0c30254780b1;p=openssl-gost%2Fengine.git diff --git a/gosthash2012.c b/gosthash2012.c index d6cde21..9548bfb 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -9,9 +9,12 @@ */ #include "gosthash2012.h" -#ifdef __x86_64__ -# include -# include +#if defined(__x86_64__) || defined(__e2k__) +# ifdef _MSC_VER +# include +# else +# include +# endif #endif #if defined(_WIN32) || defined(_WINDOWS) @@ -64,7 +67,7 @@ static INLINE void add512(union uint512_u * RESTRICT x, unsigned int CF = 0; unsigned int i; -# ifdef __x86_64__ +# ifdef HAVE_ADDCARRY_U64 for (i = 0; i < 8; i++) CF = _addcarry_u64(CF, x->QWORD[i] , y->QWORD[i], &(x->QWORD[i])); # else @@ -118,7 +121,7 @@ static void g(union uint512_u *h, const union uint512_u * RESTRICT N, LOAD(N, xmm0, xmm2, xmm4, xmm6); XLPS128M(h, xmm0, xmm2, xmm4, xmm6); - LOAD(m, xmm1, xmm3, xmm5, xmm7); + ULOAD(m, xmm1, xmm3, xmm5, xmm7); XLPS128R(xmm0, xmm2, xmm4, xmm6, xmm1, xmm3, xmm5, xmm7); for (i = 0; i < 11; i++) @@ -128,12 +131,15 @@ static void g(union uint512_u *h, const union uint512_u * RESTRICT N, X128R(xmm0, xmm2, xmm4, xmm6, xmm1, xmm3, xmm5, xmm7); X128M(h, xmm0, xmm2, xmm4, xmm6); - X128M(m, xmm0, xmm2, xmm4, xmm6); - - UNLOAD(h, xmm0, xmm2, xmm4, xmm6); + ULOAD(m, xmm1, xmm3, xmm5, xmm7); + X128R(xmm0, xmm2, xmm4, xmm6, xmm1, xmm3, xmm5, xmm7); + STORE(h, xmm0, xmm2, xmm4, xmm6); +# ifndef __i386__ /* Restore the Floating-point status on the CPU */ + /* This is only required on MMX, but EXTRACT32 is using MMX */ _mm_empty(); +# endif #else union uint512_u Ki, data; unsigned int i; @@ -189,7 +195,6 @@ static INLINE void stage3(gost2012_hash_ctx * CTX) void gost2012_hash_block(gost2012_hash_ctx * CTX, const unsigned char *data, size_t len) { - register size_t chunksize; register size_t bufsize = CTX->bufsize; if (bufsize == 0) { @@ -202,7 +207,7 @@ void gost2012_hash_block(gost2012_hash_ctx * CTX, } while (len) { - chunksize = 64 - bufsize; + register size_t chunksize = 64 - bufsize; if (chunksize > len) chunksize = len;