Skip to content

[compiler-rt][AArch64][Android] Use getauxval on Android. #102979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions compiler-rt/lib/builtins/aarch64/sme-abi-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ _Bool __aarch64_has_sme_and_tpidr2_el0;

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

#if defined(__linux__)

#ifndef AT_HWCAP2
#define AT_HWCAP2 26
#if defined(__ANDROID__)
#include <sys/auxv.h>
#elif __has_include(<sys/auxv.h>)
#include <sys/auxv.h>
#else
#define getauxval(x) 0
#endif
#include "../cpu_model/aarch64/hwcap.inc"

#ifndef HWCAP2_SME
#define HWCAP2_SME (1 << 23)
#endif

extern unsigned long int __getauxval (unsigned long int);

static _Bool has_sme(void) {
return __getauxval(AT_HWCAP2) & HWCAP2_SME;
}
static _Bool has_sme(void) { return getauxval(AT_HWCAP2) & HWCAP2_SME; }

#else // defined(__linux__)

Expand Down
Loading