Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/absl/base/dynamic_annotations.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright 2017 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 
0015 // This file defines dynamic annotations for use with dynamic analysis tool
0016 // such as valgrind, PIN, etc.
0017 //
0018 // Dynamic annotation is a source code annotation that affects the generated
0019 // code (that is, the annotation is not a comment). Each such annotation is
0020 // attached to a particular instruction and/or to a particular object (address)
0021 // in the program.
0022 //
0023 // The annotations that should be used by users are macros in all upper-case
0024 // (e.g., ABSL_ANNOTATE_THREAD_NAME).
0025 //
0026 // Actual implementation of these macros may differ depending on the dynamic
0027 // analysis tool being used.
0028 //
0029 // This file supports the following configurations:
0030 // - Dynamic Annotations enabled (with static thread-safety warnings disabled).
0031 //   In this case, macros expand to functions implemented by Thread Sanitizer,
0032 //   when building with TSan. When not provided an external implementation,
0033 //   dynamic_annotations.cc provides no-op implementations.
0034 //
0035 // - Static Clang thread-safety warnings enabled.
0036 //   When building with a Clang compiler that supports thread-safety warnings,
0037 //   a subset of annotations can be statically-checked at compile-time. We
0038 //   expand these macros to static-inline functions that can be analyzed for
0039 //   thread-safety, but afterwards elided when building the final binary.
0040 //
0041 // - All annotations are disabled.
0042 //   If neither Dynamic Annotations nor Clang thread-safety warnings are
0043 //   enabled, then all annotation-macros expand to empty.
0044 
0045 #ifndef ABSL_BASE_DYNAMIC_ANNOTATIONS_H_
0046 #define ABSL_BASE_DYNAMIC_ANNOTATIONS_H_
0047 
0048 #include <stddef.h>
0049 #include <stdint.h>
0050 
0051 #include "absl/base/attributes.h"
0052 #include "absl/base/config.h"
0053 #ifdef __cplusplus
0054 #include "absl/base/macros.h"
0055 #endif
0056 
0057 #ifdef ABSL_HAVE_HWADDRESS_SANITIZER
0058 #include <sanitizer/hwasan_interface.h>
0059 #endif
0060 
0061 // TODO(rogeeff): Remove after the backward compatibility period.
0062 #include "absl/base/internal/dynamic_annotations.h"  // IWYU pragma: export
0063 
0064 // -------------------------------------------------------------------------
0065 // Decide which features are enabled.
0066 
0067 #ifdef ABSL_HAVE_THREAD_SANITIZER
0068 
0069 #define ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED 1
0070 #define ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED 1
0071 #define ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED 1
0072 #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 0
0073 #define ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED 1
0074 
0075 #else
0076 
0077 #define ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED 0
0078 #define ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED 0
0079 #define ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED 0
0080 
0081 // Clang provides limited support for static thread-safety analysis through a
0082 // feature called Annotalysis. We configure macro-definitions according to
0083 // whether Annotalysis support is available. When running in opt-mode, GCC
0084 // will issue a warning, if these attributes are compiled. Only include them
0085 // when compiling using Clang.
0086 
0087 #if defined(__clang__)
0088 #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 1
0089 #if !defined(SWIG)
0090 #define ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED 1
0091 #endif
0092 #else
0093 #define ABSL_INTERNAL_ANNOTALYSIS_ENABLED 0
0094 #endif
0095 
0096 // Read/write annotations are enabled in Annotalysis mode; disabled otherwise.
0097 #define ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED \
0098   ABSL_INTERNAL_ANNOTALYSIS_ENABLED
0099 
0100 #endif  // ABSL_HAVE_THREAD_SANITIZER
0101 
0102 #ifdef __cplusplus
0103 #define ABSL_INTERNAL_BEGIN_EXTERN_C extern "C" {
0104 #define ABSL_INTERNAL_END_EXTERN_C }  // extern "C"
0105 #define ABSL_INTERNAL_GLOBAL_SCOPED(F) ::F
0106 #define ABSL_INTERNAL_STATIC_INLINE inline
0107 #else
0108 #define ABSL_INTERNAL_BEGIN_EXTERN_C  // empty
0109 #define ABSL_INTERNAL_END_EXTERN_C    // empty
0110 #define ABSL_INTERNAL_GLOBAL_SCOPED(F) F
0111 #define ABSL_INTERNAL_STATIC_INLINE static inline
0112 #endif
0113 
0114 // -------------------------------------------------------------------------
0115 // Define race annotations.
0116 
0117 #if ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED == 1
0118 // Some of the symbols used in this section (e.g. AnnotateBenignRaceSized) are
0119 // defined by the compiler-based sanitizer implementation, not by the Abseil
0120 // library. Therefore they do not use ABSL_INTERNAL_C_SYMBOL.
0121 
0122 // -------------------------------------------------------------
0123 // Annotations that suppress errors. It is usually better to express the
0124 // program's synchronization using the other annotations, but these can be used
0125 // when all else fails.
0126 
0127 // Report that we may have a benign race at `pointer`, with size
0128 // "sizeof(*(pointer))". `pointer` must be a non-void* pointer. Insert at the
0129 // point where `pointer` has been allocated, preferably close to the point
0130 // where the race happens. See also ABSL_ANNOTATE_BENIGN_RACE_STATIC.
0131 #define ABSL_ANNOTATE_BENIGN_RACE(pointer, description) \
0132   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateBenignRaceSized)  \
0133   (__FILE__, __LINE__, pointer, sizeof(*(pointer)), description)
0134 
0135 // Same as ABSL_ANNOTATE_BENIGN_RACE(`address`, `description`), but applies to
0136 // the memory range [`address`, `address`+`size`).
0137 #define ABSL_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \
0138   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateBenignRaceSized)              \
0139   (__FILE__, __LINE__, address, size, description)
0140 
0141 // Enable (`enable`!=0) or disable (`enable`==0) race detection for all threads.
0142 // This annotation could be useful if you want to skip expensive race analysis
0143 // during some period of program execution, e.g. during initialization.
0144 #define ABSL_ANNOTATE_ENABLE_RACE_DETECTION(enable)        \
0145   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateEnableRaceDetection) \
0146   (__FILE__, __LINE__, enable)
0147 
0148 // -------------------------------------------------------------
0149 // Annotations useful for debugging.
0150 
0151 // Report the current thread `name` to a race detector.
0152 #define ABSL_ANNOTATE_THREAD_NAME(name) \
0153   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateThreadName)(__FILE__, __LINE__, name)
0154 
0155 // -------------------------------------------------------------
0156 // Annotations useful when implementing locks. They are not normally needed by
0157 // modules that merely use locks. The `lock` argument is a pointer to the lock
0158 // object.
0159 
0160 // Report that a lock has been created at address `lock`.
0161 #define ABSL_ANNOTATE_RWLOCK_CREATE(lock) \
0162   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreate)(__FILE__, __LINE__, lock)
0163 
0164 // Report that a linker initialized lock has been created at address `lock`.
0165 #ifdef ABSL_HAVE_THREAD_SANITIZER
0166 #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock)          \
0167   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreateStatic) \
0168   (__FILE__, __LINE__, lock)
0169 #else
0170 #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock) \
0171   ABSL_ANNOTATE_RWLOCK_CREATE(lock)
0172 #endif
0173 
0174 // Report that the lock at address `lock` is about to be destroyed.
0175 #define ABSL_ANNOTATE_RWLOCK_DESTROY(lock) \
0176   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockDestroy)(__FILE__, __LINE__, lock)
0177 
0178 // Report that the lock at address `lock` has been acquired.
0179 // `is_w`=1 for writer lock, `is_w`=0 for reader lock.
0180 #define ABSL_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)     \
0181   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockAcquired) \
0182   (__FILE__, __LINE__, lock, is_w)
0183 
0184 // Report that the lock at address `lock` is about to be released.
0185 // `is_w`=1 for writer lock, `is_w`=0 for reader lock.
0186 #define ABSL_ANNOTATE_RWLOCK_RELEASED(lock, is_w)     \
0187   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockReleased) \
0188   (__FILE__, __LINE__, lock, is_w)
0189 
0190 // Apply ABSL_ANNOTATE_BENIGN_RACE_SIZED to a static variable `static_var`.
0191 #define ABSL_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)      \
0192   namespace {                                                          \
0193   class static_var##_annotator {                                       \
0194    public:                                                             \
0195     static_var##_annotator() {                                         \
0196       ABSL_ANNOTATE_BENIGN_RACE_SIZED(&static_var, sizeof(static_var), \
0197                                       #static_var ": " description);   \
0198     }                                                                  \
0199   };                                                                   \
0200   static static_var##_annotator the##static_var##_annotator;           \
0201   }  // namespace
0202 
0203 // Function prototypes of annotations provided by the compiler-based sanitizer
0204 // implementation.
0205 ABSL_INTERNAL_BEGIN_EXTERN_C
0206 void AnnotateRWLockCreate(const char* file, int line,
0207                           const volatile void* lock);
0208 void AnnotateRWLockCreateStatic(const char* file, int line,
0209                                 const volatile void* lock);
0210 void AnnotateRWLockDestroy(const char* file, int line,
0211                            const volatile void* lock);
0212 void AnnotateRWLockAcquired(const char* file, int line,
0213                             const volatile void* lock, long is_w);  // NOLINT
0214 void AnnotateRWLockReleased(const char* file, int line,
0215                             const volatile void* lock, long is_w);  // NOLINT
0216 void AnnotateBenignRace(const char* file, int line,
0217                         const volatile void* address, const char* description);
0218 void AnnotateBenignRaceSized(const char* file, int line,
0219                              const volatile void* address, size_t size,
0220                              const char* description);
0221 void AnnotateThreadName(const char* file, int line, const char* name);
0222 void AnnotateEnableRaceDetection(const char* file, int line, int enable);
0223 ABSL_INTERNAL_END_EXTERN_C
0224 
0225 #else  // ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED == 0
0226 
0227 #define ABSL_ANNOTATE_RWLOCK_CREATE(lock)                            // empty
0228 #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock)                     // empty
0229 #define ABSL_ANNOTATE_RWLOCK_DESTROY(lock)                           // empty
0230 #define ABSL_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)                    // empty
0231 #define ABSL_ANNOTATE_RWLOCK_RELEASED(lock, is_w)                    // empty
0232 #define ABSL_ANNOTATE_BENIGN_RACE(address, description)              // empty
0233 #define ABSL_ANNOTATE_BENIGN_RACE_SIZED(address, size, description)  // empty
0234 #define ABSL_ANNOTATE_THREAD_NAME(name)                              // empty
0235 #define ABSL_ANNOTATE_ENABLE_RACE_DETECTION(enable)                  // empty
0236 #define ABSL_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)    // empty
0237 
0238 #endif  // ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED
0239 
0240 // -------------------------------------------------------------------------
0241 // Define memory annotations.
0242 
0243 #ifdef ABSL_HAVE_MEMORY_SANITIZER
0244 
0245 #include <sanitizer/msan_interface.h>
0246 
0247 #define ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(address, size) \
0248   __msan_unpoison(address, size)
0249 
0250 #define ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size) \
0251   __msan_allocated_memory(address, size)
0252 
0253 #else  // !defined(ABSL_HAVE_MEMORY_SANITIZER)
0254 
0255 #define ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(address, size)    // empty
0256 #define ABSL_ANNOTATE_MEMORY_IS_UNINITIALIZED(address, size)  // empty
0257 
0258 #endif  // ABSL_HAVE_MEMORY_SANITIZER
0259 
0260 // -------------------------------------------------------------------------
0261 // Define IGNORE_READS_BEGIN/_END attributes.
0262 
0263 #if defined(ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED)
0264 
0265 #define ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE \
0266   __attribute((exclusive_lock_function("*")))
0267 #define ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE \
0268   __attribute((unlock_function("*")))
0269 
0270 #else  // !defined(ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED)
0271 
0272 #define ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE  // empty
0273 #define ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE    // empty
0274 
0275 #endif  // defined(ABSL_INTERNAL_IGNORE_READS_ATTRIBUTE_ENABLED)
0276 
0277 // -------------------------------------------------------------------------
0278 // Define IGNORE_READS_BEGIN/_END annotations.
0279 
0280 #if ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED == 1
0281 // Some of the symbols used in this section (e.g. AnnotateIgnoreReadsBegin) are
0282 // defined by the compiler-based implementation, not by the Abseil
0283 // library. Therefore they do not use ABSL_INTERNAL_C_SYMBOL.
0284 
0285 // Request the analysis tool to ignore all reads in the current thread until
0286 // ABSL_ANNOTATE_IGNORE_READS_END is called. Useful to ignore intentional racey
0287 // reads, while still checking other reads and all writes.
0288 // See also ABSL_ANNOTATE_UNPROTECTED_READ.
0289 #define ABSL_ANNOTATE_IGNORE_READS_BEGIN()              \
0290   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreReadsBegin) \
0291   (__FILE__, __LINE__)
0292 
0293 // Stop ignoring reads.
0294 #define ABSL_ANNOTATE_IGNORE_READS_END()              \
0295   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreReadsEnd) \
0296   (__FILE__, __LINE__)
0297 
0298 // Function prototypes of annotations provided by the compiler-based sanitizer
0299 // implementation.
0300 ABSL_INTERNAL_BEGIN_EXTERN_C
0301 void AnnotateIgnoreReadsBegin(const char* file, int line)
0302     ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE;
0303 void AnnotateIgnoreReadsEnd(const char* file,
0304                             int line) ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE;
0305 ABSL_INTERNAL_END_EXTERN_C
0306 
0307 #elif defined(ABSL_INTERNAL_ANNOTALYSIS_ENABLED)
0308 
0309 // When Annotalysis is enabled without Dynamic Annotations, the use of
0310 // static-inline functions allows the annotations to be read at compile-time,
0311 // while still letting the compiler elide the functions from the final build.
0312 //
0313 // TODO(delesley) -- The exclusive lock here ignores writes as well, but
0314 // allows IGNORE_READS_AND_WRITES to work properly.
0315 
0316 #define ABSL_ANNOTATE_IGNORE_READS_BEGIN()                          \
0317   ABSL_INTERNAL_GLOBAL_SCOPED(                                      \
0318       ABSL_INTERNAL_C_SYMBOL(AbslInternalAnnotateIgnoreReadsBegin)) \
0319   ()
0320 
0321 #define ABSL_ANNOTATE_IGNORE_READS_END()                          \
0322   ABSL_INTERNAL_GLOBAL_SCOPED(                                    \
0323       ABSL_INTERNAL_C_SYMBOL(AbslInternalAnnotateIgnoreReadsEnd)) \
0324   ()
0325 
0326 ABSL_INTERNAL_STATIC_INLINE void ABSL_INTERNAL_C_SYMBOL(
0327     AbslInternalAnnotateIgnoreReadsBegin)()
0328     ABSL_INTERNAL_IGNORE_READS_BEGIN_ATTRIBUTE {}
0329 
0330 ABSL_INTERNAL_STATIC_INLINE void ABSL_INTERNAL_C_SYMBOL(
0331     AbslInternalAnnotateIgnoreReadsEnd)()
0332     ABSL_INTERNAL_IGNORE_READS_END_ATTRIBUTE {}
0333 
0334 #else
0335 
0336 #define ABSL_ANNOTATE_IGNORE_READS_BEGIN()  // empty
0337 #define ABSL_ANNOTATE_IGNORE_READS_END()    // empty
0338 
0339 #endif
0340 
0341 // -------------------------------------------------------------------------
0342 // Define IGNORE_WRITES_BEGIN/_END annotations.
0343 
0344 #if ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED == 1
0345 
0346 // Similar to ABSL_ANNOTATE_IGNORE_READS_BEGIN, but ignore writes instead.
0347 #define ABSL_ANNOTATE_IGNORE_WRITES_BEGIN() \
0348   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreWritesBegin)(__FILE__, __LINE__)
0349 
0350 // Stop ignoring writes.
0351 #define ABSL_ANNOTATE_IGNORE_WRITES_END() \
0352   ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateIgnoreWritesEnd)(__FILE__, __LINE__)
0353 
0354 // Function prototypes of annotations provided by the compiler-based sanitizer
0355 // implementation.
0356 ABSL_INTERNAL_BEGIN_EXTERN_C
0357 void AnnotateIgnoreWritesBegin(const char* file, int line);
0358 void AnnotateIgnoreWritesEnd(const char* file, int line);
0359 ABSL_INTERNAL_END_EXTERN_C
0360 
0361 #else
0362 
0363 #define ABSL_ANNOTATE_IGNORE_WRITES_BEGIN()  // empty
0364 #define ABSL_ANNOTATE_IGNORE_WRITES_END()    // empty
0365 
0366 #endif
0367 
0368 // -------------------------------------------------------------------------
0369 // Define the ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_* annotations using the more
0370 // primitive annotations defined above.
0371 //
0372 //     Instead of doing
0373 //        ABSL_ANNOTATE_IGNORE_READS_BEGIN();
0374 //        ... = x;
0375 //        ABSL_ANNOTATE_IGNORE_READS_END();
0376 //     one can use
0377 //        ... = ABSL_ANNOTATE_UNPROTECTED_READ(x);
0378 
0379 #if defined(ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED)
0380 
0381 // Start ignoring all memory accesses (both reads and writes).
0382 #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \
0383   do {                                                \
0384     ABSL_ANNOTATE_IGNORE_READS_BEGIN();               \
0385     ABSL_ANNOTATE_IGNORE_WRITES_BEGIN();              \
0386   } while (0)
0387 
0388 // Stop ignoring both reads and writes.
0389 #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END() \
0390   do {                                              \
0391     ABSL_ANNOTATE_IGNORE_WRITES_END();              \
0392     ABSL_ANNOTATE_IGNORE_READS_END();               \
0393   } while (0)
0394 
0395 #ifdef __cplusplus
0396 // ABSL_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
0397 #define ABSL_ANNOTATE_UNPROTECTED_READ(x) \
0398   absl::base_internal::AnnotateUnprotectedRead(x)
0399 
0400 namespace absl {
0401 ABSL_NAMESPACE_BEGIN
0402 namespace base_internal {
0403 
0404 template <typename T>
0405 inline T AnnotateUnprotectedRead(const volatile T& x) {  // NOLINT
0406   ABSL_ANNOTATE_IGNORE_READS_BEGIN();
0407   T res = x;
0408   ABSL_ANNOTATE_IGNORE_READS_END();
0409   return res;
0410 }
0411 
0412 }  // namespace base_internal
0413 ABSL_NAMESPACE_END
0414 }  // namespace absl
0415 #endif
0416 
0417 #else
0418 
0419 #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN()  // empty
0420 #define ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END()    // empty
0421 #define ABSL_ANNOTATE_UNPROTECTED_READ(x) (x)
0422 
0423 #endif
0424 
0425 // -------------------------------------------------------------------------
0426 // Address sanitizer annotations
0427 
0428 #ifdef ABSL_HAVE_ADDRESS_SANITIZER
0429 // Describe the current state of a contiguous container such as e.g.
0430 // std::vector or std::string. For more details see
0431 // sanitizer/common_interface_defs.h, which is provided by the compiler.
0432 #include <sanitizer/common_interface_defs.h>
0433 
0434 #define ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid) \
0435   __sanitizer_annotate_contiguous_container(beg, end, old_mid, new_mid)
0436 #define ABSL_ADDRESS_SANITIZER_REDZONE(name) \
0437   struct {                                   \
0438     alignas(8) char x[8];                    \
0439   } name
0440 
0441 #else
0442 
0443 #define ABSL_ANNOTATE_CONTIGUOUS_CONTAINER(beg, end, old_mid, new_mid)  // empty
0444 #define ABSL_ADDRESS_SANITIZER_REDZONE(name) static_assert(true, "")
0445 
0446 #endif  // ABSL_HAVE_ADDRESS_SANITIZER
0447 
0448 // -------------------------------------------------------------------------
0449 // HWAddress sanitizer annotations
0450 
0451 #ifdef __cplusplus
0452 namespace absl {
0453 #ifdef ABSL_HAVE_HWADDRESS_SANITIZER
0454 // Under HWASAN changes the tag of the pointer.
0455 template <typename T>
0456 T* HwasanTagPointer(T* ptr, uintptr_t tag) {
0457   return reinterpret_cast<T*>(__hwasan_tag_pointer(ptr, tag));
0458 }
0459 #else
0460 template <typename T>
0461 T* HwasanTagPointer(T* ptr, uintptr_t) {
0462   return ptr;
0463 }
0464 #endif
0465 }  // namespace absl
0466 #endif
0467 
0468 // -------------------------------------------------------------------------
0469 // Undefine the macros intended only for this file.
0470 
0471 #undef ABSL_INTERNAL_RACE_ANNOTATIONS_ENABLED
0472 #undef ABSL_INTERNAL_READS_ANNOTATIONS_ENABLED
0473 #undef ABSL_INTERNAL_WRITES_ANNOTATIONS_ENABLED
0474 #undef ABSL_INTERNAL_ANNOTALYSIS_ENABLED
0475 #undef ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED
0476 #undef ABSL_INTERNAL_BEGIN_EXTERN_C
0477 #undef ABSL_INTERNAL_END_EXTERN_C
0478 #undef ABSL_INTERNAL_STATIC_INLINE
0479 
0480 #endif  // ABSL_BASE_DYNAMIC_ANNOTATIONS_H_