Browse files

remove mod in round-to-page-size function

  • Loading branch information...
kevinlawler committed Jun 22, 2011
1 parent 2390f90 commit ed38db520cb2dfe2dc3703249bc23bd2778c7349
Showing with 2 additions and 4 deletions.
  1. +2 −4 km.c
6 km.c
@@ -17,7 +17,6 @@ I PG; //pagesize: size_t page_size = (size_t) sysconf (_SC_PAGESIZE);
Z I cl2(I v);
Z I kexpander(K *p,I n);
-Z I nearest(I i,I m);
Z K kapn_(K *a,V *v,I n);
Z V amem(I k);
Z V kalloc(I k);
@@ -60,9 +59,8 @@ K ci(K a){if(a)a->c++; R a;}
I bp(I t) {SW(ABS(t)){CSR(1, R sizeof(I)) CSR(2, R sizeof(F)) CSR(3, R sizeof(C)) default: R sizeof(V); } } //Default 0/+-4/5/6/7 (assumes sizeof(K)==sizeof(S)==...)
I sz(I t,I n){R 3*sizeof(I)+(7==t?TYPE_SEVEN_SIZE:n)*bp(t)+(3==ABS(t));} //not recursive. assert sz() > 0: Everything gets valid block for simplified munmap/(free)
-Z I nearest(I i,I m){I k=i%m;R k?i+m-k:i;} //up 0,8,...,8,16,16,...
-#define nearPG(i) nearest((i),PG)
-//#define nearI(i) nearest((i),sizeof(I))
+Z I nearPG(I i){ I k=((size_t)i)&(PG-1);R k?i+PG-k:i;}//up 0,8,...,8,16,16,...
//This is an untested idea for avoiding all that goes on in backing out of memory allocations when an error occurs inside a function before everything is done:
//If you control the memory allocator one possibility is to work in "claimed" (sbreak) but "free" space and build the K data structure there.

0 comments on commit ed38db5

Please sign in to comment.