| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef ABSL_BASE_DYNAMIC_ANNOTATIONS_H_ |
| #define ABSL_BASE_DYNAMIC_ANNOTATIONS_H_ |
|
|
| #include <stddef.h> |
| #include <stdint.h> |
|
|
| #include "absl/base/attributes.h" |
| #include "absl/base/config.h" |
| #ifdef __cplusplus |
| #include "absl/base/macros.h" |
| #endif |
|
|
| #ifdef ABSL_HAVE_HWADDRESS_SANITIZER |
| #include <sanitizer/hwasan_interface.h> |
| #endif |
|
|
| |
| #include "absl/base/internal/dynamic_annotations.h" |
|
|
| |
| |
|
|
| #ifdef ABSL_HAVE_THREAD_SANITIZER |
|
|
| #define ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED 1 |
| #define ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED 1 |
| #define ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED 1 |
| #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 0 |
| #define ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED 1 |
|
|
| #else |
|
|
| #define ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED 0 |
| #define ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED 0 |
| #define ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED 0 |
|
|
| |
| |
| |
| |
| |
|
|
| #if defined(__clang__) |
| #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 1 |
| #if !defined(SWIG) |
| #define ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED 1 |
| #endif |
| #else |
| #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 0 |
| #endif |
|
|
| |
| #define ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED \ |
| ABSL_INTERNAL_ANNOTALYSIS_ENABLED |
|
|
| #endif |
|
|
| #ifdef __cplusplus |
| #define ABSL_INTERNAL_BEGIN_EXTERN_C extern "C" { |
| #define ABSL_INTERNAL_END_EXTERN_C } |
| #define ABSL_INTERNAL_GLOBAL_SCOPED(F) ::F |
| #define ABSL_INTERNAL_STATIC_INLINE inline |
| #else |
| #define ABSL_INTERNAL_BEGIN_EXTERN_C |
| #define ABSL_INTERNAL_END_EXTERN_C |
| #define ABSL_INTERNAL_GLOBAL_SCOPED(F) F |
| #define ABSL_INTERNAL_STATIC_INLINE static inline |
| #endif |
|
|
| |
| |
|
|
| #if ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED == 1 |
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| #define ABSL_ANNOTATE_BENIGN_RACE(pointer, description) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateBenignRaceSized) \ |
| (__FILE__, __LINE__, pointer, sizeof(*(pointer)), description) |
|
|
| |
| |
| #define ABSL_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateBenignRaceSized) \ |
| (__FILE__, __LINE__, address, size, description) |
|
|
| |
| |
| |
| #define ABSL_ANNOTATE_ENABLE_RACE_DETECTION(enable) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateEnableRaceDetection) \ |
| (__FILE__, __LINE__, enable) |
|
|
| |
| |
|
|
| |
| #define ABSL_ANNOTATE_THREAD_NAME(name) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateThreadName)(__FILE__, __LINE__, name) |
|
|
| |
| |
| |
| |
|
|
| |
| #define ABSL_ANNOTATE_RWLOCK_CREATE(lock) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreate)(__FILE__, __LINE__, lock) |
|
|
| |
| #ifdef ABSL_HAVE_THREAD_SANITIZER |
| #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreateStatic) \ |
| (__FILE__, __LINE__, lock) |
| #else |
| #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock) \ |
| ABSL_ANNOTATE_RWLOCK_CREATE(lock) |
| #endif |
|
|
| |
| #define ABSL_ANNOTATE_RWLOCK_DESTROY(lock) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockDestroy)(__FILE__, __LINE__, lock) |
|
|
| |
| |
| #define ABSL_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockAcquired) \ |
| (__FILE__, __LINE__, lock, is_w) |
|
|
| |
| |
| #define ABSL_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockReleased) \ |
| (__FILE__, __LINE__, lock, is_w) |
|
|
| |
| #define ABSL_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ |
| namespace { \ |
| class static_var##_annotator { \ |
| public: \ |
| static_var##_annotator() { \ |
| ABSL_ANNOTATE_BENIGN_RACE_SIZED(&static_var, sizeof(static_var), \ |
| #static_var ": " description); \ |
| } \ |
| }; \ |
| static static_var##_annotator the##static_var##_annotator; \ |
| } |
|
|
| |
| |
| ABSL_INTERNAL_BEGIN_EXTERN_C |
| void AnnotateRWLockCreate(const char* file, int line, |
| const volatile void* lock); |
| void AnnotateRWLockCreateStatic(const char* file, int line, |
| const volatile void* lock); |
| void AnnotateRWLockDestroy(const char* file, int line, |
| const volatile void* lock); |
| void AnnotateRWLockAcquired(const char* file, int line, |
| const volatile void* lock, long is_w); |
| void AnnotateRWLockReleased(const char* file, int line, |
| const volatile void* lock, long is_w); |
| void AnnotateBenignRace(const char* file, int line, |
| const volatile void* address, const char* description); |
| void AnnotateBenignRaceSized(const char* file, int line, |
| const volatile void* address, size_t size, |
| const char* description); |
| void AnnotateThreadName(const char* file, int line, const char* name); |
| void AnnotateEnableRaceDetection(const char* file, int line, int enable); |
| ABSL_INTERNAL_END_EXTERN_C |
|
|
| #else |
|
|
| #define ABSL_ANNOTATE_RWLOCK_CREATE(lock) |
| #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock) |
| #define ABSL_ANNOTATE_RWLOCK_DESTROY(lock) |
| #define ABSL_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) |
| #define ABSL_ANNOTATE_RWLOCK_RELEASED(lock, is_w) |
| #define ABSL_ANNOTATE_BENIGN_RACE(address, description) |
| #define ABSL_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) |
| #define ABSL_ANNOTATE_THREAD_NAME(name) |
| #define ABSL_ANNOTATE_ENABLE_RACE_DETECTION(enable) |
| #define ABSL_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) |
|
|
| #endif |
|
|
| |
| |
|
|
| #ifdef ABSL_HAVE_MEMORY_SANITIZER |
|
|
| #include <sanitizer/msan_interface.h> |
|
|
| #define ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \ |
| __msan_unpoison(address, size) |
|
|
| #define ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) \ |
| __msan_allocated_memory(address, size) |
|
|
| #else |
|
|
| |
| #ifdef ABSL_HAVE_THREAD_SANITIZER |
| #define ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \ |
| do { \ |
| (void)(address); \ |
| (void)(size); \ |
| } while (0) |
| #define ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) \ |
| do { \ |
| (void)(address); \ |
| (void)(size); \ |
| } while (0) |
| #else |
|
|
| #define ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) |
| #define ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) |
|
|
| #endif |
|
|
| #endif |
|
|
| |
| |
|
|
| #if defined(ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED) |
|
|
| #define ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE \ |
| __attribute((exclusive_lock_function("*"))) |
| #define ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE \ |
| __attribute((unlock_function("*"))) |
|
|
| #else |
|
|
| #define ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE |
| #define ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE |
|
|
| #endif |
|
|
| |
| |
|
|
| #if ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED == 1 |
| |
| |
| |
|
|
| |
| |
| |
| |
| #define ABSL_ANNOTATE_IGNORE_READS_BEGIN() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreReadsBegin) \ |
| (__FILE__, __LINE__) |
|
|
| |
| #define ABSL_ANNOTATE_IGNORE_READS_END() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreReadsEnd) \ |
| (__FILE__, __LINE__) |
|
|
| |
| |
| ABSL_INTERNAL_BEGIN_EXTERN_C |
| void AnnotateIgnoreReadsBegin(const char* file, int line) |
| ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE; |
| void AnnotateIgnoreReadsEnd(const char* file, |
| int line) ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE; |
| ABSL_INTERNAL_END_EXTERN_C |
|
|
| #elif defined(ABSL_INTERNAL_ANNOTALYSIS_ENABLED) |
|
|
| |
| |
| |
| |
| |
| |
|
|
| #define ABSL_ANNOTATE_IGNORE_READS_BEGIN() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED( \ |
| ABSL_INTERNAL_C_SYMBOL(AbslInternalAnnotateIgnoreReadsBegin)) \ |
| () |
|
|
| #define ABSL_ANNOTATE_IGNORE_READS_END() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED( \ |
| ABSL_INTERNAL_C_SYMBOL(AbslInternalAnnotateIgnoreReadsEnd)) \ |
| () |
|
|
| ABSL_INTERNAL_STATIC_INLINE void ABSL_INTERNAL_C_SYMBOL( |
| AbslInternalAnnotateIgnoreReadsBegin)() |
| ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE {} |
|
|
| ABSL_INTERNAL_STATIC_INLINE void ABSL_INTERNAL_C_SYMBOL( |
| AbslInternalAnnotateIgnoreReadsEnd)() |
| ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE {} |
|
|
| #else |
|
|
| #define ABSL_ANNOTATE_IGNORE_READS_BEGIN() |
| #define ABSL_ANNOTATE_IGNORE_READS_END() |
|
|
| #endif |
|
|
| |
| |
|
|
| #if ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED == 1 |
|
|
| |
| #define ABSL_ANNOTATE_IGNORE_WRITES_BEGIN() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreWritesBegin)(__FILE__, __LINE__) |
|
|
| |
| #define ABSL_ANNOTATE_IGNORE_WRITES_END() \ |
| ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreWritesEnd)(__FILE__, __LINE__) |
|
|
| |
| |
| ABSL_INTERNAL_BEGIN_EXTERN_C |
| void AnnotateIgnoreWritesBegin(const char* file, int line); |
| void AnnotateIgnoreWritesEnd(const char* file, int line); |
| ABSL_INTERNAL_END_EXTERN_C |
|
|
| #else |
|
|
| #define ABSL_ANNOTATE_IGNORE_WRITES_BEGIN() |
| #define ABSL_ANNOTATE_IGNORE_WRITES_END() |
|
|
| #endif |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #if defined(ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED) |
|
|
| |
| #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \ |
| do { \ |
| ABSL_ANNOTATE_IGNORE_READS_BEGIN(); \ |
| ABSL_ANNOTATE_IGNORE_WRITES_BEGIN(); \ |
| } while (0) |
|
|
| |
| #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END() \ |
| do { \ |
| ABSL_ANNOTATE_IGNORE_WRITES_END(); \ |
| ABSL_ANNOTATE_IGNORE_READS_END(); \ |
| } while (0) |
|
|
| #ifdef __cplusplus |
| |
| #define ABSL_ANNOTATE_UNPROTECTED_READ(x) \ |
| absl::base_internal::AnnotateUnprotectedRead(x) |
|
|
| namespace absl { |
| ABSL_NAMESPACE_BEGIN |
| namespace base_internal { |
|
|
| template <typename T> |
| inline T AnnotateUnprotectedRead(const volatile T& x) { |
| ABSL_ANNOTATE_IGNORE_READS_BEGIN(); |
| T res = x; |
| ABSL_ANNOTATE_IGNORE_READS_END(); |
| return res; |
| } |
|
|
| } |
| ABSL_NAMESPACE_END |
| } |
| #endif |
|
|
| #else |
|
|
| #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() |
| #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END() |
| #define ABSL_ANNOTATE_UNPROTECTED_READ(x) (x) |
|
|
| #endif |
|
|
| |
| |
|
|
| #ifdef ABSL_HAVE_ADDRESS_SANITIZER |
| |
| |
| |
| #include <sanitizer/common_interface_defs.h> |
|
|
| #define ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid) \ |
| __sanitizer_annotate_contiguous_container(beg, end, old_mid, new_mid) |
| #define ABSL_ADDRESS_SANITIZER_REDZONE(name) \ |
| struct { \ |
| alignas(8) char x[8]; \ |
| } name |
|
|
| #else |
|
|
| #define ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid) |
| #define ABSL_ADDRESS_SANITIZER_REDZONE(name) static_assert(true, "") |
|
|
| #endif |
|
|
| |
| |
|
|
| #ifdef __cplusplus |
| namespace absl { |
| #ifdef ABSL_HAVE_HWADDRESS_SANITIZER |
| |
| template <typename T> |
| T* HwasanTagPointer(T* ptr, uintptr_t tag) { |
| return reinterpret_cast<T*>(__hwasan_tag_pointer(ptr, tag)); |
| } |
| #else |
| template <typename T> |
| T* HwasanTagPointer(T* ptr, uintptr_t) { |
| return ptr; |
| } |
| #endif |
| } |
| #endif |
|
|
| |
| |
|
|
| #undef ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED |
| #undef ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED |
| #undef ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED |
| #undef ABSL_INTERNAL_ANNOTALYSIS_ENABLED |
| #undef ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED |
| #undef ABSL_INTERNAL_BEGIN_EXTERN_C |
| #undef ABSL_INTERNAL_END_EXTERN_C |
| #undef ABSL_INTERNAL_STATIC_INLINE |
|
|
| #endif |
|
|