]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Use size of size_t instead of data-model for bit-widths
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Fri, 24 Jun 2022 06:07:09 +0000 (08:07 +0200)
committerKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 4 Jul 2022 10:03:04 +0000 (12:03 +0200)
This commit drops the generic and confusing data-model check (that
is a platform-specific value of bit-widths for various data types) in
favor of checking the actually used size (i.e. size_t).

configure.ac
src/lib/bits.c
src/lib/compat.h
src/lib/test-mempool-allocfree.c
src/lib/test-mempool-alloconly.c
src/lib/test-mempool.c

index 9e561af10b17abf9b0cbc18e946e768153037484..0f0f69d234e36558014d43366918e5c6e4350616 100644 (file)
@@ -335,6 +335,7 @@ AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(size_t)
 
 AC_SYS_LARGEFILE
 
index 6366cf24cbec21ab4998b83ead7d4f8225c82dd5..a76a815996990bdface255ec5dbdbb9d658d1905 100644 (file)
@@ -6,7 +6,7 @@
  * We could use bits_required64() unconditionally, but that's unnecessary
  * and way more heavy weight on 32-bit systems.
  */
-#ifdef _LP64
+#if SIZEOF_SIZE_T > 4
 #define BITS_REQUIRED(x)       bits_required64(x)
 #else
 #define BITS_REQUIRED(x)       bits_required32(x)
index 7ab1340af39a24cf79e41d804edc504ab29b577e..869732d08e33c65168e3d652b5e43a4a94a57740 100644 (file)
@@ -1,34 +1,6 @@
 #ifndef COMPAT_H
 #define COMPAT_H
 
-/*
- *
- *
- *
- * This block decides whether 32 or 64 bit pointers are used.
- * Shallow research indicates, that ILP32 is used for x32 and arm64ilp32 modes
- * but is it still necessary?
- * https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
- *
- *
- *
- */
-/* _ILP32 and _LP64 are common but not universal, make sure that exactly one
-   of them is defined. */
-#if !defined(_ILP32) && \
-       (SIZEOF_INT == 4) && (SIZEOF_LONG == 4) && (SIZEOF_VOID_P == 4)
-#  define _ILP32
-#endif
-#if !defined(_LP64) && \
-       (SIZEOF_INT == 4) && (SIZEOF_LONG == 8) && (SIZEOF_VOID_P == 8)
-#  define _LP64
-#endif
-#if defined(_ILP32) && defined(_LP64)
-#  error "Cannot have both _ILP32 and _LP64 defined"
-#elif !defined(_ILP32) && !defined(_LP64)
-#  error "Must have one of _ILP32 and _LP64 defined"
-#endif
-
 #if defined(HAVE_TYPEOF) && !defined(__cplusplus)
 #  define HAVE_TYPE_CHECKS
 #endif
index 6fd69dc0014cefa43058d36322ea8036eaa11bab..82d4304d18d47244d704496ef794a0338a5832d2 100644 (file)
@@ -114,7 +114,7 @@ enum fatal_test_state fatal_mempool_allocfree(unsigned int stage)
                (void)p_malloc(pool, POOL_MAX_ALLOC_SIZE + 1ULL);
                return FATAL_TEST_FAILURE;
 
-#ifdef _LP64 /* malloc(POOL_MAX_ALLOC_SIZE) may succeed with 32bit */
+#if SIZEOF_SIZE_T > 4 /* malloc(POOL_MAX_ALLOC_SIZE) may succeed with 32bit */
        case 2: /* physically impossible size */
                test_expect_fatal_string("Out of memory");
                (void)p_malloc(pool, POOL_MAX_ALLOC_SIZE);
index c3b0001b7955b11dae5e114970614afbd51f627c..e014be75f0a10d53c8f5e7c24e98dc7f737f7d7f 100644 (file)
@@ -73,7 +73,7 @@ enum fatal_test_state fatal_mempool_alloconly(unsigned int stage)
                (void)p_malloc(pool, POOL_MAX_ALLOC_SIZE + 1ULL);
                return FATAL_TEST_FAILURE;
 
-#ifdef _LP64 /* malloc(POOL_MAX_ALLOC_SIZE) may succeed with 32bit */
+#if SIZEOF_SIZE_T > 4 /* malloc(POOL_MAX_ALLOC_SIZE) may succeed with 32bit */
        case 2: /* physically impossible size */
                test_expect_fatal_string("Out of memory");
                (void)p_malloc(pool, POOL_MAX_ALLOC_SIZE);
index 7c707dd33a9d71261dc69348013ea1287638d1ef..35ea2d96688ebf1ffaba33efe3f83d06ef939385 100644 (file)
@@ -10,7 +10,7 @@ typedef char uint32max_array_t[65535];
 
 #define BIG_MAX                        POOL_MAX_ALLOC_SIZE
 
-#if defined(_LP64)
+#if SIZEOF_SIZE_T > 4
 #define LITTLE_MAX             ((unsigned long long) INT32_MAX)
 #else
 #define LITTLE_MAX             ((unsigned long long) INT16_MAX)