aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/cpuid
diff options
context:
space:
mode:
authorDavid Carlier <[email protected]>2019-04-15 07:31:25 +0000
committerDavid Carlier <[email protected]>2019-04-15 07:57:05 +0000
commit7c80d3fc0b39921eeabf677172ee66ce8dacd998 (patch)
tree0606bd762a65f15e52a5610c9ae94cee84dcb6b8 /src/lib/utils/cpuid
parent7573bccb5ef9ad6c51f304ee7041d0e2cb6151d8 (diff)
Provides auxiliary vector support for FreeBSD.
somewhat similar to Linux's counterpart but mainly for cpu features.
Diffstat (limited to 'src/lib/utils/cpuid')
-rw-r--r--src/lib/utils/cpuid/cpuid_arm.cpp12
-rw-r--r--src/lib/utils/cpuid/cpuid_ppc.cpp8
2 files changed, 8 insertions, 12 deletions
diff --git a/src/lib/utils/cpuid/cpuid_arm.cpp b/src/lib/utils/cpuid/cpuid_arm.cpp
index b5626f96b..bc9ac5daa 100644
--- a/src/lib/utils/cpuid/cpuid_arm.cpp
+++ b/src/lib/utils/cpuid/cpuid_arm.cpp
@@ -9,10 +9,7 @@
#if defined(BOTAN_TARGET_CPU_IS_ARM_FAMILY)
-#if defined(BOTAN_TARGET_OS_HAS_GETAUXVAL)
- #include <sys/auxv.h>
-
-#elif defined(BOTAN_TARGET_OS_IS_IOS)
+#if defined(BOTAN_TARGET_OS_IS_IOS)
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -106,7 +103,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
{
uint64_t detected_features = 0;
-#if defined(BOTAN_TARGET_OS_HAS_GETAUXVAL)
+#if defined(BOTAN_TARGET_OS_HAS_GETAUXVAL) || defined(BOTAN_TARGET_OS_HAS_ELF_AUX_INFO)
/*
* On systems with getauxval these bits should normally be defined
* in bits/auxv.h but some buggy? glibc installs seem to miss them.
@@ -142,6 +139,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
};
#if defined(AT_DCACHEBSIZE)
+ // Exists only on Linux
const unsigned long dcache_line = ::getauxval(AT_DCACHEBSIZE);
// plausibility check
@@ -149,7 +147,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
*cache_line_size = static_cast<size_t>(dcache_line);
#endif
- const unsigned long hwcap_neon = ::getauxval(ARM_hwcap_bit::ARCH_hwcap_neon);
+ const unsigned long hwcap_neon = OS::get_auxval(ARM_hwcap_bit::ARCH_hwcap_neon);
if(hwcap_neon & ARM_hwcap_bit::NEON_bit)
detected_features |= CPUID::CPUID_ARM_NEON_BIT;
@@ -158,7 +156,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
It doesn't seem worth optimizing this out, since getauxval is
just reading a field in the ELF header.
*/
- const unsigned long hwcap_crypto = ::getauxval(ARM_hwcap_bit::ARCH_hwcap_crypto);
+ const unsigned long hwcap_crypto = OS::get_auxval(ARM_hwcap_bit::ARCH_hwcap_crypto);
if(hwcap_crypto & ARM_hwcap_bit::AES_bit)
detected_features |= CPUID::CPUID_ARM_AES_BIT;
if(hwcap_crypto & ARM_hwcap_bit::PMULL_bit)
diff --git a/src/lib/utils/cpuid/cpuid_ppc.cpp b/src/lib/utils/cpuid/cpuid_ppc.cpp
index 1c1b68658..08a04cafd 100644
--- a/src/lib/utils/cpuid/cpuid_ppc.cpp
+++ b/src/lib/utils/cpuid/cpuid_ppc.cpp
@@ -19,8 +19,6 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
-#elif defined(BOTAN_TARGET_OS_HAS_GETAUXVAL)
- #include <sys/auxv.h>
#endif
#endif
@@ -55,7 +53,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
if(error == 0 && vector_type > 0)
return CPUID::CPUID_ALTIVEC_BIT;
-#elif defined(BOTAN_TARGET_OS_HAS_GETAUXVAL) && defined(BOTAN_TARGET_ARCH_IS_PPC64)
+#elif (defined(BOTAN_TARGET_OS_HAS_GETAUXVAL) || defined(BOTAN_TARGET_HAS_ELF_AUX_INFO)) && defined(BOTAN_TARGET_ARCH_IS_PPC64)
enum PPC_hwcap_bit {
ALTIVEC_bit = (1 << 28),
@@ -67,11 +65,11 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
uint64_t detected_features = 0;
- const unsigned long hwcap_altivec = ::getauxval(PPC_hwcap_bit::ARCH_hwcap_altivec);
+ const unsigned long hwcap_altivec = OS::get_auxval(PPC_hwcap_bit::ARCH_hwcap_altivec);
if(hwcap_altivec & PPC_hwcap_bit::ALTIVEC_bit)
detected_features |= CPUID::CPUID_ALTIVEC_BIT;
- const unsigned long hwcap_crypto = ::getauxval(PPC_hwcap_bit::ARCH_hwcap_crypto);
+ const unsigned long hwcap_crypto = OS::get_auxval(PPC_hwcap_bit::ARCH_hwcap_crypto);
if(hwcap_crypto & PPC_hwcap_bit::CRYPTO_bit)
detected_features |= CPUID::CPUID_PPC_CRYPTO_BIT;