提交 96bf88d5 编写于 作者: T Tom Lane

Always use our own versions of *printf().

We've spent an awful lot of effort over the years in coping with
platform-specific vagaries of the *printf family of functions.  Let's just
forget all that mess and standardize on always using src/port/snprintf.c.
This gets rid of a lot of configure logic, and it will allow a saner
approach to dealing with %m (though actually changing that is left for
a follow-on patch).

Preliminary performance testing suggests that as it stands, snprintf.c is
faster than the native printf functions for some tasks on some platforms,
and slower for other cases.  A pending patch will improve that, though
cases with floating-point conversions will doubtless remain slower unless
we want to put a *lot* of effort into that.  Still, we've not observed
that *printf is really a performance bottleneck for most workloads, so
I doubt this matters much.

Patch by me, reviewed by Michael Paquier

Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
上级 758ce9b7
...@@ -20,15 +20,8 @@ fi])# PGAC_C_SIGNED ...@@ -20,15 +20,8 @@ fi])# PGAC_C_SIGNED
# PGAC_C_PRINTF_ARCHETYPE # PGAC_C_PRINTF_ARCHETYPE
# ----------------------- # -----------------------
# Select the format archetype to be used by gcc to check printf-type functions. # Select the format archetype to be used by gcc to check printf-type functions.
# We prefer "gnu_printf", which matches the features glibc supports, notably # We prefer "gnu_printf", as that most closely matches the features supported
# %m, 'z' and 'll' width modifiers ('ll' only matters if int64 requires it), # by src/port/snprintf.c (particularly the %m conversion spec).
# and argument order control if we're doing --enable-nls. On platforms where
# the native printf doesn't have 'z'/'ll' or arg control, we replace it with
# src/port/snprintf.c which does, so that the only potential mismatch here is
# whether or not %m is supported. We need that for elog/ereport, so we live
# with the fact that erroneous use of %m in plain printf calls won't be
# detected. (It appears that many versions of gcc/clang wouldn't report it
# even if told to check according to plain printf archetype, anyway.)
AC_DEFUN([PGAC_PRINTF_ARCHETYPE], AC_DEFUN([PGAC_PRINTF_ARCHETYPE],
[AC_CACHE_CHECK([for printf format archetype], pgac_cv_printf_archetype, [AC_CACHE_CHECK([for printf format archetype], pgac_cv_printf_archetype,
[ac_save_c_werror_flag=$ac_c_werror_flag [ac_save_c_werror_flag=$ac_c_werror_flag
......
...@@ -171,106 +171,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO], ...@@ -171,106 +171,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO],
])])# PGAC_STRUCT_ADDRINFO ])])# PGAC_STRUCT_ADDRINFO
# PGAC_FUNC_SNPRINTF_ARG_CONTROL
# ---------------------------------------
# Determine if snprintf supports %1$ argument selection, e.g. %5$ selects
# the fifth argument after the printf format string.
# This is not in the C99 standard, but in the Single Unix Specification (SUS).
# It is used in our language translation strings.
#
AC_DEFUN([PGAC_FUNC_SNPRINTF_ARG_CONTROL],
[AC_MSG_CHECKING([whether snprintf supports argument control])
AC_CACHE_VAL(pgac_cv_snprintf_arg_control,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
#include <string.h>
int main()
{
char buf[100];
/* can it swap arguments? */
snprintf(buf, 100, "%2\$d %1\$d", 3, 4);
if (strcmp(buf, "4 3") != 0)
return 1;
return 0;
}]])],
[pgac_cv_snprintf_arg_control=yes],
[pgac_cv_snprintf_arg_control=no],
[pgac_cv_snprintf_arg_control=cross])
])dnl AC_CACHE_VAL
AC_MSG_RESULT([$pgac_cv_snprintf_arg_control])
])# PGAC_FUNC_SNPRINTF_ARG_CONTROL
# PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
# ---------------------------------
# Determine if snprintf supports the z length modifier for printing
# size_t-sized variables. That's supported by C99 and POSIX but not
# all platforms play ball, so we must test whether it's working.
#
AC_DEFUN([PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT],
[AC_MSG_CHECKING([whether snprintf supports the %z modifier])
AC_CACHE_VAL(pgac_cv_snprintf_size_t_support,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
#include <string.h>
int main()
{
char bufz[100];
char buf64[100];
/*
* Print the largest unsigned number fitting in a size_t using both %zu
* and the previously-determined format for 64-bit integers. Note that
* we don't run this code unless we know snprintf handles 64-bit ints.
*/
bufz[0] = '\0'; /* in case snprintf fails to emit anything */
snprintf(bufz, sizeof(bufz), "%zu", ~((size_t) 0));
snprintf(buf64, sizeof(buf64), "%" INT64_MODIFIER "u",
(unsigned PG_INT64_TYPE) ~((size_t) 0));
if (strcmp(bufz, buf64) != 0)
return 1;
return 0;
}]])],
[pgac_cv_snprintf_size_t_support=yes],
[pgac_cv_snprintf_size_t_support=no],
[pgac_cv_snprintf_size_t_support=cross])
])dnl AC_CACHE_VAL
AC_MSG_RESULT([$pgac_cv_snprintf_size_t_support])
])# PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
# PGAC_FUNC_SNPRINTF_C99_RESULT
# -----------------------------
# Determine whether snprintf returns the desired buffer length when
# it overruns the actual buffer length. That's required by C99 and POSIX
# but ancient platforms don't behave that way, so we must test.
# While we're at it, let's just verify that it doesn't physically overrun
# the buffer.
#
AC_DEFUN([PGAC_FUNC_SNPRINTF_C99_RESULT],
[AC_MSG_CHECKING([whether snprintf handles buffer overrun per C99])
AC_CACHE_VAL(pgac_cv_snprintf_c99_result,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
#include <string.h>
int main()
{
char buf[10];
strcpy(buf, "abcdefghi");
if (snprintf(buf, 4, "%d", 123456) != 6)
return 1;
if (strcmp(buf, "123") != 0 || buf[4] != 'e')
return 1;
return 0;
}]])],
[pgac_cv_snprintf_c99_result=yes],
[pgac_cv_snprintf_c99_result=no],
[pgac_cv_snprintf_c99_result=cross])
])dnl AC_CACHE_VAL
AC_MSG_RESULT([$pgac_cv_snprintf_c99_result])
])# PGAC_FUNC_SNPRINTF_C99_RESULT
# PGAC_TYPE_LOCALE_T # PGAC_TYPE_LOCALE_T
# ------------------ # ------------------
# Check for the locale_t type and find the right header file. macOS # Check for the locale_t type and find the right header file. macOS
......
...@@ -15367,97 +15367,6 @@ $as_echo "#define HAVE_PS_STRINGS 1" >>confdefs.h ...@@ -15367,97 +15367,6 @@ $as_echo "#define HAVE_PS_STRINGS 1" >>confdefs.h
fi fi
# We use our snprintf.c emulation if either snprintf() or vsnprintf()
# is missing. Yes, there are machines that have only one. We may
# also decide to use snprintf.c if snprintf() is present but does not
# have all the features we need --- see below.
if test "$PORTNAME" = "win32"; then
# Win32 gets snprintf.c built unconditionally.
#
# To properly translate all NLS languages strings, we must support the
# *printf() %$ format, which allows *printf() arguments to be selected
# by position in the translated string.
#
# libintl versions < 0.13 use the native *printf() functions, and Win32
# *printf() doesn't understand %$, so we must use our /port versions,
# which do understand %$. libintl versions >= 0.13 include their own
# *printf versions on Win32. The libintl 0.13 release note text is:
#
# C format strings with positions, as they arise when a translator
# needs to reorder a sentence, are now supported on all platforms.
# On those few platforms (NetBSD and Woe32) for which the native
# printf()/fprintf()/... functions don't support such format
# strings, replacements are provided through <libintl.h>.
#
# We could use libintl >= 0.13's *printf() if we were sure that we had
# 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.
#
# We do this unconditionally whether NLS is used or not so we are sure
# that all Win32 libraries and binaries behave the same.
pgac_need_repl_snprintf=yes
else
pgac_need_repl_snprintf=no
for ac_func in snprintf
do :
ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
if test "x$ac_cv_func_snprintf" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SNPRINTF 1
_ACEOF
else
pgac_need_repl_snprintf=yes
fi
done
for ac_func in vsnprintf
do :
ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf"
if test "x$ac_cv_func_vsnprintf" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_VSNPRINTF 1
_ACEOF
else
pgac_need_repl_snprintf=yes
fi
done
fi
# Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
# include/c.h will provide declarations. Note this is a separate test
# from whether the functions exist in the C library --- there are
# systems that have the functions but don't bother to declare them :-(
ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
if test "x$ac_cv_have_decl_snprintf" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_SNPRINTF $ac_have_decl
_ACEOF
ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VSNPRINTF $ac_have_decl
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf" >&5
$as_echo_n "checking for isinf... " >&6; } $as_echo_n "checking for isinf... " >&6; }
if ${ac_cv_func_isinf+:} false; then : if ${ac_cv_func_isinf+:} false; then :
...@@ -16175,53 +16084,6 @@ fi ...@@ -16175,53 +16084,6 @@ fi
# Run tests below here # Run tests below here
# -------------------- # --------------------
# For NLS, force use of our snprintf if system's doesn't do arg control.
# See comment above at snprintf test for details.
if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf supports argument control" >&5
$as_echo_n "checking whether snprintf supports argument control... " >&6; }
if ${pgac_cv_snprintf_arg_control+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
pgac_cv_snprintf_arg_control=cross
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <string.h>
int main()
{
char buf[100];
/* can it swap arguments? */
snprintf(buf, 100, "%2\$d %1\$d", 3, 4);
if (strcmp(buf, "4 3") != 0)
return 1;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_snprintf_arg_control=yes
else
pgac_cv_snprintf_arg_control=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_snprintf_arg_control" >&5
$as_echo "$pgac_cv_snprintf_arg_control" >&6; }
if test $pgac_cv_snprintf_arg_control != yes ; then
pgac_need_repl_snprintf=yes
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long int is 64 bits" >&5 { $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; } $as_echo_n "checking whether long int is 64 bits... " >&6; }
...@@ -16401,8 +16263,6 @@ _ACEOF ...@@ -16401,8 +16263,6 @@ _ACEOF
# Select the printf length modifier that goes with that, too. # 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 if test x"$pg_int64_type" = x"long long int" ; then
INT64_MODIFIER='"ll"' INT64_MODIFIER='"ll"'
else else
...@@ -16415,120 +16275,6 @@ cat >>confdefs.h <<_ACEOF ...@@ -16415,120 +16275,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
# 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; }
if ${pgac_cv_snprintf_size_t_support+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
pgac_cv_snprintf_size_t_support=cross
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <string.h>
int main()
{
char bufz[100];
char buf64[100];
/*
* Print the largest unsigned number fitting in a size_t using both %zu
* and the previously-determined format for 64-bit integers. Note that
* we don't run this code unless we know snprintf handles 64-bit ints.
*/
bufz[0] = '\0'; /* in case snprintf fails to emit anything */
snprintf(bufz, sizeof(bufz), "%zu", ~((size_t) 0));
snprintf(buf64, sizeof(buf64), "%" INT64_MODIFIER "u",
(unsigned PG_INT64_TYPE) ~((size_t) 0));
if (strcmp(bufz, buf64) != 0)
return 1;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_snprintf_size_t_support=yes
else
pgac_cv_snprintf_size_t_support=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_snprintf_size_t_support" >&5
$as_echo "$pgac_cv_snprintf_size_t_support" >&6; }
if test "$pgac_cv_snprintf_size_t_support" != yes; then
pgac_need_repl_snprintf=yes
fi
fi
# Force use of our snprintf if the system's doesn't handle buffer overrun
# as specified by C99.
if test "$pgac_need_repl_snprintf" = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf handles buffer overrun per C99" >&5
$as_echo_n "checking whether snprintf handles buffer overrun per C99... " >&6; }
if ${pgac_cv_snprintf_c99_result+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
pgac_cv_snprintf_c99_result=cross
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <string.h>
int main()
{
char buf[10];
strcpy(buf, "abcdefghi");
if (snprintf(buf, 4, "%d", 123456) != 6)
return 1;
if (strcmp(buf, "123") != 0 || buf[4] != 'e')
return 1;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_snprintf_c99_result=yes
else
pgac_cv_snprintf_c99_result=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_snprintf_c99_result" >&5
$as_echo "$pgac_cv_snprintf_c99_result" >&6; }
if test "$pgac_cv_snprintf_c99_result" != yes; then
pgac_need_repl_snprintf=yes
fi
fi
# Now we have checked all the reasons to replace snprintf
if test $pgac_need_repl_snprintf = yes; then
$as_echo "#define USE_REPL_SNPRINTF 1" >>confdefs.h
case " $LIBOBJS " in
*" snprintf.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS snprintf.$ac_objext"
;;
esac
fi
# has to be down here, rather than with the other builtins, because # has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE. # the test uses PG_INT64_TYPE.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_mul_overflow" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_mul_overflow" >&5
......
...@@ -1622,53 +1622,6 @@ if test "$pgac_cv_var_PS_STRINGS" = yes ; then ...@@ -1622,53 +1622,6 @@ if test "$pgac_cv_var_PS_STRINGS" = yes ; then
fi fi
# We use our snprintf.c emulation if either snprintf() or vsnprintf()
# is missing. Yes, there are machines that have only one. We may
# also decide to use snprintf.c if snprintf() is present but does not
# have all the features we need --- see below.
if test "$PORTNAME" = "win32"; then
# Win32 gets snprintf.c built unconditionally.
#
# To properly translate all NLS languages strings, we must support the
# *printf() %$ format, which allows *printf() arguments to be selected
# by position in the translated string.
#
# libintl versions < 0.13 use the native *printf() functions, and Win32
# *printf() doesn't understand %$, so we must use our /port versions,
# which do understand %$. libintl versions >= 0.13 include their own
# *printf versions on Win32. The libintl 0.13 release note text is:
#
# C format strings with positions, as they arise when a translator
# needs to reorder a sentence, are now supported on all platforms.
# On those few platforms (NetBSD and Woe32) for which the native
# printf()/fprintf()/... functions don't support such format
# strings, replacements are provided through <libintl.h>.
#
# We could use libintl >= 0.13's *printf() if we were sure that we had
# 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.
#
# We do this unconditionally whether NLS is used or not so we are sure
# that all Win32 libraries and binaries behave the same.
pgac_need_repl_snprintf=yes
else
pgac_need_repl_snprintf=no
AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
fi
# Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
# include/c.h will provide declarations. Note this is a separate test
# from whether the functions exist in the C library --- there are
# systems that have the functions but don't bother to declare them :-(
AC_CHECK_DECLS([snprintf, vsnprintf])
dnl Cannot use AC_CHECK_FUNC because isinf may be a macro dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
AC_CACHE_CHECK([for isinf], ac_cv_func_isinf, AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([ [AC_LINK_IFELSE([AC_LANG_PROGRAM([
...@@ -1838,16 +1791,6 @@ for the exact reason.]])], ...@@ -1838,16 +1791,6 @@ for the exact reason.]])],
# Run tests below here # Run tests below here
# -------------------- # --------------------
# For NLS, force use of our snprintf if system's doesn't do arg control.
# See comment above at snprintf test for details.
if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
PGAC_FUNC_SNPRINTF_ARG_CONTROL
if test $pgac_cv_snprintf_arg_control != yes ; then
pgac_need_repl_snprintf=yes
fi
fi
dnl Check to see if we have a working 64-bit integer type. dnl Check to see if we have a working 64-bit integer type.
dnl Since Postgres 8.4, we no longer support compilers without a working 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 64-bit type; but we have to determine whether that type is called
...@@ -1870,8 +1813,6 @@ AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type, ...@@ -1870,8 +1813,6 @@ AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
[Define to the name of a signed 64-bit integer type.]) [Define to the name of a signed 64-bit integer type.])
# Select the printf length modifier that goes with that, too. # 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 if test x"$pg_int64_type" = x"long long int" ; then
INT64_MODIFIER='"ll"' INT64_MODIFIER='"ll"'
else else
...@@ -1881,30 +1822,6 @@ fi ...@@ -1881,30 +1822,6 @@ fi
AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER, AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
[Define to the appropriate printf length modifier for 64-bit ints.]) [Define to the appropriate printf length modifier for 64-bit ints.])
# 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
pgac_need_repl_snprintf=yes
fi
fi
# Force use of our snprintf if the system's doesn't handle buffer overrun
# as specified by C99.
if test "$pgac_need_repl_snprintf" = no; then
PGAC_FUNC_SNPRINTF_C99_RESULT
if test "$pgac_cv_snprintf_c99_result" != yes; then
pgac_need_repl_snprintf=yes
fi
fi
# Now we have checked all the reasons to replace snprintf
if test $pgac_need_repl_snprintf = yes; then
AC_DEFINE(USE_REPL_SNPRINTF, 1, [Use replacement snprintf() functions.])
AC_LIBOBJ(snprintf)
fi
# has to be down here, rather than with the other builtins, because # has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE. # the test uses PG_INT64_TYPE.
PGAC_C_BUILTIN_OP_OVERFLOW PGAC_C_BUILTIN_OP_OVERFLOW
......
...@@ -1147,14 +1147,6 @@ typedef union PGAlignedXLogBlock ...@@ -1147,14 +1147,6 @@ typedef union PGAlignedXLogBlock
* standard C library. * standard C library.
*/ */
#if !HAVE_DECL_SNPRINTF
extern int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
#endif
#if !HAVE_DECL_VSNPRINTF
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
extern int fdatasync(int fildes); extern int fdatasync(int fildes);
#endif #endif
......
...@@ -166,10 +166,6 @@ ...@@ -166,10 +166,6 @@
don't. */ don't. */
#undef HAVE_DECL_RTLD_NOW #undef HAVE_DECL_RTLD_NOW
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
/* Define to 1 if you have the declaration of `strlcat', and to 0 if you /* Define to 1 if you have the declaration of `strlcat', and to 0 if you
don't. */ don't. */
#undef HAVE_DECL_STRLCAT #undef HAVE_DECL_STRLCAT
...@@ -194,10 +190,6 @@ ...@@ -194,10 +190,6 @@
don't. */ don't. */
#undef HAVE_DECL_SYS_SIGLIST #undef HAVE_DECL_SYS_SIGLIST
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VSNPRINTF
/* Define to 1 if you have the `dlopen' function. */ /* Define to 1 if you have the `dlopen' function. */
#undef HAVE_DLOPEN #undef HAVE_DLOPEN
...@@ -510,9 +502,6 @@ ...@@ -510,9 +502,6 @@
/* Define to 1 if you have the `shm_open' function. */ /* Define to 1 if you have the `shm_open' function. */
#undef HAVE_SHM_OPEN #undef HAVE_SHM_OPEN
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have spinlocks. */ /* Define to 1 if you have spinlocks. */
#undef HAVE_SPINLOCKS #undef HAVE_SPINLOCKS
...@@ -715,9 +704,6 @@ ...@@ -715,9 +704,6 @@
/* Define to 1 if you have the <uuid/uuid.h> header file. */ /* Define to 1 if you have the <uuid/uuid.h> header file. */
#undef HAVE_UUID_UUID_H #undef HAVE_UUID_UUID_H
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Define to 1 if you have the <wchar.h> header file. */ /* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H #undef HAVE_WCHAR_H
...@@ -926,9 +912,6 @@ ...@@ -926,9 +912,6 @@
/* Define to 1 to build with PAM support. (--with-pam) */ /* Define to 1 to build with PAM support. (--with-pam) */
#undef USE_PAM #undef USE_PAM
/* Use replacement snprintf() functions. */
#undef USE_REPL_SNPRINTF
/* Define to 1 to use software CRC-32C implementation (slicing-by-8). */ /* Define to 1 to use software CRC-32C implementation (slicing-by-8). */
#undef USE_SLICING_BY_8_CRC32C #undef USE_SLICING_BY_8_CRC32C
......
...@@ -135,10 +135,6 @@ ...@@ -135,10 +135,6 @@
don't. */ don't. */
#define HAVE_DECL_RTLD_NOW 0 #define HAVE_DECL_RTLD_NOW 0
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#define HAVE_DECL_SNPRINTF 1
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you /* Define to 1 if you have the declaration of `strnlen', and to 0 if you
don't. */ don't. */
#define HAVE_DECL_STRNLEN 1 #define HAVE_DECL_STRNLEN 1
...@@ -151,10 +147,6 @@ ...@@ -151,10 +147,6 @@
don't. */ don't. */
#define HAVE_DECL_STRTOULL 1 #define HAVE_DECL_STRTOULL 1
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
don't. */
#define HAVE_DECL_VSNPRINTF 1
/* Define to 1 if you have the `dlopen' function. */ /* Define to 1 if you have the `dlopen' function. */
/* #undef HAVE_DLOPEN */ /* #undef HAVE_DLOPEN */
...@@ -376,9 +368,6 @@ ...@@ -376,9 +368,6 @@
/* Define to 1 if you have the `setsid' function. */ /* Define to 1 if you have the `setsid' function. */
/* #undef HAVE_SETSID */ /* #undef HAVE_SETSID */
/* Define to 1 if you have the `snprintf' function. */
/* #undef HAVE_SNPRINTF */
/* Define to 1 if you have spinlocks. */ /* Define to 1 if you have spinlocks. */
#define HAVE_SPINLOCKS 1 #define HAVE_SPINLOCKS 1
...@@ -556,9 +545,6 @@ ...@@ -556,9 +545,6 @@
/* Define to 1 if you have the <utime.h> header file. */ /* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1 #define HAVE_UTIME_H 1
/* Define to 1 if you have the `vsnprintf' function. */
#define HAVE_VSNPRINTF 1
/* Define to 1 if you have the <wchar.h> header file. */ /* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
...@@ -715,9 +701,6 @@ ...@@ -715,9 +701,6 @@
/* Define to 1 to build with PAM support. (--with-pam) */ /* Define to 1 to build with PAM support. (--with-pam) */
/* #undef USE_PAM */ /* #undef USE_PAM */
/* Use replacement snprintf() functions. */
#define USE_REPL_SNPRINTF 1
/* Define to 1 to use software CRC-32C implementation (slicing-by-8). */ /* Define to 1 to use software CRC-32C implementation (slicing-by-8). */
#if (_MSC_VER < 1500) #if (_MSC_VER < 1500)
#define USE_SLICING_BY_8_CRC32C 1 #define USE_SLICING_BY_8_CRC32C 1
......
...@@ -134,7 +134,12 @@ extern unsigned char pg_tolower(unsigned char ch); ...@@ -134,7 +134,12 @@ extern unsigned char pg_tolower(unsigned char ch);
extern unsigned char pg_ascii_toupper(unsigned char ch); extern unsigned char pg_ascii_toupper(unsigned char ch);
extern unsigned char pg_ascii_tolower(unsigned char ch); extern unsigned char pg_ascii_tolower(unsigned char ch);
#ifdef USE_REPL_SNPRINTF /*
* Beginning in v12, we always replace snprintf() and friends with our own
* implementation. This symbol is no longer consulted by the core code,
* but keep it defined anyway in case any extensions are looking at it.
*/
#define USE_REPL_SNPRINTF 1
/* /*
* Versions of libintl >= 0.13 try to replace printf() and friends with * Versions of libintl >= 0.13 try to replace printf() and friends with
...@@ -187,7 +192,6 @@ extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2); ...@@ -187,7 +192,6 @@ extern int pg_printf(const char *fmt,...) pg_attribute_printf(1, 2);
#define fprintf pg_fprintf #define fprintf pg_fprintf
#define printf pg_printf #define printf pg_printf
#endif #endif
#endif /* USE_REPL_SNPRINTF */
/* Replace strerror() with our own, somewhat more robust wrapper */ /* Replace strerror() with our own, somewhat more robust wrapper */
extern char *pg_strerror(int errnum); extern char *pg_strerror(int errnum);
......
...@@ -31,7 +31,8 @@ SHLIB_EXPORTS = exports.txt ...@@ -31,7 +31,8 @@ SHLIB_EXPORTS = exports.txt
# Need to recompile any libpgport object files # Need to recompile any libpgport object files
LIBS := $(filter-out -lpgport, $(LIBS)) LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= informix.o strerror.o $(filter snprintf.o strnlen.o, $(LIBOBJS)) $(WIN32RES) OBJS= informix.o snprintf.o strerror.o \
$(filter strnlen.o, $(LIBOBJS)) $(WIN32RES)
PKG_CONFIG_REQUIRES_PRIVATE = libecpg libpgtypes PKG_CONFIG_REQUIRES_PRIVATE = libecpg libpgtypes
......
...@@ -26,8 +26,8 @@ override CFLAGS += $(PTHREAD_CFLAGS) ...@@ -26,8 +26,8 @@ override CFLAGS += $(PTHREAD_CFLAGS)
LIBS := $(filter-out -lpgport, $(LIBS)) LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \ OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o pgstrcasecmp.o strerror.o \ connect.o misc.o path.o pgstrcasecmp.o snprintf.o strerror.o \
$(filter snprintf.o strlcpy.o strnlen.o win32setlocale.o isinf.o, $(LIBOBJS)) \ $(filter strlcpy.o strnlen.o win32setlocale.o isinf.o, $(LIBOBJS)) \
$(WIN32RES) $(WIN32RES)
# thread.c is needed only for non-WIN32 implementation of path.c # thread.c is needed only for non-WIN32 implementation of path.c
......
...@@ -30,8 +30,8 @@ SHLIB_LINK += $(filter -lm, $(LIBS)) ...@@ -30,8 +30,8 @@ SHLIB_LINK += $(filter -lm, $(LIBS))
SHLIB_EXPORTS = exports.txt SHLIB_EXPORTS = exports.txt
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \ OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
pgstrcasecmp.o strerror.o \ pgstrcasecmp.o snprintf.o strerror.o \
$(filter rint.o snprintf.o strnlen.o, $(LIBOBJS)) \ $(filter rint.o strnlen.o, $(LIBOBJS)) \
string.o \ string.o \
$(WIN32RES) $(WIN32RES)
......
...@@ -36,9 +36,9 @@ OBJS= fe-auth.o fe-auth-scram.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-l ...@@ -36,9 +36,9 @@ OBJS= fe-auth.o fe-auth-scram.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-l
libpq-events.o libpq-events.o
# libpgport C files we always use # libpgport C files we always use
OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o pqsignal.o \ OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o pqsignal.o \
strerror.o thread.o snprintf.o strerror.o thread.o
# libpgport C files that are needed if identified by configure # libpgport C files that are needed if identified by configure
OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o system.o snprintf.o strlcpy.o strnlen.o win32error.o win32setlocale.o, $(LIBOBJS)) OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o system.o strlcpy.o strnlen.o win32error.o win32setlocale.o, $(LIBOBJS))
ifeq ($(enable_strong_random), yes) ifeq ($(enable_strong_random), yes)
OBJS += pg_strong_random.o OBJS += pg_strong_random.o
......
...@@ -29,11 +29,8 @@ ...@@ -29,11 +29,8 @@
* Sometimes perl carefully scribbles on our *printf macros. * Sometimes perl carefully scribbles on our *printf macros.
* So we undefine them here and redefine them after it's done its dirty deed. * So we undefine them here and redefine them after it's done its dirty deed.
*/ */
#ifdef USE_REPL_SNPRINTF
#undef snprintf #undef snprintf
#undef vsnprintf #undef vsnprintf
#endif
/* /*
* ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's * ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's
...@@ -99,7 +96,6 @@ ...@@ -99,7 +96,6 @@
#endif #endif
/* put back our snprintf and vsnprintf */ /* put back our snprintf and vsnprintf */
#ifdef USE_REPL_SNPRINTF
#ifdef snprintf #ifdef snprintf
#undef snprintf #undef snprintf
#endif #endif
...@@ -113,7 +109,6 @@ ...@@ -113,7 +109,6 @@
#define vsnprintf pg_vsnprintf #define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf #define snprintf pg_snprintf
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#endif /* USE_REPL_SNPRINTF */
/* perl version and platform portability */ /* perl version and platform portability */
#define NEED_eval_pv #define NEED_eval_pv
......
...@@ -33,11 +33,8 @@ ...@@ -33,11 +33,8 @@
* Sometimes python carefully scribbles on our *printf macros. * Sometimes python carefully scribbles on our *printf macros.
* So we undefine them here and redefine them after it's done its dirty deed. * So we undefine them here and redefine them after it's done its dirty deed.
*/ */
#ifdef USE_REPL_SNPRINTF
#undef snprintf #undef snprintf
#undef vsnprintf #undef vsnprintf
#endif
#if defined(_MSC_VER) && defined(_DEBUG) #if defined(_MSC_VER) && defined(_DEBUG)
/* Python uses #pragma to bring in a non-default libpython on VC++ if /* Python uses #pragma to bring in a non-default libpython on VC++ if
...@@ -124,7 +121,6 @@ typedef int Py_ssize_t; ...@@ -124,7 +121,6 @@ typedef int Py_ssize_t;
#include <eval.h> #include <eval.h>
/* put back our snprintf and vsnprintf */ /* put back our snprintf and vsnprintf */
#ifdef USE_REPL_SNPRINTF
#ifdef snprintf #ifdef snprintf
#undef snprintf #undef snprintf
#endif #endif
...@@ -138,7 +134,6 @@ typedef int Py_ssize_t; ...@@ -138,7 +134,6 @@ typedef int Py_ssize_t;
#define vsnprintf pg_vsnprintf #define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf #define snprintf pg_snprintf
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#endif /* USE_REPL_SNPRINTF */
/* /*
* Used throughout, and also by the Python 2/3 porting layer, so it's easier to * Used throughout, and also by the Python 2/3 porting layer, so it's easier to
......
...@@ -33,7 +33,8 @@ LIBS += $(PTHREAD_LIBS) ...@@ -33,7 +33,8 @@ LIBS += $(PTHREAD_LIBS)
OBJS = $(LIBOBJS) $(PG_CRC32C_OBJS) chklocale.o erand48.o inet_net_ntop.o \ OBJS = $(LIBOBJS) $(PG_CRC32C_OBJS) chklocale.o erand48.o inet_net_ntop.o \
noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \ noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \
pgstrcasecmp.o pqsignal.o \ pgstrcasecmp.o pqsignal.o \
qsort.o qsort_arg.o quotes.o sprompt.o strerror.o tar.o thread.o qsort.o qsort_arg.o quotes.o snprintf.o sprompt.o strerror.o \
tar.o thread.o
ifeq ($(enable_strong_random), yes) ifeq ($(enable_strong_random), yes)
OBJS += pg_strong_random.o OBJS += pg_strong_random.o
......
...@@ -18,7 +18,7 @@ and adding infrastructure to recompile the object files: ...@@ -18,7 +18,7 @@ and adding infrastructure to recompile the object files:
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \ OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o exec.o \ connect.o misc.o path.o exec.o \
$(filter snprintf.o, $(LIBOBJS)) $(filter strlcat.o, $(LIBOBJS))
The problem is that there is no testing of which object files need to be The problem is that there is no testing of which object files need to be
added, but missing functions usually show up when linking user added, but missing functions usually show up when linking user
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册