Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b929614

Browse files
committed
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
1 parent 1d96c1b commit b929614

File tree

5 files changed

+24
-178
lines changed

5 files changed

+24
-178
lines changed

config/c-library.m4

-55
Original file line numberDiff line numberDiff line change
@@ -171,61 +171,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO],
171171
])])# PGAC_STRUCT_ADDRINFO
172172

173173

174-
# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
175-
# ---------------------------------------
176-
# Determine which length modifier snprintf uses for long long int. We
177-
# handle ll, q, and I64. The result is in shell variable
178-
# LONG_LONG_INT_MODIFIER.
179-
#
180-
# MinGW uses '%I64d', though gcc throws a warning with -Wall,
181-
# while '%lld' doesn't generate a warning, but doesn't work.
182-
#
183-
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER],
184-
[AC_MSG_CHECKING([snprintf length modifier for long long int])
185-
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_modifier,
186-
[for pgac_modifier in 'll' 'q' 'I64'; do
187-
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
188-
#include <string.h>
189-
typedef long long int ac_int64;
190-
#define INT64_FORMAT "%${pgac_modifier}d"
191-
192-
ac_int64 a = 20000001;
193-
ac_int64 b = 40000005;
194-
195-
int does_int64_snprintf_work()
196-
{
197-
ac_int64 c;
198-
char buf[100];
199-
200-
if (sizeof(ac_int64) != 8)
201-
return 0; /* doesn't look like the right size */
202-
203-
c = a * b;
204-
snprintf(buf, 100, INT64_FORMAT, c);
205-
if (strcmp(buf, "800000140000005") != 0)
206-
return 0; /* either multiply or snprintf is busted */
207-
return 1;
208-
}
209-
210-
int
211-
main() {
212-
return (! does_int64_snprintf_work());
213-
}]])],
214-
[pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break],
215-
[],
216-
[pgac_cv_snprintf_long_long_int_modifier=cross; break])
217-
done])dnl AC_CACHE_VAL
218-
219-
LONG_LONG_INT_MODIFIER=''
220-
221-
case $pgac_cv_snprintf_long_long_int_modifier in
222-
cross) AC_MSG_RESULT([cannot test (not on host machine)]);;
223-
?*) AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_modifier])
224-
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
225-
*) AC_MSG_RESULT(none);;
226-
esac])# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
227-
228-
229174
# PGAC_FUNC_SNPRINTF_ARG_CONTROL
230175
# ---------------------------------------
231176
# Determine if snprintf supports %1$ argument selection, e.g. %5$ selects

configure

+9-83
Original file line numberDiff line numberDiff line change
@@ -15092,7 +15092,7 @@ if test "$PORTNAME" = "win32"; then
1509215092
# strings, replacements are provided through <libintl.h>.
1509315093
#
1509415094
# We could use libintl >= 0.13's *printf() if we were sure that we had
15095-
# a litint >= 0.13 at runtime, but seeing that there is no clean way
15095+
# a libintl >= 0.13 at runtime, but seeing that there is no clean way
1509615096
# to guarantee that, it is best to just use our own, so we are sure to
1509715097
# get %$ support. In include/port.h we disable the *printf() macros
1509815098
# that might have been defined by libintl.
@@ -15924,7 +15924,6 @@ fi
1592415924

1592515925

1592615926

15927-
1592815927
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long int is 64 bits" >&5
1592915928
$as_echo_n "checking whether long int is 64 bits... " >&6; }
1593015929
if ${pgac_cv_type_long_int_64+:} false; then :
@@ -16102,96 +16101,23 @@ cat >>confdefs.h <<_ACEOF
1610216101
_ACEOF
1610316102

1610416103

