From: Willy Tarreau Date: Wed, 3 Jun 2020 15:49:00 +0000 (+0200) Subject: REORG: include: move SWAP/MID_RANGE/MAX_RANGE from tools.h to standard.h X-Git-Tag: v2.2-dev9~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d653a6285ee9e0dd18743e13d930f2425dece14;p=thirdparty%2Fhaproxy.git REORG: include: move SWAP/MID_RANGE/MAX_RANGE from tools.h to standard.h Tools.h doesn't make sense for these 3 macros alone anymore, let's move them to standard.h which will ultimately become again tools.h once moved. --- diff --git a/include/common/standard.h b/include/common/standard.h index fdbfc48a9c..2f1dffe36c 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -65,6 +65,16 @@ * power of 2, and 0 otherwise */ #define POWEROF2(x) (((x) & ((x)-1)) == 0) +#define SWAP(a, b) do { typeof(a) t; t = a; a = b; b = t; } while(0) + +/* return an integer of type with only the highest bit set. may be + * both a variable or a type. + */ +#define MID_RANGE(ret) ((typeof(ret))1 << (8*sizeof(ret) - 1)) + +/* return the largest possible integer of type , with all bits set */ +#define MAX_RANGE(ret) (~(typeof(ret))0) + /* rotate left a 64-bit integer by bits */ static inline uint64_t rotl64(uint64_t v, uint8_t bits) { diff --git a/include/common/tools.h b/include/common/tools.h index 8db38c6b45..e663ec2e75 100644 --- a/include/common/tools.h +++ b/include/common/tools.h @@ -22,16 +22,6 @@ #ifndef _COMMON_TOOLS_H #define _COMMON_TOOLS_H -#define SWAP(a, b) do { typeof(a) t; t = a; a = b; b = t; } while(0) - -/* return an integer of type with only the highest bit set. may be - * both a variable or a type. - */ -#define MID_RANGE(ret) ((typeof(ret))1 << (8*sizeof(ret) - 1)) - -/* return the largest possible integer of type , with all bits set */ -#define MAX_RANGE(ret) (~(typeof(ret))0) - #endif /* _COMMON_TOOLS_H */ /*