diff options
author | Ben Warren <ben@skyportsystems.com> | 2016-04-04 21:32:01 -0400 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-04-14 10:17:25 -0700 |
commit | b44aaaaff8d826535025f4f8d12808c4ef36a7a8 (patch) | |
tree | f92ded62a92a0c7ed6c17e9147d888693155e0d0 /lib/util.h | |
parent | 792d377d8330606ad122dae5f941e5088c10cf14 (diff) | |
download | openvswitch-b44aaaaff8d826535025f4f8d12808c4ef36a7a8.tar.gz |
Misc cleanup with "util.h" header files
Removed redundant #includes and moved some macros to different file
scope
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Acked-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/util.h')
-rw-r--r-- | lib/util.h | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/lib/util.h b/lib/util.h index 5a429d7a5..55e2c6722 100644 --- a/lib/util.h +++ b/lib/util.h @@ -20,15 +20,10 @@ #include <arpa/inet.h> #include <inttypes.h> #include <limits.h> -#include <stdarg.h> -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "compiler.h" -#include "openvswitch/types.h" #include "openvswitch/util.h" extern char *program_name; @@ -48,48 +43,6 @@ extern char *program_name; #define __ARRAY_SIZE(ARRAY) __ARRAY_SIZE_NOCHECK(ARRAY) #endif -/* Returns the number of elements in ARRAY. */ -#define ARRAY_SIZE(ARRAY) __ARRAY_SIZE(ARRAY) - -/* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ -#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)) - -/* Returns the least number that, when added to X, yields a multiple of Y. */ -#define PAD_SIZE(X, Y) (ROUND_UP(X, Y) - (X)) - -/* Returns X rounded down to the nearest multiple of 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))) - -static inline bool -is_pow2(uintmax_t x) -{ - return IS_POW2(x); -} - -/* Returns X rounded up to a power of 2. X must be a constant expression. */ -#define ROUND_UP_POW2(X) RUP2__(X) -#define RUP2__(X) (RUP2_1(X) + 1) -#define RUP2_1(X) (RUP2_2(X) | (RUP2_2(X) >> 16)) -#define RUP2_2(X) (RUP2_3(X) | (RUP2_3(X) >> 8)) -#define RUP2_3(X) (RUP2_4(X) | (RUP2_4(X) >> 4)) -#define RUP2_4(X) (RUP2_5(X) | (RUP2_5(X) >> 2)) -#define RUP2_5(X) (RUP2_6(X) | (RUP2_6(X) >> 1)) -#define RUP2_6(X) ((X) - 1) - -/* Returns X rounded down to a power of 2. X must be a constant expression. */ -#define ROUND_DOWN_POW2(X) RDP2__(X) -#define RDP2__(X) (RDP2_1(X) - (RDP2_1(X) >> 1)) -#define RDP2_1(X) (RDP2_2(X) | (RDP2_2(X) >> 16)) -#define RDP2_2(X) (RDP2_3(X) | (RDP2_3(X) >> 8)) -#define RDP2_3(X) (RDP2_4(X) | (RDP2_4(X) >> 4)) -#define RDP2_4(X) (RDP2_5(X) | (RDP2_5(X) >> 2)) -#define RDP2_5(X) ( (X) | ( (X) >> 1)) /* This system's cache line size, in bytes. * Being wrong hurts performance but not correctness. */ @@ -117,10 +70,6 @@ ovs_prefetch_range(const void *start, size_t size) #define OVS_NOT_REACHED() abort() -/* Given ATTR, and TYPE, cast the ATTR to TYPE by first casting ATTR to - * (void *). This is to suppress the alignment warning issued by clang. */ -#define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR)) - /* Use "%"PRIuSIZE to format size_t with printf(). */ #ifdef _WIN32 #define PRIdSIZE "Id" |