summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-11-24 17:53:25 -0500
committerJeffrey Walton <noloader@gmail.com>2017-11-24 17:53:25 -0500
commit2abf7d7bc4c3d6c019ba5aedb65f39ba53db1b8b (patch)
tree334f7b04beb61e9f9e8c017064b35089ba59f02a
parent3b80ead6959990d17bfa16bc631ea1402e11e282 (diff)
downloadcryptopp-git-2abf7d7bc4c3d6c019ba5aedb65f39ba53db1b8b.tar.gz
Fix compile on MIPS due to missing definition of NULL
Whitespace check-in
-rw-r--r--sse-simd.cpp83
1 files changed, 43 insertions, 40 deletions
diff --git a/sse-simd.cpp b/sse-simd.cpp
index 87cbeaff..868d445d 100644
--- a/sse-simd.cpp
+++ b/sse-simd.cpp
@@ -10,6 +10,9 @@
#include "config.h"
#include "cpu.h"
+// Needed by MIPS for definition of NULL
+#include "stdcpp.h"
+
#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
# include <signal.h>
# include <setjmp.h>
@@ -33,71 +36,71 @@ extern "C" {
extern "C"
{
- static jmp_buf s_jmpNoSSE2;
- static void SigIllHandlerSSE2(int)
- {
- longjmp(s_jmpNoSSE2, 1);
- }
+ static jmp_buf s_jmpNoSSE2;
+ static void SigIllHandlerSSE2(int)
+ {
+ longjmp(s_jmpNoSSE2, 1);
+ }
}
#endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
bool CPU_ProbeSSE2()
{
- // Apple switched to Intel desktops in 2005/2006 using
- // Core2 Duo's, which provides SSE2 and above.
+ // Apple switched to Intel desktops in 2005/2006 using
+ // Core2 Duo's, which provides SSE2 and above.
#if CRYPTOPP_BOOL_X64 || defined(__APPLE__)
- return true;
+ return true;
#elif defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
- return false;
+ return false;
#elif defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
__try
- {
+ {
# if CRYPTOPP_SSE2_ASM_AVAILABLE
- AS2(por xmm0, xmm0) // executing SSE2 instruction
+ AS2(por xmm0, xmm0) // executing SSE2 instruction
# elif CRYPTOPP_SSE2_INTRIN_AVAILABLE
- __m128i x = _mm_setzero_si128();
- return _mm_cvtsi128_si32(x) == 0;
+ __m128i x = _mm_setzero_si128();
+ return _mm_cvtsi128_si32(x) == 0;
# endif
- }
- // GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION
- __except (EXCEPTION_EXECUTE_HANDLER)
- {
- return false;
- }
- return true;
+ }
+ // GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ return false;
+ }
+ return true;
#else
- // longjmp and clobber warnings. Volatile is required.
- // http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
- volatile bool result = true;
+ // longjmp and clobber warnings. Volatile is required.
+ // http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
+ volatile bool result = true;
- volatile SigHandler oldHandler = signal(SIGILL, SigIllHandlerSSE2);
- if (oldHandler == SIG_ERR)
- return false;
+ volatile SigHandler oldHandler = signal(SIGILL, SigIllHandlerSSE2);
+ if (oldHandler == SIG_ERR)
+ return false;
# ifndef __MINGW32__
- volatile sigset_t oldMask;
- if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
- return false;
+ volatile sigset_t oldMask;
+ if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
+ return false;
# endif
- if (setjmp(s_jmpNoSSE2))
- result = false;
- else
- {
+ if (setjmp(s_jmpNoSSE2))
+ result = false;
+ else
+ {
# if CRYPTOPP_SSE2_ASM_AVAILABLE
- __asm __volatile ("por %xmm0, %xmm0");
+ __asm __volatile ("por %xmm0, %xmm0");
# elif CRYPTOPP_SSE2_INTRIN_AVAILABLE
- __m128i x = _mm_setzero_si128();
- result = _mm_cvtsi128_si32(x) == 0;
+ __m128i x = _mm_setzero_si128();
+ result = _mm_cvtsi128_si32(x) == 0;
# endif
- }
+ }
# ifndef __MINGW32__
- sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
+ sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR);
# endif
- signal(SIGILL, oldHandler);
- return result;
+ signal(SIGILL, oldHandler);
+ return result;
#endif
}