[llvm-commits] CVS: llvm/include/llvm/System/MappedFile.h

Reid Spencer reid at x10sys.com
Tue Aug 22 09:04:37 PDT 2006



Changes in directory llvm/include/llvm/System:

MappedFile.h updated: 1.10 -> 1.11
---
Log message:

For PR797: http://llvm.org/PR797 :
Make MappedFile not throw any exceptions.


---
Diffs of the changes:  (+24 -7)

 MappedFile.h |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)


Index: llvm/include/llvm/System/MappedFile.h
diff -u llvm/include/llvm/System/MappedFile.h:1.10 llvm/include/llvm/System/MappedFile.h:1.11
--- llvm/include/llvm/System/MappedFile.h:1.10	Wed Jul 26 11:55:39 2006
+++ llvm/include/llvm/System/MappedFile.h	Tue Aug 22 11:04:22 2006
@@ -48,8 +48,7 @@
     /// Construct a MappedFile to the \p path in the operating system's file
     /// system with the mapping \p options provided.
     /// @throws std::string if an error occurs
-    MappedFile(const Path& path, int options = READ_ACCESS)
-      : path_(path), options_(options), base_(0), info_(0) { initialize(); }
+    MappedFile() : path_(), options_(READ_ACCESS), base_(0), info_(0) {}
 
     /// Destruct a MappedFile and release all memory associated with it.
     /// @throws std::string if an error occurs
@@ -101,6 +100,18 @@
   /// @name Mutators
   /// @{
   public:
+    /// Open a file to be mapped and get its size but don't map it yet.
+    /// @returns true if an error occurred
+    bool open(
+      const sys::Path& p, ///< Path to file to be mapped
+      int options = READ_ACCESS, ///< Access mode for the mapping
+      std::string* ErrMsg = 0 ///< Optional error string pointer
+    ) {
+      path_ = p;
+      options_ = options;
+      return initialize(ErrMsg);
+    }
+
     /// The mapped file is removed from memory. If the file was mapped for
     /// write access, the memory contents will be automatically synchronized
     /// with the file's disk contents.
@@ -108,9 +119,12 @@
     void unmap();
 
     /// The mapped file is put into memory.
-    /// @returns The base memory address of the mapped file.
+    /// @returns The base memory address of the mapped file or 0 if an error
+    /// occurred.
     /// @brief Map the file into memory.
-    void* map();
+    void* map(
+      std::string* ErrMsg ///< Optional error string pointer
+    );
 
     /// This method causes the size of the file, and consequently the size
     /// of the mapping to be set. This is logically the same as unmap(),
@@ -122,14 +136,17 @@
     /// @brief Set the size of the file and memory mapping.
     void size(size_t new_size);
 
-    void close() { terminate(); }
+    void close() { if (info_) terminate(); }
 
   /// @}
   /// @name Implementation
   /// @{
   private:
-    void initialize(); ///< Initialize platform-specific portion
-    void terminate();  ///< Terminate platform-specific portion
+    /// @brief Initialize platform-specific portion
+    bool initialize(std::string* ErrMsg); 
+
+    /// @brief Terminate platform-specific portion
+    void terminate();  
 
   /// @}
   /// @name Data






More information about the llvm-commits mailing list