mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 01:44:13 +08:00
mdbx-test: обновление ГПСЧ.
This commit is contained in:
parent
3373631cff
commit
00c4e2636e
@ -107,18 +107,22 @@ uint64_t prng64_white(uint64_t &state) {
|
||||
return bleach64(state);
|
||||
}
|
||||
|
||||
uint32_t prng32(uint64_t &state) {
|
||||
return (uint32_t)(prng64_careless(state) >> 32);
|
||||
uint32_t prng32_fast(uint64_t &state) {
|
||||
return uint32_t(prng64_careless(state) >> 32);
|
||||
}
|
||||
|
||||
uint32_t prng32_white(uint64_t &state) {
|
||||
return bleach32(uint32_t(prng64_careless(state) >> 32));
|
||||
}
|
||||
|
||||
void prng_fill(uint64_t &state, void *ptr, size_t bytes) {
|
||||
uint32_t u32 = prng32(state);
|
||||
uint32_t u32 = prng32_fast(state);
|
||||
|
||||
while (bytes >= 4) {
|
||||
memcpy(ptr, &u32, 4);
|
||||
ptr = (uint32_t *)ptr + 1;
|
||||
bytes -= 4;
|
||||
u32 = prng32(state);
|
||||
u32 = prng32_fast(state);
|
||||
}
|
||||
|
||||
switch (bytes & 3) {
|
||||
@ -140,7 +144,7 @@ void prng_fill(uint64_t &state, void *ptr, size_t bytes) {
|
||||
|
||||
void prng_seed(uint64_t seed) { prng_state = bleach64(seed); }
|
||||
|
||||
uint32_t prng32(void) { return prng32(prng_state); }
|
||||
uint32_t prng32(void) { return prng32_white(prng_state); }
|
||||
|
||||
uint64_t prng64(void) { return prng64_white(prng_state); }
|
||||
|
||||
|
@ -288,24 +288,26 @@ inline bool is_samedata(const MDBX_val &a, const MDBX_val &b) {
|
||||
}
|
||||
std::string format(const char *fmt, ...);
|
||||
|
||||
static inline uint64_t bleach64(uint64_t v) {
|
||||
// Tommy Ettinger, https://www.blogger.com/profile/04953541827437796598
|
||||
// http://mostlymangling.blogspot.com/2019/01/better-stronger-mixer-and-test-procedure.html
|
||||
v ^= rot64(v, 25) ^ rot64(v, 50);
|
||||
v *= UINT64_C(0xA24BAED4963EE407);
|
||||
v ^= rot64(v, 24) ^ rot64(v, 49);
|
||||
v *= UINT64_C(0x9FB21C651E98DF25);
|
||||
return v ^ v >> 28;
|
||||
static inline uint64_t bleach64(uint64_t x) {
|
||||
// NASAM from Tommy Ettinger,
|
||||
// https://www.blogger.com/profile/04953541827437796598
|
||||
// http://mostlymangling.blogspot.com/2020/01/nasam-not-another-strange-acronym-mixer.html
|
||||
x ^= rot64(x, 25) ^ rot64(x, 47);
|
||||
x *= UINT64_C(0x9E6C63D0676A9A99);
|
||||
x ^= x >> 23 ^ x >> 51;
|
||||
x *= UINT64_C(0x9E6D62D06F6A9A9B);
|
||||
x ^= x >> 23 ^ x >> 51;
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline uint32_t bleach32(uint32_t x) {
|
||||
// https://github.com/skeeto/hash-prospector
|
||||
// exact bias: 0.17353355999581582
|
||||
// exact bias: 0.10760229515479501
|
||||
x ^= x >> 16;
|
||||
x *= UINT32_C(0x7feb352d);
|
||||
x *= UINT32_C(0x21f0aaad);
|
||||
x ^= 0x3027C563 ^ (x >> 15);
|
||||
x *= UINT32_C(0x846ca68b);
|
||||
x ^= x >> 16;
|
||||
x *= UINT32_C(0x0d35a2d97);
|
||||
x ^= x >> 15;
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -343,7 +345,8 @@ static inline double u64_to_double1(uint64_t v) {
|
||||
}
|
||||
|
||||
uint64_t prng64_white(uint64_t &state);
|
||||
uint32_t prng32(uint64_t &state);
|
||||
uint32_t prng32_white(uint64_t &state);
|
||||
uint32_t prng32_fast(uint64_t &state);
|
||||
void prng_fill(uint64_t &state, void *ptr, size_t bytes);
|
||||
|
||||
extern uint64_t prng_state;
|
||||
|
Loading…
x
Reference in New Issue
Block a user