configure: add --extra-cflags
[fio.git] / t / axmap.c
... / ...
CommitLineData
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#include "../lib/axmap.h"
10
11void *smalloc(size_t size)
12{
13 return malloc(size);
14}
15
16void sfree(void *ptr)
17{
18 free(ptr);
19}
20
21int main(int argc, char *argv[])
22{
23 struct fio_lfsr lfsr;
24 size_t osize, size = (1UL << 28) - 200;
25 struct axmap *map;
26 uint64_t ff;
27 int seed = 1;
28
29 if (argc > 1) {
30 size = strtoul(argv[1], NULL, 10);
31 if (argc > 2)
32 seed = strtoul(argv[2], NULL, 10);
33 }
34
35 printf("Using %llu entries\n", (unsigned long long) size);
36
37 lfsr_init(&lfsr, size, seed);
38 map = axmap_new(size);
39 osize = size;
40
41 while (size--) {
42 uint64_t val;
43
44 if (lfsr_next(&lfsr, &val, osize)) {
45 printf("lfsr: short loop\n");
46 break;
47 }
48 axmap_set(map, val);
49 }
50
51 ff = axmap_next_free(map, osize);
52 if (ff != (uint64_t) -1ULL) {
53 printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff);
54 return 1;
55 }
56
57 return 0;
58}