9 #include "../lib/lfsr.h"
10 #include "../lib/axmap.h"
12 void *smalloc(size_t size)
22 static int test_regular(size_t size, int seed)
30 printf("Using %llu entries...", (unsigned long long) size);
33 lfsr_init(&lfsr, size, seed, seed & 0xF);
34 map = axmap_new(size);
41 if (lfsr_next(&lfsr, &val)) {
42 printf("lfsr: short loop\n");
46 if (axmap_isset(map, val)) {
47 printf("bit already set\n");
52 if (!axmap_isset(map, val)) {
53 printf("bit not set\n");
62 ff = axmap_next_free(map, osize);
63 if (ff != (uint64_t) -1ULL) {
64 printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff);
73 static int test_multi(size_t size, unsigned int bit_off)
75 unsigned int map_size = size;
77 uint64_t val = bit_off;
80 printf("Test multi %llu entries %u offset...", (unsigned long long) size, bit_off);
83 map = axmap_new(map_size);
84 while (val + 128 <= map_size) {
86 for (i = val; i < val + 128; i++) {
87 if (axmap_isset(map, val + i)) {
88 printf("bit already set\n");
97 err = axmap_set_nr(map, val, 128);
99 printf("only set %u bits\n", err);
104 for (i = 0; i < 128; i++) {
105 if (!axmap_isset(map, val + i)) {
106 printf("bit not set: %llu\n", (unsigned long long) val + i);
124 int main(int argc, char *argv[])
126 size_t size = (1UL << 23) - 200;
130 size = strtoul(argv[1], NULL, 10);
132 seed = strtoul(argv[2], NULL, 10);
135 if (test_regular(size, seed))
137 if (test_multi(size, 0))
139 if (test_multi(size, 17))