Mostly abolish inline assembler code in favour of dedicated files.
[catacomb] / rand / rand.c
index f9f16d5..c2540f7 100644 (file)
@@ -161,24 +161,14 @@ CPU_DISPATCH(static, return, int, quick, (rand_pool *r), (r),
 
 static int trivial_quick(rand_pool *r) { return (-1); }
 
-#if __GNUC__ && (CPUFAM_X86 || CPUFAM_AMD64)
-static int rdrand_quick(rand_pool *r)
-{
-  unsigned long rr;
-  int i = 16;
-
-  __asm__ ("0: rdrand %0; jc 9f; dec %1; jnz 0b; 9:"
-          : "=r" (rr), "=r" (i) : "1" (i) : "cc");
-  if (!i) return (-1);
-  rand_add(r, &rr, sizeof(rr), 8*sizeof(rr));
-  return (0);
-}
+#if CPUFAM_X86 || CPUFAM_AMD64
+extern int rand_quick_x86ish_rdrand(rand_pool */*r*/);
 #endif
 
 static quick__functype *pick_quick(void)
 {
-#if __GNUC__ && (CPUFAM_X86 || CPUFAM_AMD64)
-  DISPATCH_PICK_COND(rand_quick, rdrand_quick,
+#if CPUFAM_X86 || CPUFAM_AMD64
+  DISPATCH_PICK_COND(rand_quick, rand_quick_x86ish_rdrand,
                     cpu_feature_p(CPUFEAT_X86_RDRAND));
 #endif
   DISPATCH_PICK_FALLBACK(rand_quick, trivial_quick);