| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // The Native Client port of V8 uses an interpreter, so | 115 // The Native Client port of V8 uses an interpreter, so |
| 116 // code pages don't need PROT_EXEC. | 116 // code pages don't need PROT_EXEC. |
| 117 mprotect(address, size, PROT_READ); | 117 mprotect(address, size, PROT_READ); |
| 118 #else | 118 #else |
| 119 mprotect(address, size, PROT_READ | PROT_EXEC); | 119 mprotect(address, size, PROT_READ | PROT_EXEC); |
| 120 #endif | 120 #endif |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 // Create guard pages. | 124 // Create guard pages. |
| 125 void OS::Guard(void* address, const size_t size) { | 125 void OS::Guard(void* const address, size_t const size) { |
| 126 #if V8_OS_CYGWIN | 126 #if V8_OS_CYGWIN |
| 127 DWORD oldprotect; | 127 DWORD oldprotect; |
| 128 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); | 128 VirtualProtect(address, size, PAGE_NOACCESS, &oldprotect); |
| 129 #else | 129 #else |
| 130 mprotect(address, size, PROT_NONE); | 130 mprotect(address, size, PROT_NONE); |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 // Remove guard pages. |
| 136 void OS::Unguard(void* const address, size_t const size) { |
| 137 #if V8_OS_CYGWIN |
| 138 DWORD oldprotect; |
| 139 VirtualProtect(address, size, PAGE_READWRITE, &oldprotect); |
| 140 #else |
| 141 mprotect(address, size, PROT_READ | PROT_WRITE); |
| 142 #endif |
| 143 } |
| 144 |
| 145 |
| 135 static LazyInstance<RandomNumberGenerator>::type | 146 static LazyInstance<RandomNumberGenerator>::type |
| 136 platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; | 147 platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; |
| 137 | 148 |
| 138 | 149 |
| 139 void OS::Initialize(int64_t random_seed, bool hard_abort, | 150 void OS::Initialize(int64_t random_seed, bool hard_abort, |
| 140 const char* const gc_fake_mmap) { | 151 const char* const gc_fake_mmap) { |
| 141 if (random_seed) { | 152 if (random_seed) { |
| 142 platform_random_number_generator.Pointer()->SetSeed(random_seed); | 153 platform_random_number_generator.Pointer()->SetSeed(random_seed); |
| 143 } | 154 } |
| 144 g_hard_abort = hard_abort; | 155 g_hard_abort = hard_abort; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 681 |
| 671 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 682 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
| 672 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 683 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
| 673 int result = pthread_setspecific(pthread_key, value); | 684 int result = pthread_setspecific(pthread_key, value); |
| 674 DCHECK_EQ(0, result); | 685 DCHECK_EQ(0, result); |
| 675 USE(result); | 686 USE(result); |
| 676 } | 687 } |
| 677 | 688 |
| 678 | 689 |
| 679 } } // namespace v8::base | 690 } } // namespace v8::base |
| OLD | NEW |