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

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

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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
« no previous file with comments | « src/base/platform/platform.h ('k') | src/base/platform/platform-freebsd.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 Cygwin goes here. For the POSIX-compatible 5 // Platform-specific code for Cygwin 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 #include <errno.h> 8 #include <errno.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <semaphore.h> 10 #include <semaphore.h>
(...skipping 20 matching lines...) Expand all
31 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 31 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
32 struct tm* t = localtime(&tv); 32 struct tm* t = localtime(&tv);
33 if (NULL == t) return ""; 33 if (NULL == t) return "";
34 return tzname[0]; // The location of the timezone string on Cygwin. 34 return tzname[0]; // The location of the timezone string on Cygwin.
35 } 35 }
36 36
37 37
38 double OS::LocalTimeOffset(TimezoneCache* cache) { 38 double OS::LocalTimeOffset(TimezoneCache* cache) {
39 // On Cygwin, struct tm does not contain a tm_gmtoff field. 39 // On Cygwin, struct tm does not contain a tm_gmtoff field.
40 time_t utc = time(NULL); 40 time_t utc = time(NULL);
41 ASSERT(utc != -1); 41 DCHECK(utc != -1);
42 struct tm* loc = localtime(&utc); 42 struct tm* loc = localtime(&utc);
43 ASSERT(loc != NULL); 43 DCHECK(loc != NULL);
44 // time - localtime includes any daylight savings offset, so subtract it. 44 // time - localtime includes any daylight savings offset, so subtract it.
45 return static_cast<double>((mktime(loc) - utc) * msPerSecond - 45 return static_cast<double>((mktime(loc) - utc) * msPerSecond -
46 (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0)); 46 (loc->tm_isdst > 0 ? 3600 * msPerSecond : 0));
47 } 47 }
48 48
49 49
50 void* OS::Allocate(const size_t requested, 50 void* OS::Allocate(const size_t requested,
51 size_t* allocated, 51 size_t* allocated,
52 bool is_executable) { 52 bool is_executable) {
53 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); 53 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } 199 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
200 200
201 201
202 VirtualMemory::VirtualMemory(size_t size) 202 VirtualMemory::VirtualMemory(size_t size)
203 : address_(ReserveRegion(size)), size_(size) { } 203 : address_(ReserveRegion(size)), size_(size) { }
204 204
205 205
206 VirtualMemory::VirtualMemory(size_t size, size_t alignment) 206 VirtualMemory::VirtualMemory(size_t size, size_t alignment)
207 : address_(NULL), size_(0) { 207 : address_(NULL), size_(0) {
208 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); 208 DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
209 size_t request_size = RoundUp(size + alignment, 209 size_t request_size = RoundUp(size + alignment,
210 static_cast<intptr_t>(OS::AllocateAlignment())); 210 static_cast<intptr_t>(OS::AllocateAlignment()));
211 void* address = ReserveRegion(request_size); 211 void* address = ReserveRegion(request_size);
212 if (address == NULL) return; 212 if (address == NULL) return;
213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment); 213 uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment);
214 // Try reducing the size by freeing and then reallocating a specific area. 214 // Try reducing the size by freeing and then reallocating a specific area.
215 bool result = ReleaseRegion(address, request_size); 215 bool result = ReleaseRegion(address, request_size);
216 USE(result); 216 USE(result);
217 ASSERT(result); 217 DCHECK(result);
218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS); 218 address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
219 if (address != NULL) { 219 if (address != NULL) {
220 request_size = size; 220 request_size = size;
221 ASSERT(base == static_cast<uint8_t*>(address)); 221 DCHECK(base == static_cast<uint8_t*>(address));
222 } else { 222 } else {
223 // Resizing failed, just go with a bigger area. 223 // Resizing failed, just go with a bigger area.
224 address = ReserveRegion(request_size); 224 address = ReserveRegion(request_size);
225 if (address == NULL) return; 225 if (address == NULL) return;
226 } 226 }
227 address_ = address; 227 address_ = address;
228 size_ = request_size; 228 size_ = request_size;
229 } 229 }
230 230
231 231
232 VirtualMemory::~VirtualMemory() { 232 VirtualMemory::~VirtualMemory() {
233 if (IsReserved()) { 233 if (IsReserved()) {
234 bool result = ReleaseRegion(address_, size_); 234 bool result = ReleaseRegion(address_, size_);
235 ASSERT(result); 235 DCHECK(result);
236 USE(result); 236 USE(result);
237 } 237 }
238 } 238 }
239 239
240 240
241 bool VirtualMemory::IsReserved() { 241 bool VirtualMemory::IsReserved() {
242 return address_ != NULL; 242 return address_ != NULL;
243 } 243 }
244 244
245 245
246 void VirtualMemory::Reset() { 246 void VirtualMemory::Reset() {
247 address_ = NULL; 247 address_ = NULL;
248 size_ = 0; 248 size_ = 0;
249 } 249 }
250 250
251 251
252 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { 252 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
253 return CommitRegion(address, size, is_executable); 253 return CommitRegion(address, size, is_executable);
254 } 254 }
255 255
256 256
257 bool VirtualMemory::Uncommit(void* address, size_t size) { 257 bool VirtualMemory::Uncommit(void* address, size_t size) {
258 ASSERT(IsReserved()); 258 DCHECK(IsReserved());
259 return UncommitRegion(address, size); 259 return UncommitRegion(address, size);
260 } 260 }
261 261
262 262
263 void* VirtualMemory::ReserveRegion(size_t size) { 263 void* VirtualMemory::ReserveRegion(size_t size) {
264 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS); 264 return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
265 } 265 }
266 266
267 267
268 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { 268 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
(...skipping 25 matching lines...) Expand all
294 return VirtualFree(base, 0, MEM_RELEASE) != 0; 294 return VirtualFree(base, 0, MEM_RELEASE) != 0;
295 } 295 }
296 296
297 297
298 bool VirtualMemory::HasLazyCommits() { 298 bool VirtualMemory::HasLazyCommits() {
299 // TODO(alph): implement for the platform. 299 // TODO(alph): implement for the platform.
300 return false; 300 return false;
301 } 301 }
302 302
303 } } // namespace v8::base 303 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/platform/platform.h ('k') | src/base/platform/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698