summaryrefslogtreecommitdiffstats
path: root/src/arch/arm.c
blob: 02f0107b76ba9473f16b3d6cef2a9f94d6436b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "acconfig.h"
#include "arch/probe.h"

/* flags we export */
int ceph_arch_neon = 0;
int ceph_arch_aarch64_crc32 = 0;
int ceph_arch_aarch64_pmull = 0;

#include <stdio.h>

#if __linux__

#include <elf.h>
#include <link.h> // ElfW macro
#include <sys/auxv.h>

#if __arm__ || __aarch64__
#include <asm/hwcap.h>
#endif // __arm__

#endif // __linux__

int ceph_arch_arm_probe(void)
{
#if __linux__
	unsigned long hwcap = getauxval(AT_HWCAP);
#if __arm__
	ceph_arch_neon = (hwcap & HWCAP_NEON) == HWCAP_NEON;
#elif __aarch64__
	ceph_arch_neon = (hwcap & HWCAP_ASIMD) == HWCAP_ASIMD;
	ceph_arch_aarch64_crc32 = (hwcap & HWCAP_CRC32) == HWCAP_CRC32;
	ceph_arch_aarch64_pmull = (hwcap & HWCAP_PMULL) == HWCAP_PMULL;
#endif
#endif // __linux__
	return 0;
}