Index: src/platform-openbsd.cc |
=================================================================== |
--- src/platform-openbsd.cc (revision 6353) |
+++ src/platform-openbsd.cc (working copy) |
@@ -213,6 +213,7 @@ |
: file_(file), memory_(memory), size_(size) { } |
virtual ~PosixMemoryMappedFile(); |
virtual void* memory() { return memory_; } |
+ virtual int size() { return size_; } |
private: |
FILE* file_; |
void* memory_; |
@@ -220,6 +221,19 @@ |
}; |
+OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { |
+ FILE* file = fopen(name, "w+"); |
+ if (file == NULL) return NULL; |
+ |
+ fseek(file, 0, SEEK_END); |
+ int size = ftell(file); |
+ |
+ void* memory = |
+ mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); |
+ return new PosixMemoryMappedFile(file, memory, size); |
+} |
+ |
+ |
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, |
void* initial) { |
FILE* file = fopen(name, "w+"); |