[llvm-commits] CVS: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Feb 22 12:13:02 PST 2005
Changes in directory llvm-poolalloc/runtime/PtrCompAllocator:
PtrCompAllocator.cpp updated: 1.2 -> 1.3
---
Log message:
Make sure that node #0 is reserved for the null pointer.
---
Diffs of the changes: (+11 -9)
PtrCompAllocator.cpp | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
Index: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp
diff -u llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.2 llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.3
--- llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.2 Tue Feb 22 14:11:26 2005
+++ llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp Tue Feb 22 14:12:49 2005
@@ -175,15 +175,6 @@
free(Pool->BitVector);
}
-static void CreatePool(PoolTy *Pool) __attribute__((noinline));
-static void CreatePool(PoolTy *Pool) {
- Pool->PoolBase = (char*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0);
- Pool->NumNodesInBitVector = 1024;
- Pool->BitVector = (unsigned long*)malloc(Pool->NumNodesInBitVector*2/8);
- Pool->NumUsed = 0;
-}
-
static inline void MarkNodeAllocated(PoolTy *Pool, unsigned long NodeNum) {
Pool->BitVector[NodeNum*2/(sizeof(long)*8)] |=
3 << (2*(NodeNum & (sizeof(long)*8/2-1)));
@@ -194,6 +185,17 @@
~(3 << (2*(NodeNum & (sizeof(long)*8/2-1))));
}
+static void CreatePool(PoolTy *Pool) __attribute__((noinline));
+static void CreatePool(PoolTy *Pool) {
+ Pool->PoolBase = (char*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0);
+ Pool->NumNodesInBitVector = 1024;
+ Pool->BitVector = (unsigned long*)malloc(Pool->NumNodesInBitVector*2/8);
+
+ // Mark the null pointer allocated.
+ Pool->NumUsed = 1;
+ MarkNodeAllocated(Pool, 0);
+}
unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes) {
assert(Pool && "Null pool pointer passed in to poolalloc!\n");
More information about the llvm-commits
mailing list