13 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) 14 # if defined(__GNUC__) 17 # if CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE || defined(__ARM_NEON) 18 # include <arm_neon.h> 20 # if (CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) || defined(__ARM_ACLE) 21 # include <arm_acle.h> 23 #endif // ARM32 and ARM64 Headers 26 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 29 #if (CRYPTOPP_GCC_VERSION >= 40800) 30 # include <x86intrin.h> 32 #if (CRYPTOPP_MSC_VERSION >= 1400) 37 #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 38 # include <emmintrin.h> 40 #if CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 41 # include <tmmintrin.h> 43 #if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 44 # include <smmintrin.h> 45 # include <nmmintrin.h> 47 #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 48 # include <wmmintrin.h> 50 #if CRYPTOPP_BOOL_AVX_INTRINSICS_AVAILABLE 51 # include <immintrin.h> 53 #if CRYPTOPP_BOOL_AVX2_INTRINSICS_AVAILABLE 54 # include <zmmintrin.h> 56 #endif // X86/X64/X32 Headers 59 #if defined(_MSC_VER) || defined(__BORLANDC__) 60 # define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 62 # define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 66 #if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) 68 #define INTEL_PREFIX ".intel_syntax;" 69 #define INTEL_NOPREFIX ".intel_syntax;" 70 #define ATT_PREFIX ".att_syntax;" 71 #define ATT_NOPREFIX ".att_syntax;" 72 #elif defined(__GNUC__) 74 #define INTEL_PREFIX ".intel_syntax prefix;" 75 #define INTEL_NOPREFIX ".intel_syntax noprefix;" 76 #define ATT_PREFIX ".att_syntax prefix;" 77 #define ATT_NOPREFIX ".att_syntax noprefix;" 81 #define INTEL_NOPREFIX 86 #ifdef CRYPTOPP_GENERATE_X64_MASM 88 #define CRYPTOPP_X86_ASM_AVAILABLE 89 #define CRYPTOPP_BOOL_X64 1 90 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 97 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_DOXYGEN_PROCESSING 99 #define CRYPTOPP_CPUID_AVAILABLE 102 #ifndef CRYPTOPP_DOXYGEN_PROCESSING 104 extern CRYPTOPP_DLL
bool g_x86DetectionDone;
105 extern CRYPTOPP_DLL
bool g_hasMMX;
106 extern CRYPTOPP_DLL
bool g_hasISSE;
107 extern CRYPTOPP_DLL
bool g_hasSSE2;
108 extern CRYPTOPP_DLL
bool g_hasSSSE3;
109 extern CRYPTOPP_DLL
bool g_hasSSE4;
110 extern CRYPTOPP_DLL
bool g_hasAESNI;
111 extern CRYPTOPP_DLL
bool g_hasCLMUL;
112 extern CRYPTOPP_DLL
bool g_isP4;
113 extern CRYPTOPP_DLL
bool g_hasRDRAND;
114 extern CRYPTOPP_DLL
bool g_hasRDSEED;
115 extern CRYPTOPP_DLL
bool g_hasPadlockRNG;
116 extern CRYPTOPP_DLL
bool g_hasPadlockACE;
117 extern CRYPTOPP_DLL
bool g_hasPadlockACE2;
118 extern CRYPTOPP_DLL
bool g_hasPadlockPHE;
119 extern CRYPTOPP_DLL
bool g_hasPadlockPMM;
120 extern CRYPTOPP_DLL word32 g_cacheLineSize;
122 CRYPTOPP_DLL
void CRYPTOPP_API DetectX86Features();
123 CRYPTOPP_DLL
bool CRYPTOPP_API CpuId(word32 input, word32 output[4]);
124 #endif // CRYPTOPP_DOXYGEN_PROCESSING 132 #if CRYPTOPP_BOOL_X64 135 if (!g_x86DetectionDone)
147 #if CRYPTOPP_BOOL_X64 150 if (!g_x86DetectionDone)
162 #if CRYPTOPP_BOOL_X64 165 if (!g_x86DetectionDone)
177 if (!g_x86DetectionDone)
187 if (!g_x86DetectionDone)
197 if (!g_x86DetectionDone)
207 if (!g_x86DetectionDone)
217 if (!g_x86DetectionDone)
227 if (!g_x86DetectionDone)
237 if (!g_x86DetectionDone)
247 if (!g_x86DetectionDone)
249 return g_hasPadlockRNG;
257 if (!g_x86DetectionDone)
259 return g_hasPadlockACE;
267 if (!g_x86DetectionDone)
269 return g_hasPadlockACE2;
277 if (!g_x86DetectionDone)
279 return g_hasPadlockPHE;
287 if (!g_x86DetectionDone)
289 return g_hasPadlockPMM;
301 if (!g_x86DetectionDone)
303 return g_cacheLineSize;
306 #elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) 308 extern bool g_ArmDetectionDone;
309 extern bool g_hasNEON, g_hasPMULL, g_hasCRC32, g_hasAES, g_hasSHA1, g_hasSHA2;
310 void CRYPTOPP_API DetectArmFeatures();
318 inline bool HasNEON()
320 if (!g_ArmDetectionDone)
331 inline bool HasPMULL()
333 if (!g_ArmDetectionDone)
346 inline bool HasCRC32()
348 if (!g_ArmDetectionDone)
363 if (!g_ArmDetectionDone)
376 inline bool HasSHA1()
378 if (!g_ArmDetectionDone)
391 inline bool HasSHA2()
393 if (!g_ArmDetectionDone)
404 return CRYPTOPP_L1_CACHE_LINE_SIZE;
411 return CRYPTOPP_L1_CACHE_LINE_SIZE;
414 #endif // X86/X32/X64 and ARM 418 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 420 #ifdef CRYPTOPP_GENERATE_X64_MASM 421 #define AS1(x) x*newline* 422 #define AS2(x, y) x, y*newline* 423 #define AS3(x, y, z) x, y, z*newline* 424 #define ASS(x, y, a, b, c, d) x, y, a*64+b*16+c*4+d*newline* 425 #define ASL(x) label##x:*newline* 426 #define ASJ(x, y, z) x label##y*newline* 427 #define ASC(x, y) x label##y*newline* 428 #define AS_HEX(y) 0##y##h 429 #elif defined(_MSC_VER) || defined(__BORLANDC__) 430 #define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 431 #define AS1(x) __asm {x} 432 #define AS2(x, y) __asm {x, y} 433 #define AS3(x, y, z) __asm {x, y, z} 434 #define ASS(x, y, a, b, c, d) __asm {x, y, (a)*64+(b)*16+(c)*4+(d)} 435 #define ASL(x) __asm {label##x:} 436 #define ASJ(x, y, z) __asm {x label##y} 437 #define ASC(x, y) __asm {x label##y} 438 #define CRYPTOPP_NAKED __declspec(naked) 439 #define AS_HEX(y) 0x##y 441 #define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 444 #define GNU_AS1(x) #x ";" NEW_LINE 445 #define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE 446 #define GNU_AS3(x, y, z) #x ", " #y ", " #z ";" NEW_LINE 447 #define GNU_ASL(x) "\n" #x ":" NEW_LINE 448 #define GNU_ASJ(x, y, z) #x " " #y #z ";" NEW_LINE 449 #define AS1(x) GNU_AS1(x) 450 #define AS2(x, y) GNU_AS2(x, y) 451 #define AS3(x, y, z) GNU_AS3(x, y, z) 452 #define ASS(x, y, a, b, c, d) #x ", " #y ", " #a "*64+" #b "*16+" #c "*4+" #d ";" 453 #define ASL(x) GNU_ASL(x) 454 #define ASJ(x, y, z) GNU_ASJ(x, y, z) 455 #define ASC(x, y) #x " " #y ";" 456 #define CRYPTOPP_NAKED 457 #define AS_HEX(y) 0x##y 463 #ifdef CRYPTOPP_GENERATE_X64_MASM 464 #define ASM_MOD(x, y) ((x) MOD (y)) 465 #define XMMWORD_PTR XMMWORD PTR 468 #define ASM_MOD(x, y) ((x)-((x)/(y))*(y)) 473 #if CRYPTOPP_BOOL_X86 481 #define AS_REG_1d ecx 482 #define AS_REG_2d edx 483 #define AS_REG_3d esi 484 #define AS_REG_4d edi 485 #define AS_REG_5d eax 486 #define AS_REG_6d ebx 487 #define AS_REG_7d ebp 489 #define WORD_REG(x) e##x 490 #define WORD_PTR DWORD PTR 491 #define AS_PUSH_IF86(x) AS1(push e##x) 492 #define AS_POP_IF86(x) AS1(pop e##x) 493 #define AS_JCXZ jecxz 494 #elif CRYPTOPP_BOOL_X32 500 #define AS_REG_6 r10d 501 #define AS_REG_7 r11d 502 #define AS_REG_1d ecx 503 #define AS_REG_2d edx 504 #define AS_REG_3d r8d 505 #define AS_REG_4d r9d 506 #define AS_REG_5d eax 507 #define AS_REG_6d r10d 508 #define AS_REG_7d r11d 510 #define WORD_REG(x) e##x 511 #define WORD_PTR DWORD PTR 512 #define AS_PUSH_IF86(x) AS1(push r##x) 513 #define AS_POP_IF86(x) AS1(pop r##x) 514 #define AS_JCXZ jecxz 515 #elif CRYPTOPP_BOOL_X64 516 #ifdef CRYPTOPP_GENERATE_X64_MASM 524 #define AS_REG_1d ecx 525 #define AS_REG_2d edx 526 #define AS_REG_3d r8d 527 #define AS_REG_4d r9d 528 #define AS_REG_5d eax 529 #define AS_REG_6d r10d 530 #define AS_REG_7d r11d 539 #define AS_REG_1d edi 540 #define AS_REG_2d esi 541 #define AS_REG_3d edx 542 #define AS_REG_4d ecx 543 #define AS_REG_5d r8d 544 #define AS_REG_6d r9d 545 #define AS_REG_7d r10d 548 #define WORD_REG(x) r##x 549 #define WORD_PTR QWORD PTR 550 #define AS_PUSH_IF86(x) 551 #define AS_POP_IF86(x) 552 #define AS_JCXZ jrcxz 556 #define AS_XMM_OUTPUT4(labelPrefix, inputPtr, outputPtr, x0, x1, x2, x3, t, p0, p1, p2, p3, increment)\ 557 AS2( test inputPtr, inputPtr)\ 558 ASC( jz, labelPrefix##3)\ 559 AS2( test inputPtr, 15)\ 560 ASC( jnz, labelPrefix##7)\ 561 AS2( pxor xmm##x0, [inputPtr+p0*16])\ 562 AS2( pxor xmm##x1, [inputPtr+p1*16])\ 563 AS2( pxor xmm##x2, [inputPtr+p2*16])\ 564 AS2( pxor xmm##x3, [inputPtr+p3*16])\ 565 AS2( add inputPtr, increment*16)\ 566 ASC( jmp, labelPrefix##3)\ 568 AS2( movdqu xmm##t, [inputPtr+p0*16])\ 569 AS2( pxor xmm##x0, xmm##t)\ 570 AS2( movdqu xmm##t, [inputPtr+p1*16])\ 571 AS2( pxor xmm##x1, xmm##t)\ 572 AS2( movdqu xmm##t, [inputPtr+p2*16])\ 573 AS2( pxor xmm##x2, xmm##t)\ 574 AS2( movdqu xmm##t, [inputPtr+p3*16])\ 575 AS2( pxor xmm##x3, xmm##t)\ 576 AS2( add inputPtr, increment*16)\ 578 AS2( test outputPtr, 15)\ 579 ASC( jnz, labelPrefix##8)\ 580 AS2( movdqa [outputPtr+p0*16], xmm##x0)\ 581 AS2( movdqa [outputPtr+p1*16], xmm##x1)\ 582 AS2( movdqa [outputPtr+p2*16], xmm##x2)\ 583 AS2( movdqa [outputPtr+p3*16], xmm##x3)\ 584 ASC( jmp, labelPrefix##9)\ 586 AS2( movdqu [outputPtr+p0*16], xmm##x0)\ 587 AS2( movdqu [outputPtr+p1*16], xmm##x1)\ 588 AS2( movdqu [outputPtr+p2*16], xmm##x2)\ 589 AS2( movdqu [outputPtr+p3*16], xmm##x3)\ 591 AS2( add outputPtr, increment*16) 593 #endif // X86/X32/X64 597 #endif // CRYPTOPP_CPU_H bool HasISSE()
Determines SSE availability.
bool HasSSE4()
Determines SSE4 availability.
bool HasSSSE3()
Determines SSSE3 availability.
bool HasPadlockRNG()
Determines Padlock RNG availability.
bool IsP4()
Determines if the CPU is an Intel P4.
Library configuration file.
int GetCacheLineSize()
Provides the cache line size.
bool HasRDRAND()
Determines RDRAND availability.
bool HasRDSEED()
Determines RDSEED availability.
bool HasCLMUL()
Determines Carryless Multiply availability.
bool HasPadlockACE2()
Determines Padlock ACE2 availability.
bool HasPadlockPHE()
Determines Padlock PHE availability.
bool HasPadlockPMM()
Determines Padlock PMM availability.
bool HasAESNI()
Determines AES-NI availability.
bool HasSSE2()
Determines SSE2 availability.
bool HasMMX()
Determines MMX availability.
Crypto++ library namespace.
bool HasPadlockACE()
Determines Padlock ACE availability.