summaryrefslogtreecommitdiff
path: root/absl/base/dynamic_annotations.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base/dynamic_annotations.h')
-rw-r--r--absl/base/dynamic_annotations.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/absl/base/dynamic_annotations.h b/absl/base/dynamic_annotations.h
index 3ea7c156..7ba8912e 100644
--- a/absl/base/dynamic_annotations.h
+++ b/absl/base/dynamic_annotations.h
@@ -46,6 +46,7 @@
#define ABSL_BASE_DYNAMIC_ANNOTATIONS_H_
#include <stddef.h>
+#include <stdint.h>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
@@ -53,6 +54,10 @@
#include "absl/base/macros.h"
#endif
+#ifdef ABSL_HAVE_HWADDRESS_SANITIZER
+#include <sanitizer/hwasan_interface.h>
+#endif
+
// TODO(rogeeff): Remove after the backward compatibility period.
#include "absl/base/internal/dynamic_annotations.h" // IWYU pragma: export
@@ -111,7 +116,7 @@
#if ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED == 1
// Some of the symbols used in this section (e.g. AnnotateBenignRaceSized) are
-// defined by the compiler-based santizer implementation, not by the Abseil
+// defined by the compiler-based sanitizer implementation, not by the Abseil
// library. Therefore they do not use ABSL_INTERNAL_C_SYMBOL.
// -------------------------------------------------------------
@@ -457,6 +462,26 @@ ABSL_NAMESPACE_END
#endif // ABSL_HAVE_ADDRESS_SANITIZER
// -------------------------------------------------------------------------
+// HWAddress sanitizer annotations
+
+#ifdef __cplusplus
+namespace absl {
+#ifdef ABSL_HAVE_HWADDRESS_SANITIZER
+// Under HWASAN changes the tag of the pointer.
+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
+} // namespace absl
+#endif
+
+// -------------------------------------------------------------------------
// Undefine the macros intended only for this file.
#undef ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED