Skip to content

Commit 7932aec

Browse files
committed
Librhash: Make print-info output runtime cpu features
1 parent faa052a commit 7932aec

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

librhash/test_lib.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,16 @@ static unsigned find_hash(const char* name)
14111411
return 0;
14121412
}
14131413

1414+
/**
1415+
* Detect and print CPU features.
1416+
*/
1417+
static void print_cpu_features(void)
1418+
{
1419+
printf("CPU:%s%s\n",
1420+
(has_cpu_feature(CPU_FEATURE_SSE4_2) ? " SSE_4.2" : ""),
1421+
(has_cpu_feature(CPU_FEATURE_SHANI) ? " SHANI" : ""));
1422+
}
1423+
14141424
/**
14151425
* Print status of OpenSSL plugin.
14161426
*/
@@ -1492,6 +1502,7 @@ int main(int argc, char* argv[])
14921502
test_generic_assumptions();
14931503
if (print_info) {
14941504
printf("%s", compiler_flags);
1505+
print_cpu_features();
14951506
print_openssl_status();
14961507
} else if (test_speed) {
14971508
test_known_strings(hash_id);

librhash/test_lib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ char* compiler_flags = "Compile-time flags:"
312312
#endif
313313

314314
/* cpu features */
315+
#ifdef HAS_GCC_INTEL_CPUID
316+
" HAS_GCC_INTEL_CPUID"
317+
#endif
318+
#ifdef HAS_MSVC_INTEL_CPUID
319+
" HAS_MSVC_INTEL_CPUID"
320+
#endif
315321
#ifdef CPU_X64
316322
" CPU_X64"
317323
#endif

0 commit comments

Comments
 (0)