From 650b607f339cd0ffa32e205e4501ec3fcfa88fbf Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 23 Nov 2019 16:24:08 +0100 Subject: Fix various data type problems - Make sure the mockup constant for AT_FDCWD is actualy an int - Don't use %lld printf format specified, mscrt doesn't have that - On 64 bit windows, use %I64u format specified for size_t - Seperate the overflow macro stuff from the form specifier stuff - Move the whole thing to compat.h and clean it up a little so it becomes readable. Signed-off-by: David Oberhollenzer --- include/util/util.h | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'include/util') diff --git a/include/util/util.h b/include/util/util.h index 095f02a..a133067 100644 --- a/include/util/util.h +++ b/include/util/util.h @@ -18,34 +18,6 @@ #define container_of(ptr, type, member) \ ((type *)((char *)ptr - offsetof(type, member))) -#if defined(__GNUC__) || defined(__clang__) -#define UI_ADD_OV __builtin_uadd_overflow -#define UL_ADD_OV __builtin_uaddl_overflow -#define ULL_ADD_OV __builtin_uaddll_overflow - -#define UI_MUL_OV __builtin_umul_overflow -#define UL_MUL_OV __builtin_umull_overflow -#define ULL_MUL_OV __builtin_umulll_overflow -#else -#error Sorry, I do not know how to trap integer overflows with this compiler -#endif - -#if SIZEOF_SIZE_T <= SIZEOF_INT -#define SZ_ADD_OV UI_ADD_OV -#define SZ_MUL_OV UI_MUL_OV -#define PRI_SZ "%u" -#elif SIZEOF_SIZE_T == SIZEOF_LONG -#define SZ_ADD_OV UL_ADD_OV -#define SZ_MUL_OV UL_MUL_OV -#define PRI_SZ "%lu" -#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG -#define SZ_ADD_OV ULL_ADD_OV -#define SZ_MUL_OV ULL_MUL_OV -#define PRI_SZ "%llu" -#else -#error Cannot determine maximum value of size_t -#endif - /* Helper for allocating data structures with flexible array members. -- cgit v1.2.3