[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp
Reid Spencer
reid at x10sys.com
Mon Dec 13 10:29:09 PST 2004
Changes in directory llvm/lib/Support:
FileUtilities.cpp updated: 1.29 -> 1.30
---
Log message:
For PR351: http://llvm.cs.uiuc.edu/PR351 :
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.
---
Diffs of the changes: (+0 -46)
Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.29 llvm/lib/Support/FileUtilities.cpp:1.30
--- llvm/lib/Support/FileUtilities.cpp:1.29 Mon Dec 13 11:01:53 2004
+++ llvm/lib/Support/FileUtilities.cpp Mon Dec 13 12:28:59 2004
@@ -196,52 +196,6 @@
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
//
More information about the llvm-commits
mailing list