2021-10-13 03:25:16 +01:00
|
|
|
/*
|
2021-10-13 03:46:47 +01:00
|
|
|
* This file is part of the Aaru Data Preservation Suite.
|
2024-12-19 15:21:40 +00:00
|
|
|
* Copyright (c) 2019-2025 Natalia Portillo.
|
2021-10-13 03:46:47 +01:00
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2021-10-13 03:25:16 +01:00
|
|
|
|
2021-10-13 03:30:02 +01:00
|
|
|
#ifndef AARU_CHECKSUMS_NATIVE_SIMD_H
|
|
|
|
|
#define AARU_CHECKSUMS_NATIVE_SIMD_H
|
|
|
|
|
|
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
|
|
|
|
|
|
2023-09-23 18:55:52 +01:00
|
|
|
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
2021-09-26 19:44:47 +01:00
|
|
|
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
|
|
|
|
|
2021-10-05 00:30:24 +01:00
|
|
|
#ifdef _MSC_VER
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_AVX2
|
|
|
|
|
#define TARGET_WITH_SSSE3
|
|
|
|
|
#define TARGET_WITH_CLMUL
|
2021-10-05 00:30:24 +01:00
|
|
|
#else
|
2024-04-30 15:12:48 +01:00
|
|
|
#define TARGET_WITH_AVX2 __attribute__((target("avx2")))
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_SSSE3 __attribute__((target("ssse3")))
|
|
|
|
|
#define TARGET_WITH_CLMUL __attribute__((target("pclmul,sse4.1")))
|
2021-10-05 00:30:24 +01:00
|
|
|
#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
|
|
|
|
2021-10-13 00:41:58 +01:00
|
|
|
#if(defined(__arm__) || defined(_M_ARM)) && !defined(_WIN32)
|
2024-04-30 15:12:48 +01:00
|
|
|
#define HWCAP_NEON (1 << 12)
|
|
|
|
|
#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
|
|
|
|
|
|
2021-10-13 00:41:58 +01:00
|
|
|
#if(defined(__aarch64__) || defined(_M_ARM64)) && !defined(_WIN32)
|
2024-04-30 15:12:48 +01:00
|
|
|
#define HWCAP_NEON (1 << 1)
|
|
|
|
|
#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
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_NEON
|
2021-10-05 00:30:24 +01:00
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#else // _MSC_VER
|
2021-10-05 00:30:24 +01:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_NEON
|
2021-10-05 00:30:24 +01:00
|
|
|
#else
|
2021-10-05 04:18:11 +01:00
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#if(__ARM_ARCH >= 7 || defined(__ARM_ARCH_8A))
|
2021-10-05 04:18:11 +01:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#endif // __ARM_ARCH_7A__
|
2021-10-05 04:18:11 +01:00
|
|
|
|
|
|
|
|
#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__
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_NEON __attribute__((target("neon")))
|
2021-10-05 04:18:11 +01:00
|
|
|
#else
|
2023-09-23 18:55:52 +01:00
|
|
|
#define TARGET_WITH_NEON __attribute__((target("fpu=neon")))
|
2021-10-05 04:18:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#endif // __aarch64__ || _M_ARM64
|
2021-10-05 00:30:24 +01:00
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#endif // _MSC_VER
|
2021-10-05 00:30:24 +01:00
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#endif // __aarch64__ || _M_ARM64 || __arm__ || _M_ARM
|
2021-10-13 03:30:02 +01:00
|
|
|
|
2024-04-30 15:12:48 +01:00
|
|
|
#endif // AARU_CHECKSUMS_NATIVE_CRC32_SIMD_H
|