Remove support for Unix systems without the POSIX signal APIs.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 Aug 2015 16:55:59 +0000 (12:55 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 Aug 2015 16:56:10 +0000 (12:56 -0400)
Remove configure's checks for HAVE_POSIX_SIGNALS, HAVE_SIGPROCMASK, and
HAVE_SIGSETJMP.  These APIs are required by the Single Unix Spec v2
(POSIX 1997), which we generally consider to define our minimum required
set of Unix APIs.  Moreover, no buildfarm member has reported not having
them since 2012 or before, which means that even if the code is still live
somewhere, it's untested --- and we've made plenty of signal-handling
changes of late.  So just take these APIs as given and save the cycles for
configure probes for them.

However, we can't remove as much C code as I'd hoped, because the Windows
port evidently still uses the non-POSIX code paths for signal masking.
Since we're largely emulating these BSD-style APIs for Windows anyway, it
might be a good thing to switch over to POSIX-like notation and thereby
remove a few more #ifdefs.  But I'm not in a position to code or test that.
In the meantime, we can at least make things a bit more transparent by
testing for WIN32 explicitly in these places.

config/c-library.m4
configure
configure.in
src/Makefile.global.in
src/backend/libpq/pqsignal.c
src/include/c.h
src/include/libpq/pqsignal.h
src/include/pg_config.h.in
src/include/pg_config.h.win32
src/makefiles/Makefile.hpux
src/port/pqsignal.c

index 7b1d9f4063d4a76625b75051dc5a607d79433f95..1d28c454bae7feb1b97988e65e0f50dc2f925174 100644 (file)
@@ -170,33 +170,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO],
 ])])# PGAC_STRUCT_ADDRINFO
 
 
-# PGAC_FUNC_POSIX_SIGNALS
-# -----------------------
-# Check to see if the machine has the POSIX signal interface. Define
-# HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
-# to yes or no.
-#
-# Note that this test only compiles a test program, it doesn't check
-# whether the routines actually work. If that becomes a problem, make
-# a fancier check.
-AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
-[AC_CACHE_CHECK(for POSIX signal interface, pgac_cv_func_posix_signals,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <signal.h>
-],
-[struct sigaction act, oact;
-sigemptyset(&act.sa_mask);
-act.sa_flags = SA_RESTART;
-sigaction(0, &act, &oact);])],
-[pgac_cv_func_posix_signals=yes],
-[pgac_cv_func_posix_signals=no])])
-if test x"$pgac_cv_func_posix_signals" = xyes ; then
-  AC_DEFINE(HAVE_POSIX_SIGNALS, 1,
-            [Define to 1 if you have the POSIX signal interface.])
-fi
-HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
-AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
-
-
 # PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
 # ---------------------------------------
 # Determine which length modifier snprintf uses for long long int.  We
index 0376a7ca9197cb860096fd14694adf98677f662d..99ef10f0f73cc7f569501b64d78e732448f6bd13 100755 (executable)
--- a/configure
+++ b/configure
@@ -649,7 +649,6 @@ XGETTEXT
 MSGMERGE
 MSGFMT_FLAGS
 MSGFMT
-HAVE_POSIX_SIGNALS
 PG_CRC32C_OBJS
 CFLAGS_SSE42
 have_win32_dbghelp
@@ -12289,7 +12288,7 @@ fi
 LIBS_including_readline="$LIBS"
 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 
