diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-13 12:02:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-13 12:02:29 +0000 |
commit | 751ac5be401fcb4b633a5ea3116de2f9d7452bbb (patch) | |
tree | 442d9b37f3c5f5d306a9eef7b35363b78ac1c5a3 /src/mt19937ar-cok/mt19937ar-cok.h | |
parent | Adding upstream version 0.36. (diff) | |
download | nwipe-751ac5be401fcb4b633a5ea3116de2f9d7452bbb.tar.xz nwipe-751ac5be401fcb4b633a5ea3116de2f9d7452bbb.zip |
Adding upstream version 0.37.upstream/0.37upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/mt19937ar-cok/mt19937ar-cok.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/mt19937ar-cok/mt19937ar-cok.h b/src/mt19937ar-cok/mt19937ar-cok.h index afcc873..202a0f5 100644 --- a/src/mt19937ar-cok/mt19937ar-cok.h +++ b/src/mt19937ar-cok/mt19937ar-cok.h @@ -1,30 +1,29 @@ /* - * mt19937ar-cok.h: The Mersenne Twister PRNG implementation for nwipe. - * + * mt19937ar-cok.h: The Mersenne Twister PRNG implementation for nwipe. */ #ifndef MT19937AR_H_ #define MT19937AR_H_ /* Period parameters */ -#define N 624 -#define M 397 -#define MATRIX_A 0x9908b0dfUL /* constant vector a */ +#define MT_STATE_SIZE 624 +#define MT_MIDDLE_WORD 397 +#define MATRIX_A 0x9908b0dfUL /* constant vector a */ #define UMASK 0x80000000UL /* most significant w-r bits */ #define LMASK 0x7fffffffUL /* least significant r bits */ -#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) ) -#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL)) +#define MIXBITS( u, v ) ( ( (u) &UMASK ) | ( (v) &LMASK ) ) +#define TWIST( u, v ) ( ( MIXBITS( u, v ) >> 1 ) ^ ( (v) &1UL ? MATRIX_A : 0UL ) ) typedef struct twister_state_t_ { - unsigned long array[N]; - int left; - int initf; - unsigned long *next; -} twister_state_t; + unsigned long array[MT_STATE_SIZE]; // Updated to use MT_STATE_SIZE + int left; + int initf; + unsigned long* next; +} twister_state_t; /* Initialize the MT state. ( 0 < key_length <= 624 ). */ -void twister_init( twister_state_t* state, unsigned long init_key[], unsigned long key_length); +void twister_init( twister_state_t* state, unsigned long init_key[], unsigned long key_length ); /* Generate a random integer on the [0,0xffffffff] interval. */ unsigned long twister_genrand_int32( twister_state_t* state ); |