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

Side by Side Diff: src/base/platform/platform-solaris.cc

Issue 1111733002: [clang] Use -Wshorten-64-to-32 to enable warnings about 64bit to 32bit truncations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win warnings. Created 5 years, 7 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
« no previous file with comments | « src/base/platform/platform-qnx.cc ('k') | src/base/platform/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Platform-specific code for Solaris 10 goes here. For the POSIX-compatible 5 // Platform-specific code for Solaris 10 goes here. For the POSIX-compatible
6 // parts, the implementation is in platform-posix.cc. 6 // parts, the implementation is in platform-posix.cc.
7 7
8 #ifdef __sparc 8 #ifdef __sparc
9 # error "V8 does not support the SPARC CPU architecture." 9 # error "V8 does not support the SPARC CPU architecture."
10 #endif 10 #endif
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const size_t msize = RoundUp(requested, getpagesize()); 56 const size_t msize = RoundUp(requested, getpagesize());
57 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); 57 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
58 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); 58 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);
59 59
60 if (mbase == MAP_FAILED) return NULL; 60 if (mbase == MAP_FAILED) return NULL;
61 *allocated = msize; 61 *allocated = msize;
62 return mbase; 62 return mbase;
63 } 63 }
64 64
65 65
66 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
67 public:
68 PosixMemoryMappedFile(FILE* file, void* memory, int size)
69 : file_(file), memory_(memory), size_(size) { }
70 virtual ~PosixMemoryMappedFile();
71 virtual void* memory() { return memory_; }
72 virtual int size() { return size_; }
73 private:
74 FILE* file_;
75 void* memory_;
76 int size_;
77 };
78
79
80 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
81 FILE* file = fopen(name, "r+");
82 if (file == NULL) return NULL;
83
84 fseek(file, 0, SEEK_END);
85 int size = ftell(file);
86
87 void* memory =
88 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
89 return new PosixMemoryMappedFile(file, memory, size);
90 }
91
92
93 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
94 void* initial) {
95 FILE* file = fopen(name, "w+");
96 if (file == NULL) return NULL;
97 int result = fwrite(initial, size, 1, file);
98 if (result < 1) {
99 fclose(file);
100 return NULL;
101 }
102 void* memory =
103 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
104 return new PosixMemoryMappedFile(file, memory, size);
105 }
106
107
108 PosixMemoryMappedFile::~PosixMemoryMappedFile() {
109 if (memory_) munmap(memory_, size_);
110 fclose(file_);
111 }
112
113
114 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { 66 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
115 return std::vector<SharedLibraryAddress>(); 67 return std::vector<SharedLibraryAddress>();
116 } 68 }
117 69
118 70
119 void OS::SignalCodeMovingGC() { 71 void OS::SignalCodeMovingGC() {
120 } 72 }
121 73
122 74
123 // Constants used for mmap. 75 // Constants used for mmap.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return munmap(base, size) == 0; 202 return munmap(base, size) == 0;
251 } 203 }
252 204
253 205
254 bool VirtualMemory::HasLazyCommits() { 206 bool VirtualMemory::HasLazyCommits() {
255 // TODO(alph): implement for the platform. 207 // TODO(alph): implement for the platform.
256 return false; 208 return false;
257 } 209 }
258 210
259 } } // namespace v8::base 211 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/platform/platform-qnx.cc ('k') | src/base/platform/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698