Skip to content

Commit cd634f5

Browse files
[compiler-rt][AArch64][Android] Use getauxval on Android. (#102979)
__getauxval is a libgcc function that doesn't exist on Android. Also on Linux let's use getauxval as it is anyway used other places in compiler-rt.
1 parent 448d8fa commit cd634f5

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

compiler-rt/lib/builtins/aarch64/sme-abi-init.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
77

88
// We have multiple ways to check that the function has SME, depending on our
99
// target.
10-
// * For Linux we can use __getauxval().
10+
// * For Linux/Glibc we can use getauxval().
11+
// * For Android we can use getauxval().
1112
// * For newlib we can use __aarch64_sme_accessible().
1213

1314
#if defined(__linux__)
1415

15-
#ifndef AT_HWCAP2
16-
#define AT_HWCAP2 26
16+
#if defined(__ANDROID__)
17+
#include <sys/auxv.h>
18+
#elif __has_include(<sys/auxv.h>)
19+
#include <sys/auxv.h>
20+
#else
21+
#define getauxval(x) 0
1722
#endif
23+
#include "../cpu_model/aarch64/hwcap.inc"
1824

19-
#ifndef HWCAP2_SME
20-
#define HWCAP2_SME (1 << 23)
21-
#endif
22-
23-
extern unsigned long int __getauxval (unsigned long int);
24-
25-
static _Bool has_sme(void) {
26-
return __getauxval(AT_HWCAP2) & HWCAP2_SME;
27-
}
25+
static _Bool has_sme(void) { return getauxval(AT_HWCAP2) & HWCAP2_SME; }
2826

2927
#else // defined(__linux__)
3028

0 commit comments

Comments
 (0)