12#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
17#if defined(_ARCH_PWR8) || defined(__CRYPTO__)
22extern const char PPC_POWER8_FNAME[] = __FILE__;
24NAMESPACE_BEGIN(CryptoPP)
28#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
30 typedef void (*SigHandler)(int);
32 static jmp_buf s_jmpSIGILL;
33 static void SigIllHandler(
int)
35 longjmp(s_jmpSIGILL, 1);
40#if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
44#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
46#elif defined(CRYPTOPP_POWER8_AVAILABLE)
47# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
51 volatile int result =
false;
53 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
54 if (oldHandler == SIG_ERR)
57 volatile sigset_t oldMask;
58 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
60 signal(SIGILL, oldHandler);
64 if (setjmp(s_jmpSIGILL))
72#if CRYPTOPP_BIG_ENDIAN
73 __asm__ __volatile__ (
".byte 0x10, 0x01, 0x00, 0xc0 \n\t" : : :
"v0");
75 __asm__ __volatile__ (
".byte 0xc0, 0x00, 0x01, 0x10 \n\t" : : :
"v0");
80 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
81 signal(SIGILL, oldHandler);
92#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
94#elif (CRYPTOPP_POWER8_VMULL_AVAILABLE)
96 volatile bool result =
false;
98 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
99 if (oldHandler == SIG_ERR)
102 volatile sigset_t oldMask;
103 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
105 signal(SIGILL, oldHandler);
109 if (setjmp(s_jmpSIGILL))
114#if CRYPTOPP_BIG_ENDIAN
115 __asm__ __volatile__ (
".byte 0x10, 0x00, 0x0c, 0xc8 \n\t" : : :
"v0");
117 __asm__ __volatile__ (
".byte 0xc8, 0x0c, 0x00, 0x10 \n\t" : : :
"v0");
122 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
123 signal(SIGILL, oldHandler);
133#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
135#elif defined(CRYPTOPP_POWER8_AES_AVAILABLE)
136# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
140 volatile int result =
false;
142 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
143 if (oldHandler == SIG_ERR)
146 volatile sigset_t oldMask;
147 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
149 signal(SIGILL, oldHandler);
153 if (setjmp(s_jmpSIGILL))
158#if CRYPTOPP_BIG_ENDIAN
159 __asm__ __volatile__ (
".byte 0x10, 0x00, 0x0d, 0x08 \n\t"
160 ".byte 0x10, 0x00, 0x0d, 0x09 \n\t" : : :
"v0");
162 __asm__ __volatile__ (
".byte 0x08, 0x0d, 0x00, 0x10 \n\t"
163 ".byte 0x09, 0x0d, 0x00, 0x10 \n\t" : : :
"v0");
168 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
169 signal(SIGILL, oldHandler);
177bool CPU_ProbeSHA256()
179#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
181#elif defined(CRYPTOPP_POWER8_SHA_AVAILABLE)
182# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
186 volatile int result =
false;
188 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
189 if (oldHandler == SIG_ERR)
192 volatile sigset_t oldMask;
193 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
195 signal(SIGILL, oldHandler);
199 if (setjmp(s_jmpSIGILL))
204#if CRYPTOPP_BIG_ENDIAN
205 __asm__ __volatile__ (
".byte 0x10, 0x00, 0xfe, 0x82 \n\t" : : :
"v0");
207 __asm__ __volatile__ (
".byte 0x82, 0xfe, 0x00, 0x10 \n\t" : : :
"v0");
212 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
213 signal(SIGILL, oldHandler);
221bool CPU_ProbeSHA512()
223#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
225#elif defined(CRYPTOPP_POWER8_SHA_AVAILABLE)
226# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
230 volatile int result =
false;
232 volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
233 if (oldHandler == SIG_ERR)
236 volatile sigset_t oldMask;
237 if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
239 signal(SIGILL, oldHandler);
243 if (setjmp(s_jmpSIGILL))
248#if CRYPTOPP_BIG_ENDIAN
249 __asm__ __volatile__ (
".byte 0x10, 0x00, 0xfe, 0xc2 \n\t" : : :
"v0");
251 __asm__ __volatile__ (
".byte 0xc2, 0xfe, 0x00, 0x10 \n\t" : : :
"v0");
256 sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
257 signal(SIGILL, oldHandler);
Library configuration file.
Support functions for PowerPC and vector operations.