$NetBSD: patch-builtins_printf.def,v 1.1 2022/11/25 23:29:47 adam Exp $ Fixes PRIdMAX and PRIuMAX on AIX < 5.1. --- builtins/printf.def.orig 2014-01-03 15:35:33.000000000 +0000 +++ builtins/printf.def @@ -95,6 +95,11 @@ $END # undef PRIdMAX #endif +#if defined (_AIX) && !defined (_AIX51) + /* AIX defines do not work. Undefine them. */ +# undef PRIdMAX +# undef PRIuMAX +#endif #if !defined (PRIdMAX) # if HAVE_LONG_LONG # define PRIdMAX "lld" @@ -102,6 +107,13 @@ $END # define PRIdMAX "ld" # endif #endif +#if !defined (PRIuMAX) && defined (_AIX) +# if HAVE_LONG_LONG +# define PRIuMAX "llu" +# else +# define PRIuMAX "lu" +# endif +#endif #if !defined (errno) extern int errno; @@ -594,7 +606,11 @@ printf_builtin (list) p = pp = getintmax (); if (p != pp) { +#if defined (_AIX) && !defined (_AIX51) + f = mklong (start, PRIdMAX, sizeof (intmax_t) - 2); +#else f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2); +#endif PF (f, pp); } else @@ -621,7 +637,11 @@ printf_builtin (list) p = pp = getuintmax (); if (p != pp) { +#if defined (_AIX) && !defined (_AIX51) + f = mklong (start, PRIuMAX, sizeof (uintmax_t) - 2); +#else f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2); +#endif PF (f, pp); } else