]> git.ipfire.org Git - thirdparty/gnulib.git/commit
cpu-supports: a module to honor GLIBC_TUNABLES=glibc.cpu.hwcaps
authorPádraig Brady <P@draigBrady.com>
Fri, 12 Sep 2025 15:55:45 +0000 (16:55 +0100)
committerPádraig Brady <P@draigBrady.com>
Sun, 14 Sep 2025 12:16:29 +0000 (13:16 +0100)
commit16deb62f09149e8fc2a4be55fcb3bfe6f9f7310c
tree282443054462587e74d1889ba161f385cbb85004
parent0f6c3055370024529122de7b11f9c51e5482f8ee
cpu-supports: a module to honor GLIBC_TUNABLES=glibc.cpu.hwcaps

This functionality is useful to allow better test coverage at least,
and may be useful for users to tune their environment,
avoiding CPU throttling for example.

* lib/cpu-supports.h (cpu_supports): A new wrapper that
checks that the GLIBC_TUNABLES environment variable allows
the hardware feature, before checking with __builtin_cpu_supports().
(cpu_may_support): Only perform the GLIBC_TUNABLES check,
which is useful if using other interfaces like getauxval().
(gcc_feature_to_glibc_hwcap): An internal helper that will resolve
at compile time with standard optimizations enabled.
* lib/cpu-supports.c (hwcap_allowed): Query the GLIBC_TUNABLES
environment variable (read once per process), to see if the
passed GLIBC_HWCAP is allowed.
* modules/cpu-supports: New module definition.
* modules/cpu-supports-tests: New test module definition.
* tests/test-cpu-supports.c: New tests.
ChangeLog
lib/cpu-supports.c [new file with mode: 0644]
lib/cpu-supports.h [new file with mode: 0644]
modules/cpu-supports [new file with mode: 0644]
modules/cpu-supports-tests [new file with mode: 0644]
tests/test-cpu-supports.c [new file with mode: 0644]