Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 POSIX goes here. This is not a platform on its | 5 // Platform-specific code for POSIX goes here. This is not a platform on its |
| 6 // own, but contains the parts which are the same across the POSIX platforms | 6 // own, but contains the parts which are the same across the POSIX platforms |
| 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. | 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <limits.h> | 10 #include <limits.h> |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 // Create guard pages. | 122 // Create guard pages. |
| 123 void OS::Guard(void* address, const size_t size) { | 123 void OS::Guard(void* address, const size_t size) { |
| 124 #if V8_OS_CYGWIN | 124 #if V8_OS_CYGWIN |
| 125 DWORD oldprotect; | 125 DWORD oldprotect; |
| 126 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); | 126 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); |
| 127 #else | 127 #else |
| 128 mprotect(address, size, PROT_NONE); | 128 mprotect(address, size, PROT_NONE); |
| 129 #endif | 129 #endif |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Make a region of memory readable and writable. | |
| 133 void OS::Unprotect(void* address, const size_t size) { | |
|
Michael Lippautz
2016/10/27 14:41:50
Maybe we should have OS::Protect as a dual functio
Eric Holk
2016/10/28 16:20:13
I think I'd probably do OS::Protect and take flags
| |
| 134 #if V8_OS_CYGWIN | |
| 135 DWORD oldprotect; | |
| 136 VirtualProtect(address, size, PAGE_READWRITE, &oldprotect); | |
| 137 #else | |
| 138 mprotect(address, size, PROT_READ | PROT_WRITE); | |
| 139 #endif | |
| 140 } | |
| 132 | 141 |
| 133 static LazyInstance<RandomNumberGenerator>::type | 142 static LazyInstance<RandomNumberGenerator>::type |
| 134 platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; | 143 platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; |
| 135 | 144 |
| 136 | 145 |
| 137 void OS::Initialize(int64_t random_seed, bool hard_abort, | 146 void OS::Initialize(int64_t random_seed, bool hard_abort, |
| 138 const char* const gc_fake_mmap) { | 147 const char* const gc_fake_mmap) { |
| 139 if (random_seed) { | 148 if (random_seed) { |
| 140 platform_random_number_generator.Pointer()->SetSeed(random_seed); | 149 platform_random_number_generator.Pointer()->SetSeed(random_seed); |
| 141 } | 150 } |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 | 751 |
| 743 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 752 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 744 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 753 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 745 int result = pthread_setspecific(pthread_key, value); | 754 int result = pthread_setspecific(pthread_key, value); |
| 746 DCHECK_EQ(0, result); | 755 DCHECK_EQ(0, result); |
| 747 USE(result); | 756 USE(result); |
| 748 } | 757 } |
| 749 | 758 |
| 750 } // namespace base | 759 } // namespace base |
| 751 } // namespace v8 | 760 } // namespace v8 |
| OLD | NEW |