Merge pull request #3732 from ccawley2011/fix-arm

Fix compilation on ARM
This commit is contained in:
Weiyi Wang 2018-05-26 20:14:55 +03:00 committed by GitHub
commit 09982c3386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

View file

@ -189,13 +189,20 @@ if(MSVC AND NOT CRYPTOPP_DISABLE_ASM)
endif() endif()
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT CRYPTOPP_DISABLE_ASM) if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT CRYPTOPP_DISABLE_ASM)
if(${CMAKE_GENERATOR} MATCHES ".*ARM") check_cxx_compiler_flag(-msse2 CRYPTOPP_HAS_MSSE2)
message(STATUS "Disabling ASM because ARM is specified as target platform.") check_cxx_compiler_flag(-msse4.1 CRYPTOPP_HAS_MSSE41)
else() check_cxx_compiler_flag(-msse4.2 CRYPTOPP_HAS_MSSE42)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rijndael-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1 -maes") check_cxx_compiler_flag(-maes CRYPTOPP_HAS_MAES)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sha-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha") check_cxx_compiler_flag(-msha CRYPTOPP_HAS_MSHA)
if (CRYPTOPP_HAS_MSSE2)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sse-simd.cpp PROPERTIES COMPILE_FLAGS "-msse2") set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sse-simd.cpp PROPERTIES COMPILE_FLAGS "-msse2")
endif() endif()
if (CRYPTOPP_HAS_MSSE41 AND CRYPTOPP_HAS_MAES)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rijndael-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1 -maes")
endif()
if (CRYPTOPP_HAS_MSSE42 AND CRYPTOPP_HAS_MSHA)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sha-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha")
endif()
endif() endif()
#============================================================================ #============================================================================

View file

@ -4,7 +4,7 @@
#pragma once #pragma once
#if !defined(ARCHITECTURE_x86_64) && !defined(ARCHITECTURE_ARM) #if !defined(ARCHITECTURE_x86_64)
#include <cstdlib> // for exit #include <cstdlib> // for exit
#endif #endif
#include "common/common_types.h" #include "common/common_types.h"
@ -32,8 +32,6 @@
#ifdef ARCHITECTURE_x86_64 #ifdef ARCHITECTURE_x86_64
#define Crash() __asm__ __volatile__("int $3") #define Crash() __asm__ __volatile__("int $3")
#elif defined(ARCHITECTURE_ARM)
#define Crash() __asm__ __volatile__("trap")
#else #else
#define Crash() exit(1) #define Crash() exit(1)
#endif #endif

View file

@ -69,7 +69,7 @@ inline u32 swap32(u32 _data) {
inline u64 swap64(u64 _data) { inline u64 swap64(u64 _data) {
return _byteswap_uint64(_data); return _byteswap_uint64(_data);
} }
#elif ARCHITECTURE_ARM #elif defined(ARCHITECTURE_ARM) && (__ARM_ARCH >= 6)
inline u16 swap16(u16 _data) { inline u16 swap16(u16 _data) {
u32 data = _data; u32 data = _data;
__asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data)); __asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data));