Download src/rtc_base/sanitizer.h from camenduru/pocketsphinx: direct link, hf CLI and curl.
- Browser
- Download file 4.64 kB
-
https://huggingface.co/camenduru/pocketsphinx/resolve/main/src/rtc_base/sanitizer.h
- Command line
-
hf download hf://camenduru/pocketsphinx/src/rtc_base/sanitizer.h
-
curl -L -o sanitizer.h https://huggingface.co/camenduru/pocketsphinx/resolve/main/src/rtc_base/sanitizer.h
4.64 kB
| /* | |
| * Copyright 2016 The WebRTC Project Authors. All rights reserved. | |
| * | |
| * Use of this source code is governed by a BSD-style license | |
| * that can be found in the LICENSE file in the root of the source | |
| * tree. An additional intellectual property rights grant can be found | |
| * in the file PATENTS. All contributing project authors may | |
| * be found in the AUTHORS file in the root of the source tree. | |
| */ | |
| // Ask ASan to mark the memory range [ptr, ptr + element_size * num_elements) | |
| // as being unaddressable, so that reads and writes are not allowed. ASan may | |
| // narrow the range to the nearest alignment boundaries. | |
| static inline void rtc_AsanPoison(const volatile void* ptr, | |
| size_t element_size, | |
| size_t num_elements) { | |
| ASAN_POISON_MEMORY_REGION(ptr, element_size * num_elements); | |
| (void)ptr; | |
| (void)element_size; | |
| (void)num_elements; | |
| } | |
| // Ask ASan to mark the memory range [ptr, ptr + element_size * num_elements) | |
| // as being addressable, so that reads and writes are allowed. ASan may widen | |
| // the range to the nearest alignment boundaries. | |
| static inline void rtc_AsanUnpoison(const volatile void* ptr, | |
| size_t element_size, | |
| size_t num_elements) { | |
| ASAN_UNPOISON_MEMORY_REGION(ptr, element_size * num_elements); | |
| (void)ptr; | |
| (void)element_size; | |
| (void)num_elements; | |
| } | |
| // Ask MSan to mark the memory range [ptr, ptr + element_size * num_elements) | |
| // as being uninitialized. | |
| static inline void rtc_MsanMarkUninitialized(const volatile void* ptr, | |
| size_t element_size, | |
| size_t num_elements) { | |
| __msan_poison(ptr, element_size * num_elements); | |
| (void)ptr; | |
| (void)element_size; | |
| (void)num_elements; | |
| } | |
| // Force an MSan check (if any bits in the memory range [ptr, ptr + | |
| // element_size * num_elements) are uninitialized the call will crash with an | |
| // MSan report). | |
| static inline void rtc_MsanCheckInitialized(const volatile void* ptr, | |
| size_t element_size, | |
| size_t num_elements) { | |
| __msan_check_mem_is_initialized(ptr, element_size * num_elements); | |
| (void)ptr; | |
| (void)element_size; | |
| (void)num_elements; | |
| } | |
| namespace rtc { | |
| namespace sanitizer_impl { | |
| template <typename T> | |
| constexpr bool IsTriviallyCopyable() { | |
| return static_cast<bool>(absl::is_trivially_copy_constructible<T>::value && | |
| (absl::is_trivially_copy_assignable<T>::value || | |
| !std::is_copy_assignable<T>::value) && | |
| absl::is_trivially_destructible<T>::value); | |
| } | |
| } // namespace sanitizer_impl | |
| template <typename T> | |
| inline void AsanPoison(const T& mem) { | |
| rtc_AsanPoison(mem.data(), sizeof(mem.data()[0]), mem.size()); | |
| } | |
| template <typename T> | |
| inline void AsanUnpoison(const T& mem) { | |
| rtc_AsanUnpoison(mem.data(), sizeof(mem.data()[0]), mem.size()); | |
| } | |
| template <typename T> | |
| inline void MsanMarkUninitialized(const T& mem) { | |
| rtc_MsanMarkUninitialized(mem.data(), sizeof(mem.data()[0]), mem.size()); | |
| } | |
| template <typename T> | |
| inline T MsanUninitialized(T t) { | |
| // TODO(bugs.webrtc.org/8762): Switch to std::is_trivially_copyable when it | |
| // becomes available in downstream projects. | |
| static_assert(sanitizer_impl::IsTriviallyCopyable<T>(), ""); | |
| rtc_MsanMarkUninitialized(&t, sizeof(T), 1); | |
| return t; | |
| } | |
| template <typename T> | |
| inline void MsanCheckInitialized(const T& mem) { | |
| rtc_MsanCheckInitialized(mem.data(), sizeof(mem.data()[0]), mem.size()); | |
| } | |
| } // namespace rtc | |