mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Fix armeabi and armv7-a for Android (GH #509)
This commit is contained in:
parent
09f1a2fb38
commit
f0c2324f6b
@ -13,12 +13,19 @@ LN ?= ln -sf
|
||||
|
||||
IS_i686 := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c 'i.86')
|
||||
IS_x86_64 := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c 'x86_64|amd64')
|
||||
IS_ARM := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c 'arm')
|
||||
IS_ARMv8 := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c 'aarch32|aarch64')
|
||||
CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
|
||||
|
||||
IS_IOS ?= 0
|
||||
IS_ANDROID ?= 0
|
||||
IS_ARM_EMBEDDED ?= 0
|
||||
IS_NEON ?= 0
|
||||
|
||||
# Fixup ARM
|
||||
ifeq ($(IS_ARMv8),1)
|
||||
IS_ARM := 0
|
||||
endif
|
||||
|
||||
# Can be used by Android and Embeeded cross-compiles. Disable by default because
|
||||
# Android and embedded users typically don't run this configuration.
|
||||
@ -179,10 +186,48 @@ ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
|
||||
endif # MAKECMDGOALS
|
||||
endif # Dead code stripping
|
||||
|
||||
# Pickup ARMv7 and NEON. Do it after Android, iOS and Embedded flags have been set.
|
||||
ifeq ($(IS_ARM),1)
|
||||
IS_ARMv7 := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -dM -E - 2>/dev/null | $(EGREP) -i -c '__ARM_ARCH 7')
|
||||
ifeq ($(IS_ARMv7),1)
|
||||
IS_NEON := 1
|
||||
else
|
||||
IS_NEON := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -dM -E - 2>/dev/null | $(EGREP) -i -c -E '\<__ARM_NEON\>')
|
||||
endif
|
||||
endif
|
||||
|
||||
# ARMv7-a
|
||||
ifeq ($(IS_ARMv7),1)
|
||||
ifeq ($(findstring -march=armv7-a,$(CXXFLAGS)),)
|
||||
NEON_FLAG = -march=armv7-a
|
||||
GCM_FLAG = -march=armv7-a
|
||||
ARIA_FLAG = -march=armv7-a
|
||||
BLAKE2_FLAG = -march=armv7-a
|
||||
endif
|
||||
endif
|
||||
|
||||
# NEON
|
||||
ifeq ($(IS_NEON),1)
|
||||
ifeq ($(findstring -mfpu=neon,$(CXXFLAGS)),)
|
||||
NEON_FLAG += -mfpu=neon
|
||||
GCM_FLAG += -mfpu=neon
|
||||
ARIA_FLAG += -mfpu=neon
|
||||
BLAKE2_FLAG += -mfpu=neon
|
||||
ifeq ($(IS_ANDROID),1)
|
||||
ifeq ($(findstring -mfloat-abi=softfp,$(CXXFLAGS)),)
|
||||
NEON_FLAG += -mfloat-abi=softfp
|
||||
GCM_FLAG += -mfloat-abi=softfp
|
||||
ARIA_FLAG += -mfloat-abi=softfp
|
||||
BLAKE2_FLAG += -mfloat-abi=softfp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# ARMv8-a
|
||||
ifeq ($(IS_ARMv8),1)
|
||||
HAVE_NEON := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -march=armv8-a -dM -E - 2>/dev/null | $(EGREP) -i -c __ARM_NEON)
|
||||
ifeq ($(HAVE_NEON),1)
|
||||
ifneq ($(IS_ARMv8),0)
|
||||
IS_NEON := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -march=armv8-a -dM -E - 2>/dev/null | $(EGREP) -i -c __ARM_NEON)
|
||||
ifeq ($(IS_NEON),1)
|
||||
ARIA_FLAG = -march=armv8-a
|
||||
BLAKE2_FLAG = -march=armv8-a
|
||||
NEON_FLAG = -march=armv8-a
|
||||
|
@ -10,6 +10,10 @@
|
||||
#include "config.h"
|
||||
#include "misc.h"
|
||||
|
||||
#if !(defined(__ARM_NEON) || defined(_MSC_VER))
|
||||
# undef CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
@ -11,6 +11,10 @@
|
||||
#include "misc.h"
|
||||
#include "blake2.h"
|
||||
|
||||
#if !(defined(__ARM_NEON) || defined(_MSC_VER))
|
||||
# undef CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_SSE42_AVAILABLE)
|
||||
# include <emmintrin.h>
|
||||
# include <nmmintrin.h>
|
||||
|
7
config.h
7
config.h
@ -541,9 +541,10 @@ NAMESPACE_END
|
||||
#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
|
||||
|
||||
// Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains.
|
||||
// Android still uses ARMv5 and ARMv6 so we have to be conservative when enabling NEON.
|
||||
#if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
|
||||
# if defined(__ARM_NEON__) || defined(__ARM_FEATURE_NEON) || (CRYPTOPP_MSC_VERSION >= 1700) || \
|
||||
(CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30500)
|
||||
# if defined(__ARM_NEON__) || defined(__ARM_FEATURE_NEON) || \
|
||||
(__ARM_ARCH >= 7) || (CRYPTOPP_MSC_VERSION >= 1700)
|
||||
# define CRYPTOPP_ARM_NEON_AVAILABLE 1
|
||||
# endif
|
||||
#endif
|
||||
@ -564,7 +565,7 @@ NAMESPACE_END
|
||||
// TODO: Add MSC_VER and ARM-64 platform define when available
|
||||
#if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__apple_build_version__)
|
||||
# if (defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_MSC_VERSION >= 1910) || \
|
||||
defined(__aarch32__) || defined(__aarch64__)) && !defined(__ANDROID__)
|
||||
defined(__aarch32__) || defined(__aarch64__))
|
||||
# define CRYPTOPP_ARM_CRC32_AVAILABLE 1
|
||||
# endif
|
||||
#endif
|
||||
|
15
crc-simd.cpp
15
crc-simd.cpp
@ -11,8 +11,10 @@
|
||||
#include "misc.h"
|
||||
|
||||
// We set CRYPTOPP_ARM_CRC32_AVAILABLE based on compiler version.
|
||||
// If the crypto is not available, then we have to disable it here.
|
||||
#if !(defined(__ARM_FEATURE_CRC32) || defined(_MSC_VER))
|
||||
// If the crc is not available, then we have to disable it here.
|
||||
// Android does not provide -march=armv8-a+crc or -march=armv8.1-a+crc, so
|
||||
// it looks like we will have to disable CRC acceleration of their devices.
|
||||
#if !(defined(__ARM_FEATURE_CRC32) || defined(_MSC_VER)) || defined(__ANDROID__)
|
||||
# undef CRYPTOPP_ARM_CRC32_AVAILABLE
|
||||
#endif
|
||||
|
||||
@ -20,12 +22,11 @@
|
||||
# include <nmmintrin.h>
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
#if (CRYPTOPP_ARM_CRC32_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
|
||||
|
7
crc.cpp
7
crc.cpp
@ -8,6 +8,13 @@
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
// We set CRYPTOPP_ARM_CRC32_AVAILABLE based on compiler version.
|
||||
// Android does not provide -march=armv8-a+crc or -march=armv8.1-a+crc, so
|
||||
// it looks like we will have to disable CRC acceleration of their devices.
|
||||
#if defined(__ANDROID__)
|
||||
# undef CRYPTOPP_ARM_CRC32_AVAILABLE
|
||||
#endif
|
||||
|
||||
// crc-simd.cpp
|
||||
#if (CRYPTOPP_ARM_CRC32_AVAILABLE)
|
||||
extern void CRC32_Update_ARMV8(const byte *s, size_t n, word32& c);
|
||||
|
@ -35,7 +35,7 @@
|
||||
# include <wmmintrin.h>
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE || CRYPTOPP_ARM_PMULL_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
#include "config.h"
|
||||
#include "stdcpp.h"
|
||||
|
||||
#if !(defined(__ARM_NEON) || defined(_MSC_VER))
|
||||
# undef CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
@ -41,10 +41,9 @@
|
||||
|
||||
#if (CRYPTOPP_ARM_AES_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_ALTIVEC_AVAILABLE)
|
||||
|
@ -22,12 +22,11 @@
|
||||
# include <immintrin.h>
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
#if (CRYPTOPP_ARM_SHA_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
|
||||
|
@ -29,10 +29,9 @@
|
||||
|
||||
#if (CRYPTOPP_ARM_SHA_AVAILABLE)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
|
||||
# include <arm_acle.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
|
||||
|
Loading…
Reference in New Issue
Block a user