Index: base/allocator/partition_allocator/address_space_randomization.cc |
diff --git a/third_party/WebKit/Source/wtf/allocator/AddressSpaceRandomization.cpp b/base/allocator/partition_allocator/address_space_randomization.cc |
similarity index 89% |
rename from third_party/WebKit/Source/wtf/allocator/AddressSpaceRandomization.cpp |
rename to base/allocator/partition_allocator/address_space_randomization.cc |
index 4fca2678ef82e6648d6ae80a33e9fb47dc2fb4dc..de4c3def62bc4f18957360eeb0d563ae49bf8029 100644 |
--- a/third_party/WebKit/Source/wtf/allocator/AddressSpaceRandomization.cpp |
+++ b/base/allocator/partition_allocator/address_space_randomization.cc |
@@ -2,26 +2,26 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "wtf/allocator/AddressSpaceRandomization.h" |
+#include "base/allocator/partition_allocator/address_space_randomization.h" |
-#include "wtf/SpinLock.h" |
-#include "wtf/allocator/PageAllocator.h" |
+#include "base/allocator/partition_allocator/page_allocator.h" |
+#include "base/synchronization/spin_lock.h" |
-#if OS(WIN) |
+#if defined(OS_WIN) |
Primiano Tucci (use gerrit)
2016/11/22 14:28:32
IWYU: #include "build/build_config.h"
palmer
2016/11/24 01:05:55
Done.
|
#include <windows.h> |
#else |
#include <sys/time.h> |
#include <unistd.h> |
#endif |
-namespace WTF { |
+namespace base { |
namespace { |
// This is the same PRNG as used by tcmalloc for mapping address randomness; |
// see http://burtleburtle.net/bob/rand/smallprng.html |
struct ranctx { |
- SpinLock lock; |
+ subtle::SpinLock lock; |
bool initialized; |
uint32_t a; |
uint32_t b; |
@@ -43,14 +43,14 @@ uint32_t ranvalInternal(ranctx* x) { |
#undef rot |
uint32_t ranval(ranctx* x) { |
- SpinLock::Guard guard(x->lock); |
+ subtle::SpinLock::Guard guard(x->lock); |
if (UNLIKELY(!x->initialized)) { |
x->initialized = true; |
char c; |
uint32_t seed = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&c)); |
uint32_t pid; |
uint32_t usec; |
-#if OS(WIN) |
+#if defined(OS_WIN) |
pid = GetCurrentProcessId(); |
SYSTEMTIME st; |
GetSystemTime(&st); |
@@ -88,7 +88,7 @@ void* getRandomPageBase() { |
random |= static_cast<uintptr_t>(ranval(&s_ranctx)); |
// This address mask gives a low liklihood of address space collisions. |
// We handle the situation gracefully if there is a collision. |
-#if OS(WIN) |
+#if defined(OS_WIN) |
// 64-bit Windows has a bizarrely small 8TB user address space. |
// Allocates in the 1-5TB region. |
// TODO(cevans): I think Win 8.1 has 47-bits like Linux. |
@@ -107,7 +107,7 @@ void* getRandomPageBase() { |
random &= 0x3fffffffffUL; |
random += 0x1000000000UL; |
#else // !CPU(X86_64) && !CPU(ARM64) |
-#if OS(WIN) |
+#if defined(OS_WIN) |
// On win32 host systems the randomization plus huge alignment causes |
// excessive fragmentation. Plus most of these systems lack ASLR, so the |
// randomization isn't buying anything. In that case we just skip it. |
@@ -117,7 +117,7 @@ void* getRandomPageBase() { |
isWow64 = FALSE; |
if (!isWow64) |
return nullptr; |
-#endif // OS(WIN) |
+#endif // defined(OS_WIN) |
// This is a good range on Windows, Linux and Mac. |
// Allocates in the 0.5-1.5GB region. |
random &= 0x3fffffff; |
@@ -127,4 +127,4 @@ void* getRandomPageBase() { |
return reinterpret_cast<void*>(random); |
} |
-} // namespace WTF |
+} // namespace base |