blob: 7909383e71a367ba6d294db47602d5c34272c74e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "philox.h"
extern inline uint64_t philox_next64(philox_state *state);
extern inline uint32_t philox_next32(philox_state *state);
extern void philox_jump(philox_state *state) {
/* Advances state as-if 2^128 draws were made */
state->ctr->v[2]++;
if (state->ctr->v[2] == 0) {
state->ctr->v[3]++;
}
}
extern void philox_advance(uint64_t *step, philox_state *state) {
int i, carry = 0;
uint64_t v_orig;
for (i = 0; i < 4; i++) {
if (carry == 1) {
state->ctr->v[i]++;
carry = state->ctr->v[i] == 0 ? 1 : 0;
}
v_orig = state->ctr->v[i];
state->ctr->v[i] += step[i];
if (state->ctr->v[i] < v_orig && carry == 0) {
carry = 1;
}
}
}
|