From 93c6c18cf9731f47b386dd445dc13363423c507e Mon Sep 17 00:00:00 2001 From: Vincent Milum Jr Date: Tue, 8 Dec 2020 13:32:04 -0800 Subject: [PATCH] Adding ARM AT_HWCAP support for FreeBSD (#7750) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7750 Reviewed By: ltamasi Differential Revision: D25400609 Pulled By: pdillinger fbshipit-source-id: 13b15e2f490acc011b648fbd9615ea8e580cccc7 --- util/crc32c_arm64.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/util/crc32c_arm64.cc b/util/crc32c_arm64.cc index 80dbf0528..e04e38c0c 100644 --- a/util/crc32c_arm64.cc +++ b/util/crc32c_arm64.cc @@ -43,21 +43,23 @@ extern bool pmull_runtime_flag; uint32_t crc32c_runtime_check(void) { -#ifdef ROCKSDB_AUXV_GETAUXVAL_PRESENT - uint64_t auxv = getauxval(AT_HWCAP); - return (auxv & HWCAP_CRC32) != 0; -#else - return 0; + uint64_t auxv = 0; +#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT) + auxv = getauxval(AT_HWCAP); +#elif defined(__FreeBSD__) + elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv)); #endif + return (auxv & HWCAP_CRC32) != 0; } bool crc32c_pmull_runtime_check(void) { -#ifdef ROCKSDB_AUXV_GETAUXVAL_PRESENT - uint64_t auxv = getauxval(AT_HWCAP); - return (auxv & HWCAP_PMULL) != 0; -#else - return false; + uint64_t auxv = 0; +#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT) + auxv = getauxval(AT_HWCAP); +#elif defined(__FreeBSD__) + elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv)); #endif + return (auxv & HWCAP_PMULL) != 0; } #ifdef ROCKSDB_UBSAN_RUN