]> mj.ucw.cz Git - libucw.git/blobdiff - lib/qache.c
Use big_alloc().
[libucw.git] / lib / qache.c
index a973be458a5d88f15fd6177bdfb14efdedc95eba..3c4be273ab1c1bd0b24d100cc4439781da75a61c 100644 (file)
@@ -7,12 +7,13 @@
 #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/stat.h>
 #include <sys/mman.h>
 #include <sys/user.h>
 
@@ -82,7 +83,7 @@ qache_msync(struct qache *q UNUSED, uns start UNUSED, uns len UNUSED)
   /* We don't need msyncing on Linux, since the mappings are guaranteed to be coherent */
   len += (start % PAGE_SIZE);
   start -= start % PAGE_SIZE;
-  len = ALIGN(len, PAGE_SIZE);
+  len = ALIGN_TO(len, PAGE_SIZE);
   if (msync(q->mmap_data + start, len, MS_ASYNC | MS_INVALIDATE) < 0)
     log(L_ERROR, "Cache %s: msync failed: %m", q->file_name);
 #endif
@@ -313,7 +314,7 @@ qache_create(struct qache *q, struct qache_params *par)
   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);
@@ -383,7 +384,7 @@ qache_open(struct qache_params *par)
   q->file_name = xstrdup(par->file_name);
 
   ASSERT(par->block_size >= 8 && !(par->block_size & (par->block_size-1)));
-  par->cache_size = ALIGN(par->cache_size, par->block_size);
+  par->cache_size = ALIGN_TO(par->cache_size, par->block_size);
 
   if (par->force_reset <= 0 && qache_open_existing(q, par))
     ;