8 #include "../lib/lfsr.h"
9 #include "../lib/axmap.h"
11 void *smalloc(size_t size)
21 static int test_regular(size_t size, int seed)
29 printf("Using %llu entries...", (unsigned long long) size);
32 lfsr_init(&lfsr, size, seed, seed & 0xF);
33 map = axmap_new(size);
40 if (lfsr_next(&lfsr, &val)) {
41 printf("lfsr: short loop\n");
45 if (axmap_isset(map, val)) {
46 printf("bit already set\n");
51 if (!axmap_isset(map, val)) {
52 printf("bit not set\n");
61 ff = axmap_next_free(map, osize);
62 if (ff != (uint64_t) -1ULL) {
63 printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff);
72 static int test_multi(size_t size, unsigned int bit_off)
74 unsigned int map_size = size;
76 uint64_t val = bit_off;
79 printf("Test multi %llu entries %u offset...", (unsigned long long) size, bit_off);
82 map = axmap_new(map_size);
83 while (val + 128 <= map_size) {
85 for (i = val; i < val + 128; i++) {
86 if (axmap_isset(map, val + i)) {
87 printf("bit already set\n");
96 err = axmap_set_nr(map, val, 128);
98 printf("only set %u bits\n", err);
103 for (i = 0; i < 128; i++) {
104 if (!axmap_isset(map, val + i)) {
105 printf("bit not set: %llu\n", (unsigned long long) val + i);
123 int main(int argc, char *argv[])
125 size_t size = (1UL << 23) - 200;
129 size = strtoul(argv[1], NULL, 10);
131 seed = strtoul(argv[2], NULL, 10);
134 if (test_regular(size, seed))
136 if (test_multi(size, 0))
138 if (test_multi(size, 17))