Readability refactoring

This commit is contained in:
VegOwOtenks 2025-02-28 23:04:38 +01:00
parent 87f592ea8b
commit 50070e6963
2 changed files with 8 additions and 8 deletions

View file

@ -25,7 +25,7 @@ uint64_t rotate_uint64_left(uint64_t bytes, int degree)
} }
uint64_t xoshiro256_next(xoshiro256_state_t* state) { uint64_t xoshiro256_next(Xoshiro256State* state) {
uint64_t* uint64_state = state->state; uint64_t* uint64_state = state->state;
const uint64_t result = rotate_uint64_left(uint64_state[0] + uint64_state[3], 23) + uint64_state[0]; const uint64_t result = rotate_uint64_left(uint64_state[0] + uint64_state[3], 23) + uint64_state[0];
@ -48,7 +48,7 @@ uint64_t xoshiro256_next(xoshiro256_state_t* state) {
to 2^128 calls to next(); it can be used to generate 2^128 to 2^128 calls to next(); it can be used to generate 2^128
non-overlapping subsequences for parallel computations. */ non-overlapping subsequences for parallel computations. */
void jump(xoshiro256_state_t* state) { void jump(Xoshiro256State* state) {
uint64_t* uint64_state = state->state; uint64_t* uint64_state = state->state;
static const uint64_t JUMP[] = { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c }; static const uint64_t JUMP[] = { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c };
@ -80,7 +80,7 @@ void jump(xoshiro256_state_t* state) {
from each of which jump() will generate 2^64 non-overlapping from each of which jump() will generate 2^64 non-overlapping
subsequences for parallel distributed computations. */ subsequences for parallel distributed computations. */
void long_jump(xoshiro256_state_t* state) { void long_jump(Xoshiro256State* state) {
uint64_t* uint64_state = state->state; uint64_t* uint64_state = state->state;
static const uint64_t LONG_JUMP[] = { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 }; static const uint64_t LONG_JUMP[] = { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 };
@ -103,4 +103,4 @@ void long_jump(xoshiro256_state_t* state) {
uint64_state[1] = s1; uint64_state[1] = s1;
uint64_state[2] = s2; uint64_state[2] = s2;
uint64_state[3] = s3; uint64_state[3] = s3;
} }

View file

@ -22,12 +22,12 @@
#include <stdint.h> #include <stdint.h>
typedef struct XoshiroState { typedef struct XoshiroState_s {
uint64_t state[4]; uint64_t state[4];
} xoshiro256_state_t; } Xoshiro256State;
uint64_t rotate_uint64_left(uint64_t bytes, int degree); uint64_t rotate_uint64_left(uint64_t bytes, int degree);
uint64_t xoshiro256_next(xoshiro256_state_t *state); uint64_t xoshiro256_next(Xoshiro256State *state);
#endif #endif