16105-
# If we found "long int" is 64 bits, assume snprintf handles it. If
16106-
# we found we need to use "long long int", better check. We cope with
16107-
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
16108-
# work, fall back to our own snprintf emulation (which we know uses %lld).
16109-
16110-
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
16111-
if test $pgac_need_repl_snprintf = no; then
16112-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking snprintf length modifier for long long int" >&5
16113-
$as_echo_n "checking snprintf length modifier for long long int... " >&6; }
16114-
if ${pgac_cv_snprintf_long_long_int_modifier+:} false; then :
16115-
$as_echo_n "(cached) " >&6
16104+
# Select the printf length modifier that goes with that, too.
16105+
# (This used to be bound up with replacement-snprintf selection, but now
16106+
# we assume that the native *printf functions use standard length modifiers.)
16107+
if test x"$pg_int64_type" = x"long long int" ; then
16108+
INT64_MODIFIER='"ll"'
1611616109
else
16117-
for pgac_modifier in 'll' 'q' 'I64'; do
16118-
if test "$cross_compiling" = yes; then :
16119-
pgac_cv_snprintf_long_long_int_modifier=cross; break
16120-
else
16121-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16122-
/* end confdefs.h. */
16123-
#include <stdio.h>
16124-
#include <string.h>
16125-
typedef long long int ac_int64;
16126-
#define INT64_FORMAT "%${pgac_modifier}d"
16127-
16128-
ac_int64 a = 20000001;
16129-
ac_int64 b = 40000005;
16130-
16131-
int does_int64_snprintf_work()
16132-
{
16133-
ac_int64 c;
16134-
char buf[100];
16135-
16136-
if (sizeof(ac_int64) != 8)
16137-
return 0; /* doesn't look like the right size */
16138-
16139-
c = a * b;
16140-
snprintf(buf, 100, INT64_FORMAT, c);
16141-
if (strcmp(buf, "800000140000005") != 0)
16142-
return 0; /* either multiply or snprintf is busted */
16143-
return 1;
16144-
}
16145-
16146-
int
16147-
main() {
16148-
return (! does_int64_snprintf_work());
16149-
}
16150-
_ACEOF
16151-
if ac_fn_c_try_run "$LINENO"; then :
16152-
pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break
16110+
INT64_MODIFIER='"l"'
1615316111
fi
16154-
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
16155-
conftest.$ac_objext conftest.beam conftest.$ac_ext
16156-
fi
16157-
16158-
done
16159-
fi
16160-
16161-
LONG_LONG_INT_MODIFIER=''
16162-
16163-
case $pgac_cv_snprintf_long_long_int_modifier in
16164-
cross) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot test (not on host machine)" >&5
16165-
$as_echo "cannot test (not on host machine)" >&6; };;
16166-
?*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_snprintf_long_long_int_modifier" >&5
16167-
$as_echo "$pgac_cv_snprintf_long_long_int_modifier" >&6; }
16168-
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
16169-
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
16170-
$as_echo "none" >&6; };;
16171-
esac
16172-
if test "$LONG_LONG_INT_MODIFIER" = ""; then
16173-
# Force usage of our own snprintf, since system snprintf is broken
16174-
pgac_need_repl_snprintf=yes
16175-
LONG_LONG_INT_MODIFIER='ll'
16176-
fi
16177-
else
16178-
# Here if we previously decided we needed to use our own snprintf
16179-
LONG_LONG_INT_MODIFIER='ll'
16180-
fi
16181-
else
16182-
# Here if we are not using 'long long int' at all
16183-
LONG_LONG_INT_MODIFIER='l'
16184-
fi
16185-
16186-
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
1618716112

1618816113

1618916114
cat >>confdefs.h <<_ACEOF
1619016115
#define INT64_MODIFIER $INT64_MODIFIER
1619116116
_ACEOF
1619216117

1619316118

16194-
# Also force use of our snprintf if the system's doesn't support the %z flag.
16119+
# Force use of our snprintf if the system's doesn't support the %z flag.
16120+
# (Note this test uses PG_INT64_TYPE and INT64_MODIFIER.)
1619516121
if test "$pgac_need_repl_snprintf" = no; then
1619616122
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf supports the %z modifier" >&5
1619716123
$as_echo_n "checking whether snprintf supports the %z modifier... " >&6; }

configure.in

+13-38
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ if test "$PORTNAME" = "win32"; then
16011601
# strings, replacements are provided through <libintl.h>.
16021602
#
16031603
# We could use libintl >= 0.13's *printf() if we were sure that we had
1604-
# a litint >= 0.13 at runtime, but seeing that there is no clean way
1604+
# a libintl >= 0.13 at runtime, but seeing that there is no clean way
16051605
# to guarantee that, it is best to just use our own, so we are sure to
16061606
# get %$ support. In include/port.h we disable the *printf() macros
16071607
# that might have been defined by libintl.
@@ -1804,20 +1804,9 @@ fi
18041804

