Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita65e086

Browse files
committed
Remove support for Unix systems without the POSIX signal APIs.
Remove configure's checks for HAVE_POSIX_SIGNALS, HAVE_SIGPROCMASK, andHAVE_SIGSETJMP. These APIs are required by the Single Unix Spec v2(POSIX 1997), which we generally consider to define our minimum requiredset of Unix APIs. Moreover, no buildfarm member has reported not havingthem since 2012 or before, which means that even if the code is still livesomewhere, it's untested --- and we've made plenty of signal-handlingchanges of late. So just take these APIs as given and save the cycles forconfigure probes for them.However, we can't remove as much C code as I'd hoped, because the Windowsport evidently still uses the non-POSIX code paths for signal masking.Since we're largely emulating these BSD-style APIs for Windows anyway, itmight be a good thing to switch over to POSIX-like notation and therebyremove 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 bytesting for WIN32 explicitly in these places.
1 parent8f7d044 commita65e086

File tree

11 files changed

+27
-200
lines changed

11 files changed

+27
-200
lines changed

‎config/c-library.m4

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -170,33 +170,6 @@ AC_DEFUN([PGAC_STRUCT_ADDRINFO],
170170
])])# PGAC_STRUCT_ADDRINFO
171171

172172

173-
# PGAC_FUNC_POSIX_SIGNALS
174-
# -----------------------
175-
# Check to see if the machine has the POSIX signal interface. Define
176-
# HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
177-
# to yes or no.
178-
#
179-
# Note that this test only compiles a test program, it doesn't check
180-
# whether the routines actually work. If that becomes a problem, make
181-
# a fancier check.
182-
AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
183-
[AC_CACHE_CHECK(forPOSIXsignalinterface,pgac_cv_func_posix_signals,
184-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <signal.h>
185-
],
186-
[struct sigaction act, oact;
187-
sigemptyset(&act.sa_mask);
188-
act.sa_flags = SA_RESTART;
189-
sigaction(0, &act, &oact);])],
190-
[pgac_cv_func_posix_signals=yes],
191-
[pgac_cv_func_posix_signals=no])])
192-
if test x"$pgac_cv_func_posix_signals" = xyes ; then
193-
AC_DEFINE(HAVE_POSIX_SIGNALS,1,
194-
[Define to 1 if you have the POSIX signal interface.])
195-
fi
196-
HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
197-
AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
198-
199-
200173
# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
201174
# ---------------------------------------
202175
# Determine which length modifier snprintf uses for long long int. We

‎configure

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ XGETTEXT
649649
MSGMERGE
650650
MSGFMT_FLAGS
651651
MSGFMT
652-
HAVE_POSIX_SIGNALS
653652
PG_CRC32C_OBJS
654653
CFLAGS_SSE42
655654
have_win32_dbghelp
@@ -12289,7 +12288,7 @@ fi
1228912288
LIBS_including_readline="$LIBS"
1229012289
LIBS=`echo"$LIBS"| sed -e's/-ledit//g' -e's/-lreadline//g'`
1229112290

12292-
forac_funcin cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_opensigprocmasksymlink sync_file_range towlower utime utimes wcstombs wcstombs_l
12291+
forac_funcin 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
1229312292
do:
1229412293
as_ac_var=`$as_echo"ac_cv_func_$ac_func"|$as_tr_sh`
1229512294
ac_fn_c_check_func"$LINENO""$ac_func""$as_ac_var"
@@ -13048,38 +13047,6 @@ esac
1304813047

1304913048
fi
1305013049

13051-
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for sigsetjmp">&5
13052-
$as_echo_n"checking for sigsetjmp...">&6; }
13053-
if${pgac_cv_func_sigsetjmp+:}false;then:
13054-
$as_echo_n"(cached)">&6
13055-
else
13056-
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
13057-
/* end confdefs.h. */
13058-
#include <setjmp.h>
13059-
int
13060-
main ()
13061-
{
13062-
sigjmp_buf x; sigsetjmp(x, 1);
13063-
;
13064-
return 0;
13065-
}
13066-
_ACEOF
13067-
if ac_fn_c_try_link"$LINENO";then:
13068-
pgac_cv_func_sigsetjmp=yes
13069-
else
13070-
pgac_cv_func_sigsetjmp=no
13071-
fi
13072-
rm -f core conftest.err conftest.$ac_objext \
13073-
conftest$ac_exeext conftest.$ac_ext
13074-
fi
13075-
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_func_sigsetjmp">&5
13076-
$as_echo"$pgac_cv_func_sigsetjmp">&6; }
13077-
iftest x"$pgac_cv_func_sigsetjmp" = x"yes";then
13078-
13079-
$as_echo"#define HAVE_SIGSETJMP 1">>confdefs.h
13080-
13081-
fi
13082-
1308313050
ac_fn_c_check_decl"$LINENO""sys_siglist""ac_cv_have_decl_sys_siglist""#include <signal.h>
1308413051
/* NetBSD declares sys_siglist in unistd.h. */
1308513052
#ifdef HAVE_UNISTD_H
@@ -14635,54 +14602,6 @@ fi
1463514602

