From ba25dd97f3b7f47580c6c6db5a4b516e811e3104 Mon Sep 17 00:00:00 2001 From: sof Date: Mon, 13 Sep 1999 11:01:07 +0000 Subject: [PATCH] [project @ 1999-09-13 11:01:05 by sof] GMP only depends on libiberty for the implementation of random(). Avoid this dep. on a (pure) Win32 platform. --- ghc/rts/gmp/mpn/generic/random2.c | 8 ++++++++ ghc/rts/gmp/urandom.h | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/ghc/rts/gmp/mpn/generic/random2.c b/ghc/rts/gmp/mpn/generic/random2.c index 2954608..7ac442a 100644 --- a/ghc/rts/gmp/mpn/generic/random2.c +++ b/ghc/rts/gmp/mpn/generic/random2.c @@ -31,6 +31,14 @@ random () { return mrand48 (); } +#elif defined(_WIN32) && !(defined(__CYGWIN__) || defined(__CYGWIN32__)) +/* MS CRT supplies just the poxy rand(), with an upper bound of 0x7fff */ +static inline unsigned long +random () +{ + return rand () ^ (rand () << 16) ^ (rand() << 32); +} + #else long random (); #endif diff --git a/ghc/rts/gmp/urandom.h b/ghc/rts/gmp/urandom.h index 994e7bd..37221c2 100644 --- a/ghc/rts/gmp/urandom.h +++ b/ghc/rts/gmp/urandom.h @@ -29,6 +29,16 @@ urandom () #define __URANDOM #endif +#if defined(_WIN32) && !(defined(__CYGWIN__) || defined(__CYGWIN32__)) +/* MS CRT supplies just the poxy rand(), with an upper bound of 0x7fff */ +static inline unsigned long +urandom () +{ + return rand () ^ (rand () << 16) ^ (rand() << 32); +} +#define __URANDOM +#endif + #if defined (__alpha) && !defined (__URANDOM) /* DEC OSF/1 1.2 random() returns a double. */ long mrand48 (); -- 1.7.10.4