#undef LOCAL_DEBUG
#include "lib/lib.h"
+#include "lib/bitops.h"
#include "lib/fastbuf.h"
#include "lib/qache.h"
-#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
bzero(&h, sizeof(h));
h.magic = QACHE_MAGIC;
h.block_size = par->block_size;
- h.block_shift = fls(h.block_size);
+ h.block_shift = bit_fls(h.block_size);
h.num_blocks = par->cache_size >> h.block_shift;
h.format_id = par->format_id;
h.entry_table_start = sizeof(h);
log(L_INFO, "Cache %s: created (%d bytes, %d slots, %d buckets)", q->file_name, par->cache_size, h.max_entries, h.hash_size);
if ((q->mmap_data = mmap(NULL, par->cache_size, PROT_READ | PROT_WRITE, MAP_SHARED, q->fd, 0)) == MAP_FAILED)
- die("Cache %s: mmap failed (%m)", par->cache_size);
+ die("Cache %s: mmap failed (%m)", par->file_name);
q->file_size = par->cache_size;
qache_setup_pointers(q);
}
if (par->force_reset <= 0 && qache_open_existing(q, par))
;
else if (par->force_reset < 0)
- die("Cache %s: read-only access requested, but no data available");
+ die("Cache %s: read-only access requested, but no data available", q->file_name);
else
qache_create(q, par);
return q;