--- a/RandomRDRand.st Wed Mar 27 15:22:56 2019 +0100
+++ b/RandomRDRand.st Thu Mar 28 11:08:37 2019 +0100
@@ -92,20 +92,18 @@
isSupported
"true if this architecture supports hardware random numbers"
- ^ OperatingSystem getCPUType = 'x86_64'
- and:[ (OperatingSystem getSystemInfo at:#extendedInstructions ifAbsent:#())
- includes:#aes ]
+ ^ (OperatingSystem getSystemInfo at:#extendedInstructions ifAbsent:#())
+ includes:#rdmd
"
self isSupported
"
+
+ "Modified: / 28-03-2019 / 10:59:32 / Stefan Vogel"
! !
!RandomRDRand methodsFor:'initialization'!
-initialize
-!
-
seed:seed
"/ ignored
! !
@@ -133,30 +131,24 @@
do {
#ifdef USE_DRAND64
cf = _rdrand64_step(&r);
-#else
-# ifdef USE_DRAND32
+#elif defined(USE_DRAND32)
cf = _rdrand32_step(&r);
-# else
-# if defined(__x86__) && defined(__GNUC__) && (__GNUC__ >= 2)
+#elif defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 2)
// Encoding of rdrand %eax
asm(".byte 0x0F, 0xC7, 0xF0; adcl $0,%1"
: "=a" (r), "=r" (cf)
: "0" (r), "1" (cf)
: "cc");
-# else
-# if defined(__x86_64__) && defined(__GNUC__) && (__GNUC__ >= 2)
+#elif defined(__x86_64__) && defined(__GNUC__) && (__GNUC__ >= 2)
// Encoding of rdrand %rax
asm(".byte 0x48, 0x0F, 0xC7, 0xF0; adcl $0,%1"
: "=a" (r), "=r" (cf)
: "0" (r), "1" (cf)
: "cc");
-# else
+#else
goto unsupported;
-# endif
-# endif
-# endif
#endif
} while ((cf != 0) && (--count > 0));
if (cf == 0) {
@@ -173,6 +165,8 @@
"
self new nextInteger
"
+
+ "Modified: / 28-03-2019 / 10:46:29 / Stefan Vogel"
! !
!RandomRDRand class methodsFor:'documentation'!