diff options
Diffstat (limited to 'absl/base/dynamic_annotations.h')
-rw-r--r-- | absl/base/dynamic_annotations.h | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/absl/base/dynamic_annotations.h b/absl/base/dynamic_annotations.h index 5ea697b7..c470c747 100644 --- a/absl/base/dynamic_annotations.h +++ b/absl/base/dynamic_annotations.h @@ -47,7 +47,11 @@ #include <stddef.h> +#include "absl/base/attributes.h" #include "absl/base/config.h" +#ifdef __cplusplus +#include "absl/base/macros.h" +#endif // TODO(rogeeff): Remove after the backward compatibility period. #include "absl/base/internal/dynamic_annotations.h" // IWYU pragma: export @@ -90,7 +94,8 @@ // Read/write annotations are enabled in Annotalysis mode; disabled otherwise. #define ABSL_INTERNAL_READS_WRITES_ANNOTATIONS_ENABLED \ ABSL_INTERNAL_ANNOTALYSIS_ENABLED -#endif + +#endif // ABSL_HAVE_THREAD_SANITIZER #ifdef __cplusplus #define ABSL_INTERNAL_BEGIN_EXTERN_C extern "C" { @@ -152,7 +157,7 @@ ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreate)(__FILE__, __LINE__, lock) // Report that a linker initialized lock has been created at address `lock`. -#ifdef THREAD_SANITIZER +#ifdef ABSL_HAVE_THREAD_SANITIZER #define ABSL_ANNOTATE_RWLOCK_CREATE_STATIC(lock) \ ABSL_INTERNAL_GLOBAL_SCOPED(AnnotateRWLockCreateStatic) \ (__FILE__, __LINE__, lock) @@ -417,41 +422,30 @@ ABSL_NAMESPACE_END #endif +#ifdef __cplusplus +#ifdef ABSL_HAVE_THREAD_SANITIZER ABSL_INTERNAL_BEGIN_EXTERN_C - -// ------------------------------------------------------------------------- -// Return non-zero value if running under valgrind. -// -// If "valgrind.h" is included into dynamic_annotations.cc, -// the regular valgrind mechanism will be used. -// See http://valgrind.org/docs/manual/manual-core-adv.html about -// RUNNING_ON_VALGRIND and other valgrind "client requests". -// The file "valgrind.h" may be obtained by doing -// svn co svn://svn.valgrind.org/valgrind/trunk/include -// -// If for some reason you can't use "valgrind.h" or want to fake valgrind, -// there are two ways to make this function return non-zero: -// - Use environment variable: export RUNNING_ON_VALGRIND=1 -// - Make your tool intercept the function RunningOnValgrind() and -// change its return value. -// -int RunningOnValgrind(void); - -// ValgrindSlowdown returns: -// * 1.0, if (RunningOnValgrind() == 0) -// * 50.0, if (RunningOnValgrind() != 0 && getenv("VALGRIND_SLOWDOWN") == -// NULL) -// * atof(getenv("VALGRIND_SLOWDOWN")) otherwise -// This function can be used to scale timeout values: -// EXAMPLE: -// for (;;) { -// DoExpensiveBackgroundTask(); -// SleepForSeconds(5 * ValgrindSlowdown()); -// } -// -double ValgrindSlowdown(void); - +int RunningOnValgrind(); +double ValgrindSlowdown(); ABSL_INTERNAL_END_EXTERN_C +#else +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace base_internal { +ABSL_DEPRECATED( + "Don't use this interface. It is misleading and is being deleted.") +ABSL_ATTRIBUTE_ALWAYS_INLINE inline int RunningOnValgrind() { return 0; } +ABSL_DEPRECATED( + "Don't use this interface. It is misleading and is being deleted.") +ABSL_ATTRIBUTE_ALWAYS_INLINE inline double ValgrindSlowdown() { return 1.0; } +} // namespace base_internal +ABSL_NAMESPACE_END +} // namespace absl + +using absl::base_internal::RunningOnValgrind; +using absl::base_internal::ValgrindSlowdown; +#endif +#endif // ------------------------------------------------------------------------- // Address sanitizer annotations |