summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libgmp/tests/urandom.h
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/lib/libgmp/tests/urandom.h')
-rw-r--r--gnu/lib/libgmp/tests/urandom.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gnu/lib/libgmp/tests/urandom.h b/gnu/lib/libgmp/tests/urandom.h
new file mode 100644
index 0000000..e018580
--- /dev/null
+++ b/gnu/lib/libgmp/tests/urandom.h
@@ -0,0 +1,17 @@
+#if defined (hpux) || defined (__alpha__)
+/* HPUX lacks random(). DEC Alpha's random() returns a double. */
+static inline unsigned long
+urandom ()
+{
+ return mrand48 ();
+}
+#else
+long random ();
+
+static inline unsigned long
+urandom ()
+{
+ /* random() returns 31 bits, we want 32. */
+ return random() ^ (random() << 1);
+}
+#endif
OpenPOWER on IntegriCloud