13 #if (CRYPTOPP_SSE42_AVAILABLE)
14 # include <nmmintrin.h>
18 #if (CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(_M_ARM64)
19 # include <arm_neon.h>
22 #if (CRYPTOPP_ARM_ACLE_AVAILABLE)
24 # include <arm_acle.h>
27 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
32 #ifndef EXCEPTION_EXECUTE_HANDLER
33 # define EXCEPTION_EXECUTE_HANDLER 1
37 extern const char CRC_SIMD_FNAME[] = __FILE__;
41 #ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
43 typedef void (*SigHandler)(int);
45 static jmp_buf s_jmpSIGILL;
46 static void SigIllHandler(
int)
48 longjmp(s_jmpSIGILL, 1);
51 #endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
53 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
57 #if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
59 #elif (CRYPTOPP_ARM_CRC32_AVAILABLE)
60 # if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
61 volatile bool result =
true;
64 word32 w=0, x=1; word16 y=2;
byte z=3;
74 __except (EXCEPTION_EXECUTE_HANDLER)
83 volatile bool result =
true;
85 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
86 if (oldHandler == SIG_ERR)
89 volatile sigset_t oldMask;
90 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
93 if (setjmp(s_jmpSIGILL))
97 word32 w=0, x=1; word16 y=2;
byte z=3;
109 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
110 signal(SIGILL, oldHandler);
115 #endif // CRYPTOPP_ARM_CRC32_AVAILABLE
117 #endif // ARM32 or ARM64
119 #if (CRYPTOPP_ARM_CRC32_AVAILABLE)
120 void CRC32_Update_ARMV8(
const byte *s,
size_t n, word32& c)
122 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
125 for(; n > 4; s+=4, n-=4)
126 c = __crc32w(c, *(
const word32 *)(
void*)s);
128 for(; n > 0; s++, n--)
132 void CRC32C_Update_ARMV8(
const byte *s,
size_t n, word32& c)
134 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
135 c = __crc32cb(c, *s);
137 for(; n > 4; s+=4, n-=4)
138 c = __crc32cw(c, *(
const word32 *)(
void*)s);
140 for(; n > 0; s++, n--)
141 c = __crc32cb(c, *s);
145 #if (CRYPTOPP_SSE42_AVAILABLE)
146 void CRC32C_Update_SSE42(
const byte *s,
size_t n, word32& c)
148 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
149 c = _mm_crc32_u8(c, *s);
151 for(; n > 4; s+=4, n-=4)
152 c = _mm_crc32_u32(c, *(
const word32 *)(
void*)s);
154 for(; n > 0; s++, n--)
155 c = _mm_crc32_u8(c, *s);