summaryrefslogtreecommitdiff
path: root/absl/base/optimization.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-02-23 14:30:26 -0800
committerGravatar rogeeff <rogeeff@google.com>2022-02-24 12:28:55 -0500
commit5e4ea1ce097f3571e7d87af33b6b30d11b3a211e (patch)
tree62fbf34f7e310a9ef6602acee8fa7d61ae32df09 /absl/base/optimization.h
parent0ad7994f10624cd1538b1287e56cae5ac9c0cb40 (diff)
Export of internal Abseil changes
-- 7473df9e4922c589f6b27cf546aad097381ae552 by Martijn Vels <mvels@google.com>: Make ABSL_ASSUME publicly available PiperOrigin-RevId: 430540224 Change-Id: I760e2d86e3a0b676cd2a6d26e0225a77381e948f -- c83e38bc421f715b3c1e20150c2f1ffe8e633028 by Abseil Team <absl-team@google.com>: Alias absl::bind_front to std::bind_front if available This avoids ambiguity between the two when enabling C++20. PiperOrigin-RevId: 430486679 GitOrigin-RevId: 7473df9e4922c589f6b27cf546aad097381ae552 Change-Id: I1e9bba09a8946480ce10ddd28e86b6c86191d38c
Diffstat (limited to 'absl/base/optimization.h')
-rw-r--r--absl/base/optimization.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/absl/base/optimization.h b/absl/base/optimization.h
index d090be12..6fe03c43 100644
--- a/absl/base/optimization.h
+++ b/absl/base/optimization.h
@@ -181,22 +181,7 @@
#define ABSL_PREDICT_TRUE(x) (x)
#endif
-// ABSL_INTERNAL_ASSUME(cond)
-// Informs the compiler that a condition is always true and that it can assume
-// it to be true for optimization purposes. The call has undefined behavior if
-// the condition is false.
-// In !NDEBUG mode, the condition is checked with an assert().
-// NOTE: The expression must not have side effects, as it will only be evaluated
-// in some compilation modes and not others.
-//
-// Example:
-//
-// int x = ...;
-// ABSL_INTERNAL_ASSUME(x >= 0);
-// // The compiler can optimize the division to a simple right shift using the
-// // assumption specified above.
-// int y = x / 16;
-//
+// Platform and compilation mode dependent implementation of ABSL_ASSUME.
#if !defined(NDEBUG)
#define ABSL_INTERNAL_ASSUME(cond) assert(cond)
#elif ABSL_HAVE_BUILTIN(__builtin_assume)
@@ -215,6 +200,24 @@
} while (0)
#endif
+// ABSL_ASSUME(cond)
+// Informs the compiler that a condition is always true and that it can assume
+// it to be true for optimization purposes. The call has undefined behavior if
+// the condition is false.
+// In !NDEBUG mode, the condition is checked with an assert().
+// NOTE: The expression must not have side effects, as it may only be evaluated
+// in some compilation modes and not others.
+//
+// Example:
+//
+// int x = ...;
+// ABSL_ASSUME(x >= 0);
+// // The compiler can optimize the division to a simple right shift using the
+// // assumption specified above.
+// int y = x / 16;
+//
+#define ABSL_ASSUME(cond) ABSL_INTERNAL_ASSUME(cond)
+
// ABSL_INTERNAL_UNIQUE_SMALL_NAME(cond)
// This macro forces small unique name on a static file level symbols like
// static local variables or static functions. This is intended to be used in