-for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
+for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -13048,38 +13047,6 @@ esac
 
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
-$as_echo_n "checking for sigsetjmp... " >&6; }
-if ${pgac_cv_func_sigsetjmp+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <setjmp.h>
-int
-main ()
-{
-sigjmp_buf x; sigsetjmp(x, 1);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_func_sigsetjmp=yes
-else
-  pgac_cv_func_sigsetjmp=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_sigsetjmp" >&5
-$as_echo "$pgac_cv_func_sigsetjmp" >&6; }
-if test x"$pgac_cv_func_sigsetjmp" = x"yes"; then
-
-$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
-
-fi
-
 ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h>
 /* NetBSD declares sys_siglist in unistd.h.  */
 #ifdef HAVE_UNISTD_H
 
 
 
-# Check that POSIX signals are available if thread safety is enabled.
-if test "$PORTNAME" != "win32"
-then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for POSIX signal interface" >&5
-$as_echo_n "checking for POSIX signal interface... " >&6; }
-if ${pgac_cv_func_posix_signals+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <signal.h>
-
-int
-main ()
-{
-struct sigaction act, oact;
-sigemptyset(&act.sa_mask);
-act.sa_flags = SA_RESTART;
-sigaction(0, &act, &oact);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_func_posix_signals=yes
-else
-  pgac_cv_func_posix_signals=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_posix_signals" >&5
-$as_echo "$pgac_cv_func_posix_signals" >&6; }
-if test x"$pgac_cv_func_posix_signals" = xyes ; then
-
-$as_echo "#define HAVE_POSIX_SIGNALS 1" >>confdefs.h
-
-fi
-HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
-
-if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
-  as_fn_error $? "
-Thread-safety requires POSIX signals, which are not supported by this
-operating system;  use --disable-thread-safety to disable thread safety." "$LINENO" 5
-fi
-fi
-
-
 # Select semaphore implementation type.
 if test "$PORTNAME" != "win32"; then
   if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
index 5f16530fca87f00e7c41c9070688aa9b42c1f631..4143451c40e72905dec4e1652dc6494c009260f3 100644 (file)
@@ -1406,7 +1406,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
 LIBS_including_readline="$LIBS"
 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 
-AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
+AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
 
 AC_REPLACE_FUNCS(fseeko)
 case $host_os in
@@ -1596,18 +1596,6 @@ if test "$PORTNAME" = "cygwin"; then
   AC_LIBOBJ(dirmod)
 fi
 
-dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
-dnl (especially on GNU libc)
-dnl See also comments in c.h.
-AC_CACHE_CHECK([for sigsetjmp], pgac_cv_func_sigsetjmp,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <setjmp.h>],
-            [sigjmp_buf x; sigsetjmp(x, 1);])],
-            [pgac_cv_func_sigsetjmp=yes],
-            [pgac_cv_func_sigsetjmp=no])])
-if test x"$pgac_cv_func_sigsetjmp" = x"yes"; then
-  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
-fi
-
 AC_CHECK_DECLS([sys_siglist], [], [],
 [#include <signal.h>
 /* NetBSD declares sys_siglist in unistd.h.  */
@@ -1932,18 +1920,6 @@ fi
 AC_SUBST(PG_CRC32C_OBJS)
 
 
-# Check that POSIX signals are available if thread safety is enabled.
-if test "$PORTNAME" != "win32"
-then
-PGAC_FUNC_POSIX_SIGNALS
-if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
-  AC_MSG_ERROR([
-Thread-safety requires POSIX signals, which are not supported by this
-operating system;  use --disable-thread-safety to disable thread safety.])
-fi
-fi
-
-
 # Select semaphore implementation type.
 if test "$PORTNAME" != "win32"; then
   if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
index 39a7879bb69caed1fcbc4c2b0d587a953a760a2c..6871c3c6143b3eddec6a6906774b00707ce26bbd 100644 (file)
@@ -432,9 +432,6 @@ host_cpu = @host_cpu@
 # Make HAVE_IPV6 available for initdb script creation
 HAVE_IPV6= @HAVE_IPV6@
 
-# The HP-UX port makefile, for one, needs access to this symbol
-HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
-
 # This is mainly for use on FreeBSD, where we have both a.out and elf
 # systems now.  May be applicable to other systems to?
 ELF_SYSTEM= @ELF_SYS@
index 5f17d765816463abbdbbffd3662ec1033014d11e..b19c4539f3f9ec28d5cba104695ae3397b9dee5f 100644 (file)
@@ -18,7 +18,7 @@
 #include "libpq/pqsignal.h"
 
 
-#ifdef HAVE_SIGPROCMASK
+#ifndef WIN32
 sigset_t       UnBlockSig,
                        BlockSig,
                        StartupBlockSig;
@@ -45,7 +45,7 @@ int                   UnBlockSig,
 void
 pqinitmask(void)
 {
-#ifdef HAVE_SIGPROCMASK
+#ifndef WIN32
 
        sigemptyset(&UnBlockSig);
 
@@ -101,7 +101,7 @@ pqinitmask(void)
 #ifdef SIGALRM
        sigdelset(&StartupBlockSig, SIGALRM);
 #endif
-#else
+#else                                                  /* WIN32 */
        /* Set the signals we want. */
        UnBlockSig = 0;
        BlockSig = sigmask(SIGQUIT) |
index f5da4676c6fb60f71795c1ec5330342c7945f163..8163b000df1fe457f465509566ccd9d1542cf98c 100644 (file)
@@ -1051,9 +1051,9 @@ extern int        vsnprintf(char *str, size_t count, const char *fmt, va_list args);
 /*
  * When there is no sigsetjmp, its functionality is provided by plain
  * setjmp. Incidentally, nothing provides setjmp's functionality in
- * that case.
+ * that case.  We now support the case only on Windows.
  */
-#ifndef HAVE_SIGSETJMP
+#ifdef WIN32
 #define sigjmp_buf jmp_buf
 #define sigsetjmp(x,y) setjmp(x)
 #define siglongjmp longjmp
index 4b85342f325a34a3988df1e084e947d66927d6c8..33642475314025451951b2b0dc488840c78b4577 100644 (file)
 
 #include <signal.h>
 
-#ifdef HAVE_SIGPROCMASK
+#ifndef WIN32
 extern sigset_t UnBlockSig,
                        BlockSig,
                        StartupBlockSig;
 
 #define PG_SETMASK(mask)       sigprocmask(SIG_SETMASK, mask, NULL)
-#else                                                  /* not HAVE_SIGPROCMASK */
+#else                                                  /* WIN32 */
+/*
+ * Windows doesn't provide the POSIX signal API, so we use something
+ * approximating the old BSD signal API.
+ */
 extern int     UnBlockSig,
                        BlockSig,
                        StartupBlockSig;
 
-#ifndef WIN32
-#define PG_SETMASK(mask)       sigsetmask(*((int*)(mask)))
-#else
-#define PG_SETMASK(mask)               pqsigsetmask(*((int*)(mask)))
-int                    pqsigsetmask(int mask);
-#endif
+extern int     pqsigsetmask(int mask);
 
+#define PG_SETMASK(mask)               pqsigsetmask(*(mask))
 #define sigaddset(set, signum) (*(set) |= (sigmask(signum)))
 #define sigdelset(set, signum) (*(set) &= ~(sigmask(signum)))
-#endif   /* not HAVE_SIGPROCMASK */
+#endif   /* WIN32 */
 
 extern void pqinitmask(void);
 
index 1dcc9a9ee7ab28137cd733649aeefd3653637d65..dda73a8b4cedc88b0d85be0ac6f7cf74a27dc201 100644 (file)
 /* Define to 1 if you have the `posix_fadvise' function. */
 #undef HAVE_POSIX_FADVISE
 
-/* Define to 1 if you have the POSIX signal interface. */
-#undef HAVE_POSIX_SIGNALS
-
 /* Define to 1 if the assembler supports PPC's LWARX mutex hint bit. */
 #undef HAVE_PPC_LWARX_MUTEX_HINT
 
 /* Define to 1 if you have the `shm_open' function. */
 #undef HAVE_SHM_OPEN
 
-/* Define to 1 if you have the `sigprocmask' function. */
-#undef HAVE_SIGPROCMASK
-
-/* Define to 1 if you have sigsetjmp(). */
-#undef HAVE_SIGSETJMP
-
 /* Define to 1 if you have the `snprintf' function. */
 #undef HAVE_SNPRINTF
 
index bf69ef5bdeb86a52c45e8c3833ad61bfd41501c6..6f7a773c5bee9fff85675b1f59031744c79b1a22 100644 (file)
 /* Define to 1 if you have the <poll.h> header file. */
 /* #undef HAVE_POLL_H */
 
-/* Define to 1 if you have the POSIX signal interface. */
-/* #undef HAVE_POSIX_SIGNALS */
-
 /* Define to 1 if you have the `pstat' function. */
 /* #undef HAVE_PSTAT */
 
 /* Define to 1 if you have the `setsid' function. */
 /* #undef HAVE_SETSID */
 
-/* Define to 1 if you have the `sigprocmask' function. */
-/* #undef HAVE_SIGPROCMASK */
-
-/* Define to 1 if you have sigsetjmp(). */
-/* #undef HAVE_SIGSETJMP */
-
 /* Define to 1 if you have the `snprintf' function. */
 /* #undef HAVE_SNPRINTF */
 
index 1917d61b43601eff4b0524a85d02ca1eb1ba0daa..97bd0ba6d9e27e2c9694a0d587bfbc36b8b4b052 100644 (file)
@@ -1,10 +1,3 @@
-# If we don't have POSIX signals, we need to use the libBSD signal routines.
-# (HPUX 9 and early HPUX 10 releases don't have POSIX signals.)  Link in
-# libBSD only in that case.
-ifeq ($(HAVE_POSIX_SIGNALS), no)
-   LIBS := -lBSD $(LIBS)
-endif
-
 # Using X/Open Networking Interfaces requires to link with libxnet.
 # Without specifying this, bind(), getpeername() and so on don't work
 # correctly in the LP64 data model.
index f475b58acd0c17a217eb2582b27ba91e688cdc13..3e538d8c9851e8785b4a09a23b54edcc17717170 100644 (file)
  * IDENTIFICATION
  *       src/port/pqsignal.c
  *
- *     A NOTE ABOUT SIGNAL HANDLING ACROSS THE VARIOUS PLATFORMS.
- *
- *     pg_config.h defines the macro HAVE_POSIX_SIGNALS for some platforms and
- *     not for others.  We use that here to decide how to handle signalling.
- *
- *     Ultrix and SunOS provide BSD signal(2) semantics by default.
- *
- *     SVID2 and POSIX signal(2) semantics differ from BSD signal(2)
- *     semantics.  We can use the POSIX sigaction(2) on systems that
- *     allow us to request restartable signals (SA_RESTART).
- *
- *     Some systems don't allow restartable signals at all unless we
- *     link to a special BSD library.
- *
- *     We devoutly hope that there aren't any Unix-oid systems that provide
- *     neither POSIX signals nor BSD signals.  The alternative is to do
- *     signal-handler reinstallation, which doesn't work well at all.
+ *     We now assume that all Unix-oid systems have POSIX sigaction(2)
+ *     with support for restartable signals (SA_RESTART).  We used to also
+ *     support BSD-style signal(2), but there really shouldn't be anything
+ *     out there anymore that doesn't have the POSIX API.
  *
  *     Windows, of course, is resolutely in a class by itself.  In the backend,
  *     we don't use this file at all; src/backend/port/win32/signal.c provides
  *     pqsignal() for the backend environment.  Frontend programs can use
- *     this version of pqsignal() if they wish, but beware that Windows
- *     requires signal-handler reinstallation, because indeed it provides
- *     neither POSIX signals nor BSD signals :-(
+ *     this version of pqsignal() if they wish, but beware that this does
+ *     not provide restartable signals on Windows.
+ *
  * ------------------------------------------------------------------------
  */
 
@@ -52,9 +39,7 @@
 pqsigfunc
 pqsignal(int signo, pqsigfunc func)
 {
-#if !defined(HAVE_POSIX_SIGNALS)
-       return signal(signo, func);
-#else
+#ifndef WIN32
        struct sigaction act,
                                oact;
 
@@ -68,7 +53,9 @@ pqsignal(int signo, pqsigfunc func)
        if (sigaction(signo, &act, &oact) < 0)
                return SIG_ERR;
        return oact.sa_handler;
-#endif   /* !HAVE_POSIX_SIGNALS */
+#else                                                  /* WIN32 */
+       return signal(signo, func);
+#endif
 }
 
 #endif   /* !defined(WIN32) || defined(FRONTEND) */