Improve LFSR implementation
[archipelago] / xseg / peers / user / bench-lfsr.h
1 #ifndef FIO_LFSR_H
2 #define FIO_LFSR_H
3 #include <inttypes.h>
4
5 #define MAX_TAPS        6
6
7 struct lfsr_taps {
8         unsigned int length;
9         unsigned int taps[MAX_TAPS];
10 };
11
12
13 struct bench_lfsr {
14         uint64_t xormask;
15         uint64_t last_val;
16         uint64_t cached_bit;
17         uint64_t max_val;
18         uint64_t num_vals;
19         uint64_t cycle_length;
20         unsigned int spin;
21 };
22
23 uint64_t lfsr_next(struct bench_lfsr *lfsr);
24 int lfsr_init(struct bench_lfsr *lfsr, uint64_t size,
25                 unsigned long seed, unsigned int spin);
26 int lfsr_reset(struct bench_lfsr *lfsr, unsigned long seed);
27 #endif