28 lines · plain
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 __init_cpu_features_constructor(hwcap, arg);7}8 9void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) {10 unsigned long hwcap, hwcap2, hwcap3, hwcap4 = 0;11 // CPU features already initialized.12 if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED))13 return;14 15 elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);16 elf_aux_info(AT_HWCAP2, &hwcap2, sizeof hwcap2);17 elf_aux_info(AT_HWCAP3, &hwcap3, sizeof hwcap3);18 elf_aux_info(AT_HWCAP4, &hwcap4, sizeof hwcap4);19 20 __ifunc_arg_t arg;21 arg._size = sizeof(__ifunc_arg_t);22 arg._hwcap = hwcap;23 arg._hwcap2 = hwcap2;24 arg._hwcap3 = hwcap3;25 arg._hwcap4 = hwcap4;26 __init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg);27}28