1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-06 22:12:47 -05:00

Add CPU feature checks on M1 macOS.

I booted my M1 Mac into macOS rather than Asahi for the first time in
a while, and discovered that an OS update seems to have added some
sysctl flags indicating the presence of the CPU extensions that I
previously knew of no way to check for! Added them checks to
arm_arch_queries.c, though I've also retained backwards compat with
the previous OS version which didn't have them at all.
This commit is contained in:
Simon Tatham
2022-08-16 18:39:12 +01:00
parent 840043f06e
commit fd840f0dfe
2 changed files with 27 additions and 13 deletions

View File

@ -49,15 +49,19 @@ static inline u_long getauxval(int which) { return 0; }
#endif /* defined __arm__ || defined __aarch64__ */
#if defined __APPLE__
static inline bool test_sysctl_flag(const char *flagname)
typedef enum { SYSCTL_MISSING, SYSCTL_OFF, SYSCTL_ON } SysctlResult;
static inline SysctlResult test_sysctl_flag(const char *flagname)
{
#if HAVE_SYSCTLBYNAME
int value;
size_t size = sizeof(value);
return (sysctlbyname(flagname, &value, &size, NULL, 0) == 0 &&
size == sizeof(value) && value != 0);
if (sysctlbyname(flagname, &value, &size, NULL, 0) == 0 &&
size == sizeof(value)) {
return value != 0 ? SYSCTL_ON : SYSCTL_OFF;
}
#else /* HAVE_SYSCTLBYNAME */
return false;
return SYSCTL_MISSING;
#endif /* HAVE_SYSCTLBYNAME */
}
#endif /* defined __APPLE__ */