@@ -62,21 +62,47 @@ static __inline int simple_cmp(const void *a, const void *b) {
62
62
#ifdef _WIN32
63
63
64
64
#include <time.h>
65
+ /* Written in 2015 by Sebastiano Vigna ([email protected] )
66
+
67
+ To the extent possible under law, the author has dedicated all copyright
68
+ and related and neighboring rights to this software to the public domain
69
+ worldwide. This software is distributed without any warranty.
70
+
71
+ See <http://creativecommons.org/publicdomain/zero/1.0/>. */
72
+
73
+ #include <stdint.h>
74
+
75
+ /* This is a fixed-increment version of Java 8's SplittableRandom generator
76
+ See http://dx.doi.org/10.1145/2714064.2660195 and
77
+ http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
78
+
79
+ It is a very fast generator passing BigCrush, and it can be useful if
80
+ for some reason you absolutely want 64 bits of state. */
81
+
82
+ static uint64_t x ; /* The state can be seeded with any value. */
83
+
84
+ uint64_t next () {
85
+ uint64_t z = (x += 0x9e3779b97f4a7c15 );
86
+ z = (z ^ (z >> 30 )) * 0xbf58476d1ce4e5b9 ;
87
+ z = (z ^ (z >> 27 )) * 0x94d049bb133111eb ;
88
+ return z ^ (z >> 31 );
89
+ }
65
90
static __inline void srand48 (long seed ) {
66
- srand (seed );
91
+ //srand(seed);
92
+ x = seed ;
67
93
}
68
94
69
95
static __inline long lrand48 (void ) {
70
- int x ;
71
- rand_s (& x );
72
- return x & 0x7fffffff ;
96
+ return next () & 0x7fffffff ;
97
+ // int x;
98
+ // rand_s(&x);
99
+ // return x & 0x7fffffff;
73
100
}
74
101
75
102
static __inline double utime (void ) {
76
- //struct timespec ts;
77
- //timespec_get(&ts, TIME_UTC);
78
- //return 1000000.0 * ts.tv_sec + ts.tv_nsec / 1000.0;
79
- return lrand48 ();
103
+ struct timespec ts ;
104
+ timespec_get (& ts , TIME_UTC );
105
+ return 1000000.0 * ts .tv_sec + ts .tv_nsec / 1000.0 ;
80
106
}
81
107
#else
82
108
0 commit comments