Index: src/platform-freebsd.cc |
=================================================================== |
--- src/platform-freebsd.cc (revision 6353) |
+++ src/platform-freebsd.cc (working copy) |
@@ -215,6 +215,7 @@ |
: file_(file), memory_(memory), size_(size) { } |
virtual ~PosixMemoryMappedFile(); |
virtual void* memory() { return memory_; } |
+ virtual int size() { return size_; } |
private: |
FILE* file_; |
void* memory_; |
@@ -222,6 +223,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+"); |