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, size) __msan_unpoison(p, size) | 178 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) |
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) | |
186 #else // MEMORY_SANITIZER | 179 #else // MEMORY_SANITIZER |
187 #define MSAN_UNPOISON(p, size) | 180 #define MSAN_UNPOISON(p, s) |
188 #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) | |
189 #endif // MEMORY_SANITIZER | 181 #endif // MEMORY_SANITIZER |
190 | 182 |
191 // Macro useful for writing cross-platform function pointers. | 183 // Macro useful for writing cross-platform function pointers. |
192 #if !defined(CDECL) | 184 #if !defined(CDECL) |
193 #if defined(OS_WIN) | 185 #if defined(OS_WIN) |
194 #define CDECL __cdecl | 186 #define CDECL __cdecl |
195 #else // defined(OS_WIN) | 187 #else // defined(OS_WIN) |
196 #define CDECL | 188 #define CDECL |
197 #endif // defined(OS_WIN) | 189 #endif // defined(OS_WIN) |
198 #endif // !defined(CDECL) | 190 #endif // !defined(CDECL) |
199 | 191 |
200 // Macro for hinting that an expression is likely to be false. | 192 // Macro for hinting that an expression is likely to be false. |
201 #if !defined(UNLIKELY) | 193 #if !defined(UNLIKELY) |
202 #if defined(COMPILER_GCC) | 194 #if defined(COMPILER_GCC) |
203 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 195 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
204 #else | 196 #else |
205 #define UNLIKELY(x) (x) | 197 #define UNLIKELY(x) (x) |
206 #endif // defined(COMPILER_GCC) | 198 #endif // defined(COMPILER_GCC) |
207 #endif // !defined(UNLIKELY) | 199 #endif // !defined(UNLIKELY) |
208 | 200 |
209 #endif // BASE_COMPILER_SPECIFIC_H_ | 201 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |