2021-10-05 00:30:24 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#define ALIGNED_(n) __declspec(align(n))
|
|
|
|
|
#else
|
|
|
|
|
#define ALIGNED_(n) __attribute__((aligned(n)))
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-26 19:44:47 +01:00
|
|
|
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
|
|
|
|
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
|
|
|
|
|
2021-10-05 00:30:24 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#define AVX2
|
2021-10-12 23:25:54 +01:00
|
|
|
#define SSSE3
|
2021-10-05 00:30:24 +01:00
|
|
|
#define CLMUL
|
|
|
|
|
#else
|
2021-09-28 22:30:57 +01:00
|
|
|
#define AVX2 __attribute__((target("avx2")))
|
2021-10-05 00:30:24 +01:00
|
|
|
#define SSSE3 __attribute__((target("ssse3")))
|
|
|
|
|
#define CLMUL __attribute__((target("pclmul,sse4.1")))
|
|
|
|
|
#endif
|
2021-09-28 22:30:57 +01:00
|
|
|
|
2021-10-05 02:21:51 +01:00
|
|
|
AARU_EXPORT int have_clmul(void);
|
|
|
|
|
AARU_EXPORT int have_ssse3(void);
|
|
|
|
|
AARU_EXPORT int have_avx2(void);
|
2021-09-26 19:44:47 +01:00
|
|
|
#endif
|
2021-09-29 01:27:02 +01:00
|
|
|
|
|
|
|
|
#if defined(__arm__) || defined(_M_ARM)
|
|
|
|
|
#define HWCAP_NEON (1 << 12)
|
2021-10-05 00:30:24 +01:00
|
|
|
#define HWCAP2_AES (1 << 0)
|
2021-09-29 02:49:40 +01:00
|
|
|
#define HWCAP2_CRC32 (1 << 4)
|
2021-09-29 01:27:02 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64)
|
|
|
|
|
#define HWCAP_NEON (1 << 1)
|
2021-10-05 00:30:24 +01:00
|
|
|
#define HWCAP_AES (1 << 3)
|
2021-09-29 02:49:40 +01:00
|
|
|
#define HWCAP_CRC32 (1 << 7)
|
2021-09-29 01:27:02 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
2021-10-05 02:21:51 +01:00
|
|
|
AARU_EXPORT int have_neon(void);
|
|
|
|
|
AARU_EXPORT int have_arm_crc32(void);
|
|
|
|
|
AARU_EXPORT int have_arm_crypto(void);
|
2021-10-05 00:30:24 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
|
|
|
|
|
2021-10-05 04:18:11 +01:00
|
|
|
#ifndef __ARM_FEATURE_CRC32
|
|
|
|
|
#define __ARM_FEATURE_CRC32 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-10-05 00:30:24 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
|
|
|
|
#define TARGET_ARMV8_WITH_CRC
|
2021-10-05 04:18:11 +01:00
|
|
|
#define TARGET_WITH_CRYPTO
|
|
|
|
|
#define TARGET_WITH_SIMD
|
2021-10-05 00:30:24 +01:00
|
|
|
|
|
|
|
|
#else // _MSC_VER
|
|
|
|
|
|
|
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64)
|
2021-10-05 04:18:11 +01:00
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
|
#define TARGET_ARMV8_WITH_CRC __attribute__((target("crc")))
|
|
|
|
|
#else
|
2021-10-05 00:30:24 +01:00
|
|
|
#define TARGET_ARMV8_WITH_CRC __attribute__((target("+crc")))
|
2021-10-05 04:18:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
|
#define TARGET_WITH_CRYPTO __attribute__((target("crypto")))
|
|
|
|
|
#else
|
2021-10-05 00:30:24 +01:00
|
|
|
#define TARGET_WITH_CRYPTO __attribute__((target("+crypto")))
|
2021-10-05 04:18:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
2021-10-05 00:30:24 +01:00
|
|
|
#define TARGET_WITH_SIMD
|
|
|
|
|
#else
|
2021-10-05 04:18:11 +01:00
|
|
|
|
|
|
|
|
#if __ARM_ARCH >= 8
|
|
|
|
|
|
|
|
|
|
#ifdef __clang__
|
2021-10-05 00:30:24 +01:00
|
|
|
#define TARGET_ARMV8_WITH_CRC __attribute__((target("armv8-a,crc")))
|
2021-10-05 04:18:11 +01:00
|
|
|
#else
|
|
|
|
|
#define TARGET_ARMV8_WITH_CRC __attribute__((target("arch=armv8-a+crc")))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // __ARM_ARCH >= 8
|
|
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
|
#define TARGET_WITH_CRYPTO __attribute__((target("armv8-a,crypto")))
|
|
|
|
|
#else
|
|
|
|
|
#define TARGET_WITH_CRYPTO __attribute__((target("fpu=crypto-neon-fp-armv8")))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
|
#define TARGET_WITH_SIMD __attribute__((target("neon")))
|
|
|
|
|
#else
|
|
|
|
|
#define TARGET_WITH_SIMD __attribute__((target("fpu=neon")))
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-10-05 00:30:24 +01:00
|
|
|
#endif // __aarch64__ || _M_ARM64
|
|
|
|
|
|
|
|
|
|
#endif // _MSC_VER
|
|
|
|
|
|
|
|
|
|
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|