To: vim_dev@googlegroups.com Subject: Patch 8.2.5061 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5061 Problem: C89 requires signal handlers to return void. Solution: Drop RETSIGTYPE and hard-code a void return value. Files: src/configure.ac, src/auto/configure, src/if_cscope.c, src/os_unix.c, src/pty.c, src/os_mac.h, src/os_vms_conf.h, src/config.h.in, src/osdef1.h.in *** ../vim-8.2.5060/src/configure.ac 2022-06-05 20:03:11.107910014 +0100 --- src/configure.ac 2022-06-05 21:59:49.612896873 +0100 *************** *** 3644,3660 **** 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([ --- 3644,3649 ---- *** ../vim-8.2.5060/src/auto/configure 2022-06-05 20:03:11.107910014 +0100 --- src/auto/configure 2022-06-05 21:59:52.300891825 +0100 *************** *** 12412,12459 **** 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 - #include - - 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 --- 12412,12417 ---- *** ../vim-8.2.5060/src/if_cscope.c 2022-02-12 11:18:32.318462415 +0000 --- src/if_cscope.c 2022-06-05 21:53:46.305588743 +0100 *************** *** 2181,2191 **** /* * Used to catch and ignore SIGALRM below. */ ! static RETSIGTYPE sig_handler SIGDEFARG(sigarg) { // do nothing - SIGRETURN; } #endif --- 2181,2190 ---- /* * Used to catch and ignore SIGALRM below. */ ! static void sig_handler SIGDEFARG(sigarg) { // do nothing } #endif *** ../vim-8.2.5060/src/os_unix.c 2022-06-05 16:55:50.698774344 +0100 --- src/os_unix.c 2022-06-05 21:56:44.841246066 +0100 *************** *** 99,105 **** static int sysmouse_open(void); static void sysmouse_close(void); ! static RETSIGTYPE sig_sysmouse SIGPROTOARG; #endif /* --- 99,105 ---- static int sysmouse_open(void); static void sysmouse_close(void); ! static void sig_sysmouse SIGPROTOARG; #endif /* *************** *** 171,203 **** static void handle_resize(void); #if defined(SIGWINCH) ! static RETSIGTYPE sig_winch SIGPROTOARG; #endif #if defined(SIGTSTP) ! static RETSIGTYPE 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; #endif #if defined(SIGUSR1) ! static RETSIGTYPE catch_sigusr1 SIGPROTOARG; #endif #if defined(SIGPWR) ! static RETSIGTYPE catch_sigpwr SIGPROTOARG; #endif #if defined(SIGALRM) && defined(FEAT_X11) && !defined(FEAT_GUI_GTK) # define SET_SIG_ALARM ! static RETSIGTYPE 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 catch_int_signal(void); static void set_signals(void); ! static void catch_signals(RETSIGTYPE (*func_deadly)(), RETSIGTYPE (*func_other)()); #ifdef HAVE_SIGPROCMASK # define SIGSET_DECL(set) sigset_t set; # define BLOCK_SIGNALS(set) block_signals(set) --- 171,203 ---- static void handle_resize(void); #if defined(SIGWINCH) ! static void sig_winch SIGPROTOARG; #endif #if defined(SIGTSTP) ! 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 void catch_sigint SIGPROTOARG; #endif #if defined(SIGUSR1) ! static void catch_sigusr1 SIGPROTOARG; #endif #if defined(SIGPWR) ! static void catch_sigpwr SIGPROTOARG; #endif #if defined(SIGALRM) && defined(FEAT_X11) && !defined(FEAT_GUI_GTK) # define SET_SIG_ALARM ! 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 void deathtrap SIGPROTOARG; static void catch_int_signal(void); static void set_signals(void); ! 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,219 **** static int save_patterns(int num_pat, char_u **pat, int *num_file, char_u ***file); #ifndef SIG_ERR ! # define SIG_ERR ((RETSIGTYPE (*)())-1) #endif // volatile because it is used in signal handler sig_winch(). --- 213,219 ---- static int save_patterns(int num_pat, char_u **pat, int *num_file, char_u ***file); #ifndef SIG_ERR ! # define SIG_ERR ((void (*)())-1) #endif // volatile because it is used in signal handler sig_winch(). *************** *** 864,881 **** * Let me try it with a few tricky defines from my own osdef.h (jw). */ #if defined(SIGWINCH) ! static RETSIGTYPE sig_winch SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch); do_resize = TRUE; - SIGRETURN; } #endif #if defined(SIGTSTP) ! static RETSIGTYPE sig_tstp SIGDEFARG(sigarg) { // Second time we get called we actually need to suspend --- 864,880 ---- * Let me try it with a few tricky defines from my own osdef.h (jw). */ #if defined(SIGWINCH) ! static void sig_winch SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGWINCH, (void (*)())sig_winch); do_resize = TRUE; } #endif #if defined(SIGTSTP) ! static void sig_tstp SIGDEFARG(sigarg) { // Second time we get called we actually need to suspend *************** *** 890,936 **** #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); #endif - SIGRETURN; } #endif #if defined(SIGINT) ! static RETSIGTYPE catch_sigint SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGINT, (RETSIGTYPE (*)())catch_sigint); got_int = TRUE; - SIGRETURN; } #endif #if defined(SIGUSR1) ! static RETSIGTYPE catch_sigusr1 SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1); got_sigusr1 = TRUE; - SIGRETURN; } #endif #if defined(SIGPWR) ! static RETSIGTYPE catch_sigpwr SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGPWR, (RETSIGTYPE (*)())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 --- 889,931 ---- #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, (void (*)())sig_tstp); #endif } #endif #if defined(SIGINT) ! static void catch_sigint SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGINT, (void (*)())catch_sigint); got_int = TRUE; } #endif #if defined(SIGUSR1) ! static void catch_sigusr1 SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! signal(SIGUSR1, (void (*)())catch_sigusr1); got_sigusr1 = TRUE; } #endif #if defined(SIGPWR) ! static void catch_sigpwr SIGDEFARG(sigarg) { // this is not required on all systems, but it doesn't hurt anybody ! 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); } #endif *************** *** 938,949 **** /* * signal function for alarm(). */ ! static RETSIGTYPE sig_alarm SIGDEFARG(sigarg) { // doesn't do anything, just to break a system call sig_alarm_called = TRUE; - SIGRETURN; } #endif --- 933,943 ---- /* * signal function for alarm(). */ ! static void sig_alarm SIGDEFARG(sigarg) { // doesn't do anything, just to break a system call sig_alarm_called = TRUE; } #endif *************** *** 1021,1027 **** * NOTE: Avoid unsafe functions, such as allocating memory, they can result in * a deadlock. */ ! static RETSIGTYPE deathtrap SIGDEFARG(sigarg) { static int entered = 0; // count the number of times we got here. --- 1015,1021 ---- * NOTE: Avoid unsafe functions, such as allocating memory, they can result in * a deadlock. */ ! static void deathtrap SIGDEFARG(sigarg) { static int entered = 0; // count the number of times we got here. *************** *** 1054,1060 **** // 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; # endif // When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return --- 1048,1054 ---- // 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) ! return; # endif // When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return *************** *** 1082,1088 **** # endif ) && !vim_handle_signal(sigarg)) ! SIGRETURN; #endif // Remember how often we have been called. --- 1076,1082 ---- # endif ) && !vim_handle_signal(sigarg)) ! return; #endif // Remember how often we have been called. *************** *** 1181,1188 **** may_core_dump(); abort(); #endif - - SIGRETURN; } /* --- 1175,1180 ---- *************** *** 1202,1208 **** } #if defined(SIGCONT) ! static RETSIGTYPE sigcont_handler SIGPROTOARG; /* * With multi-threading, suspending might not work immediately. Catch the --- 1194,1200 ---- } #if defined(SIGCONT) ! static void sigcont_handler SIGPROTOARG; /* * With multi-threading, suspending might not work immediately. Catch the *************** *** 1216,1227 **** * volatile because it is used in signal handler sigcont_handler(). */ static volatile sig_atomic_t sigcont_received; ! static RETSIGTYPE sigcont_handler SIGPROTOARG; /* * signal handler for SIGCONT */ ! static RETSIGTYPE sigcont_handler SIGDEFARG(sigarg) { if (in_mch_suspend) --- 1208,1219 ---- * volatile because it is used in signal handler sigcont_handler(). */ static volatile sig_atomic_t sigcont_received; ! static void sigcont_handler SIGPROTOARG; /* * signal handler for SIGCONT */ ! static void sigcont_handler SIGDEFARG(sigarg) { if (in_mch_suspend) *************** *** 1239,1246 **** cursor_on_force(); out_flush(); } - - SIGRETURN; } #endif --- 1231,1236 ---- *************** *** 1392,1398 **** /* * WINDOW CHANGE signal is handled with sig_winch(). */ ! signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch); #endif #ifdef SIGTSTP --- 1382,1388 ---- /* * WINDOW CHANGE signal is handled with sig_winch(). */ ! signal(SIGWINCH, (void (*)())sig_winch); #endif #ifdef SIGTSTP *************** *** 1404,1410 **** # ifdef FEAT_GUI : gui.in_use || gui.starting ? SIG_DFL # endif ! : (RETSIGTYPE (*)())sig_tstp); #endif #if defined(SIGCONT) signal(SIGCONT, sigcont_handler); --- 1394,1400 ---- # ifdef FEAT_GUI : gui.in_use || gui.starting ? SIG_DFL # endif ! : (void (*)())sig_tstp); #endif #if defined(SIGCONT) signal(SIGCONT, sigcont_handler); *************** *** 1424,1430 **** /* * Call user's handler on SIGUSR1 */ ! signal(SIGUSR1, (RETSIGTYPE (*)())catch_sigusr1); #endif /* --- 1414,1420 ---- /* * Call user's handler on SIGUSR1 */ ! signal(SIGUSR1, (void (*)())catch_sigusr1); #endif /* *************** *** 1439,1445 **** * Catch SIGPWR (power failure?) to preserve the swap files, so that no * work will be lost. */ ! signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr); #endif /* --- 1429,1435 ---- * Catch SIGPWR (power failure?) to preserve the swap files, so that no * work will be lost. */ ! signal(SIGPWR, (void (*)())catch_sigpwr); #endif /* *************** *** 1463,1469 **** static void catch_int_signal(void) { ! signal(SIGINT, (RETSIGTYPE (*)())catch_sigint); } #endif --- 1453,1459 ---- static void catch_int_signal(void) { ! signal(SIGINT, (void (*)())catch_sigint); } #endif *************** *** 1479,1486 **** static void catch_signals( ! RETSIGTYPE (*func_deadly)(), ! RETSIGTYPE (*func_other)()) { int i; --- 1469,1476 ---- static void catch_signals( ! void (*func_deadly)(), ! void (*func_other)()) { int i; *************** *** 1932,1938 **** if (x11_window != 0 && x11_display == NULL) { #ifdef SET_SIG_ALARM ! RETSIGTYPE (*sig_save)(); #endif #ifdef ELAPSED_FUNC elapsed_T start_tv; --- 1922,1928 ---- if (x11_window != 0 && x11_display == NULL) { #ifdef SET_SIG_ALARM ! void (*sig_save)(); #endif #ifdef ELAPSED_FUNC elapsed_T start_tv; *************** *** 1947,1961 **** * the network connection is bad. Set an alarm timer to get out. */ sig_alarm_called = FALSE; ! sig_save = (RETSIGTYPE (*)())signal(SIGALRM, ! (RETSIGTYPE (*)())sig_alarm); alarm(2); #endif x11_display = XOpenDisplay(NULL); #ifdef SET_SIG_ALARM alarm(0); ! signal(SIGALRM, (RETSIGTYPE (*)())sig_save); if (p_verbose > 0 && sig_alarm_called) verb_msg(_("Opening the X display timed out")); #endif --- 1937,1950 ---- * the network connection is bad. Set an alarm timer to get out. */ sig_alarm_called = FALSE; ! sig_save = (void (*)())signal(SIGALRM, (void (*)())sig_alarm); alarm(2); #endif x11_display = XOpenDisplay(NULL); #ifdef SET_SIG_ALARM alarm(0); ! signal(SIGALRM, (void (*)())sig_save); if (p_verbose > 0 && sig_alarm_called) verb_msg(_("Opening the X display timed out")); #endif *************** *** 7267,7273 **** // 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); # endif return 1; // succeed } --- 7256,7262 ---- // 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 : (void (*)())sig_tstp); # endif return 1; // succeed } *************** *** 7400,7406 **** mouse.u.mode.signal = SIGUSR2; if (ioctl(1, CONS_MOUSECTL, &mouse) != -1) { ! signal(SIGUSR2, (RETSIGTYPE (*)())sig_sysmouse); mouse.operation = MOUSE_SHOW; ioctl(1, CONS_MOUSECTL, &mouse); return OK; --- 7389,7395 ---- mouse.u.mode.signal = SIGUSR2; if (ioctl(1, CONS_MOUSECTL, &mouse) != -1) { ! signal(SIGUSR2, (void (*)())sig_sysmouse); mouse.operation = MOUSE_SHOW; ioctl(1, CONS_MOUSECTL, &mouse); return OK; *************** *** 7427,7433 **** /* * Gets info from sysmouse and adds special keys to input buf. */ ! static RETSIGTYPE sig_sysmouse SIGDEFARG(sigarg) { struct mouse_info mouse; --- 7416,7422 ---- /* * Gets info from sysmouse and adds special keys to input buf. */ ! static void sig_sysmouse SIGDEFARG(sigarg) { struct mouse_info mouse; *************** *** 8357,8363 **** /* * Handle SIGALRM for a timeout. */ ! static RETSIGTYPE set_flag SIGDEFARG(sigarg) { if (alarm_pending) --- 8346,8352 ---- /* * Handle SIGALRM for a timeout. */ ! static void set_flag SIGDEFARG(sigarg) { if (alarm_pending) *** ../vim-8.2.5060/src/pty.c 2022-02-07 10:45:12.799027338 +0000 --- src/pty.c 2022-06-05 21:55:33.957381410 +0100 *************** *** 188,194 **** { int f; char *m; ! RETSIGTYPE (*sigcld) SIGPROTOARG; static char TtyName[32]; // used for opening a new pty-pair if ((f = posix_openpt(O_RDWR | O_NOCTTY | O_EXTRA)) == -1) --- 188,194 ---- { int f; char *m; ! 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,265 **** { int f; char *name; ! RETSIGTYPE (*sigcld) SIGPROTOARG; /* * SIGCHLD set to SIG_DFL for _getpty() because it may fork() and --- 259,265 ---- { int f; char *name; ! void (*sigcld) SIGPROTOARG; /* * SIGCHLD set to SIG_DFL for _getpty() because it may fork() and *************** *** 312,318 **** { int f; char *m; ! RETSIGTYPE (*sigcld) SIGPROTOARG; // used for opening a new pty-pair: static char TtyName[32]; --- 312,318 ---- { int f; char *m; ! void (*sigcld) SIGPROTOARG; // used for opening a new pty-pair: static char TtyName[32]; *** ../vim-8.2.5060/src/os_mac.h 2022-06-05 16:55:50.694774344 +0100 --- src/os_mac.h 2022-06-05 21:57:12.729193056 +0100 *************** *** 250,257 **** #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 --- 250,255 ---- *** ../vim-8.2.5060/src/os_vms_conf.h 2022-05-12 20:35:32.327574779 +0100 --- src/os_vms_conf.h 2022-06-05 21:57:20.541178233 +0100 *************** *** 65,82 **** // Define if you have the nanosleep() function. // #undef HAVE_NANOSLEEP - // Define if you can safely include both and . - #define TIME_WITH_SYS_TIME - // Define if you can safely include both and . // #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 --- 65,73 ---- *** ../vim-8.2.5060/src/config.h.in 2022-06-05 16:55:50.690774344 +0100 --- src/config.h.in 2022-06-05 21:57:06.241205368 +0100 *************** *** 132,143 **** #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 --- 132,137 ---- *** ../vim-8.2.5060/src/osdef1.h.in 2020-02-26 15:15:31.072386953 +0000 --- src/osdef1.h.in 2022-06-05 22:01:43.168684256 +0100 *************** *** 105,113 **** extern int toupper(int); extern int tolower(int); ! extern RETSIGTYPE (*signal(int, RETSIGTYPE (*func) SIGPROTOARG)) SIGPROTOARG; #ifdef HAVE_SIGSET ! extern RETSIGTYPE (*sigset(int, RETSIGTYPE (*func) SIGPROTOARG)) SIGPROTOARG; #endif #if defined(HAVE_SETJMP_H) --- 105,113 ---- extern int toupper(int); extern int tolower(int); ! extern void (*signal(int, void (*func) SIGPROTOARG)) SIGPROTOARG; #ifdef HAVE_SIGSET ! extern void (*sigset(int, void (*func) SIGPROTOARG)) SIGPROTOARG; #endif #if defined(HAVE_SETJMP_H) *** ../vim-8.2.5060/src/version.c 2022-06-05 20:03:11.111910014 +0100 --- src/version.c 2022-06-05 22:00:41.348799854 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5061, /**/ -- MESKIMEN'S LAW There's never time to do it right, but always time to do it over. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///