| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #define RTC_HAS_MSAN 0 | 26 #define RTC_HAS_MSAN 0 |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if RTC_HAS_ASAN | 29 #if RTC_HAS_ASAN |
| 30 #include <sanitizer/asan_interface.h> | 30 #include <sanitizer/asan_interface.h> |
| 31 #endif | 31 #endif |
| 32 #if RTC_HAS_MSAN | 32 #if RTC_HAS_MSAN |
| 33 #include <sanitizer/msan_interface.h> | 33 #include <sanitizer/msan_interface.h> |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #ifdef __has_attribute |
| 37 #if __has_attribute(no_sanitize) |
| 38 #define RTC_NO_SANITIZE(what) __attribute__((no_sanitize(what))) |
| 39 #endif |
| 40 #endif |
| 41 #ifndef RTC_NO_SANITIZE |
| 42 #define RTC_NO_SANITIZE(what) |
| 43 #endif |
| 44 |
| 36 // Ask ASan to mark the memory range [ptr, ptr + element_size * num_elements) | 45 // Ask ASan to mark the memory range [ptr, ptr + element_size * num_elements) |
| 37 // as being unaddressable, so that reads and writes are not allowed. ASan may | 46 // as being unaddressable, so that reads and writes are not allowed. ASan may |
| 38 // narrow the range to the nearest alignment boundaries. | 47 // narrow the range to the nearest alignment boundaries. |
| 39 static inline void rtc_AsanPoison(const volatile void* ptr, | 48 static inline void rtc_AsanPoison(const volatile void* ptr, |
| 40 size_t element_size, | 49 size_t element_size, |
| 41 size_t num_elements) { | 50 size_t num_elements) { |
| 42 #if RTC_HAS_ASAN | 51 #if RTC_HAS_ASAN |
| 43 ASAN_POISON_MEMORY_REGION(ptr, element_size * num_elements); | 52 ASAN_POISON_MEMORY_REGION(ptr, element_size * num_elements); |
| 44 #endif | 53 #endif |
| 45 } | 54 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 template <typename T> | 107 template <typename T> |
| 99 inline void MsanCheckInitialized(const T& mem) { | 108 inline void MsanCheckInitialized(const T& mem) { |
| 100 rtc_MsanCheckInitialized(mem.data(), sizeof(mem.data()[0]), mem.size()); | 109 rtc_MsanCheckInitialized(mem.data(), sizeof(mem.data()[0]), mem.size()); |
| 101 } | 110 } |
| 102 | 111 |
| 103 } // namespace rtc | 112 } // namespace rtc |
| 104 | 113 |
| 105 #endif // __cplusplus | 114 #endif // __cplusplus |
| 106 | 115 |
| 107 #endif // WEBRTC_BASE_SANITIZER_H_ | 116 #endif // WEBRTC_BASE_SANITIZER_H_ |
| OLD | NEW |