2 * Xorshift Pseudo Random Number Generator based on work by David Blackman
3 * and Sebastiano Vigna (vigna@acm.org).
5 * "Further scramblings of Marsaglia's xorshift generators"
6 * http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
7 * http://prng.di.unimi.it/xoroshiro128plusplus.c
9 * To the extent possible under law, the author has dedicated all copyright
10 * and related and neighboring rights to this software to the public domain
11 * worldwide. This software is distributed without any warranty.
13 * See <http://creativecommons.org/publicdomain/zero/1.0/>.
15 * This is xoroshiro128++ 1.0, one of our all-purpose, rock-solid,
16 * small-state generators. It is extremely (sub-ns) fast and it passes all
17 * tests we are aware of, but its state space is large enough only for
21 #include <sys/vdev_draid.h>
23 static inline uint64_t rotl(const uint64_t x
, int k
)
25 return (x
<< k
) | (x
>> (64 - k
));
29 vdev_draid_rand(uint64_t *s
)
31 const uint64_t s0
= s
[0];
33 const uint64_t result
= rotl(s0
+ s1
, 17) + s0
;
36 s
[0] = rotl(s0
, 49) ^ s1
^ (s1
<< 21); // a, b
37 s
[1] = rotl(s1
, 28); // c