summaryrefslogtreecommitdiff
path: root/src/test/test-random-util.c
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2018-11-08 09:47:16 -0500
committerLennart Poettering <lennart@poettering.net>2018-11-10 14:56:53 +0100
commit33dbab6fde5423ce61b5544ca49afa13495477a8 (patch)
treebe46001261b2f1786d0706589a36df5031296980 /src/test/test-random-util.c
parente29a9fcb29a0509ccc30bcfe07ecf5dc2b4de9ea (diff)
downloadsystemd-33dbab6fde5423ce61b5544ca49afa13495477a8.tar.gz
random-util: allow RDRAND to be used in 32-bit x86 binaries
Rename rdrand64 to rdrand, and switch from uint64_t to unsigned long. This produces code that will compile/assemble on both x86-64 and x86-32. This could be useful when running a 32-bit copy of systemd on a modern Intel processor. RDRAND is inherently arch-specific, so relying on the compiler-defined 'long' type seems reasonable.
Diffstat (limited to 'src/test/test-random-util.c')
-rw-r--r--src/test/test-random-util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/test-random-util.c b/src/test/test-random-util.c
index a59c6374b2..94c431f7e6 100644
--- a/src/test/test-random-util.c
+++ b/src/test/test-random-util.c
@@ -35,19 +35,19 @@ static void test_pseudo_random_bytes(void) {
}
}
-static void test_rdrand64(void) {
+static void test_rdrand(void) {
int r, i;
for (i = 0; i < 10; i++) {
- uint64_t x = 0;
+ unsigned long x = 0;
- r = rdrand64(&x);
+ r = rdrand(&x);
if (r < 0) {
log_error_errno(r, "RDRAND failed: %m");
return;
}
- printf("%" PRIx64 "\n", x);
+ printf("%lx\n", x);
}
}
@@ -61,7 +61,7 @@ int main(int argc, char **argv) {
test_pseudo_random_bytes();
- test_rdrand64();
+ test_rdrand();
return 0;
}