11// Tests RDRAND CPU Instruction
22// https://github.com/cjee21/RDRAND-Tester
3- // Last modified 2021-03-25
3+ // Last modified 2021-03-28
44
55#include <stdio.h>
66#include <stdint.h>
77#include <string.h>
88#include <stdlib.h>
99#include <cpuid.h> // for __get_cpuid intrinsic
1010
11- #define VERSION 20210325
12- #define TEST_NUM 5
11+ #define VERSION 20210328 // application version number
12+ #define TEST_NUM 20 // number of tests to perform
1313
1414#ifdef __x86_64__
1515#define ARCH "x86_64"
@@ -63,8 +63,8 @@ int main() {
6363 "Testing RDRAND...\n\n" ,
6464 support [1 ], support [supports_rdseed ()]);
6565
66- // test 5 times
67- for (int i = 0 ; i < 5 ; ++ i ) {
66+ // test for TEST_NUM times
67+ for (int i = 0 ; i < TEST_NUM ; ++ i ) {
6868 // max 10 retires to get a successful RDRAND
6969 success = rdrand_retry (10 , & rand_num [i ]);
7070 if (!success ) {
@@ -74,10 +74,10 @@ int main() {
7474
7575 // display results
7676#ifdef __x86_64__
77- printf ("try: %i success: %i random number: %20llu (0x%016llx)\n" , i + 1 , success , (unsigned long long )rand_num [i ], (unsigned long long )rand_num [i ]);
77+ printf ("try: %3i success: %i random number: %20llu (0x%016llx)\n" , i + 1 , success , (unsigned long long )rand_num [i ], (unsigned long long )rand_num [i ]);
7878#endif
7979#ifdef __i386__
80- printf ("try: %i success: %i random number: %10u (0x%08x)\n" , i + 1 , success , (unsigned )rand_num [i ], (unsigned )rand_num [i ]);
80+ printf ("try: %3i success: %i random number: %10u (0x%08x)\n" , i + 1 , success , (unsigned )rand_num [i ], (unsigned )rand_num [i ]);
8181#endif
8282 }
8383
0 commit comments