Guard dynamic library loading.
[oota-llvm.git] / lib / Support / Allocator.cpp
index 8ccd3908446a4a47ecf96f49d49bdecb09bef673..db0d8f31e55dc0618b1a316eec960474fa150ad1 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Recycler.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Streams.h"
 #include <ostream>
@@ -45,10 +46,10 @@ public:
   
   /// Allocate - Allocate and return at least the specified number of bytes.
   ///
-  void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) {
+  void *Allocate(size_t AllocSize, size_t Alignment, MemRegion **RegPtr) {
     
     char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) 
-                            & ~(Alignment-1));
+                            & ~((uintptr_t) Alignment-1));
 
     // Speculate the new value of NextPtr.
     char* NextPtrTmp = Result + AllocSize;
@@ -113,7 +114,7 @@ void BumpPtrAllocator::Reset() {
   TheMemory = MRP;
 }
 
-void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
+void *BumpPtrAllocator::Allocate(size_t Size, size_t Align) {
   MemRegion *MRP = (MemRegion*)TheMemory;
   void *Ptr = MRP->Allocate(Size, Align, &MRP);
   TheMemory = MRP;
@@ -130,3 +131,11 @@ void BumpPtrAllocator::PrintStats() const {
   cerr << "\nNumber of memory regions: " << NumRegions << "\n";
   cerr << "Bytes allocated: " << BytesUsed << "\n";
 }
+
+void llvm::PrintRecyclerStats(size_t Size,
+                              size_t Align,
+                              size_t FreeListSize) {
+  cerr << "Recycler element size: " << Size << '\n';
+  cerr << "Recycler element alignment: " << Align << '\n';
+  cerr << "Number of elements free for recycling: " << FreeListSize << '\n';
+}