]> mj.ucw.cz Git - libucw.git/blobdiff - lib/bigalloc.c
Merge with git+ssh://git.ucw.cz/projects/sherlock/GIT/sherlock.git#v3.10.1
[libucw.git] / lib / bigalloc.c
index b4589c4ab54909a5846d4aa071f48ca0bd4bb661..ad6aeff0cd523e9acc97bcc53408e8367abb989d 100644 (file)
 #include "lib/lib.h"
 
 #include <sys/mman.h>
-#include <sys/user.h>
 
 static unsigned int
 big_round(unsigned int len)
 {
-  return ALIGN_TO(len, PAGE_SIZE);
+  return ALIGN_TO(len, CPU_PAGE_SIZE);
 }
 
 void *
@@ -23,15 +22,15 @@ big_alloc(unsigned int len)
 {
   len = big_round(len);
 #ifdef CONFIG_DEBUG
-  len += 2*PAGE_SIZE;
+  len += 2*CPU_PAGE_SIZE;
 #endif
   byte *p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
   if (p == (byte*) MAP_FAILED)
     die("Cannot mmap %d bytes of memory: %m", len);
 #ifdef CONFIG_DEBUG
-  mprotect(p, PAGE_SIZE, PROT_NONE);
-  mprotect(p+len-PAGE_SIZE, PAGE_SIZE, PROT_NONE);
-  p += PAGE_SIZE;
+  mprotect(p, CPU_PAGE_SIZE, PROT_NONE);
+  mprotect(p+len-CPU_PAGE_SIZE, CPU_PAGE_SIZE, PROT_NONE);
+  p += CPU_PAGE_SIZE;
 #endif
   return p;
 }
@@ -40,11 +39,11 @@ void
 big_free(void *start, unsigned int len)
 {
   byte *p = start;
-  ASSERT(!((addr_int_t) p & (PAGE_SIZE-1)));
+  ASSERT(!((uintptr_t) p & (CPU_PAGE_SIZE-1)));
   len = big_round(len);
 #ifdef CONFIG_DEBUG
-  p -= PAGE_SIZE;
-  len += 2*PAGE_SIZE;
+  p -= CPU_PAGE_SIZE;
+  len += 2*CPU_PAGE_SIZE;
 #endif
   munmap(p, len);
 }