diff --git a/configure b/configure index ec35de5ba65..3f91117f245 100755 --- a/configure +++ b/configure @@ -16853,6 +16853,39 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of intmax_t" >&5 +$as_echo_n "checking size of intmax_t... " >&6; } +if ${ac_cv_sizeof_intmax_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (intmax_t))" "ac_cv_sizeof_intmax_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_intmax_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (intmax_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_intmax_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_intmax_t" >&5 +$as_echo "$ac_cv_sizeof_intmax_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INTMAX_T $ac_cv_sizeof_intmax_t +_ACEOF + + # Determine memory alignment requirements for the basic C data types. diff --git a/configure.ac b/configure.ac index 7284f1ff622..8f390027403 100644 --- a/configure.ac +++ b/configure.ac @@ -1983,6 +1983,7 @@ AC_CHECK_SIZEOF([void *]) AC_CHECK_SIZEOF([size_t]) AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([long long]) +AC_CHECK_SIZEOF([intmax_t]) # Determine memory alignment requirements for the basic C data types. diff --git a/meson.build b/meson.build index 622598546ae..718150e3ac0 100644 --- a/meson.build +++ b/meson.build @@ -1776,6 +1776,8 @@ cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args)) cdata.set('SIZEOF_LONG_LONG', cc.sizeof('long long', args: test_c_args)) cdata.set('SIZEOF_VOID_P', cc.sizeof('void *', args: test_c_args)) cdata.set('SIZEOF_SIZE_T', cc.sizeof('size_t', args: test_c_args)) +cdata.set('SIZEOF_INTMAX_T', cc.sizeof('intmax_t', args: test_c_args, + prefix: '#include ')) # Check if __int128 is a working 128 bit integer type, and if so diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index b0b0cfdaf79..72434ce957e 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -645,6 +645,9 @@ RELSEG_SIZE requires an initdb. */ #undef RELSEG_SIZE +/* The size of `intmax_t', as computed by sizeof. */ +#undef SIZEOF_INTMAX_T + /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 6541182df6d..d914547fae2 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -563,6 +563,15 @@ nextch2: else longflag = 1; goto nextch2; + case 'j': +#if SIZEOF_INTMAX_T == SIZEOF_LONG + longflag = 1; +#elif SIZEOF_INTMAX_T == SIZEOF_LONG_LONG + longlongflag = 1; +#else +#error "cannot find integer type of the same size as intmax_t" +#endif + goto nextch2; case 'z': #if SIZEOF_SIZE_T == SIZEOF_LONG longflag = 1; @@ -826,6 +835,15 @@ nextch1: else longflag = 1; goto nextch1; + case 'j': +#if SIZEOF_INTMAX_T == SIZEOF_LONG + longflag = 1; +#elif SIZEOF_INTMAX_T == SIZEOF_LONG_LONG + longlongflag = 1; +#else +#error "cannot find integer type of the same size as intmax_t" +#endif + goto nextch1; case 'z': #if SIZEOF_SIZE_T == SIZEOF_LONG longflag = 1;