1void __init_cpu_features_resolver(unsigned long hwcap, 2 const __ifunc_arg_t *arg) { 3 if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED)) 4 return; 5 6 // ifunc resolvers don't have hwcaps in arguments on Android API lower 7 // than 30. If so, set feature detection done and keep all CPU features 8 // unsupported (zeros). To detect this case in runtime we check existence 9 // of memfd_create function from Standard C library which was introduced in 10 // Android API 30. 11 int memfd_create(const char *, unsigned int) __attribute__((weak)); 12 if (!memfd_create) 13 return; 14 15 __init_cpu_features_constructor(hwcap, arg); 16} 17 18void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) { 19 // CPU features already initialized. 20 if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED)) 21 return; 22 23 // Don't set any CPU features, 24 // detection could be wrong on Exynos 9810. 25 if (__isExynos9810()) 26 return; 27 28 unsigned long hwcap = getauxval(AT_HWCAP); 29 unsigned long hwcap2 = getauxval(AT_HWCAP2); 30 31 __ifunc_arg_t arg; 32 arg._size = sizeof(__ifunc_arg_t); 33 arg._hwcap = hwcap; 34 arg._hwcap2 = hwcap2; 35 __init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg); 36} 37