13#if (CRYPTOPP_SSE42_AVAILABLE)
14# include <nmmintrin.h>
17#if (CRYPTOPP_ARM_ACLE_HEADER)
22#if (CRYPTOPP_ARM_CRC32_AVAILABLE)
26#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
31#if CRYPTOPP_MSC_VERSION
32# pragma warning(disable: 4244)
35#ifndef EXCEPTION_EXECUTE_HANDLER
36# define EXCEPTION_EXECUTE_HANDLER 1
39#define CONST_WORD32_CAST(x) ((const word32 *)(void*)(x))
40#define CONST_WORD64_CAST(x) ((const word64 *)(void*)(x))
43extern const char CRC_SIMD_FNAME[] = __FILE__;
47#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
49 typedef void (*SigHandler)(int);
51 static jmp_buf s_jmpSIGILL;
52 static void SigIllHandler(
int)
54 longjmp(s_jmpSIGILL, 1);
59#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
63#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
65#elif (CRYPTOPP_ARM_CRC32_AVAILABLE)
66# if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
67 volatile bool result =
true;
78 __except (EXCEPTION_EXECUTE_HANDLER)
87 volatile bool result =
true;
89 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
90 if (oldHandler == SIG_ERR)
93 volatile sigset_t oldMask;
94 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
96 signal(SIGILL, oldHandler);
100 if (setjmp(s_jmpSIGILL))
104 word32 w=0, x=1;
byte z=3;
114 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
115 signal(SIGILL, oldHandler);
124#if (CRYPTOPP_ARM_CRC32_AVAILABLE)
125void CRC32_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
127 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
130 for(; n >= 16; s+=16, n-=16)
131 c =
CRC32Wx4(c, CONST_WORD32_CAST(s));
133 for(; n >= 4; s+=4, n-=4)
134 c =
CRC32W(c, *CONST_WORD32_CAST(s));
136 for(; n > 0; s++, n--)
140void CRC32C_Update_ARMV8(
const byte *s,
size_t n,
word32& c)
142 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
145 for(; n >= 16; s+=16, n-=16)
148 for(; n >= 4; s+=4, n-=4)
149 c =
CRC32CW(c, *CONST_WORD32_CAST(s));
151 for(; n > 0; s++, n--)
156#if (CRYPTOPP_SSE42_AVAILABLE)
157void CRC32C_Update_SSE42(
const byte *s,
size_t n,
word32& c)
164 for(; !IsAligned<word64>(s) && n > 0; s++, n--)
165 v = _mm_crc32_u8(v, *s);
167 for(; !IsAligned<word32>(s) && n > 0; s++, n--)
168 v = _mm_crc32_u8(v, *s);
172 for(; n >= 32; s+=32, n-=32)
174 v = _mm_crc32_u64(_mm_crc32_u64(_mm_crc32_u64(_mm_crc32_u64(v,
175 *CONST_WORD64_CAST(s+ 0)), *CONST_WORD64_CAST(s+ 8)),
176 *CONST_WORD64_CAST(s+16)), *CONST_WORD64_CAST(s+24));
180 for(; n >= 16; s+=16, n-=16)
182 v = _mm_crc32_u32(_mm_crc32_u32(_mm_crc32_u32(_mm_crc32_u32(v,
183 *CONST_WORD32_CAST(s+ 0)), *CONST_WORD32_CAST(s+ 4)),
184 *CONST_WORD32_CAST(s+ 8)), *CONST_WORD32_CAST(s+12));
187 for(; n >= 4; s+=4, n-=4)
188 v = _mm_crc32_u32(v, *CONST_WORD32_CAST(s));
190 for(; n > 0; s++, n--)
191 v = _mm_crc32_u8(v, *s);
193 c =
static_cast<word32>(v);
Support functions for ARM and vector operations.
uint32_t CRC32CWx4(uint32_t crc, const uint32_t vals[4])
CRC32-C checksum.
uint32_t CRC32CB(uint32_t crc, uint8_t val)
CRC32-C checksum.
uint32_t CRC32W(uint32_t crc, uint32_t val)
CRC32 checksum.
uint32_t CRC32B(uint32_t crc, uint8_t val)
CRC32 checksum.
uint32_t CRC32CW(uint32_t crc, uint32_t val)
CRC32-C checksum.
uint32_t CRC32Wx4(uint32_t crc, const uint32_t vals[4])
CRC32 checksum.
Library configuration file.
unsigned int word32
32-bit unsigned datatype
Utility functions for the Crypto++ library.
Crypto++ library namespace.