diff options
Diffstat (limited to 'chromium/base/compiler_specific.h')
-rw-r--r-- | chromium/base/compiler_specific.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/chromium/base/compiler_specific.h b/chromium/base/compiler_specific.h index 47ca9778b67..63297dcaf00 100644 --- a/chromium/base/compiler_specific.h +++ b/chromium/base/compiler_specific.h @@ -128,13 +128,11 @@ #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) #endif -// Return the byte alignment of the given type (available at compile time). Use -// sizeof(type) prior to checking __alignof to workaround Visual C++ bug: -// http://goo.gl/isH0C +// Return the byte alignment of the given type (available at compile time). // Use like: // ALIGNOF(int32) // this would be 4 #if defined(COMPILER_MSVC) -#define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) +#define ALIGNOF(type) __alignof(type) #elif defined(COMPILER_GCC) #define ALIGNOF(type) __alignof__(type) #endif @@ -175,9 +173,17 @@ // Mark a memory region fully initialized. // Use this to annotate code that deliberately reads uninitialized data, for // example a GC scavenging root set pointers from the stack. -#define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) +#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size) + +// Check a memory region for initializedness, as if it was being used here. +// If any bits are uninitialized, crash with an MSan report. +// Use this to sanitize data which MSan won't be able to track, e.g. before +// passing data to another process via shared memory. +#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \ + __msan_check_mem_is_initialized(p, size) #else // MEMORY_SANITIZER -#define MSAN_UNPOISON(p, s) +#define MSAN_UNPOISON(p, size) +#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) #endif // MEMORY_SANITIZER // Macro useful for writing cross-platform function pointers. |