OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 #include <fcntl.h> | 5 #include <fcntl.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 24 matching lines...) Expand all Loading... |
35 template <typename Type> | 35 template <typename Type> |
36 Type HideValueFromCompiler(volatile Type value) { | 36 Type HideValueFromCompiler(volatile Type value) { |
37 #if defined(__GNUC__) | 37 #if defined(__GNUC__) |
38 // In a GCC compatible compiler (GCC or Clang), make this compiler barrier | 38 // In a GCC compatible compiler (GCC or Clang), make this compiler barrier |
39 // more robust than merely using "volatile". | 39 // more robust than merely using "volatile". |
40 __asm__ volatile ("" : "+r" (value)); | 40 __asm__ volatile ("" : "+r" (value)); |
41 #endif // __GNUC__ | 41 #endif // __GNUC__ |
42 return value; | 42 return value; |
43 } | 43 } |
44 | 44 |
45 // - NO_TCMALLOC (should be defined if we compile with linux_use_tcmalloc=0) | 45 // - NO_TCMALLOC (should be defined if compiled with use_allocator!="tcmalloc") |
46 // - ADDRESS_SANITIZER because it has its own memory allocator | 46 // - ADDRESS_SANITIZER because it has its own memory allocator |
47 // - IOS does not use tcmalloc | 47 // - IOS does not use tcmalloc |
48 // - OS_MACOSX does not use tcmalloc | 48 // - OS_MACOSX does not use tcmalloc |
49 #if !defined(NO_TCMALLOC) && !defined(ADDRESS_SANITIZER) && \ | 49 #if !defined(NO_TCMALLOC) && !defined(ADDRESS_SANITIZER) && \ |
50 !defined(OS_IOS) && !defined(OS_MACOSX) | 50 !defined(OS_IOS) && !defined(OS_MACOSX) |
51 #define TCMALLOC_TEST(function) function | 51 #define TCMALLOC_TEST(function) function |
52 #else | 52 #else |
53 #define TCMALLOC_TEST(function) DISABLED_##function | 53 #define TCMALLOC_TEST(function) DISABLED_##function |
54 #endif | 54 #endif |
55 | 55 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // kRandomMask, so we use it as an additional detection mechanism. | 282 // kRandomMask, so we use it as an additional detection mechanism. |
283 const uintptr_t kRandomMask = 0x3fffffffffffULL; | 283 const uintptr_t kRandomMask = 0x3fffffffffffULL; |
284 bool impossible_random_address = | 284 bool impossible_random_address = |
285 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; | 285 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; |
286 EXPECT_FALSE(impossible_random_address); | 286 EXPECT_FALSE(impossible_random_address); |
287 } | 287 } |
288 | 288 |
289 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__) | 289 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__) |
290 | 290 |
291 } // namespace | 291 } // namespace |
OLD | NEW |