Fix failed compile on Ubuntu with -msse2
Also see https://github.com/noloader/cryptopp-cmake/issues/36pull/730/head
parent
99c65bdb35
commit
c992fe98a9
|
|
@ -9,7 +9,7 @@
|
||||||
// SSE2 implementation based on Botan's chacha_sse2.cpp. Many thanks
|
// SSE2 implementation based on Botan's chacha_sse2.cpp. Many thanks
|
||||||
// to Jack Lloyd and the Botan team for allowing us to use it.
|
// to Jack Lloyd and the Botan team for allowing us to use it.
|
||||||
//
|
//
|
||||||
// NEON and Power7 is upcoming.
|
// Power8 is upcoming.
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -17,16 +17,16 @@
|
||||||
#include "chacha.h"
|
#include "chacha.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE)
|
#if defined(__SSE2__) || defined(_MSC_VER)
|
||||||
# include <xmmintrin.h>
|
# include <xmmintrin.h>
|
||||||
# include <emmintrin.h>
|
# include <emmintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CRYPTOPP_SSSE3_INTRIN_AVAILABLE || CRYPTOPP_SSSE3_ASM_AVAILABLE)
|
#if defined(__SSSE3__) || defined(_MSC_VER)
|
||||||
# include <tmmintrin.h>
|
# include <tmmintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __XOP__
|
#if defined(__XOP__)
|
||||||
# include <ammintrin.h>
|
# include <ammintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -128,29 +128,31 @@ inline __m128i RotateLeft(const __m128i val)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__SSSE3__)
|
|
||||||
template <>
|
template <>
|
||||||
inline __m128i RotateLeft<8>(const __m128i val)
|
inline __m128i RotateLeft<8>(const __m128i val)
|
||||||
{
|
{
|
||||||
#ifdef __XOP__
|
#if defined(__XOP__)
|
||||||
return _mm_roti_epi32(val, 8);
|
return _mm_roti_epi32(val, 8);
|
||||||
#else
|
#elif defined(__SSSE3__)
|
||||||
const __m128i mask = _mm_set_epi8(14,13,12,15, 10,9,8,11, 6,5,4,7, 2,1,0,3);
|
const __m128i mask = _mm_set_epi8(14,13,12,15, 10,9,8,11, 6,5,4,7, 2,1,0,3);
|
||||||
return _mm_shuffle_epi8(val, mask);
|
return _mm_shuffle_epi8(val, mask);
|
||||||
|
#else
|
||||||
|
return _mm_or_si128(_mm_slli_epi32(val, 8), _mm_srli_epi32(val, 32-8));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline __m128i RotateLeft<16>(const __m128i val)
|
inline __m128i RotateLeft<16>(const __m128i val)
|
||||||
{
|
{
|
||||||
#ifdef __XOP__
|
#if defined(__XOP__)
|
||||||
return _mm_roti_epi32(val, 16);
|
return _mm_roti_epi32(val, 16);
|
||||||
#else
|
#elif defined(__SSSE3__)
|
||||||
const __m128i mask = _mm_set_epi8(13,12,15,14, 9,8,11,10, 5,4,7,6, 1,0,3,2);
|
const __m128i mask = _mm_set_epi8(13,12,15,14, 9,8,11,10, 5,4,7,6, 1,0,3,2);
|
||||||
return _mm_shuffle_epi8(val, mask);
|
return _mm_shuffle_epi8(val, mask);
|
||||||
|
#else
|
||||||
|
return _mm_or_si128(_mm_slli_epi32(val, 16), _mm_srli_epi32(val, 32-16));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // SSE3
|
|
||||||
|
|
||||||
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
#endif // CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue