[libunwind] Add SME detection for Apple platforms (#193630)
Copy SME detection sysctl code from ZA test. Also fix a logic issue in the original code while being reviewed.
This commit is contained in:
parent
b5f4f16fd9
commit
94b475dae6
2 changed files with 13 additions and 2 deletions
|
|
@ -20,6 +20,9 @@
|
|||
#include "libunwind_ext.h"
|
||||
#include "shadow_stack_unwind.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#if defined(_LIBUNWIND_HAVE_GETAUXVAL) || defined(_LIBUNWIND_HAVE_ELF_AUX_INFO)
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
|
@ -1940,7 +1943,15 @@ private:
|
|||
_LIBUNWIND_ABORT("SME ZA disable failed");
|
||||
}
|
||||
|
||||
#if defined(_LIBUNWIND_HAVE_GETAUXVAL)
|
||||
#if defined(__APPLE__)
|
||||
static bool checkHasSME() {
|
||||
int has_sme = 0;
|
||||
size_t size = sizeof(has_sme);
|
||||
if (sysctlbyname("hw.optional.arm.FEAT_SME", &has_sme, &size, NULL, 0))
|
||||
return false;
|
||||
return has_sme != 0;
|
||||
}
|
||||
#elif defined(_LIBUNWIND_HAVE_GETAUXVAL)
|
||||
static bool checkHasSME() {
|
||||
constexpr int hwcap2_sme = (1 << 23);
|
||||
unsigned long hwcap2 = getauxval(AT_HWCAP2);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
static bool checkHasSME() {
|
||||
int has_sme = 0;
|
||||
size_t size = sizeof(has_sme);
|
||||
if (!sysctlbyname("hw.optional.arm.FEAT_SME", &has_sme, &size, NULL, 0))
|
||||
if (sysctlbyname("hw.optional.arm.FEAT_SME", &has_sme, &size, NULL, 0))
|
||||
return false;
|
||||
return has_sme != 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue