For PR351:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 20:14:30 +0000 (20:14 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 20:14:30 +0000 (20:14 +0000)
Remove AllocateRWXMemory as it is not used any more in LLVM. The function
has been replaced with sys::Memory::AllocateRWX several months ago.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18912 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/SystemUtils.h
lib/Support/SystemUtils.cpp

index aea7df80eba94f10972fdabc74f8fed3c8a6d04e..e8ead132e9844d48bc55c2f31815e6a31c1d952e 100644 (file)
@@ -53,13 +53,6 @@ int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
 ///
 int ExecWait (const char * const argv[], const char * const envp[]);
 
-/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
-/// permissions.  This is typically used for JIT applications where we want
-/// to emit code to the memory then jump to it.  Getting this type of memory
-/// is very OS specific.
-///
-void *AllocateRWXMemory(unsigned NumBytes);
-
 } // End llvm namespace
 
 #endif
index 3b529df79c75b77800b5cf2bd2f00bb27aee2c3d..ba43306e8e3b19abb0c68742d6f59162306ae542 100644 (file)
@@ -286,64 +286,3 @@ int llvm::ExecWait(const char * const old_argv[],
   // Otherwise, return failure.
   return 1;
 }
-
-/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
-/// permissions.  This is typically used for JIT applications where we want
-/// to emit code to the memory then jump to it.  Getting this type of memory
-/// is very OS specific.
-///
-void *llvm::AllocateRWXMemory(unsigned NumBytes) {
-  if (NumBytes == 0) return 0;
-
-#if defined(HAVE_WINDOWS_H)
-  // On windows we use VirtualAlloc.
-  void *P = VirtualAlloc(0, NumBytes, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
-  if (P == 0) {
-    std::cerr << "Error allocating executable memory!\n";
-    abort();
-  }
-  return P;
-
-#elif defined(HAVE_MMAP)
-  static const long pageSize = GetPageSize();
-  unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
-
-/* FIXME: This should use the proper autoconf flags */
-#if defined(i386) || defined(__i386__) || defined(__x86__)
-  /* Linux and *BSD tend to have these flags named differently. */
-#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
-# define MAP_ANONYMOUS MAP_ANON
-#endif /* defined(MAP_ANON) && !defined(MAP_ANONYMOUS) */
-#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
-/* nothing */
-#else
-  std::cerr << "This architecture has an unknown MMAP implementation!\n";
-  abort();
-  return 0;
-#endif
-
-  int fd = -1;
-#if defined(__linux__)
-  fd = 0;
-#endif
-
-  unsigned mmapFlags = MAP_PRIVATE|MAP_ANONYMOUS;
-#ifdef MAP_NORESERVE
-  mmapFlags |= MAP_NORESERVE;
-#endif
-
-  void *pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
-                  mmapFlags, fd, 0);
-  if (pa == MAP_FAILED) {
-    perror("mmap");
-    abort();
-  }
-  return pa;
-#else
-  std::cerr << "Do not know how to allocate mem for the JIT without mmap!\n";
-  abort();
-  return 0;
-#endif
-}
-
-