git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Introduce ofputil_protocol, to abstract the protocol in use on a connection.
[sliver-openvswitch.git]
/
lib
/
util.h
diff --git
a/lib/util.h
b/lib/util.h
index
d504f2f
..
9318fa7
100644
(file)
--- a/
lib/util.h
+++ b/
lib/util.h
@@
-78,6
+78,20
@@
extern const char *program_name;
/* Returns true if X is a power of 2, otherwise false. */
#define IS_POW2(X) ((X) && !((X) & ((X) - 1)))
/* Returns true if X is a power of 2, otherwise false. */
#define IS_POW2(X) ((X) && !((X) & ((X) - 1)))
+static inline bool
+is_pow2(uintmax_t x)
+{
+ return IS_POW2(x);
+}
+
+/* Returns the rightmost 1-bit in 'x' (e.g. 01011000 => 00001000), or 0 if 'x'
+ * is 0. */
+static inline uintmax_t
+rightmost_1bit(uintmax_t x)
+{
+ return x & -x;
+}
+
#ifndef MIN
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#endif
#ifndef MIN
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#endif