13 #if (CRYPTOPP_SSE42_AVAILABLE)
14 # include <nmmintrin.h>
17 #if (CRYPTOPP_ARM_NEON_HEADER)
18 # include <arm_neon.h>
21 #if (CRYPTOPP_ARM_ACLE_HEADER)
23 # include <arm_acle.h>
26 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
31 #ifndef EXCEPTION_EXECUTE_HANDLER
32 # define EXCEPTION_EXECUTE_HANDLER 1
36 extern const char CRC_SIMD_FNAME[] = __FILE__;
40 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
42 typedef void (*SigHandler)(int);
44 static jmp_buf s_jmpSIGILL;
45 static void SigIllHandler(
int)
47 longjmp(s_jmpSIGILL, 1);
50 #endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
52 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
56 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
58 #elif (CRYPTOPP_ARM_CRC32_AVAILABLE)
59 # if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
60 volatile bool result =
true;
73 __except (EXCEPTION_EXECUTE_HANDLER)
82 volatile bool result =
true;
84 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
85 if (oldHandler == SIG_ERR)
88 volatile sigset_t oldMask;
89 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
91 signal(SIGILL, oldHandler);
95 if (setjmp(s_jmpSIGILL))
111 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
112 signal(SIGILL, oldHandler);
117 #endif // CRYPTOPP_ARM_CRC32_AVAILABLE
119 #endif // ARM32 or ARM64
121 #if (CRYPTOPP_ARM_CRC32_AVAILABLE)
122 void CRC32_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
124 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
127 for(; n > 4; s+=4, n-=4)
128 c = __crc32w(c, *(
const word32 *)(
void*)s);
130 for(; n > 0; s++, n--)
134 void CRC32C_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
136 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
137 c = __crc32cb(c, *s);
139 for(; n > 4; s+=4, n-=4)
140 c = __crc32cw(c, *(
const word32 *)(
void*)s);
142 for(; n > 0; s++, n--)
143 c = __crc32cb(c, *s);
147 #if (CRYPTOPP_SSE42_AVAILABLE)
148 void CRC32C_Update_SSE42(
const byte *s,
size_t n,
word32& c)
150 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
151 c = _mm_crc32_u8(c, *s);
153 for(; n > 4; s+=4, n-=4)
154 c = _mm_crc32_u32(c, *(
const word32 *)(
void*)s);
156 for(; n > 0; s++, n--)
157 c = _mm_crc32_u8(c, *s);