summaryrefslogtreecommitdiff
path: root/lib/lfsr.h
blob: 95bc07fd57da905b150f893926aee9cbc92ef1be (plain)
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
30
#ifndef FIO_LFSR_H
#define FIO_LFSR_H

#include <inttypes.h>

#define FIO_MAX_TAPS	6

struct lfsr_taps {
	unsigned int length;
	unsigned int taps[FIO_MAX_TAPS];
};


struct fio_lfsr {
	uint64_t xormask;
	uint64_t last_val;
	uint64_t cached_bit;
	uint64_t max_val;
	uint64_t num_vals;
	uint64_t cycle_length;
	uint64_t cached_cycle_length;
	unsigned int spin;
};

int lfsr_next(struct fio_lfsr *fl, uint64_t *off);
int lfsr_init(struct fio_lfsr *fl, uint64_t size,
	      uint64_t seed, unsigned int spin);
int lfsr_reset(struct fio_lfsr *fl, uint64_t seed);

#endif