aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-18 07:01:08 +0000
committerChris Lattner <sabre@nondot.org>2006-07-18 07:01:08 +0000
commit0af7093532751df4ba69a72f9ab136c682e00378 (patch)
treeb4872934534bb1dfd2265077992dcedfcd7fb2a7 /lib/System/Unix
parentcca68faac23e0a6c5bb89135cbd3b73ebcd91834 (diff)
downloadexternal_llvm-0af7093532751df4ba69a72f9ab136c682e00378.zip
external_llvm-0af7093532751df4ba69a72f9ab136c682e00378.tar.gz
external_llvm-0af7093532751df4ba69a72f9ab136c682e00378.tar.bz2
The only entry in the stat buf this code cares about is the size. Keep just
the size, not the whole stat buffer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r--lib/System/Unix/MappedFile.inc28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc
index 8cd2a96..a0dfbbd 100644
--- a/lib/System/Unix/MappedFile.inc
+++ b/lib/System/Unix/MappedFile.inc
@@ -35,8 +35,8 @@ namespace llvm {
using namespace sys;
struct sys::MappedFileInfo {
- int fd_;
- struct stat sbuf_;
+ int FD;
+ off_t Size;
};
void MappedFile::initialize() {
@@ -62,14 +62,14 @@ void MappedFile::initialize() {
ThrowErrno(std::string("Can't stat file: ") + path_.toString());
}
info_ = new MappedFileInfo;
- info_->fd_ = FD;
- info_->sbuf_ = sbuf;
+ info_->FD = FD;
+ info_->Size = sbuf.st_size;
}
void MappedFile::terminate() {
assert(info_ && "MappedFile not initialized");
- if (info_->fd_ >= 0)
- ::close(info_->fd_);
+ if (info_->FD >= 0)
+ ::close(info_->FD);
delete info_;
info_ = 0;
}
@@ -78,8 +78,8 @@ void MappedFile::unmap() {
assert(info_ && "MappedFile not initialized");
if (isMapped()) {
if (options_ & WRITE_ACCESS)
- ::msync(base_, info_->sbuf_.st_size, MS_SYNC);
- ::munmap(base_, info_->sbuf_.st_size);
+ ::msync(base_, info_->Size, MS_SYNC);
+ ::munmap(base_, info_->Size);
}
}
@@ -106,10 +106,10 @@ void* MappedFile::map() {
else
flags |= MAP_PRIVATE;
}
- size_t map_size = ((info_->sbuf_.st_size / Process::GetPageSize())+1) *
+ size_t map_size = ((info_->Size / Process::GetPageSize())+1) *
Process::GetPageSize();
- base_ = ::mmap(0, map_size, prot, flags, info_->fd_, 0);
+ base_ = ::mmap(0, map_size, prot, flags, info_->FD, 0);
if (base_ == MAP_FAILED)
ThrowErrno(std::string("Can't map file:") + path_.toString());
}
@@ -118,7 +118,7 @@ void* MappedFile::map() {
size_t MappedFile::size() const {
assert(info_ && "MappedFile not initialized");
- return info_->sbuf_.st_size;
+ return info_->Size;
}
void MappedFile::size(size_t new_size) {
@@ -128,7 +128,7 @@ void MappedFile::size(size_t new_size) {
this->unmap();
// Adjust the current size to a page boundary
- size_t cur_size = ((info_->sbuf_.st_size / Process::GetPageSize())+1) *
+ size_t cur_size = ((info_->Size / Process::GetPageSize())+1) *
Process::GetPageSize();
// Adjust the new_size to a page boundary
@@ -139,8 +139,8 @@ void MappedFile::size(size_t new_size) {
if (new_size > cur_size) {
// Ensure we can allocate at least the idodes necessary to handle the
// file size requested.
- ::lseek(info_->fd_, new_size, SEEK_SET);
- ::write(info_->fd_, "\0", 1);
+ ::lseek(info_->FD, new_size, SEEK_SET);
+ ::write(info_->FD, "\0", 1);
}
// Seek to current end of file.