2 #include "arch/probe.h"
5 int ceph_arch_neon = 0;
6 int ceph_arch_aarch64_crc32 = 0;
13 #include <link.h> // ElfW macro
15 #if __arm__ || __aarch64__
16 #include <asm/hwcap.h>
19 static unsigned long get_auxval(unsigned long type)
21 unsigned long result = 0;
22 FILE *f = fopen("/proc/self/auxv", "r");
25 while (fread(&entry, sizeof(entry), 1, f) == 1) {
26 if (entry.a_type == type) {
27 result = entry.a_un.a_val;
36 static unsigned long get_hwcap(void)
38 return get_auxval(AT_HWCAP);
43 int ceph_arch_arm_probe(void)
45 #if __arm__ && __linux__
46 ceph_arch_neon = (get_hwcap() & HWCAP_NEON) == HWCAP_NEON;
47 #elif __aarch64__ && __linux__
48 ceph_arch_neon = (get_hwcap() & HWCAP_ASIMD) == HWCAP_ASIMD;
49 # if defined(HAVE_ARMV8_CRC) && defined(HWCAP_CRC32)
50 ceph_arch_aarch64_crc32 = (get_hwcap() & HWCAP_CRC32) == HWCAP_CRC32;
54 get_hwcap(); // make compiler shut up