]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Make sure exactly one of _ILP32 and _LP64 is defined at all times
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Thu, 5 Jul 2018 14:48:49 +0000 (10:48 -0400)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Thu, 5 Jul 2018 14:48:49 +0000 (10:48 -0400)
These defines are very common, but not universal.  For example, clang on
illumos and FreeBSD always defines one of them, while 32-bit Ubuntu 16.04
doesn't define either.

src/lib/compat.h

index dbda02f809cd8278856da4e4853898921b4e6504..ce3127ddb434f2c45aed51dcd6c90b7ffdcae618 100644 (file)
@@ -1,6 +1,22 @@
 #ifndef COMPAT_H
 #define COMPAT_H
 
+/* _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
+
 /* well, this is obviously wrong since it assumes it's 64bit, but older
    GCCs don't define it and we really want it. */
 #ifndef LLONG_MAX