selftests: Provide local define of __cpuid_count()
authorReinette Chatre <reinette.chatre@intel.com>
Mon, 25 Apr 2022 21:01:11 +0000 (14:01 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 25 Apr 2022 21:12:36 +0000 (15:12 -0600)
commita23039c7306f53416ba35d230201398ea34f4640
treee8c907180bb8e8401dceacbd9c540db852187497
parent678f0cdc572c5fda940cb038d70eebb8d818adc8
selftests: Provide local define of __cpuid_count()

Some selftests depend on information provided by the CPUID instruction.
To support this dependency the selftests implement private wrappers for
CPUID.

Duplication of the CPUID wrappers should be avoided.

Both gcc and clang/LLVM provide __cpuid_count() macros but neither
the macro nor its header file are available in all the compiler
versions that need to be supported by the selftests. __cpuid_count()
as provided by gcc is available starting with gcc v4.4, so it is
not available if the latest tests need to be run in all the
environments required to support kernels v4.9 and v4.14 that
have the minimal required gcc v3.2.

Duplicate gcc's __cpuid_count() macro to provide a centrally defined
macro for __cpuid_count() to help eliminate the duplicate CPUID wrappers
while continuing to compile in older environments.

Suggested-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest.h