18051805

18061806
dnl Check to see if we have a working 64-bit integer type.
1807-
dnl This breaks down into two steps:
1808-
dnl (1) figure out if the compiler has a 64-bit int type with working
1809-
dnl arithmetic, and if so
1810-
dnl (2) see whether snprintf() can format the type correctly. (Currently,
1811-
dnl snprintf is the only library routine we really need for int8 support.)
1812-
dnl It's entirely possible to have a compiler that handles a 64-bit type
1813-
dnl when the C library doesn't; this is fairly likely when using gcc on
1814-
dnl an older platform, for example.
1815-
dnl If there is no native snprintf() or it does not handle the 64-bit type,
1816-
dnl we force our own version of snprintf() to be used instead.
1817-
dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1818-
1819-
dnl As of Postgres 8.4, we no longer support compilers without a working
1820-
dnl 64-bit type. But we still handle the case of snprintf being broken.
1807+
dnl Since Postgres 8.4, we no longer support compilers without a working
1808+
dnl 64-bit type; but we have to determine whether that type is called
1809+
dnl "long int" or "long long int".
18211810

18221811
PGAC_TYPE_64BIT_INT([long int])
18231812

@@ -1835,34 +1824,20 @@ fi
18351824
AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
18361825
[Define to the name of a signed 64-bit integer type.])
18371826

1838-
# If we found "long int" is 64 bits, assume snprintf handles it. If
1839-
# we found we need to use "long long int", better check. We cope with
1840-
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
1841-
# work, fall back to our own snprintf emulation (which we know uses %lld).
1842-
1843-
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
1844-
if test $pgac_need_repl_snprintf = no; then
1845-
PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
1846-
if test "$LONG_LONG_INT_MODIFIER" = ""; then
1847-
# Force usage of our own snprintf, since system snprintf is broken
1848-
pgac_need_repl_snprintf=yes
1849-
LONG_LONG_INT_MODIFIER='ll'
1850-
fi
1851-
else
1852-
# Here if we previously decided we needed to use our own snprintf
1853-
LONG_LONG_INT_MODIFIER='ll'
1854-
fi
1827+
# Select the printf length modifier that goes with that, too.
1828+
# (This used to be bound up with replacement-snprintf selection, but now
1829+
# we assume that the native *printf functions use standard length modifiers.)
1830+
if test x"$pg_int64_type" = x"long long int" ; then
1831+
INT64_MODIFIER='"ll"'
18551832
else
1856-
# Here if we are not using 'long long int' at all
1857-
LONG_LONG_INT_MODIFIER='l'
1833+
INT64_MODIFIER='"l"'
18581834
fi
18591835

1860-
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
1861-
18621836
AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
1863-
[Define to the appropriate snprintf length modifier for 64-bit ints.])
1837+
[Define to the appropriate printf length modifier for 64-bit ints.])
18641838

1865-
# Also force use of our snprintf if the system's doesn't support the %z flag.
1839+
# Force use of our snprintf if the system's doesn't support the %z flag.
1840+
# (Note this test uses PG_INT64_TYPE and INT64_MODIFIER.)
18661841
if test "$pgac_need_repl_snprintf" = no; then
18671842
PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
18681843
if test "$pgac_cv_snprintf_size_t_support" != yes; then

src/include/pg_config.h.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@
756756
/* Define to 1 if you have the `__strtoull' function. */
757757
#undef HAVE___STRTOULL
758758

759-
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
759+
/* Define to the appropriate printf length modifier for 64-bit ints. */
760760
#undef INT64_MODIFIER
761761

762762
/* Define to 1 if `locale_t' requires <xlocale.h>. */

src/include/pg_config.h.win32

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@
579579
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
580580
#define HAVE__VA_ARGS 1
581581

582-
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
582+
/* Define to the appropriate printf length modifier for 64-bit ints. */
583583
#define INT64_MODIFIER "ll"
584584

585585
/* Define to 1 if `locale_t' requires <xlocale.h>. */

0 commit comments

Comments
 (0)