summaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-05 22:05:19 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-05 22:05:19 +0100
commit99c48fe9974b8d70ca33674658a3da722b0d6466 (patch)
treedffbad61a62ddf128e2c258fc24bd96c5ccaf4bb /src/os_unix.c
parentde1d7343794a950bd624043901ce7b3caca3c49b (diff)
downloadvim-git-99c48fe9974b8d70ca33674658a3da722b0d6466.tar.gz
patch 8.2.5061: C89 requires signal handlers to return voidv8.2.5061
Problem: C89 requires signal handlers to return void. Solution: Drop RETSIGTYPE and hard-code a void return value.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c93
1 files changed, 41 insertions, 52 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 28113fcb3..b23adb710 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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)