projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "sflow" into "master".
[openvswitch]
/
lib
/
util.h
diff --git
a/lib/util.h
b/lib/util.h
index dad7b7c4047523f9cb71653e29260ee16272a533..962bad2f31376a23b799a818e2f6acdcce38554e 100644
(file)
--- a/
lib/util.h
+++ b/
lib/util.h
@@
-52,10
+52,19
@@
extern const char *program_name;
extern const char *program_name;
+/* Returns the number of elements in ARRAY. */
#define ARRAY_SIZE(ARRAY) (sizeof ARRAY / sizeof *ARRAY)
#define ARRAY_SIZE(ARRAY) (sizeof ARRAY / sizeof *ARRAY)
+
+/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */
#define DIV_ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y))
#define DIV_ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y))
+
+/* Returns X rounded up to the nearest multiple of Y. */
#define ROUND_UP(X, Y) (DIV_ROUND_UP(X, Y) * (Y))
#define ROUND_UP(X, Y) (DIV_ROUND_UP(X, Y) * (Y))
+
+/* Returns X rounded down to the nearest multiple of Y. */
#define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
#define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
+
+/* Returns true if X is a power of 2, otherwise false. */
#define IS_POW2(X) ((X) && !((X) & ((X) - 1)))
#ifndef MIN
#define IS_POW2(X) ((X) && !((X) & ((X) - 1)))
#ifndef MIN