For PR351:
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 18:28:59 +0000 (18:28 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 18:28:59 +0000 (18:28 +0000)
The ReadFileIntoAddressSpace and UnmapFileFromAddressSpace functions are no
longer used by LLVM. Remove them. Replacement functionality for both
functions is now encapsulated in the sys::MappedFile class.

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

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

index 885ee86c0d306b88c3943d44e638306db3352333..b243df506b5513977bc6e83cb5511adee4a34548 100644 (file)
@@ -61,17 +61,6 @@ bool MakeFileExecutable(const std::string &Filename);
 ///
 bool MakeFileReadable(const std::string &Filename);
 
-/// ReadFileIntoAddressSpace - Attempt to map the specific file into the 
-/// address space of the current process for reading.  If this succeeds, 
-/// return the address of the buffer and the length of the file mapped.  On 
-/// failure, return null.
-void *ReadFileIntoAddressSpace(const std::string &Filename, unsigned &Length);
-
-/// UnmapFileFromAddressSpace - Remove the specified file from the current
-/// address space.
-void UnmapFileFromAddressSpace(void *Buffer, unsigned Length);
-
-
 /// FDHandle - Simple handle class to make sure a file descriptor gets closed
 /// when the object is destroyed.  This handle acts similarly to an
 /// std::auto_ptr, in that the copy constructor and assignment operators
index 305f455937aafeed8a637437e6a2aad60bd73de2..ee83bc1a56a9cd424446b06189938ea51bea4d58 100644 (file)
@@ -196,52 +196,6 @@ bool llvm::MakeFileReadable(const std::string &Filename) {
   return AddPermissionsBits(Filename, 0444);
 }
 
-/// ReadFileIntoAddressSpace - Attempt to map the specific file into the
-/// address space of the current process for reading.  If this succeeds,
-/// return the address of the buffer and the length of the file mapped.  On
-/// failure, return null.
-void *llvm::ReadFileIntoAddressSpace(const std::string &Filename, 
-                                     unsigned &Length) {
-#if defined(HAVE_MMAP_FILE) && !defined(_MSC_VER)
-  sys::Path File(Filename);
-  Length = (unsigned)File.getSize();
-  if ((int)Length == -1) return 0;
-
-  FDHandle FD(open(Filename.c_str(), O_RDONLY));
-  if (FD == -1) return 0;
-
-  // If the file has a length of zero, mmap might return a null pointer.  In 
-  // this case, allocate a single byte of memory and return it instead.
-  if (Length == 0)
-    return malloc(1);
-
-  // mmap in the file all at once...
-  void *Buffer = (void*)mmap(0, Length, PROT_READ, MAP_PRIVATE, FD, 0);
-
-  if (Buffer == (void*)MAP_FAILED)
-    return 0;
-
-  return Buffer;
-#else
-  // FIXME: implement with read/write
-#error Unimplemented ReadFileIntoAddressSpace - need to use read/write.
-  return 0;
-#endif
-}
-
-/// UnmapFileFromAddressSpace - Remove the specified file from the current
-/// address space.
-void llvm::UnmapFileFromAddressSpace(void *Buffer, unsigned Length) {
-#if defined(HAVE_MMAP_FILE) && !defined(_MSC_VER)
-  if (Length)
-    munmap((char*)Buffer, Length);
-  else
-    free(Buffer);  // Zero byte files are malloc(1)'s.
-#else
-  free(Buffer);
-#endif
-}
-
 //===----------------------------------------------------------------------===//
 // FDHandle class implementation
 //