[compiler-rt] [compiler-rt][AArch64][Android] Use getauxval on Android. (PR #102979)
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 19:36:20 PDT 2024
================
@@ -20,11 +21,15 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;
#define HWCAP2_SME (1 << 23)
#endif
+#ifdef __ANDROID__
+extern unsigned long int getauxval(unsigned long int);
+#define GETAUXVAL(x) getauxval(x)
+#else
extern unsigned long int __getauxval (unsigned long int);
+#define GETAUXVAL(x) __getauxval(x)
+#endif
-static _Bool has_sme(void) {
- return __getauxval(AT_HWCAP2) & HWCAP2_SME;
-}
+static _Bool has_sme(void) { return GETAUXVAL(AT_HWCAP2) & HWCAP2_SME; }
----------------
compnerd wrote:
I think that I would rather that we inline the use of `__getauxval`. `getauxval` is a GNU "standard" interface, but was introduced in glibc only in 2.16. I don't know if anyone is targeting an older glibc, but we can do something like:
```suggestion
static _Bool has_sme(void) {
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2,16)
unsigned long int auxval = __getauxval(AT_HWCAP2);
#else
unsigned long int auxval = getauxval(AT_HWCAP2);
#endif
return auxval & HWCAP2_SME;
}
```
https://github.com/llvm/llvm-project/pull/102979
More information about the llvm-commits
mailing list