Remove configure's check for nonstandard "long long" printf modifiers.

We used to claim to support platforms using 'q' or 'I64' as the printf
length modifier for long long int, by dint of replacing snprintf with
our own code which uses the C99 standard 'll' modifier.  But that is
only adequate if we use INT64_MODIFIER only in snprintf-based calls,
not directly with the platform's native printf or fprintf.  Which
hasn't been the case for years.  We had not noticed, partially because
of inadequate test coverage, and partially because the buildfarm is
almost completely bare of machines that won't take 'll'.  The last
one seems to have been frogmouth, which was adjusted recently so that
it will take 'll'.  We might as well just give up on the pretense
that anything else works, and save ourselves some configure cycles.

Discussion: https://postgr.es/m/13103.1526749980@sss.pgh.pa.us
Discussion: https://postgr.es/m/24769.1526772680@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2018-05-23 14:19:04 -04:00
parent 1d96c1b91a
commit b929614f5e
5 changed files with 24 additions and 178 deletions

View File

@ -171,61 +171,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO],
])])# PGAC_STRUCT_ADDRINFO
# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
# ---------------------------------------
# Determine which length modifier snprintf uses for long long int. We
# handle ll, q, and I64. The result is in shell variable
# LONG_LONG_INT_MODIFIER.
#
# MinGW uses '%I64d', though gcc throws a warning with -Wall,
# while '%lld' doesn't generate a warning, but doesn't work.
#
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER],
[AC_MSG_CHECKING([snprintf length modifier for long long int])
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_modifier,
[for pgac_modifier in 'll' 'q' 'I64'; do
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
#include <string.h>
typedef long long int ac_int64;
#define INT64_FORMAT "%${pgac_modifier}d"
ac_int64 a = 20000001;
ac_int64 b = 40000005;
int does_int64_snprintf_work()
{
ac_int64 c;
char buf[100];
if (sizeof(ac_int64) != 8)
return 0; /* doesn't look like the right size */
c = a * b;
snprintf(buf, 100, INT64_FORMAT, c);
if (strcmp(buf, "800000140000005") != 0)
return 0; /* either multiply or snprintf is busted */
return 1;
}
int
main() {
return (! does_int64_snprintf_work());
}]])],
[pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break],
[],
[pgac_cv_snprintf_long_long_int_modifier=cross; break])
done])dnl AC_CACHE_VAL
LONG_LONG_INT_MODIFIER=''
case $pgac_cv_snprintf_long_long_int_modifier in
cross) AC_MSG_RESULT([cannot test (not on host machine)]);;
?*) AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_modifier])
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
*) AC_MSG_RESULT(none);;
esac])# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
# PGAC_FUNC_SNPRINTF_ARG_CONTROL
# ---------------------------------------
# Determine if snprintf supports %1$ argument selection, e.g. %5$ selects

92
configure vendored
View File

@ -15092,7 +15092,7 @@ if test "$PORTNAME" = "win32"; then
# strings, replacements are provided through <libintl.h>.
#
# We could use libintl >= 0.13's *printf() if we were sure that we had
# a litint >= 0.13 at runtime, but seeing that there is no clean way
# a libintl >= 0.13 at runtime, but seeing that there is no clean way
# to guarantee that, it is best to just use our own, so we are sure to
# get %$ support. In include/port.h we disable the *printf() macros
# that might have been defined by libintl.
@ -15924,7 +15924,6 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long int is 64 bits" >&5
$as_echo_n "checking whether long int is 64 bits... " >&6; }
if ${pgac_cv_type_long_int_64+:} false; then :
@ -16102,88 +16101,14 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# If we found "long int" is 64 bits, assume snprintf handles it. If
# we found we need to use "long long int", better check. We cope with
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
# work, fall back to our own snprintf emulation (which we know uses %lld).
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
if test $pgac_need_repl_snprintf = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking snprintf length modifier for long long int" >&5
$as_echo_n "checking snprintf length modifier for long long int... " >&6; }
if ${pgac_cv_snprintf_long_long_int_modifier+:} false; then :
$as_echo_n "(cached) " >&6
# Select the printf length modifier that goes with that, too.
# (This used to be bound up with replacement-snprintf selection, but now
# we assume that the native *printf functions use standard length modifiers.)
if test x"$pg_int64_type" = x"long long int" ; then
INT64_MODIFIER='"ll"'
else
for pgac_modifier in 'll' 'q' 'I64'; do
if test "$cross_compiling" = yes; then :
pgac_cv_snprintf_long_long_int_modifier=cross; break
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <string.h>
typedef long long int ac_int64;
#define INT64_FORMAT "%${pgac_modifier}d"
ac_int64 a = 20000001;
ac_int64 b = 40000005;
int does_int64_snprintf_work()
{
ac_int64 c;
char buf[100];
if (sizeof(ac_int64) != 8)
return 0; /* doesn't look like the right size */
c = a * b;
snprintf(buf, 100, INT64_FORMAT, c);
if (strcmp(buf, "800000140000005") != 0)
return 0; /* either multiply or snprintf is busted */
return 1;
}
int
main() {
return (! does_int64_snprintf_work());
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break
INT64_MODIFIER='"l"'
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
done
fi
LONG_LONG_INT_MODIFIER=''
case $pgac_cv_snprintf_long_long_int_modifier in
cross) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot test (not on host machine)" >&5
$as_echo "cannot test (not on host machine)" >&6; };;
?*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_snprintf_long_long_int_modifier" >&5
$as_echo "$pgac_cv_snprintf_long_long_int_modifier" >&6; }
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
$as_echo "none" >&6; };;
esac
if test "$LONG_LONG_INT_MODIFIER" = ""; then
# Force usage of our own snprintf, since system snprintf is broken
pgac_need_repl_snprintf=yes
LONG_LONG_INT_MODIFIER='ll'
fi
else
# Here if we previously decided we needed to use our own snprintf
LONG_LONG_INT_MODIFIER='ll'
fi
else
# Here if we are not using 'long long int' at all
LONG_LONG_INT_MODIFIER='l'
fi
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
cat >>confdefs.h <<_ACEOF
@ -16191,7 +16116,8 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# Also force use of our snprintf if the system's doesn't support the %z flag.
# Force use of our snprintf if the system's doesn't support the %z flag.
# (Note this test uses PG_INT64_TYPE and INT64_MODIFIER.)
if test "$pgac_need_repl_snprintf" = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf supports the %z modifier" >&5
$as_echo_n "checking whether snprintf supports the %z modifier... " >&6; }

