aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-01 06:20:44 +0000
committerChris Lattner <sabre@nondot.org>2008-04-01 06:20:44 +0000
commit98b7e612b2320ae83d2896b7828ea591a9bb7345 (patch)
tree144b9660cc8f70537979855612632636ef22f769 /lib/System
parent9ffd19af2e2a17ccd0c7ad7b4cf6d8c3e9a56bae (diff)
downloadexternal_llvm-98b7e612b2320ae83d2896b7828ea591a9bb7345.zip
external_llvm-98b7e612b2320ae83d2896b7828ea591a9bb7345.tar.gz
external_llvm-98b7e612b2320ae83d2896b7828ea591a9bb7345.tar.bz2
MappedFile is dead, remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/MappedFile.cpp34
-rw-r--r--lib/System/Unix/MappedFile.inc97
-rw-r--r--lib/System/Win32/MappedFile.inc104
3 files changed, 0 insertions, 235 deletions
diff --git a/lib/System/MappedFile.cpp b/lib/System/MappedFile.cpp
deleted file mode 100644
index d2bc403..0000000
--- a/lib/System/MappedFile.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===- MappedFile.cpp - MappedFile Support ----------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the mapped file concept.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/System/MappedFile.h"
-#include "llvm/Config/config.h"
-
-namespace llvm {
-using namespace sys;
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only TRULY operating system
-//=== independent code.
-//===----------------------------------------------------------------------===//
-
-}
-
-// Include the platform-specific parts of this class.
-#ifdef LLVM_ON_UNIX
-#include "Unix/MappedFile.inc"
-#endif
-#ifdef LLVM_ON_WIN32
-#include "Win32/MappedFile.inc"
-#endif
-
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc
deleted file mode 100644
index c85a53d..0000000
--- a/lib/System/Unix/MappedFile.inc
+++ /dev/null
@@ -1,97 +0,0 @@
-//===- Unix/MappedFile.inc - Unix MappedFile Implementation -----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the generic Unix implementation of the MappedFile concept.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Unix.h"
-#include "llvm/System/Process.h"
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-using namespace llvm;
-using namespace sys;
-
-namespace llvm {
- namespace sys {
- struct MappedFileInfo {
- int FD;
- off_t Size;
- };
- }
-}
-
-bool MappedFile::initialize(std::string* ErrMsg) {
- int FD = ::open(Path.c_str(), O_RDONLY);
- if (FD < 0) {
- MakeErrMsg(ErrMsg, "can't open file '" + Path.toString() + "'");
- return true;
- }
- const FileStatus *Status = Path.getFileStatus(false, ErrMsg);
- if (!Status) {
- ::close(FD);
- return true;
- }
- MapInfo = new MappedFileInfo();
- MapInfo->FD = FD;
- MapInfo->Size = Status->getSize();
- return false;
-}
-
-void MappedFile::terminate() {
- unmap();
- assert(MapInfo && "MappedFile not initialized");
- ::close(MapInfo->FD);
- delete MapInfo;
- MapInfo = 0;
-}
-
-void MappedFile::unmap() {
- assert(MapInfo && "MappedFile not initialized");
- if (!isMapped()) return;
-
- ::munmap(BasePtr, MapInfo->Size);
- BasePtr = 0; // Mark this as non-mapped.
-}
-
-const void* MappedFile::map(std::string* ErrMsg) {
- assert(MapInfo && "MappedFile not initialized");
- if (isMapped()) return BasePtr;
-
- int flags = MAP_PRIVATE;
-#ifdef MAP_FILE
- flags |= MAP_FILE;
-#endif
- size_t PageSize = Process::GetPageSize();
- size_t map_size = ((MapInfo->Size / PageSize)+1) * PageSize;
-
- BasePtr = ::mmap(0, map_size, PROT_READ, flags, MapInfo->FD, 0);
- if (BasePtr == MAP_FAILED) {
- MakeErrMsg(ErrMsg, "Can't map file:" + Path.toString());
- return 0;
- }
- return BasePtr;
-}
-
-size_t MappedFile::size() const {
- assert(MapInfo && "MappedFile not initialized");
- return MapInfo->Size;
-}
-
diff --git a/lib/System/Win32/MappedFile.inc b/lib/System/Win32/MappedFile.inc
deleted file mode 100644
index 4f30f56..0000000
--- a/lib/System/Win32/MappedFile.inc
+++ /dev/null
@@ -1,104 +0,0 @@
-//===- Win32/MappedFile.cpp - Win32 MappedFile Implementation ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the Win32 implementation of the MappedFile concept.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only Win32 code.
-//===----------------------------------------------------------------------===//
-
-#include "Win32.h"
-#include "llvm/System/Process.h"
-
-namespace llvm {
-using namespace sys;
-
-struct sys::MappedFileInfo {
- HANDLE hFile;
- HANDLE hMapping;
- size_t size;
-};
-
-bool MappedFile::initialize(std::string* ErrMsg) {
- assert(!MapInfo);
- MapInfo = new MappedFileInfo;
- MapInfo->hFile = INVALID_HANDLE_VALUE;
- MapInfo->hMapping = NULL;
-
- MapInfo->hFile = CreateFile(Path.c_str(), GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (MapInfo->hFile == INVALID_HANDLE_VALUE) {
- delete MapInfo;
- MapInfo = NULL;
- return MakeErrMsg(ErrMsg,
- std::string("Can't open file: ") + Path.toString());
- }
-
- LARGE_INTEGER size;
- if (!GetFileSizeEx(MapInfo->hFile, &size) ||
- (MapInfo->size = size_t(size.QuadPart), MapInfo->size != size.QuadPart)) {
- CloseHandle(MapInfo->hFile);
- delete MapInfo;
- MapInfo = NULL;
- return MakeErrMsg(ErrMsg,
- std::string("Can't get size of file: ") + Path.toString());
- }
-
- return false;
-}
-
-void MappedFile::terminate() {
- unmap();
- if (MapInfo->hFile != INVALID_HANDLE_VALUE)
- CloseHandle(MapInfo->hFile);
- delete MapInfo;
- MapInfo = NULL;
-}
-
-void MappedFile::unmap() {
- assert(MapInfo && "MappedFile not initialized");
- if (isMapped()) {
- UnmapViewOfFile(BasePtr);
- BasePtr = NULL;
- }
- if (MapInfo->hMapping != INVALID_HANDLE_VALUE) {
- CloseHandle(MapInfo->hMapping);
- MapInfo->hMapping = NULL;
- }
-}
-
-const void* MappedFile::map(std::string* ErrMsg) {
- if (!isMapped()) {
- MapInfo->hMapping = CreateFileMapping(MapInfo->hFile, NULL, PAGE_READONLY,
- 0, 0, NULL);
- if (MapInfo->hMapping == NULL) {
- MakeErrMsg(ErrMsg, std::string("Can't map file: ") + Path.toString());
- return 0;
- }
-
- BasePtr = MapViewOfFileEx(MapInfo->hMapping, FILE_MAP_READ, 0, 0, 0, NULL);
- if (BasePtr == NULL) {
- CloseHandle(MapInfo->hMapping);
- MapInfo->hMapping = NULL;
- MakeErrMsg(ErrMsg, std::string("Can't map file: ") + Path.toString());
- return 0;
- }
- }
- return BasePtr;
-}
-
-size_t MappedFile::size() const {
- assert(MapInfo && "MappedFile not initialized");
- return MapInfo->size;
-}
-
-}
-