summaryrefslogtreecommitdiff
path: root/absl/base/dynamic_annotations.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-07-24 13:00:52 -0700
committerGravatar Andy Getz <durandal@google.com>2020-07-24 16:15:46 -0400
commit2c8a5b0d890cfbd2c1e70163e347f3e00b4ddb49 (patch)
treed34982e21f00fdac3eaa2f049e2bc6113bed105b /absl/base/dynamic_annotations.h
parent41a6263fd0bcc93a90ff739785f17260f8ea061e (diff)
Export of internal Abseil changes
-- 873b52b0a691e759413c5db27dafc541a5da5263 by Andy Getzendanner <durandal@google.com>: Introduce an internal-only thread-local caching wrapper around GetTID. PiperOrigin-RevId: 323055682 -- 091a4537f1ef6e158acbf4261cfae1af7a3bdb7f by Abseil Team <absl-team@google.com>: Internal change PiperOrigin-RevId: 322864497 -- c80ccfff2a825819f31826a30f48cca3297699f8 by Evan Brown <ezb@google.com>: Roll forward b-tree changes simplifying deletion and getting rid of recursion in clear_and_delete(). We also change clear_and_delete() to avoid some unnecessary comparisons by restructuring the loops. PiperOrigin-RevId: 322658938 -- 81464c0fb9c8c6268dca2e530aba99e75e1e59ae by Gennadiy Rozental <rogeeff@google.com>: Eliminate definition of RunningOnValgrind inside the library. Fixes #674 Fixes #657 PiperOrigin-RevId: 322508440 GitOrigin-RevId: 873b52b0a691e759413c5db27dafc541a5da5263 Change-Id: I20b40c9e8fc62edcf981caab467cca33cf6fd2ba
Diffstat (limited to 'absl/base/dynamic_annotations.h')
-rw-r--r--absl/base/dynamic_annotations.h64
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