+#include "gras_config.h" /*_XBT_WIN32*/
+
+#ifdef _XBT_WIN32
+
+static unsigned int _seed = 2147483647;
+
+#ifdef __VISUALC__
+typedef unsigned __int64 uint64_t;
+typedef unsigned int uint32_t;
+#endif
+
+struct drand48_data {
+ unsigned short int __x[3]; /* Current state. */
+ unsigned short int __old_x[3]; /* Old state. */
+ unsigned short int __c; /* Additive const. in congruential formula. */
+ unsigned short int __init; /* Flag for initializing. */
+ unsigned long long int __a; /* Factor in congruential formula. */
+};
+
+static struct drand48_data __libc_drand48_data = { 0 };
+
+union ieee754_double {
+ double d;
+
+ /* This is the IEEE 754 double-precision format. */
+ struct {
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+ /* Little endian. */
+ } ieee;
+
+ /* This format makes it easier to see if a NaN is a signalling NaN. */
+ struct {
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+
+ } ieee_nan;
+};
+
+#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
+
+double drand48(void);
+
+int
+_drand48_iterate(unsigned short int xsubi[3], struct drand48_data *buffer);
+
+int
+_erand48_r(unsigned short int xsubi[3], struct drand48_data *buffer,
+ double *result);
+
+
+int
+_erand48_r(unsigned short int xsubi[3], struct drand48_data *buffer,
+ double *result)
+{
+ union ieee754_double temp;
+
+ /* Compute next state. */
+ if (_drand48_iterate(xsubi, buffer) < 0)
+ return -1;
+
+ /* Construct a positive double with the 48 random bits distributed over
+ its fractional part so the resulting FP number is [0.0,1.0). */