summaryrefslogtreecommitdiffstats
path: root/src/mt19937ar-cok/mt19937ar-cok.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 22:13:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 22:13:02 +0000
commite244c93d21bcacf1a0eedefdcc3018a362274796 (patch)
tree857e0d7bcf20546b38fff97a8702c2c1240bc23b /src/mt19937ar-cok/mt19937ar-cok.h
parentInitial commit. (diff)
downloadnwipe-e244c93d21bcacf1a0eedefdcc3018a362274796.tar.xz
nwipe-e244c93d21bcacf1a0eedefdcc3018a362274796.zip
Adding upstream version 0.36.upstream/0.36
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/mt19937ar-cok/mt19937ar-cok.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mt19937ar-cok/mt19937ar-cok.h b/src/mt19937ar-cok/mt19937ar-cok.h
new file mode 100644
index 0000000..afcc873
--- /dev/null
+++ b/src/mt19937ar-cok/mt19937ar-cok.h
@@ -0,0 +1,32 @@
+/*
+ * 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 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))
+
+typedef struct twister_state_t_
+{
+ unsigned long array[N];
+ 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);
+
+/* Generate a random integer on the [0,0xffffffff] interval. */
+unsigned long twister_genrand_int32( twister_state_t* state );
+
+#endif /* MT19937AR_H_ */