1463614603

1463714604

14638-
# Check that POSIX signals are available if thread safety is enabled.
14639-
iftest"$PORTNAME"!="win32"
14640-
then
14641-
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for POSIX signal interface">&5
14642-
$as_echo_n"checking for POSIX signal interface...">&6; }
14643-
if${pgac_cv_func_posix_signals+:}false;then:
14644-
$as_echo_n"(cached)">&6
14645-
else
14646-
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
14647-
/* end confdefs.h. */
14648-
#include <signal.h>
14649-
14650-
int
14651-
main ()
14652-
{
14653-
struct sigaction act, oact;
14654-
sigemptyset(&act.sa_mask);
14655-
act.sa_flags = SA_RESTART;
14656-
sigaction(0, &act, &oact);
14657-
;
14658-
return 0;
14659-
}
14660-
_ACEOF
14661-
if ac_fn_c_try_link"$LINENO";then:
14662-
pgac_cv_func_posix_signals=yes
14663-
else
14664-
pgac_cv_func_posix_signals=no
14665-
fi
14666-
rm -f core conftest.err conftest.$ac_objext \
14667-
conftest$ac_exeext conftest.$ac_ext
14668-
fi
14669-
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_func_posix_signals">&5
14670-
$as_echo"$pgac_cv_func_posix_signals">&6; }
14671-
iftest x"$pgac_cv_func_posix_signals" = xyes;then
14672-
14673-
$as_echo"#define HAVE_POSIX_SIGNALS 1">>confdefs.h
14674-
14675-
fi
14676-
HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
14677-
14678-
iftest"$pgac_cv_func_posix_signals"!= yes -a"$enable_thread_safety" = yes;then
14679-
as_fn_error$?"
14680-
Thread-safety requires POSIX signals, which are not supported by this
14681-
operating system; use --disable-thread-safety to disable thread safety.""$LINENO" 5
14682-
fi
14683-
fi
14684-
14685-
1468614605
# Select semaphore implementation type.
1468714606
iftest"$PORTNAME"!="win32";then
1468814607
iftest x"$USE_NAMED_POSIX_SEMAPHORES" = x"1";then

‎configure.in

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
14061406
LIBS_including_readline="$LIBS"
14071407
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
14081408

1409-
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_opensigprocmasksymlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
1409+
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])
14101410

14111411
AC_REPLACE_FUNCS(fseeko)
14121412
case $host_os in
@@ -1596,18 +1596,6 @@ if test "$PORTNAME" = "cygwin"; then
15961596
AC_LIBOBJ(dirmod)
15971597
fi
15981598

