From 818a5408bdd5b27adbd6ee8e251555753299059e Mon Sep 17 00:00:00 2001 From: hpa Date: Thu, 15 Nov 2001 22:29:51 +0000 Subject: [PATCH] Try to deal with severe AIX braindamage --- aclocal.m4 | 27 +++++++++++++++++++++++++++ config.h | 33 +++++++++++++++++++++++++++++++++ configure.in | 3 ++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/aclocal.m4 b/aclocal.m4 index 310d5b0..54e13a7 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -123,6 +123,32 @@ int deny_severity = 0; AC_MSG_RESULT([no]) ])]) +dnl ------------------------------------------------------------------------ +dnl PA_CHECK_INTTYPES_H_SANE +dnl +dnl At least some versions of AIX 4 have macros which are +dnl completely broken. Try to detect those. +dnl -------------------------------------------------------------------------- +AH_TEMPLATE([INTTYPES_H_IS_SANE], +[Define if the macros in are usable]) + +AC_DEFUN(PA_CHECK_INTTYPES_H_SANE, +[AC_CHECK_HEADERS(inttypes.h, + [ + AC_MSG_CHECKING([if inttypes.h is sane]) + AC_TRY_LINK( + [ +#include +#include + ], + [uintmax_t max = UINTMAX_C(0); + printf("%"PRIuMAX"\n", max);], + AC_MSG_RESULT([yes]) + AC_DEFINE(INTTYPES_H_IS_SANE), + AC_MSG_RESULT([no (AIX, eh?)])) + ]) +]) + dnl ------------------------------------------------------------------------ dnl PA_WITH_BOOL dnl @@ -170,3 +196,4 @@ int main() AC_MSG_RESULT(no) ])]) +dnl -------------------------------------------------------------------------- diff --git a/config.h b/config.h index 1bc483a..b1c0238 100644 --- a/config.h +++ b/config.h @@ -57,7 +57,9 @@ #endif #ifdef HAVE_INTTYPES_H +#ifdef INTTYPES_H_IS_SANE #include +#endif #else #ifdef HAVE_STDINT_H #include @@ -93,6 +95,37 @@ typedef unsigned long uintmax_t; #endif #endif +/* On some version of AIX, is buggy to the point of + unusability. We have to use macros here, not typedefs, to override. */ +#ifdef HAVE_INTTYPES_H +#ifndef INTTYPES_H_IS_SANE +#undef PRIdMAX +#undef PRIuMAX +#undef PRIxMAX +#undef INTMAX_C +#undef UINTMAX_C +#undef HAVE_STRTOUMAX + +#ifdef HAVE_LONG_LONG +#define intmax_t long long +#define uintmax_t unsigned long long +#define PRIdMAX "Ld" +#define PRIuMAX "Lu" +#define PRIxMAX "Lx" +#define INTMAX_C(x) (x##LL) +#define UINTMAX_C(x) (x##ULL) +#else +#define intmax_t long +#define uintmax_t unsigned long +#define PRIdMAX "ld" +#define PRIuMAX "lu" +#define PRIxMAX "lx" +#define INTMAX_C(x) (x##L) +#define UINTMAX_C(x) (x##UL) +#endif +#endif +#endif + /* Even if intmax_t is defined, we may need this (Solaris 8 braindamage) */ #ifndef HAVE_STRTOUMAX #if defined(HAVE_LONG_LONG) && defined(HAVE_STRTOULL) diff --git a/configure.in b/configure.in index b1755bf..a9fab1f 100644 --- a/configure.in +++ b/configure.in @@ -54,10 +54,11 @@ PA_ADD_CFLAGS(-pipe) AC_HEADER_STDC AC_CHECK_HEADERS(inttypes.h) +AC_CHECK_HEADERS(stdint.h) +PA_CHECK_INTTYPES_H_SANE AC_CHECK_HEADERS(libgen.h) AC_CHECK_HEADERS(memory.h) AC_CHECK_HEADERS(stddef.h) -AC_CHECK_HEADERS(stdint.h) AC_CHECK_HEADERS(stdlib.h) AC_CHECK_HEADERS(string.h) AC_CHECK_HEADERS(strings.h)