Fix call to mmap, so that it can be used on sparc.
authorBrian Gaeke <gaeke@uiuc.edu>
Fri, 30 May 2003 03:37:13 +0000 (03:37 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Fri, 30 May 2003 03:37:13 +0000 (03:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/SparcEmitter.cpp

index 3882b192582b5e96d3eea776b118e475e3fc9ba9..601be92857db3b4641ee78c6b7ea955b0156f71a 100644 (file)
@@ -77,20 +77,15 @@ MachineCodeEmitter *VM::createSparcEmitter(VM &V) {
 // FIXME: This should be rewritten to support a real memory manager for
 // executable memory pages!
 void * SparcEmitter::getMemory(unsigned NumPages) {
-#if 0
-  void *pa = mmap(0, 4096*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
-                  MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+  void *pa;
+  if (NumPages == 0) return 0;
+  static const long pageSize = sysconf (_SC_PAGESIZE);
+  pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+                  MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
   if (pa == MAP_FAILED) {
     perror("mmap");
     abort();
   }
-#endif
-  void *pa = malloc(4096*NumPages);
-  if (!pa) {
-    perror("malloc");
-    abort();
-  }
-  funcMemory.push_back(pa);
   return pa;
 }