summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-04-18 16:08:19 -0700
committerChristopher Wiley <wiley@google.com>2016-04-18 16:08:19 -0700
commitec9ea66a2bd3b16ed0b110cf82f18c0149438cc1 (patch)
tree065bc76231b3634161a8a3356f87359dd7bc3d25
parentc2241b9c5dbff5028558e658286c242c050594f8 (diff)
downloadcore-ec9ea66a2bd3b16ed0b110cf82f18c0149438cc1.tar.gz
core-ec9ea66a2bd3b16ed0b110cf82f18c0149438cc1.tar.bz2
core-ec9ea66a2bd3b16ed0b110cf82f18c0149438cc1.zip
Define LIKELY and UNLIKELY in a vendor friendly way
This prevents macro conflicts with vendor code. Bug: 27804373 Change-Id: I759c2b7b611203d0afdc35ddd5c2adb8f942ea17 Test: Compiles when libbinder include path changes to include libbase.
-rw-r--r--base/include/android-base/macros.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/base/include/android-base/macros.h b/base/include/android-base/macros.h
index 913a9a03e..299ec35a9 100644
--- a/base/include/android-base/macros.h
+++ b/base/include/android-base/macros.h
@@ -123,8 +123,11 @@ char(&ArraySizeHelper(T(&array)[N]))[N]; // NOLINT(readability/casting)
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
-#define LIKELY(x) __builtin_expect((x), true)
-#define UNLIKELY(x) __builtin_expect((x), false)
+// Changing this definition will cause you a lot of pain. A majority of
+// vendor code defines LIKELY and UNLIKELY this way, and includes
+// this header through an indirect path.
+#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
+#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
#define WARN_UNUSED __attribute__((warn_unused_result))