1
1
// Tests RDRAND CPU Instruction
2
2
// https://github.com/cjee21/RDRAND-Tester
3
- // Last modified 2021-03-25
3
+ // Last modified 2021-03-28
4
4
5
5
#include <stdio.h>
6
6
#include <stdint.h>
7
7
#include <string.h>
8
8
#include <stdlib.h>
9
9
#include <cpuid.h> // for __get_cpuid intrinsic
10
10
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
13
13
14
14
#ifdef __x86_64__
15
15
#define ARCH "x86_64"
@@ -63,8 +63,8 @@ int main() {
63
63
"Testing RDRAND...\n\n" ,
64
64
support [1 ], support [supports_rdseed ()]);
65
65
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 ) {
68
68
// max 10 retires to get a successful RDRAND
69
69
success = rdrand_retry (10 , & rand_num [i ]);
70
70
if (!success ) {
@@ -74,10 +74,10 @@ int main() {
74
74
75
75
// display results
76
76
#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 ]);
78
78
#endif
79
79
#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 ]);
81
81
#endif
82
82
}
83
83
0 commit comments