1599-
dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
1600-
dnl (especially on GNU libc)
1601-
dnl See also comments in c.h.
1602-
AC_CACHE_CHECK([for sigsetjmp], pgac_cv_func_sigsetjmp,
1603-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <setjmp.h>],
1604-
[sigjmp_buf x; sigsetjmp(x, 1);])],
1605-
[pgac_cv_func_sigsetjmp=yes],
1606-
[pgac_cv_func_sigsetjmp=no])])
1607-
if test x"$pgac_cv_func_sigsetjmp" = x"yes"; then
1608-
AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
1609-
fi
1610-
16111599
AC_CHECK_DECLS([sys_siglist], [], [],
16121600
[#include <signal.h>
16131601
/* NetBSD declares sys_siglist in unistd.h. */
@@ -1932,18 +1920,6 @@ fi
19321920
AC_SUBST(PG_CRC32C_OBJS)
19331921

19341922

1935-
# Check that POSIX signals are available if thread safety is enabled.
1936-
if test "$PORTNAME" != "win32"
1937-
then
1938-
PGAC_FUNC_POSIX_SIGNALS
1939-
if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
1940-
AC_MSG_ERROR([
1941-
Thread-safety requires POSIX signals, which are not supported by this
1942-
operating system; use --disable-thread-safety to disable thread safety.])
1943-
fi
1944-
fi
1945-
1946-
19471923
# Select semaphore implementation type.
19481924
if test "$PORTNAME" != "win32"; then
19491925
if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then

‎src/Makefile.global.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,6 @@ host_cpu = @host_cpu@
432432
# Make HAVE_IPV6 available for initdb script creation
433433
HAVE_IPV6= @HAVE_IPV6@
434434

435-
# The HP-UX port makefile, for one, needs access to this symbol
436-
HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
437-
438435
# This is mainly for use on FreeBSD, where we have both a.out and elf
439436
# systems now. May be applicable to other systems to?
440437
ELF_SYSTEM= @ELF_SYS@

‎src/backend/libpq/pqsignal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include"libpq/pqsignal.h"
1919

2020

21-
#ifdefHAVE_SIGPROCMASK
21+
#ifndefWIN32
2222
sigset_tUnBlockSig,
2323
BlockSig,
2424
StartupBlockSig;
@@ -45,7 +45,7 @@ intUnBlockSig,
4545
void
4646
pqinitmask(void)
4747
{
48-
#ifdefHAVE_SIGPROCMASK
48+
#ifndefWIN32
4949

5050
sigemptyset(&UnBlockSig);
5151

@@ -101,7 +101,7 @@ pqinitmask(void)
101101
#ifdefSIGALRM
102102
sigdelset(&StartupBlockSig,SIGALRM);
103103
#endif
104-
#else
104+
#else/* WIN32 */
105105
/* Set the signals we want. */
106106
UnBlockSig=0;
107107
BlockSig=sigmask(SIGQUIT) |

‎src/include/c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,9 @@ extern intvsnprintf(char *str, size_t count, const char *fmt, va_list args);
10511051
/*
10521052
* When there is no sigsetjmp, its functionality is provided by plain
10531053
* setjmp. Incidentally, nothing provides setjmp's functionality in
1054-
* that case.
1054+
* that case. We now support the case only on Windows.
10551055
*/
1056-
#ifndefHAVE_SIGSETJMP
1056+
#ifdefWIN32
10571057
#definesigjmp_buf jmp_buf
10581058
#definesigsetjmp(x,y) setjmp(x)
10591059
#definesiglongjmp longjmp

‎src/include/libpq/pqsignal.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515

1616
#include<signal.h>
1717

18-
#ifdefHAVE_SIGPROCMASK
18+
#ifndefWIN32
1919
externsigset_tUnBlockSig,
2020
BlockSig,
2121
StartupBlockSig;
2222

2323
#definePG_SETMASK(mask)sigprocmask(SIG_SETMASK, mask, NULL)
24-
#else/* not HAVE_SIGPROCMASK */
24+
#else/* WIN32 */
25+
/*
26+
* Windows doesn't provide the POSIX signal API, so we use something
27+
* approximating the old BSD signal API.
28+
*/
2529
externintUnBlockSig,
2630
BlockSig,
2731
StartupBlockSig;
2832

29-
#ifndefWIN32
30-
#definePG_SETMASK(mask)sigsetmask(*((int*)(mask)))
31-
#else
32-
#definePG_SETMASK(mask)pqsigsetmask(*((int*)(mask)))
33-
intpqsigsetmask(intmask);
34-
#endif
33+
externintpqsigsetmask(intmask);
3534

35+
#definePG_SETMASK(mask)pqsigsetmask(*(mask))
3636
#definesigaddset(set,signum)(*(set) |= (sigmask(signum)))
3737
#definesigdelset(set,signum)(*(set) &= ~(sigmask(signum)))
38-
#endif/*not HAVE_SIGPROCMASK */
38+
#endif/*WIN32 */
3939

4040
externvoidpqinitmask(void);
4141

‎src/include/pg_config.h.in

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,6 @@
379379
/* Define to 1 if you have the `posix_fadvise' function. */
380380
#undef HAVE_POSIX_FADVISE
381381

382-
/* Define to 1 if you have the POSIX signal interface. */
383-
#undef HAVE_POSIX_SIGNALS
384-
385382
/* Define to 1 if the assembler supports PPC's LWARX mutex hint bit. */
386383
#undef HAVE_PPC_LWARX_MUTEX_HINT
387384

@@ -443,12 +440,6 @@
443440
/* Define to 1 if you have the `shm_open' function. */
444441
#undef HAVE_SHM_OPEN
445442

446-
/* Define to 1 if you have the `sigprocmask' function. */
447-
#undef HAVE_SIGPROCMASK
448-
449-
/* Define to 1 if you have sigsetjmp(). */
450-
#undef HAVE_SIGSETJMP
451-
452443
/* Define to 1 if you have the `snprintf' function. */
453444
#undef HAVE_SNPRINTF
454445

‎src/include/pg_config.h.win32

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@
264264
/* Define to 1 if you have the <poll.h> header file. */
265265
/* #undef HAVE_POLL_H */
266266

267-
/* Define to 1 if you have the POSIX signal interface. */
268-
/* #undef HAVE_POSIX_SIGNALS */
269-
270267
/* Define to 1 if you have the `pstat' function. */
271268
/* #undef HAVE_PSTAT */
272269

@@ -316,12 +313,6 @@
316313
/* Define to 1 if you have the `setsid' function. */
317314
/* #undef HAVE_SETSID */
318315

319-
/* Define to 1 if you have the `sigprocmask' function. */
320-
/* #undef HAVE_SIGPROCMASK */
321-
322-
/* Define to 1 if you have sigsetjmp(). */
323-
/* #undef HAVE_SIGSETJMP */
324-
325316
/* Define to 1 if you have the `snprintf' function. */
326317
/* #undef HAVE_SNPRINTF */
327318

‎src/makefiles/Makefile.hpux

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# If we don't have POSIX signals, we need to use the libBSD signal routines.
2-
# (HPUX 9 and early HPUX 10 releases don't have POSIX signals.) Link in
3-
# libBSD only in that case.
4-
ifeq ($(HAVE_POSIX_SIGNALS), no)
5-
LIBS := -lBSD $(LIBS)
6-
endif
7-
81
# Using X/Open Networking Interfaces requires to link with libxnet.
92
# Without specifying this, bind(), getpeername() and so on don't work
103
# correctly in the LP64 data model.

‎src/port/pqsignal.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,17 @@
1111
* IDENTIFICATION
1212
* src/port/pqsignal.c
1313
*
14-
*A NOTE ABOUT SIGNAL HANDLING ACROSS THE VARIOUS PLATFORMS.
15-
*
16-
*pg_config.h defines the macro HAVE_POSIX_SIGNALS for some platforms and
17-
*not for others. We use that here to decide how to handle signalling.
18-
*
19-
*Ultrix and SunOS provide BSD signal(2) semantics by default.
20-
*
21-
*SVID2 and POSIX signal(2) semantics differ from BSD signal(2)
22-
*semantics. We can use the POSIX sigaction(2) on systems that
23-
*allow us to request restartable signals (SA_RESTART).
24-
*
25-
*Some systems don't allow restartable signals at all unless we
26-
*link to a special BSD library.
27-
*
28-
*We devoutly hope that there aren't any Unix-oid systems that provide
29-
*neither POSIX signals nor BSD signals. The alternative is to do
30-
*signal-handler reinstallation, which doesn't work well at all.
14+
*We now assume that all Unix-oid systems have POSIX sigaction(2)
15+
*with support for restartable signals (SA_RESTART). We used to also
16+
*support BSD-style signal(2), but there really shouldn't be anything
17+
*out there anymore that doesn't have the POSIX API.
3118
*
3219
*Windows, of course, is resolutely in a class by itself. In the backend,
3320
*we don't use this file at all; src/backend/port/win32/signal.c provides
3421
*pqsignal() for the backend environment. Frontend programs can use
35-
*this version of pqsignal() if they wish, but beware thatWindows
36-
*requires signal-handler reinstallation, because indeed it provides
37-
*neither POSIX signals nor BSD signals :-(
22+
*this version of pqsignal() if they wish, but beware thatthis does
23+
*not provide restartable signals on Windows.
24+
*
3825
* ------------------------------------------------------------------------
3926
*/
4027

@@ -52,9 +39,7 @@
5239
pqsigfunc
5340
pqsignal(intsigno,pqsigfuncfunc)
5441
{
55-
#if !defined(HAVE_POSIX_SIGNALS)
56-
returnsignal(signo,func);
57-
#else
42+
#ifndefWIN32
5843
structsigactionact,
5944
oact;
6045

@@ -68,7 +53,9 @@ pqsignal(int signo, pqsigfunc func)
6853
if (sigaction(signo,&act,&oact)<0)
6954
returnSIG_ERR;
7055
returnoact.sa_handler;
71-
#endif/* !HAVE_POSIX_SIGNALS */
56+
#else/* WIN32 */
57+
returnsignal(signo,func);
58+
#endif
7259
}
7360

7461
#endif/* !defined(WIN32) || defined(FRONTEND) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp