From: Josef 'Jeff' Sipek Date: Thu, 5 Jul 2018 14:48:49 +0000 (-0400) Subject: lib: Make sure exactly one of _ILP32 and _LP64 is defined at all times X-Git-Tag: 2.3.9~1600 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c21a2dbaee36c49e45a9d5872aca8caf46b3bbd7;p=thirdparty%2Fdovecot%2Fcore.git lib: Make sure exactly one of _ILP32 and _LP64 is defined at all times 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. --- diff --git a/src/lib/compat.h b/src/lib/compat.h index dbda02f809..ce3127ddb4 100644 --- a/src/lib/compat.h +++ b/src/lib/compat.h @@ -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