3f6043dbfe0e5af49182691dc747aaa1c7e6ff80
[fio.git] / t / axmap.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <fcntl.h>
4 #include <string.h>
5 #include <unistd.h>
6 #include <inttypes.h>
7
8 #include "../lib/lfsr.h"
9
10 struct axmap;
11 void axmap_set(struct axmap *, uint64_t);
12 struct axmap *axmap_new(uint64_t size);
13
14 void *smalloc(size_t size)
15 {
16         return malloc(size);
17 }
18
19 void sfree(void *ptr)
20 {
21         free(ptr);
22 }
23
24 int main(int argc, char *argv[])
25 {
26         struct fio_lfsr lfsr;
27         size_t size = (1UL << 28) - 200;
28         struct axmap *map;
29         int seed = 1;
30
31         if (argc > 1) {
32                 size = strtoul(argv[1], NULL, 10);
33                 if (argc > 2)
34                         seed = strtoul(argv[2], NULL, 10);
35         }
36
37         printf("Using %llu entries\n", (unsigned long long) size);
38
39         lfsr_init(&lfsr, size, seed);
40         map = axmap_new(size);
41
42         while (size--) {
43                 uint64_t val;
44
45                 lfsr_next(&lfsr, &val);
46                 axmap_set(map, val);
47         }
48
49         return 0;
50 }