diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2025-02-26 12:54:17 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2025-03-05 11:22:09 -0300 |
commit | 8a995670a8c25e7145201ec52b0c648dae0ff9c2 (patch) | |
tree | 6449aecfb9ca686ac93f701d92df3318f8967be6 /sysdeps/unix/sysv/linux/powerpc/cpu-features.c | |
parent | 3a9fb97caf3d4c04a812f51d4c5139cb2b9ed52e (diff) | |
download | glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.zip glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.tar.gz glibc-8a995670a8c25e7145201ec52b0c648dae0ff9c2.tar.bz2 |
powerpc: Move AT_HWCAP descriptions to ld diagnostics
The ld.so diagnostics already prints AT_HWCAP values, but only in
hexadecimal. To avoid duplicating the strings, consolidate the
hwcap_names from cpu-features.h on a new file, dl-hwcap-info.h
(and it also improves the hwcap string description with more
values).
For future AT_HWCAP3/AT_HWCAP4 extensions, it is just a matter
to add them on dl-hwcap-info.c so both ld diagnostics and
tunable filtering will parse the new values.
Checked on powerpc64le-linux-gnu.
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
Diffstat (limited to 'sysdeps/unix/sysv/linux/powerpc/cpu-features.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/cpu-features.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c index bcce635..520ccaa 100644 --- a/sysdeps/unix/sysv/linux/powerpc/cpu-features.c +++ b/sysdeps/unix/sysv/linux/powerpc/cpu-features.c @@ -21,9 +21,19 @@ #include <cpu-features.h> #include <elf/dl-tunables.h> #include <dl-tunables-parse.h> +#include <dl-hwcap-info.h> #include <unistd.h> #include <string.h> +static void set_hwcap_bit (unsigned long int *hwcap, bool disable, + unsigned long int tcb_value, unsigned int value) +{ + if (disable) + *hwcap &= ~value; + else + *hwcap |= tcb_value & value; +} + static void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) { @@ -55,32 +65,27 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) continue; size_t offset = 0; - for (int i = 0; i < array_length (hwcap_tunables); ++i) + for (int i = 0; i < __dl_hwcap_info_size; ++i) { - const char *hwcap_name = hwcap_names + offset; + const char *hwcap_name = __dl_hwcap_names + offset; size_t hwcap_name_len = strlen (hwcap_name); /* Check the tunable name on the supported list. */ if (tunable_str_comma_strcmp (&t, hwcap_name, hwcap_name_len)) { - /* Update the hwcap and hwcap2 bits. */ - if (t.disable) + switch (__dl_hwcap_info[i].hwcap) { - /* Id is 1 for hwcap2 tunable. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 &= ~(hwcap_tunables[i].mask); - else - cpu_features->hwcap &= ~(hwcap_tunables[i].mask); - } - else - { - /* Enable the features and also check that no unsupported - features were enabled by user. */ - if (hwcap_tunables[i].id) - cpu_features->hwcap2 |= (tcbv_hwcap2 & hwcap_tunables[i].mask); - else - cpu_features->hwcap |= (tcbv_hwcap & hwcap_tunables[i].mask); + case AT_HWCAP: + set_hwcap_bit (&cpu_features->hwcap, t.disable, tcbv_hwcap, + __dl_hwcap_info[i].value); + break; + + case AT_HWCAP2: + set_hwcap_bit (&cpu_features->hwcap2, t.disable, tcbv_hwcap2, + __dl_hwcap_info[i].value); + break; + + /* Ignore unknown values. */ } - break; } offset += hwcap_name_len + 1; } |