summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/port.h82
-rw-r--r--src/interfaces/ecpg/compatlib/Makefile1
-rw-r--r--src/interfaces/ecpg/ecpglib/.gitignore1
-rw-r--r--src/interfaces/ecpg/ecpglib/Makefile6
-rw-r--r--src/interfaces/ecpg/pgtypeslib/.gitignore1
-rw-r--r--src/interfaces/ecpg/pgtypeslib/Makefile6
-rw-r--r--src/interfaces/libpq/.gitignore1
-rw-r--r--src/interfaces/libpq/Makefile6
-rw-r--r--src/interfaces/libpq/bcc32.mak7
-rw-r--r--src/interfaces/libpq/win32.mak7
-rw-r--r--src/port/Makefile2
-rw-r--r--src/port/snprintf.c3
-rw-r--r--src/port/syswrap.c155
-rw-r--r--src/tools/msvc/Mkvcbuild.pm2
14 files changed, 37 insertions, 243 deletions
diff --git a/src/include/port.h b/src/include/port.h
index 3692cdbbc54..74da77ca39e 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -148,11 +148,12 @@ extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
extern unsigned char pg_toupper(unsigned char ch);
extern unsigned char pg_tolower(unsigned char ch);
+#ifdef USE_REPL_SNPRINTF
+
/*
- * Capture macro-compatible calls to printf() and friends, and redirect them
- * to wrappers that throw errors in lieu of reporting failure in a return
- * value. Versions of libintl >= 0.13 similarly redirect to versions that
- * understand the %$ format, so disable libintl macros first.
+ * Versions of libintl >= 0.13 try to replace printf() and friends with
+ * macros to their own versions that understand the %$ format. We do the
+ * same, so disable their macros, if they exist.
*/
#ifdef vsnprintf
#undef vsnprintf
@@ -160,9 +161,6 @@ extern unsigned char pg_tolower(unsigned char ch);
#ifdef snprintf
#undef snprintf
#endif
-#ifdef vsprintf
-#undef vsprintf
-#endif
#ifdef sprintf
#undef sprintf
#endif
@@ -176,61 +174,11 @@ extern unsigned char pg_tolower(unsigned char ch);
#undef printf
#endif
-extern int
-vsnprintf_throw_on_fail(char *str, size_t count, const char *fmt, va_list args)
-__attribute__((format(printf, 3, 0)));
-extern int
-snprintf_throw_on_fail(char *str, size_t count, const char *fmt,...)
-__attribute__((format(printf, 3, 4)));
-extern int
-vsprintf_throw_on_fail(char *str, const char *fmt, va_list args)
-__attribute__((format(printf, 2, 0)));
-extern int
-sprintf_throw_on_fail(char *str, const char *fmt,...)
-__attribute__((format(printf, 2, 3)));
-extern int
-vfprintf_throw_on_fail(FILE *stream, const char *fmt, va_list args)
-__attribute__((format(printf, 2, 0)));
-extern int
-fprintf_throw_on_fail(FILE *stream, const char *fmt,...)
-__attribute__((format(printf, 2, 3)));
-extern int
-printf_throw_on_fail(const char *fmt,...)
-__attribute__((format(printf, 1, 2)));
-
-/*
- * The GCC-specific code below prevents the __attribute__(... 'printf')
- * above from being replaced, and this is required because gcc doesn't
- * know anything about printf_throw_on_fail.
- */
-#ifdef __GNUC__
-#define vsnprintf(...) vsnprintf_throw_on_fail(__VA_ARGS__)
-#define snprintf(...) snprintf_throw_on_fail(__VA_ARGS__)
-#define vsprintf(...) vsprintf_throw_on_fail(__VA_ARGS__)
-#define sprintf(...) sprintf_throw_on_fail(__VA_ARGS__)
-#define vfprintf(...) vfprintf_throw_on_fail(__VA_ARGS__)
-#define fprintf(...) fprintf_throw_on_fail(__VA_ARGS__)
-#define printf(...) printf_throw_on_fail(__VA_ARGS__)
-#else
-#define vsnprintf vsnprintf_throw_on_fail
-#define snprintf snprintf_throw_on_fail
-#define vsprintf vsprintf_throw_on_fail
-#define sprintf sprintf_throw_on_fail
-#define vfprintf vfprintf_throw_on_fail
-#define fprintf fprintf_throw_on_fail
-#define printf printf_throw_on_fail
-#endif
-
-#ifdef USE_REPL_SNPRINTF
-
-/* Code outside syswrap.c should not call these. */
-
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int
pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 3, 4)));
-extern int pg_vsprintf(char *str, const char *fmt, va_list args);
extern int
pg_sprintf(char *str, const char *fmt,...)
/* This extension allows gcc to check the format string */
@@ -245,6 +193,26 @@ pg_printf(const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 1, 2)));
+/*
+ * The GCC-specific code below prevents the __attribute__(... 'printf')
+ * above from being replaced, and this is required because gcc doesn't
+ * know anything about pg_printf.
+ */
+#ifdef __GNUC__
+#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
+#define snprintf(...) pg_snprintf(__VA_ARGS__)
+#define sprintf(...) pg_sprintf(__VA_ARGS__)
+#define vfprintf(...) pg_vfprintf(__VA_ARGS__)
+#define fprintf(...) pg_fprintf(__VA_ARGS__)
+#define printf(...) pg_printf(__VA_ARGS__)
+#else
+#define vsnprintf pg_vsnprintf
+#define snprintf pg_snprintf
+#define sprintf pg_sprintf
+#define vfprintf pg_vfprintf
+#define fprintf pg_fprintf
+#define printf pg_printf
+#endif
#endif /* USE_REPL_SNPRINTF */
/*
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index 481059f4bc8..45c8f9462f4 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -36,7 +36,6 @@ all: all-lib
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib
-# XXX This library uses no symbols from snprintf.c.
snprintf.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
diff --git a/src/interfaces/ecpg/ecpglib/.gitignore b/src/interfaces/ecpg/ecpglib/.gitignore
index f3513db90c1..e6c60b16fcd 100644
--- a/src/interfaces/ecpg/ecpglib/.gitignore
+++ b/src/interfaces/ecpg/ecpglib/.gitignore
@@ -6,5 +6,4 @@
/path.c
/pgstrcasecmp.c
/strlcpy.c
-/syswrap.c
/thread.c
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 50e0b0650c6..46693896bbb 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -25,7 +25,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
LIBS := $(filter-out -lpgport, $(LIBS))
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 syswrap.o \
+ connect.o misc.o path.o pgstrcasecmp.o \
$(filter snprintf.o strlcpy.o isinf.o, $(LIBOBJS))
# thread.c is needed only for non-WIN32 implementation of path.c
@@ -58,7 +58,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file.
-path.c pgstrcasecmp.c snprintf.c strlcpy.c syswrap.c thread.c isinf.c: % : $(top_srcdir)/src/port/%
+path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c isinf.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
misc.o: misc.c $(top_builddir)/src/port/pg_config_paths.h
@@ -75,6 +75,6 @@ uninstall: uninstall-lib
clean distclean: clean-lib
rm -f $(OBJS)
- rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c syswrap.c thread.c
+ rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c
maintainer-clean: distclean maintainer-clean-lib
diff --git a/src/interfaces/ecpg/pgtypeslib/.gitignore b/src/interfaces/ecpg/pgtypeslib/.gitignore
index 83f896c7a7a..aa5bdb837f2 100644
--- a/src/interfaces/ecpg/pgtypeslib/.gitignore
+++ b/src/interfaces/ecpg/pgtypeslib/.gitignore
@@ -4,4 +4,3 @@
/exports.list
/pgstrcasecmp.c
-/syswrap.c
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index 69b8c832508..7f71e1bc5cc 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -29,7 +29,7 @@ SHLIB_LINK += -lm
SHLIB_EXPORTS = exports.txt
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
- pgstrcasecmp.o syswrap.o \
+ pgstrcasecmp.o \
$(filter rint.o snprintf.o, $(LIBOBJS))
all: all-lib
@@ -42,7 +42,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file.
-pgstrcasecmp.c rint.c snprintf.c syswrap.c: % : $(top_srcdir)/src/port/%
+pgstrcasecmp.c rint.c snprintf.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
install: all installdirs install-lib
@@ -52,6 +52,6 @@ installdirs: installdirs-lib
uninstall: uninstall-lib
clean distclean: clean-lib
- rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c syswrap.c
+ rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c
maintainer-clean: distclean maintainer-clean-lib
diff --git a/src/interfaces/libpq/.gitignore b/src/interfaces/libpq/.gitignore
index 1be81ec6588..f086ec3db7e 100644
--- a/src/interfaces/libpq/.gitignore
+++ b/src/interfaces/libpq/.gitignore
@@ -8,7 +8,6 @@
/snprintf.c
/strerror.c
/strlcpy.c
-/syswrap.c
/thread.c
/win32error.c
/pgsleep.c
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 74f10662baf..98d9e8164f2 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -33,7 +33,7 @@ LIBS := $(LIBS:-lpgport=)
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
libpq-events.o \
- md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o syswrap.o thread.o \
+ md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o, $(LIBOBJS))
ifeq ($(PORTNAME), cygwin)
@@ -80,7 +80,7 @@ backend_src = $(top_srcdir)/src/backend
# For port modules, this only happens if configure decides the module
# is needed (see filter hack in OBJS, above).
-crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c syswrap.c thread.c win32error.c pgsleep.c: % : $(top_srcdir)/src/port/%
+crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c win32error.c pgsleep.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
md5.c ip.c: % : $(backend_src)/libpq/%
@@ -133,7 +133,7 @@ ifneq (,$(findstring $(PORTNAME), win32 cygwin))
endif
clean distclean: clean-lib
- rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c syswrap.c thread.c md5.c ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h libpq.rc
+ rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h libpq.rc
# Might be left over from a Win32 client-only build
rm -f pg_config_paths.h
diff --git a/src/interfaces/libpq/bcc32.mak b/src/interfaces/libpq/bcc32.mak
index 4152ff85533..f109f27a365 100644
--- a/src/interfaces/libpq/bcc32.mak
+++ b/src/interfaces/libpq/bcc32.mak
@@ -104,7 +104,6 @@ CLEAN :
-@erase "$(INTDIR)\dirmod.obj"
-@erase "$(INTDIR)\pgsleep.obj"
-@erase "$(INTDIR)\open.obj"
- -@erase "$(INTDIR)\syswrap.obj"
-@erase "$(INTDIR)\win32error.obj"
-@erase "$(OUTDIR)\$(OUTFILENAME).lib"
-@erase "$(OUTDIR)\$(OUTFILENAME)dll.lib"
@@ -146,7 +145,6 @@ LIB32_OBJS= \
"$(INTDIR)\dirmod.obj" \
"$(INTDIR)\pgsleep.obj" \
"$(INTDIR)\open.obj" \
- "$(INTDIR)\syswrap.obj" \
"$(INTDIR)\win32error.obj" \
"$(INTDIR)\pthread-win32.obj"
@@ -275,11 +273,6 @@ LINK32_FLAGS = -Gn -L$(BCB)\lib;$(INTDIR); -x -Tpd -v
$(CPP_PROJ) /I"." ..\..\port\open.c
<<
-"$(INTDIR)\syswrap.obj" : ..\..\port\syswrap.c
- $(CPP) @<<
- $(CPP_PROJ) ..\..\port\syswrap.c
-<<
-
"$(INTDIR)\win32error.obj" : ..\..\port\win32error.c
$(CPP) @<<
$(CPP_PROJ) /I"." ..\..\port\win32error.c
diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak
index e075051f042..56b24a5cdce 100644
--- a/src/interfaces/libpq/win32.mak
+++ b/src/interfaces/libpq/win32.mak
@@ -111,7 +111,6 @@ CLEAN :
-@erase "$(INTDIR)\dirmod.obj"
-@erase "$(INTDIR)\pgsleep.obj"
-@erase "$(INTDIR)\open.obj"
- -@erase "$(INTDIR)\syswrap.obj"
-@erase "$(INTDIR)\win32error.obj"
-@erase "$(OUTDIR)\$(OUTFILENAME).lib"
-@erase "$(OUTDIR)\$(OUTFILENAME)dll.lib"
@@ -155,7 +154,6 @@ LIB32_OBJS= \
"$(INTDIR)\dirmod.obj" \
"$(INTDIR)\pgsleep.obj" \
"$(INTDIR)\open.obj" \
- "$(INTDIR)\syswrap.obj" \
"$(INTDIR)\win32error.obj" \
"$(INTDIR)\pthread-win32.obj"
@@ -313,11 +311,6 @@ LINK32_OBJS= \
$(CPP_PROJ) /I"." ..\..\port\open.c
<<
-"$(INTDIR)\syswrap.obj" : ..\..\port\syswrap.c
- $(CPP) @<<
- $(CPP_PROJ) ..\..\port\syswrap.c
-<<
-
"$(INTDIR)\win32error.obj" : ..\..\port\win32error.c
$(CPP) @<<
$(CPP_PROJ) /I"." ..\..\port\win32error.c
diff --git a/src/port/Makefile b/src/port/Makefile
index c7000ba9a61..8589108f55c 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -31,7 +31,7 @@ override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
LIBS += $(PTHREAD_LIBS)
OBJS = $(LIBOBJS) chklocale.o dirmod.o exec.o noblock.o path.o \
- pgsleep.o pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o syswrap.o thread.o
+ pgsleep.o pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o
ifneq (,$(filter $(PORTNAME),cygwin win32))
OBJS += pipe.o
endif
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 281bba169e6..32af0300310 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -99,7 +99,6 @@
/* Prevent recursion */
#undef vsnprintf
#undef snprintf
-#undef vsprintf
#undef sprintf
#undef vfprintf
#undef fprintf
@@ -176,7 +175,7 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
return len;
}
-int
+static int
pg_vsprintf(char *str, const char *fmt, va_list args)
{
PrintfTarget target;
diff --git a/src/port/syswrap.c b/src/port/syswrap.c
deleted file mode 100644
index 8415a336303..00000000000
--- a/src/port/syswrap.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * syswrap.c
- * error-throwing wrappers around POSIX functions that rarely fail
- *
- * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
- *
- *
- * IDENTIFICATION
- * src/port/syswrap.c
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef FRONTEND
-#include "postgres.h"
-#else
-#include "postgres_fe.h"
-#endif
-
-/* Prevent recursion */
-#undef vsnprintf
-#undef snprintf
-#undef vsprintf
-#undef sprintf
-#undef vfprintf
-#undef fprintf
-#undef printf
-
-/* When the libc primitives are lacking, use our own. */
-#ifdef USE_REPL_SNPRINTF
-#ifdef __GNUC__
-#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
-#define snprintf(...) pg_snprintf(__VA_ARGS__)
-#define vsprintf(...) pg_vsprintf(__VA_ARGS__)
-#define sprintf(...) pg_sprintf(__VA_ARGS__)
-#define vfprintf(...) pg_vfprintf(__VA_ARGS__)
-#define fprintf(...) pg_fprintf(__VA_ARGS__)
-#define printf(...) pg_printf(__VA_ARGS__)
-#else
-#define vsnprintf pg_vsnprintf
-#define snprintf pg_snprintf
-#define vsprintf pg_vsprintf
-#define sprintf pg_sprintf
-#define vfprintf pg_vfprintf
-#define fprintf pg_fprintf
-#define printf pg_printf
-#endif
-#endif /* USE_REPL_SNPRINTF */
-
-/*
- * We abort() in the frontend, rather than exit(), because libpq in particular
- * has no business calling exit(). These failures had better be rare.
- */
-#ifdef FRONTEND
-#define LIB_ERR(func) \
-do { \
- int discard = fprintf(stderr, "%s failed: %s\n", func, strerror(errno)); \
- (void) discard; \
- abort(); \
-} while (0)
-#else
-#define LIB_ERR(func) elog(ERROR, "%s failed: %m", func)
-#endif
-
-int
-vsnprintf_throw_on_fail(char *str, size_t count, const char *fmt, va_list args)
-{
- int save_errno;
- int ret;
-
- /*
- * On HP-UX B.11.31, a call that truncates output returns -1 without
- * setting errno. (SUSv2 allowed this until the approval of Base Working
- * Group Resolution BWG98-006.) We could avoid the save and restore of
- * errno on most platforms.
- */
- save_errno = errno;
- errno = 0;
- ret = vsnprintf(str, count, fmt, args);
- if (ret < 0 && errno != 0)
- LIB_ERR("vsnprintf");
- errno = save_errno;
- return ret;
-}
-
-int
-snprintf_throw_on_fail(char *str, size_t count, const char *fmt,...)
-{
- int ret;
- va_list args;
-
- va_start(args, fmt);
- ret = vsnprintf_throw_on_fail(str, count, fmt, args);
- va_end(args);
- return ret;
-}
-
-int
-vsprintf_throw_on_fail(char *str, const char *fmt, va_list args)
-{
- int ret;
-
- ret = vsprintf(str, fmt, args);
- if (ret < 0)
- LIB_ERR("vsprintf");
- return ret;
-}
-
-int
-sprintf_throw_on_fail(char *str, const char *fmt,...)
-{
- int ret;
- va_list args;
-
- va_start(args, fmt);
- ret = vsprintf_throw_on_fail(str, fmt, args);
- va_end(args);
- return ret;
-}
-
-int
-vfprintf_throw_on_fail(FILE *stream, const char *fmt, va_list args)
-{
- int ret;
-
- ret = vfprintf(stream, fmt, args);
- if (ret < 0)
- LIB_ERR("vfprintf");
- return ret;
-}
-
-int
-fprintf_throw_on_fail(FILE *stream, const char *fmt,...)
-{
- int ret;
- va_list args;
-
- va_start(args, fmt);
- ret = vfprintf_throw_on_fail(stream, fmt, args);
- va_end(args);
- return ret;
-}
-
-int
-printf_throw_on_fail(const char *fmt,...)
-{
- int ret;
- va_list args;
-
- va_start(args, fmt);
- ret = vfprintf_throw_on_fail(stdout, fmt, args);
- va_end(args);
- return ret;
-}
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index d1bbedc8bc2..fa97c79471d 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -52,7 +52,7 @@ sub mkvcbuild
chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
getaddrinfo.c gettimeofday.c kill.c open.c erand48.c mkdtemp.c
snprintf.c strlcat.c strlcpy.c dirmod.c exec.c noblock.c path.c pipe.c
- pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c syswrap.c thread.c
+ pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c thread.c
getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c);
$libpgport = $solution->AddProject('libpgport','lib','misc');