[llvm-commits] CVS: llvm/lib/System/Unix/MappedFile.inc

Chris Lattner lattner at cs.uiuc.edu
Tue Jul 18 00:01:20 PDT 2006



Changes in directory llvm/lib/System/Unix:

MappedFile.inc updated: 1.13 -> 1.14
---
Log message:

The only entry in the stat buf this code cares about is the size.  Keep just
the size, not the whole stat buffer.


---
Diffs of the changes:  (+14 -14)

 MappedFile.inc |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)


Index: llvm/lib/System/Unix/MappedFile.inc
diff -u llvm/lib/System/Unix/MappedFile.inc:1.13 llvm/lib/System/Unix/MappedFile.inc:1.14
--- llvm/lib/System/Unix/MappedFile.inc:1.13	Tue Jul 18 01:57:51 2006
+++ llvm/lib/System/Unix/MappedFile.inc	Tue Jul 18 02:01:08 2006
@@ -35,8 +35,8 @@
 using namespace sys;
 
 struct sys::MappedFileInfo {
-  int fd_;
-  struct stat sbuf_;
+  int   FD;
+  off_t Size;
 };
 
 void MappedFile::initialize() {
@@ -62,14 +62,14 @@
     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 @@
   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 @@
       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 @@
 
 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 @@
   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 @@
   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. 






More information about the llvm-commits mailing list