From e3e2b7283fa748c873b7e0c4ab6700822ecd030c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 20 May 2019 19:10:52 +0200 Subject: [PATCH] REORG: compat: move some integer limit definitions from standard.h to compat.h Historically standard.h was the location where we used to (re-)define the standard set of macros and functions, and to complement the ones missing on the target OS. Over time it has become a toolbox in itself relying on many other things, and its definition of LONGBITS is used everywhere else (e.g. for MAX_THREADS), resulting in painful circular dependencies. Let's move these few defines (integer sizes) to compat.h where other similar definitions normally are. --- include/common/compat.h | 14 ++++++++++++++ include/common/standard.h | 13 ------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/common/compat.h b/include/common/compat.h index 1401f91d4c..34d1b35c59 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -31,6 +31,20 @@ #include #include +// Redefine some limits that are not present everywhere +#ifndef LLONG_MAX +# define LLONG_MAX 9223372036854775807LL +# define LLONG_MIN (-LLONG_MAX - 1LL) +#endif + +#ifndef ULLONG_MAX +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +#endif + +#ifndef LONGBITS +#define LONGBITS ((unsigned int)sizeof(long) * 8) +#endif + #ifndef BITS_PER_INT #define BITS_PER_INT (8*sizeof(int)) #endif diff --git a/include/common/standard.h b/include/common/standard.h index 0bea022b91..e88a79ddf4 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -40,19 +40,6 @@ #include #include -#ifndef LLONG_MAX -# define LLONG_MAX 9223372036854775807LL -# define LLONG_MIN (-LLONG_MAX - 1LL) -#endif - -#ifndef ULLONG_MAX -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) -#endif - -#ifndef LONGBITS -#define LONGBITS ((unsigned int)sizeof(long) * 8) -#endif - /* size used for max length of decimal representation of long long int. */ #define NB_LLMAX_STR (sizeof("-9223372036854775807")-1)