patch 8.2.5061: C89 requires signal handlers to return void

Problem:    C89 requires signal handlers to return void.
Solution:   Drop RETSIGTYPE and hard-code a void return value.
This commit is contained in:
Bram Moolenaar
2022-06-05 22:05:19 +01:00
parent de1d734379
commit 99c48fe997
10 changed files with 49 additions and 129 deletions

42
src/auto/configure vendored
View File

@ -12412,48 +12412,6 @@ $as_echo "don't know" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
$as_echo_n "checking return type of signal handlers... " >&6; }
if ${ac_cv_type_signal+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <signal.h>
int
main ()
{
return *(signal (0, 0)) (0) == 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_type_signal=int
else
ac_cv_type_signal=void
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
$as_echo "$ac_cv_type_signal" >&6; }
cat >>confdefs.h <<_ACEOF
#define RETSIGTYPE $ac_cv_type_signal
_ACEOF
if test $ac_cv_type_signal = void; then
$as_echo "#define SIGRETURN return" >>confdefs.h
else
$as_echo "#define SIGRETURN return 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct sigcontext" >&5
$as_echo_n "checking for struct sigcontext... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

View File

@ -132,12 +132,6 @@
#undef PTYRANGE0
#undef PTYRANGE1
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Define as the command at the end of signal handlers ("" or "return 0;"). */
#undef SIGRETURN
/* Define if struct sigcontext is present */
#undef HAVE_SIGCONTEXT

View File

@ -3644,17 +3644,6 @@ fi
dnl Checks for library functions. ===================================
dnl TODO: this generates an obsolete warning, would need to remove and replace
dnl all RETSIGTYPE with "void" and SIGRETURN with "return".
AC_TYPE_SIGNAL
dnl find out what to use at the end of a signal function
if test $ac_cv_type_signal = void; then
AC_DEFINE(SIGRETURN, [return])
else
AC_DEFINE(SIGRETURN, [return 0])
fi
dnl check if struct sigcontext is defined (used for SGI only)
AC_MSG_CHECKING(for struct sigcontext)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([

View File

@ -2181,11 +2181,10 @@ cs_read_prompt(int i)
/*
* Used to catch and ignore SIGALRM below.
*/
static RETSIGTYPE
static void
sig_handler SIGDEFARG(sigarg)
{
// do nothing
SIGRETURN;
}
#endif

View File

@ -250,8 +250,6 @@
#endif
#undef HAVE_AVAIL_MEM
#ifndef HAVE_CONFIG_H
# define RETSIGTYPE void
# define SIGRETURN return
//# define USE_SYSTEM // Output ship do debugger :(, but not compile
# define HAVE_SYS_WAIT_H 1 // Attempt
# define HAVE_TERMIOS_H 1

View File

@ -99,7 +99,7 @@ static int mch_gpm_process(void);
static int sysmouse_open(void);
static void sysmouse_close(void);
static RETSIGTYPE sig_sysmouse SIGPROTOARG;
static void sig_sysmouse SIGPROTOARG;
#endif
/*
@ -171,33 +171,33 @@ static int do_xterm_trace(void);
static void handle_resize(void);
#if defined(SIGWINCH)
static RETSIGTYPE sig_winch SIGPROTOARG;
static void sig_winch SIGPROTOARG;
#endif
#if defined(SIGTSTP)
static RETSIGTYPE sig_tstp SIGPROTOARG;
static void sig_tstp SIGPROTOARG;
// volatile because it is used in signal handler sig_tstp() and sigcont_handler().
static volatile sig_atomic_t in_mch_suspend = FALSE;
#endif
#if defined(SIGINT)
static RETSIGTYPE catch_sigint SIGPROTOARG;
static void catch_sigint SIGPROTOARG;
#endif
#if defined(SIGUSR1)
static RETSIGTYPE catch_sigusr1 SIGPROTOARG;
static void catch_sigusr1 SIGPROTOARG;
#endif
#if defined(SIGPWR)
static RETSIGTYPE catch_sigpwr SIGPROTOARG;
static void catch_sigpwr SIGPROTOARG;
#endif
#if defined(SIGALRM) && defined(FEAT_X11) && !defined(FEAT_GUI_GTK)
# define SET_SIG_ALARM
static RETSIGTYPE sig_alarm SIGPROTOARG;
static void sig_alarm SIGPROTOARG;
// volatile because it is used in signal handler sig_alarm().
static volatile sig_atomic_t sig_alarm_called;
#endif
static RETSIGTYPE deathtrap SIGPROTOARG;
static void deathtrap SIGPROTOARG;
static void catch_int_signal(void);
static void set_signals(void);
static void catch_signals(RETSIGTYPE (*func_deadly)(), RETSIGTYPE (*func_other)());
static void catch_signals(void (*func_deadly)(), void (*func_other)());
#ifdef HAVE_SIGPROCMASK
# define SIGSET_DECL(set) sigset_t set;
# define BLOCK_SIGNALS(set) block_signals(set)
@ -213,7 +213,7 @@ static int have_dollars(int, char_u **);
static int save_patterns(int num_pat, char_u **pat, int *num_file, char_u ***file);
#ifndef SIG_ERR
# define SIG_ERR ((RETSIGTYPE (*)())-1)
# define SIG_ERR ((void (*)())-1)
#endif
// volatile because it is used in signal handler sig_winch().
@ -864,18 +864,17 @@ init_signal_stack(void)
* Let me try it with a few tricky defines from my own osdef.h (jw).
*/
#if defined(SIGWINCH)
static RETSIGTYPE
static void
sig_winch SIGDEFARG(sigarg)
{
// this is not required on all systems, but it doesn't hurt anybody
signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch);
signal(SIGWINCH, (void (*)())sig_winch);
do_resize = TRUE;
SIGRETURN;
}
#endif
#if defined(SIGTSTP)
static RETSIGTYPE
static void
sig_tstp SIGDEFARG(sigarg)
{
// Second time we get called we actually need to suspend
@ -890,47 +889,43 @@ sig_tstp SIGDEFARG(sigarg)
#if !defined(__ANDROID__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
// This is not required on all systems. On some systems (at least Android,
// OpenBSD, and DragonFlyBSD) this breaks suspending with CTRL-Z.
signal(SIGTSTP, (RETSIGTYPE (*)())sig_tstp);
signal(SIGTSTP, (void (*)())sig_tstp);
#endif
SIGRETURN;
}
#endif
#if defined(SIGINT)
static RETSIGTYPE
static void
catch_sigint SIGDEFARG(sigarg)
{
// this is not required on all systems, but it doesn't hurt anybody
signal(SIGINT, (RETSIGTYPE (*)())catch_sigint);
signal(SIGINT, (void (*)())catch_sigint);
got_int = TRUE;
SIGRETURN;
}
#endif
#if defined(SIGUSR1)
static RETSIGTYPE
static void
catch_sigusr1 SIGDEFARG(sigarg)
{
// this is not required on all systems, but it doesn't hurt anybody
signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1);
signal(SIGUSR1, (void (*)())catch_sigusr1);
got_sigusr1 = TRUE;
SIGRETURN;
}
#endif
#if defined(SIGPWR)
static RETSIGTYPE
static void
catch_sigpwr SIGDEFARG(sigarg)
{
// this is not required on all systems, but it doesn't hurt anybody
signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr);
signal(SIGPWR, (void (*)())catch_sigpwr);
/*
* I'm not sure we get the SIGPWR signal when the system is really going
* down or when the batteries are almost empty. Just preserve the swap
* files and don't exit, that can't do any harm.
*/
ml_sync_all(FALSE, FALSE);
SIGRETURN;
}
#endif
@ -938,12 +933,11 @@ catch_sigpwr SIGDEFARG(sigarg)
/*
* signal function for alarm().
*/
static RETSIGTYPE
static void
sig_alarm SIGDEFARG(sigarg)
{
// doesn't do anything, just to break a system call
sig_alarm_called = TRUE;
SIGRETURN;
}
#endif
@ -1021,7 +1015,7 @@ mch_didjmp(void)
* NOTE: Avoid unsafe functions, such as allocating memory, they can result in
* a deadlock.
*/
static RETSIGTYPE
static void
deathtrap SIGDEFARG(sigarg)
{
static int entered = 0; // count the number of times we got here.
@ -1054,7 +1048,7 @@ deathtrap SIGDEFARG(sigarg)
// interrupt us. But in cooked mode we may also get SIGQUIT, e.g., when
// pressing CTRL-\, but we don't want Vim to exit then.
if (in_mch_delay && sigarg == SIGQUIT)
SIGRETURN;
return;
# endif
// When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return
@ -1082,7 +1076,7 @@ deathtrap SIGDEFARG(sigarg)
# endif
)
&& !vim_handle_signal(sigarg))
SIGRETURN;
return;
#endif
// Remember how often we have been called.
@ -1181,8 +1175,6 @@ deathtrap SIGDEFARG(sigarg)
may_core_dump();
abort();
#endif
SIGRETURN;
}
/*
@ -1202,7 +1194,7 @@ after_sigcont(void)
}
#if defined(SIGCONT)
static RETSIGTYPE sigcont_handler SIGPROTOARG;
static void sigcont_handler SIGPROTOARG;
/*
* With multi-threading, suspending might not work immediately. Catch the
@ -1216,12 +1208,12 @@ static RETSIGTYPE sigcont_handler SIGPROTOARG;
* volatile because it is used in signal handler sigcont_handler().
*/
static volatile sig_atomic_t sigcont_received;
static RETSIGTYPE sigcont_handler SIGPROTOARG;
static void sigcont_handler SIGPROTOARG;
/*
* signal handler for SIGCONT
*/
static RETSIGTYPE
static void
sigcont_handler SIGDEFARG(sigarg)
{
if (in_mch_suspend)
@ -1239,8 +1231,6 @@ sigcont_handler SIGDEFARG(sigarg)
cursor_on_force();
out_flush();
}
SIGRETURN;
}
#endif
@ -1392,7 +1382,7 @@ set_signals(void)
/*
* WINDOW CHANGE signal is handled with sig_winch().
*/
signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch);
signal(SIGWINCH, (void (*)())sig_winch);
#endif
#ifdef SIGTSTP
@ -1404,7 +1394,7 @@ set_signals(void)
# ifdef FEAT_GUI
: gui.in_use || gui.starting ? SIG_DFL
# endif
: (RETSIGTYPE (*)())sig_tstp);
: (void (*)())sig_tstp);
#endif
#if defined(SIGCONT)
signal(SIGCONT, sigcont_handler);
@ -1424,7 +1414,7 @@ set_signals(void)
/*
* Call user's handler on SIGUSR1
*/
signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1);
signal(SIGUSR1, (void (*)())catch_sigusr1);
#endif
/*
@ -1439,7 +1429,7 @@ set_signals(void)
* Catch SIGPWR (power failure?) to preserve the swap files, so that no
* work will be lost.
*/
signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr);
signal(SIGPWR, (void (*)())catch_sigpwr);
#endif
/*
@ -1463,7 +1453,7 @@ set_signals(void)
static void
catch_int_signal(void)
{
signal(SIGINT, (RETSIGTYPE (*)())catch_sigint);
signal(SIGINT, (void (*)())catch_sigint);
}
#endif
@ -1479,8 +1469,8 @@ reset_signals(void)
static void
catch_signals(
RETSIGTYPE (*func_deadly)(),
RETSIGTYPE (*func_other)())
void (*func_deadly)(),
void (*func_other)())
{
int i;
@ -1932,7 +1922,7 @@ get_x11_windis(void)
if (x11_window != 0 && x11_display == NULL)
{
#ifdef SET_SIG_ALARM
RETSIGTYPE (*sig_save)();
void (*sig_save)();
#endif
#ifdef ELAPSED_FUNC
elapsed_T start_tv;
@ -1947,15 +1937,14 @@ get_x11_windis(void)
* the network connection is bad. Set an alarm timer to get out.
*/
sig_alarm_called = FALSE;
sig_save = (RETSIGTYPE (*)())signal(SIGALRM,
(RETSIGTYPE (*)())sig_alarm);
sig_save = (void (*)())signal(SIGALRM, (void (*)())sig_alarm);
alarm(2);
#endif
x11_display = XOpenDisplay(NULL);
#ifdef SET_SIG_ALARM
alarm(0);
signal(SIGALRM, (RETSIGTYPE (*)())sig_save);
signal(SIGALRM, (void (*)())sig_save);
if (p_verbose > 0 && sig_alarm_called)
verb_msg(_("Opening the X display timed out"));
#endif
@ -7267,7 +7256,7 @@ gpm_open(void)
// we are going to suspend or starting an external process
// so we shouldn't have problem with this
# ifdef SIGTSTP
signal(SIGTSTP, restricted ? SIG_IGN : (RETSIGTYPE (*)())sig_tstp);
signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
# endif
return 1; // succeed
}
@ -7400,7 +7389,7 @@ sysmouse_open(void)
mouse.u.mode.signal = SIGUSR2;
if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
{
signal(SIGUSR2, (RETSIGTYPE (*)())sig_sysmouse);
signal(SIGUSR2, (void (*)())sig_sysmouse);
mouse.operation = MOUSE_SHOW;
ioctl(1, CONS_MOUSECTL, &mouse);
return OK;
@ -7427,7 +7416,7 @@ sysmouse_close(void)
/*
* Gets info from sysmouse and adds special keys to input buf.
*/
static RETSIGTYPE
static void
sig_sysmouse SIGDEFARG(sigarg)
{
struct mouse_info mouse;
@ -8357,7 +8346,7 @@ static int alarm_pending = FALSE;
/*
* Handle SIGALRM for a timeout.
*/
static RETSIGTYPE
static void
set_flag SIGDEFARG(sigarg)
{
if (alarm_pending)

View File

@ -65,18 +65,9 @@
// Define if you have the nanosleep() function.
// #undef HAVE_NANOSLEEP
// Define if you can safely include both <sys/time.h> and <time.h>.
#define TIME_WITH_SYS_TIME
// Define if you can safely include both <sys/time.h> and <sys/select.h>.
// #undef SYS_SELECT_WITH_SYS_TIME
// Define as the return type of signal handlers (int or void).
#define RETSIGTYPE void
// Define as the command at the end of signal handlers ("" or "return 0;").
#define SIGRETURN return
// Define if struct sigcontext is present
#define HAVE_SIGCONTEXT

View File

@ -105,9 +105,9 @@ extern int waitpid(pid_t, int *, int);
extern int toupper(int);
extern int tolower(int);
extern RETSIGTYPE (*signal(int, RETSIGTYPE (*func) SIGPROTOARG)) SIGPROTOARG;
extern void (*signal(int, void (*func) SIGPROTOARG)) SIGPROTOARG;
#ifdef HAVE_SIGSET
extern RETSIGTYPE (*sigset(int, RETSIGTYPE (*func) SIGPROTOARG)) SIGPROTOARG;
extern void (*sigset(int, void (*func) SIGPROTOARG)) SIGPROTOARG;
#endif
#if defined(HAVE_SETJMP_H)

View File

@ -188,7 +188,7 @@ mch_openpty(char **ttyn)
{
int f;
char *m;
RETSIGTYPE (*sigcld) SIGPROTOARG;
void (*sigcld) SIGPROTOARG;
static char TtyName[32]; // used for opening a new pty-pair
if ((f = posix_openpt(O_RDWR | O_NOCTTY | O_EXTRA)) == -1)
@ -259,7 +259,7 @@ mch_openpty(char **ttyn)
{
int f;
char *name;
RETSIGTYPE (*sigcld) SIGPROTOARG;
void (*sigcld) SIGPROTOARG;
/*
* SIGCHLD set to SIG_DFL for _getpty() because it may fork() and
@ -312,7 +312,7 @@ mch_openpty(char **ttyn)
{
int f;
char *m;
RETSIGTYPE (*sigcld) SIGPROTOARG;
void (*sigcld) SIGPROTOARG;
// used for opening a new pty-pair:
static char TtyName[32];

View File

@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
5061,
/**/
5060,
/**/