View File

@ -1601,7 +1601,7 @@ if test "$PORTNAME" = "win32"; then
# strings, replacements are provided through <libintl.h>.
#
# We could use libintl >= 0.13's *printf() if we were sure that we had
# a litint >= 0.13 at runtime, but seeing that there is no clean way
# a libintl >= 0.13 at runtime, but seeing that there is no clean way
# to guarantee that, it is best to just use our own, so we are sure to
# get %$ support. In include/port.h we disable the *printf() macros
# that might have been defined by libintl.
@ -1804,20 +1804,9 @@ fi
dnl Check to see if we have a working 64-bit integer type.
dnl This breaks down into two steps:
dnl (1) figure out if the compiler has a 64-bit int type with working
dnl arithmetic, and if so
dnl (2) see whether snprintf() can format the type correctly. (Currently,
dnl snprintf is the only library routine we really need for int8 support.)
dnl It's entirely possible to have a compiler that handles a 64-bit type
dnl when the C library doesn't; this is fairly likely when using gcc on
dnl an older platform, for example.
dnl If there is no native snprintf() or it does not handle the 64-bit type,
dnl we force our own version of snprintf() to be used instead.
dnl Note this test must be run after our initial check for snprintf/vsnprintf.
dnl As of Postgres 8.4, we no longer support compilers without a working
dnl 64-bit type. But we still handle the case of snprintf being broken.
dnl Since Postgres 8.4, we no longer support compilers without a working
dnl 64-bit type; but we have to determine whether that type is called
dnl "long int" or "long long int".
PGAC_TYPE_64BIT_INT([long int])
@ -1835,34 +1824,20 @@ fi
AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
[Define to the name of a signed 64-bit integer type.])
# If we found "long int" is 64 bits, assume snprintf handles it. If
# we found we need to use "long long int", better check. We cope with
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
# work, fall back to our own snprintf emulation (which we know uses %lld).
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
if test $pgac_need_repl_snprintf = no; then
PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
if test "$LONG_LONG_INT_MODIFIER" = ""; then
# Force usage of our own snprintf, since system snprintf is broken
pgac_need_repl_snprintf=yes
LONG_LONG_INT_MODIFIER='ll'
fi
else
# Here if we previously decided we needed to use our own snprintf
LONG_LONG_INT_MODIFIER='ll'
fi
# Select the printf length modifier that goes with that, too.
# (This used to be bound up with replacement-snprintf selection, but now
# we assume that the native *printf functions use standard length modifiers.)
if test x"$pg_int64_type" = x"long long int" ; then
INT64_MODIFIER='"ll"'
else
# Here if we are not using 'long long int' at all
LONG_LONG_INT_MODIFIER='l'
INT64_MODIFIER='"l"'
fi
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
[Define to the appropriate snprintf length modifier for 64-bit ints.])
[Define to the appropriate printf length modifier for 64-bit ints.])
# Also force use of our snprintf if the system's doesn't support the %z flag.
# Force use of our snprintf if the system's doesn't support the %z flag.
# (Note this test uses PG_INT64_TYPE and INT64_MODIFIER.)
if test "$pgac_need_repl_snprintf" = no; then
PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
if test "$pgac_cv_snprintf_size_t_support" != yes; then

View File

@ -756,7 +756,7 @@
/* Define to 1 if you have the `__strtoull' function. */
#undef HAVE___STRTOULL
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
/* Define to the appropriate printf length modifier for 64-bit ints. */
#undef INT64_MODIFIER
/* Define to 1 if `locale_t' requires <xlocale.h>. */

View File

@ -579,7 +579,7 @@
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
#define HAVE__VA_ARGS 1
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
/* Define to the appropriate printf length modifier for 64-bit ints. */
#define INT64_MODIFIER "ll"
/* Define to 1 if `locale_t' requires <xlocale.h>. */