Makfile: use LINK for the link phase
[fio.git] / t / axmap.c
CommitLineData
ad1f90aa
JA
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"
32bbd3ab 9#include "../lib/axmap.h"
ad1f90aa
JA
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;
32bbd3ab 24 size_t osize, size = (1UL << 28) - 200;
ad1f90aa 25 struct axmap *map;
32bbd3ab 26 uint64_t ff;
4e59017d 27 int seed = 1;
ad1f90aa 28
4e59017d 29 if (argc > 1) {
ad1f90aa 30 size = strtoul(argv[1], NULL, 10);
4e59017d
JA
31 if (argc > 2)
32 seed = strtoul(argv[2], NULL, 10);
33 }
ad1f90aa
JA
34
35 printf("Using %llu entries\n", (unsigned long long) size);
36
4e59017d 37 lfsr_init(&lfsr, size, seed);
ad1f90aa 38 map = axmap_new(size);
32bbd3ab 39 osize = size;
ad1f90aa
JA
40
41 while (size--) {
42 uint64_t val;
43
32bbd3ab
JA
44 if (lfsr_next(&lfsr, &val, osize)) {
45 printf("lfsr: short loop\n");
46 break;
47 }
ad1f90aa
JA
48 axmap_set(map, val);
49 }
50
32bbd3ab
JA
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
ad1f90aa
JA
57 return 0;
58}