diff mbox

[ovs-dev,5/8] lib: Introduce ovs_u128_is_zero().

Message ID 1441850422-33750-5-git-send-email-joestringer@nicira.com
State Superseded
Headers show

Commit Message

Joe Stringer Sept. 10, 2015, 2 a.m. UTC
From: Daniele Di Proietto <diproiettod@vmware.com>

is_all_zeros() is quite slow for u128 initialization because:
- It is not inlined
- It checks byte by byte

This commit introduces a new function to perform this function, which
improves performance in the DPDK packet processing path for upcoming
commits that regularly check u128 values.
---
 lib/util.h | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/lib/util.h b/lib/util.h
index 7080a0c..eebc6e9 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -568,6 +568,13 @@  ovs_u128_equals(const ovs_u128 *a, const ovs_u128 *b)
     return (a->u64.hi == b->u64.hi) && (a->u64.lo == b->u64.lo);
 }
 
+/* Returns true if 'val' is 0. */
+static inline bool
+ovs_u128_is_zero(const ovs_u128 *val)
+{
+    return !(val->u64.hi || val->u64.lo);
+}
+
 void xsleep(unsigned int seconds);
 
 #ifdef _WIN32