| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
| 6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // If available, it would look like: | 168 // If available, it would look like: |
| 169 // __attribute__((format(wprintf, format_param, dots_param))) | 169 // __attribute__((format(wprintf, format_param, dots_param))) |
| 170 | 170 |
| 171 // MemorySanitizer annotations. | 171 // MemorySanitizer annotations. |
| 172 #if defined(MEMORY_SANITIZER) && !defined(OS_NACL) | 172 #if defined(MEMORY_SANITIZER) && !defined(OS_NACL) |
| 173 #include <sanitizer/msan_interface.h> | 173 #include <sanitizer/msan_interface.h> |
| 174 | 174 |
| 175 // Mark a memory region fully initialized. | 175 // Mark a memory region fully initialized. |
| 176 // Use this to annotate code that deliberately reads uninitialized data, for | 176 // Use this to annotate code that deliberately reads uninitialized data, for |
| 177 // example a GC scavenging root set pointers from the stack. | 177 // example a GC scavenging root set pointers from the stack. |
| 178 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) | 178 #define MSAN_UNPOISON(p, size) __msan_unpoison(p, size) |
| 179 |
| 180 // Check a memory region for initializedness, as if it was being used here. |
| 181 // If any bits are uninitialized, crash with an MSan report. |
| 182 // Use this to sanitize data which MSan won't be able to track, e.g. before |
| 183 // passing data to another process via shared memory. |
| 184 #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \ |
| 185 __msan_check_mem_is_initialized(p, size) |
| 179 #else // MEMORY_SANITIZER | 186 #else // MEMORY_SANITIZER |
| 180 #define MSAN_UNPOISON(p, s) | 187 #define MSAN_UNPOISON(p, size) |
| 188 #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) |
| 181 #endif // MEMORY_SANITIZER | 189 #endif // MEMORY_SANITIZER |
| 182 | 190 |
| 183 // Macro useful for writing cross-platform function pointers. | 191 // Macro useful for writing cross-platform function pointers. |
| 184 #if !defined(CDECL) | 192 #if !defined(CDECL) |
| 185 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
| 186 #define CDECL __cdecl | 194 #define CDECL __cdecl |
| 187 #else // defined(OS_WIN) | 195 #else // defined(OS_WIN) |
| 188 #define CDECL | 196 #define CDECL |
| 189 #endif // defined(OS_WIN) | 197 #endif // defined(OS_WIN) |
| 190 #endif // !defined(CDECL) | 198 #endif // !defined(CDECL) |
| 191 | 199 |
| 192 // Macro for hinting that an expression is likely to be false. | 200 // Macro for hinting that an expression is likely to be false. |
| 193 #if !defined(UNLIKELY) | 201 #if !defined(UNLIKELY) |
| 194 #if defined(COMPILER_GCC) | 202 #if defined(COMPILER_GCC) |
| 195 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 203 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 196 #else | 204 #else |
| 197 #define UNLIKELY(x) (x) | 205 #define UNLIKELY(x) (x) |
| 198 #endif // defined(COMPILER_GCC) | 206 #endif // defined(COMPILER_GCC) |
| 199 #endif // !defined(UNLIKELY) | 207 #endif // !defined(UNLIKELY) |
| 200 | 208 |
| 201 #endif // BASE_COMPILER_SPECIFIC_H_ | 209 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |