Hi Pádraig,

Pádraig Brady <[email protected]> writes:

> Thanks for the reviews all.
> I'll push the attached later (with a ChangeLog entry).

Great, thanks for adding the tests.

Some minor adjustments that you can do locally.

> 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.
> ---
>  lib/cpu-supports.c         | 79 ++++++++++++++++++++++++++++++++
>  lib/cpu-supports.h         | 92 +++++++++++++++++++++++++++++++++++++
>  modules/cpu-supports       | 27 +++++++++++
>  modules/cpu-supports-tests | 12 +++++
>  tests/test-cpu-supports.c  | 93 ++++++++++++++++++++++++++++++++++++++
>  5 files changed, 303 insertions(+)
>  create mode 100644 lib/cpu-supports.c
>  create mode 100644 lib/cpu-supports.h
>  create mode 100644 modules/cpu-supports
>  create mode 100644 modules/cpu-supports-tests
>  create mode 100644 tests/test-cpu-supports.c

I would add the module in a commit, then a test module in a second
commit. That is the convention I started to follow after noticing Bruno
do the same.

So, two commits with the following messages:

   cpu-supports: New module.
   cpu-supports: Add tests.

> diff --git a/modules/cpu-supports-tests b/modules/cpu-supports-tests
> new file mode 100644
> index 0000000000..f9b14efb6b
> --- /dev/null
> +++ b/modules/cpu-supports-tests
> @@ -0,0 +1,12 @@
> +Files:
> +tests/test-cpu-supports.c
> +tests/macros.h
> +
> +Depends-on:
> +bool
> +
> +configure.ac:
> +
> +Makefile.am:
> +TESTS += test-cpu-supports
> +check_PROGRAMS += test-cpu-supports

This test should depend on the setenv and unsetenv modules, since these
functions do not exist on some platforms (e.g. Windows). See
doc/posix-functions/{setenv,unsetenv}.texi.

Collin

Reply via email to