diff --git a/GNUmakefile b/GNUmakefile index e7501c0f..4f4cb21d 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -30,16 +30,16 @@ else GREP ?= grep endif -IS_X86 := $(shell uname -m | $(GREP) -v "64" | $(GREP) -i -c -E "i.86|x86|i86") -IS_X64 := $(shell uname -m | $(GREP) -i -c -E "(_64|d64)") -IS_PPC32 := $(shell uname -m | $(GREP) -i -v "64" | $(GREP) -i -c -E "ppc|power") -IS_PPC64 := $(shell uname -m | $(GREP) -i -c -E "ppc64|power64") -IS_ARM32 := $(shell uname -m | $(GREP) -i -v "64" | $(GREP) -i -c -E 'armhf|arm7l|eabihf') -IS_ARM64 := $(shell uname -m | $(GREP) -i -c 'aarch64') -IS_ARMV8 ?= $(shell uname -m | $(GREP) -i -c -E 'aarch32|aarch64') -IS_NEON ?= $(shell uname -m | $(GREP) -i -c -E 'armv7|armv8|aarch32|aarch64') -IS_SPARC := $(shell uname -m | $(GREP) -i -c "sparc") -IS_SPARC64 := $(shell uname -m | $(GREP) -i -c "sparc64") +IS_X86 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -v "64" | $(GREP) -i -c -E "i.86|x86|i86") +IS_X64 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c -E "(_64|d64)") +IS_PPC32 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -v "64" | $(GREP) -i -c -E "ppc|power") +IS_PPC64 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c -E "ppc64|power64") +IS_ARM32 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -v "64" | $(GREP) -i -c -E 'armhf|arm7l|eabihf') +IS_ARM64 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c 'aarch64') +IS_ARMV8 ?= $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c -E 'aarch32|aarch64') +IS_NEON ?= $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c -E 'armv7|armv8|aarch32|aarch64') +IS_SPARC := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c "sparc") +IS_SPARC64 := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | $(GREP) -i -c "sparc64") IS_AIX := $(shell uname -s | $(GREP) -i -c 'aix') IS_SUN := $(shell uname -s | $(GREP) -i -c "SunOS") diff --git a/cpu.cpp b/cpu.cpp index ed341e60..a354ed9f 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -54,6 +54,15 @@ NAMESPACE_BEGIN(CryptoPP) extern "C" { typedef void (*SigHandler)(int); }; + +extern "C" +{ + static jmp_buf s_jmpNoCPUID; + static void SigIllHandlerCPUID(int) + { + longjmp(s_jmpNoCPUID, 1); + } +} #endif // Not CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY // *************************** IA-32 CPUs *************************** @@ -83,17 +92,6 @@ inline bool CpuId(word32 func, word32 subfunc, word32 output[4]) #else -#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY -extern "C" -{ - static jmp_buf s_jmpNoCPUID; - static void SigIllHandlerCPUID(int) - { - longjmp(s_jmpNoCPUID, 1); - } -} -#endif - // Borland/Embarcadero and Issue 498 // cpu.cpp (131): E2211 Inline assembly not allowed in inline and template functions bool CpuId(word32 func, word32 subfunc, word32 output[4]) @@ -297,7 +295,7 @@ void DetectX86Features() if (!g_cacheLineSize) g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; - g_x86DetectionDone = true; + *const_cast(&g_x86DetectionDone) = true; } // *************************** ARM-32, Aarch32 and Aarch64 *************************** @@ -561,7 +559,7 @@ void DetectArmFeatures() if (!g_cacheLineSize) g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; - g_ArmDetectionDone = true; + *const_cast(&g_ArmDetectionDone) = true; } // *************************** PowerPC and PowerPC64 *************************** @@ -683,7 +681,7 @@ void DetectPowerpcFeatures() if (g_cacheLineSize <= 0) g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; - g_PowerpcDetectionDone = true; + *const_cast(&g_PowerpcDetectionDone) = true; } #endif diff --git a/sse-simd.cpp b/sse-simd.cpp index 192066d7..0bad4a48 100644 --- a/sse-simd.cpp +++ b/sse-simd.cpp @@ -42,7 +42,9 @@ extern "C" bool CPU_ProbeSSE2() { -#if CRYPTOPP_BOOL_X64 + // 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; #elif defined(CRYPTOPP_NO_CPU_FEATURE_PROBES) return false;