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

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

Issue 353113003: Remove dependency from platform files on v8.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/platform-cygwin.cc ('k') | src/platform-linux.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 FreeBSD goes here. For the POSIX-compatible 5 // Platform-specific code for FreeBSD 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 <pthread.h> 8 #include <pthread.h>
9 #include <semaphore.h> 9 #include <semaphore.h>
10 #include <signal.h> 10 #include <signal.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <sys/resource.h> 12 #include <sys/resource.h>
13 #include <sys/time.h> 13 #include <sys/time.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <sys/ucontext.h> 15 #include <sys/ucontext.h>
16 16
17 #include <sys/fcntl.h> // open 17 #include <sys/fcntl.h> // open
18 #include <sys/mman.h> // mmap & munmap 18 #include <sys/mman.h> // mmap & munmap
19 #include <sys/stat.h> // open 19 #include <sys/stat.h> // open
20 #include <sys/types.h> // mmap & munmap 20 #include <sys/types.h> // mmap & munmap
21 #include <unistd.h> // getpagesize 21 #include <unistd.h> // getpagesize
22 // If you don't have execinfo.h then you need devel/libexecinfo from ports. 22 // If you don't have execinfo.h then you need devel/libexecinfo from ports.
23 #include <errno.h> 23 #include <errno.h>
24 #include <limits.h> 24 #include <limits.h>
25 #include <stdarg.h> 25 #include <stdarg.h>
26 #include <strings.h> // index 26 #include <strings.h> // index
27 27
28 #include <cmath>
29
28 #undef MAP_TYPE 30 #undef MAP_TYPE
29 31
30 #include "src/v8.h"
31
32 #include "src/platform.h" 32 #include "src/platform.h"
33 #include "src/utils.h"
33 34
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 39
39 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { 40 const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
40 if (std::isnan(time)) return ""; 41 if (std::isnan(time)) return "";
41 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); 42 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
42 struct tm* t = localtime(&tv); 43 struct tm* t = localtime(&tv);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 size_t request_size = RoundUp(size + alignment, 186 size_t request_size = RoundUp(size + alignment,
186 static_cast<intptr_t>(OS::AllocateAlignment())); 187 static_cast<intptr_t>(OS::AllocateAlignment()));
187 void* reservation = mmap(OS::GetRandomMmapAddr(), 188 void* reservation = mmap(OS::GetRandomMmapAddr(),
188 request_size, 189 request_size,
189 PROT_NONE, 190 PROT_NONE,
190 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, 191 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
191 kMmapFd, 192 kMmapFd,
192 kMmapFdOffset); 193 kMmapFdOffset);
193 if (reservation == MAP_FAILED) return; 194 if (reservation == MAP_FAILED) return;
194 195
195 Address base = static_cast<Address>(reservation); 196 uint8_t* base = static_cast<uint8_t*>(reservation);
196 Address aligned_base = RoundUp(base, alignment); 197 uint8_t* aligned_base = RoundUp(base, alignment);
197 ASSERT_LE(base, aligned_base); 198 ASSERT_LE(base, aligned_base);
198 199
199 // Unmap extra memory reserved before and after the desired block. 200 // Unmap extra memory reserved before and after the desired block.
200 if (aligned_base != base) { 201 if (aligned_base != base) {
201 size_t prefix_size = static_cast<size_t>(aligned_base - base); 202 size_t prefix_size = static_cast<size_t>(aligned_base - base);
202 OS::Free(base, prefix_size); 203 OS::Free(base, prefix_size);
203 request_size -= prefix_size; 204 request_size -= prefix_size;
204 } 205 }
205 206
206 size_t aligned_size = RoundUp(size, OS::AllocateAlignment()); 207 size_t aligned_size = RoundUp(size, OS::AllocateAlignment());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return munmap(base, size) == 0; 298 return munmap(base, size) == 0;
298 } 299 }
299 300
300 301
301 bool VirtualMemory::HasLazyCommits() { 302 bool VirtualMemory::HasLazyCommits() {
302 // TODO(alph): implement for the platform. 303 // TODO(alph): implement for the platform.
303 return false; 304 return false;
304 } 305 }
305 306
306 } } // namespace v8::internal 307 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698