aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-10 07:44:20 +0000
committerlloyd <[email protected]>2009-11-10 07:44:20 +0000
commit32b16ba09ed2aff221c88662a30bb2449d4e139f (patch)
tree8a85e3f7fe402d847633c727b8a9e0e532c0451a
parent743014387833eb52e71fc9d4381e2a546e80f158 (diff)
Clean up cpuid test prog
-rw-r--r--doc/examples/cpuid.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/doc/examples/cpuid.cpp b/doc/examples/cpuid.cpp
index bc33ef907..76438783f 100644
--- a/doc/examples/cpuid.cpp
+++ b/doc/examples/cpuid.cpp
@@ -1,21 +1,28 @@
-#include <stdio.h>
-
+#include <iostream>
#include <botan/cpuid.h>
using namespace Botan;
+void print_if_feature(const std::string& feature_name, bool exists)
+ {
+ if(exists)
+ std::cout << feature_name << '\n';
+ else
+ std::cout << '[' << feature_name << ']' << '\n';
+ }
+
int main()
{
- printf("Cache line size: %d\n", CPUID::cache_line_size());
+ std::cout << "Cache line size = " << CPUID::cache_line_size() << "\n";
- printf("RDTSC: %d\n", CPUID::has_rdtsc());
- printf("SSE2 %d\n", CPUID::has_sse2());
- printf("SSSE3 %d\n", CPUID::has_ssse3());
- printf("SSE41 %d\n", CPUID::has_sse41());
- printf("SSE42 %d\n", CPUID::has_sse42());
- printf("AES-NI %d\n", CPUID::has_aes_intel());
+ print_if_feature("RDTSC", CPUID::has_rdtsc());
+ print_if_feature("SSE2", CPUID::has_sse2());
+ print_if_feature("SSSE3", CPUID::has_ssse3());
+ print_if_feature("SSE4.1", CPUID::has_sse41());
+ print_if_feature("SSE4.2", CPUID::has_sse42());
- printf("AES-VIA %d\n", CPUID::has_aes_via());
+ print_if_feature("AES-NI", CPUID::has_aes_intel());
+ print_if_feature("AES-VIA", CPUID::has_aes_via());
- printf("AltiVec %d\n", CPUID::has_altivec());
+ print_if_feature("AltiVec", CPUID::has_altivec());
}