diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-28 00:31:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-28 00:31:36 +0000 |
commit | 531b802e132af92aac4384206bdc6b8a4d28aa00 (patch) | |
tree | c963a3b591f17732e3e03bb16b3cdd367fe3827d /utils/fpcmp | |
parent | fb777c270bac4b95b739dad552c5ab8f5aa2aef4 (diff) | |
download | external_llvm-531b802e132af92aac4384206bdc6b8a4d28aa00.zip external_llvm-531b802e132af92aac4384206bdc6b8a4d28aa00.tar.gz external_llvm-531b802e132af92aac4384206bdc6b8a4d28aa00.tar.bz2 |
Use fileutilities instead of mmap directly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13865 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/fpcmp')
-rw-r--r-- | utils/fpcmp/fpcmp.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/utils/fpcmp/fpcmp.cpp b/utils/fpcmp/fpcmp.cpp index 7e472d4..e7e318e 100644 --- a/utils/fpcmp/fpcmp.cpp +++ b/utils/fpcmp/fpcmp.cpp @@ -37,25 +37,11 @@ namespace { /// OpenFile - mmap the specified file into the address space for reading, and /// return the length and address of the buffer. static void OpenFile(const std::string &Filename, unsigned &Len, char* &BufPtr){ - int FD = open(Filename.c_str(), O_RDONLY); - if (FD == -1 || (Len = getFileSize(Filename)) == ~0U) { + BufPtr = (char*)ReadFileIntoAddressSpace(Filename, Len); + if (BufPtr == 0) { std::cerr << "Error: cannot open file '" << Filename << "'\n"; exit(2); } - - // mmap in the file all at once... - BufPtr = (char*)mmap(0, Len, PROT_READ, MAP_PRIVATE, FD, 0); - - if (BufPtr == (char*)MAP_FAILED) { - std::cerr << "Error: cannot open file '" << Filename << "'\n"; - exit(2); - } - - // If mmap decided that the files were empty, it might have returned a - // null pointer. If so, make a new, fake pointer -- it shouldn't matter - // what it contains, because Len is 0, and it should never be read. - if (BufPtr == 0 && Len == 0) - BufPtr = new char[1]; } static bool isNumberChar(char C) { |