summaryrefslogtreecommitdiff
path: root/lib/compiler.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-01-16 16:03:03 -0800
committerBen Pfaff <blp@nicira.com>2013-01-16 16:03:03 -0800
commit4749f73d12c844b318af7f45cf45e1acac9f7c08 (patch)
tree8b052885968f7cc6f0f281f1dee0a704b1ec4477 /lib/compiler.h
parent167744623897a67ef3fd13bcaf44a84d3641fe68 (diff)
downloadopenvswitch-4749f73d12c844b318af7f45cf45e1acac9f7c08.tar.gz
util: Introduce ovs_assert macro.
An occasionally significant problem with the standard "assert" macro is that it writes the failure message to stderr. In our daemons, stderr is generally redirected to /dev/null. It's more useful to write the failure message to the log, which is what the new ovs_assert macro introduced in this patch does. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib/compiler.h')
-rw-r--r--lib/compiler.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/compiler.h b/lib/compiler.h
index 27612a74a..760389d58 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -26,6 +26,8 @@
#define ALWAYS_INLINE __attribute__((always_inline))
#define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#define SENTINEL(N) __attribute__((sentinel(N)))
+#define OVS_LIKELY(CONDITION) __builtin_expect(!!(CONDITION), 1)
+#define OVS_UNLIKELY(CONDITION) __builtin_expect(!!(CONDITION), 0)
#else
#define NO_RETURN
#define OVS_UNUSED
@@ -35,6 +37,8 @@
#define ALWAYS_INLINE
#define WARN_UNUSED_RESULT
#define SENTINEL(N)
+#define OVS_LIKELY(CONDITION) (!!(CONDITION))
+#define OVS_UNLIKELY(CONDITION) (!!(CONDITION))
#endif
/* ISO C says that a C implementation may choose any integer type for an enum