Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: src/platform-openbsd.cc

Issue 6543039: Bug: OS::MemoryMappedFile::open() should not truncate a pre-existing file. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 virtual void* memory() { return memory_; } 215 virtual void* memory() { return memory_; }
216 virtual int size() { return size_; } 216 virtual int size() { return size_; }
217 private: 217 private:
218 FILE* file_; 218 FILE* file_;
219 void* memory_; 219 void* memory_;
220 int size_; 220 int size_;
221 }; 221 };
222 222
223 223
224 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { 224 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
225 FILE* file = fopen(name, "w+"); 225 FILE* file = fopen(name, "r+");
226 if (file == NULL) return NULL; 226 if (file == NULL) return NULL;
227 227
228 fseek(file, 0, SEEK_END); 228 fseek(file, 0, SEEK_END);
229 int size = ftell(file); 229 int size = ftell(file);
230 230
231 void* memory = 231 void* memory =
232 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); 232 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
233 return new PosixMemoryMappedFile(file, memory, size); 233 return new PosixMemoryMappedFile(file, memory, size);
234 } 234 }
235 235
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 648 }
649 649
650 // This sampler is no longer the active sampler. 650 // This sampler is no longer the active sampler.
651 active_sampler_ = NULL; 651 active_sampler_ = NULL;
652 active_ = false; 652 active_ = false;
653 } 653 }
654 654
655 #endif // ENABLE_LOGGING_AND_PROFILING 655 #endif // ENABLE_LOGGING_AND_PROFILING
656 656
657 } } // namespace v8::internal 657 } } // namespace v8::internal
OLDNEW
« src/platform-freebsd.cc ('K') | « src/platform-macos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698