Mercurial > hg > octave-terminal
changeset 10246:f751dae7aab8
use gnulib signal modules
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 02 Feb 2010 04:39:29 -0500 |
parents | 4ea0bda308b7 |
children | edfceeab945a |
files | ChangeLog acinclude.m4 bootstrap.conf configure.ac src/ChangeLog src/sighandlers.cc src/sighandlers.h |
diffstat | 7 files changed, 28 insertions(+), 174 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-02-02 John W. Eaton <jwe@octave.org> + + * configure.ac: Don't call OCTAVE_SIGNAL_CHECK, + OCTAVE_REINSTALL_SIGHANDLERS, AC_C_CONST, AC_HEADER_STDC, or + AC_STRUCT_TM, AC_TYPE_SIGNAL. + Don't define RETSIGTYPE_IS_VOID. + * acinclude.m4 (OCTAVE_SIGNAL_CHECK, OCTAVE_REINSTALL_SIGHANDLERS): + Don't call AC_TYPE_SIGNAL. Assume sighandler return type is void. + (OCTAVE_SIGNAL_CHECK, OCTAVE_REINSTALL_SIGHANDLERS): Delete macros. + * bootstrap.conf (gnulib_modules): Include sigaction, signal, + and sigprocmask in the list. + 2010-02-02 John W. Eaton <jwe@octave.org> * configure.ac: Don't check for stdint.h.
--- a/acinclude.m4 +++ b/acinclude.m4 @@ -173,109 +173,6 @@ AC_DEFINE(SMART_PUTENV,1,[To quiet autoheader.]) fi]) dnl -dnl These two checks for signal functions were originally part of the -dnl aclocal.m4 file distributed with bash 2.0. -dnl -dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) -AC_DEFUN([OCTAVE_SIGNAL_CHECK], -[AC_REQUIRE([AC_TYPE_SIGNAL]) -AC_MSG_CHECKING([for type of signal functions]) -AC_CACHE_VAL(octave_cv_signal_vintage, -[ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], - [[sigset_t ss; - struct sigaction sa; - sigemptyset (&ss); - sigsuspend (&ss); - sigaction (SIGINT, &sa, (struct sigaction *) 0); - sigprocmask (SIG_BLOCK, &ss, (sigset_t *) 0);]])], - [octave_cv_signal_vintage=posix], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], - [[int mask = sigmask (SIGINT); - sigsetmask (mask); - sigblock (mask); - sigpause (mask);]])], - [octave_cv_signal_vintage=4.2bsd], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h> - RETSIGTYPE foo() { }]], - [[int mask = sigmask (SIGINT); - sigset (SIGINT, foo); - sigrelse (SIGINT); - sighold (SIGINT); - sigpause (SIGINT);]])], - [octave_cv_signal_vintage=svr3], - [octave_cv_signal_vintage=v7])])])]) -AC_MSG_RESULT([$octave_cv_signal_vintage]) -if test "$octave_cv_signal_vintage" = posix; then -AC_DEFINE(HAVE_POSIX_SIGNALS, 1, [Define if you have POSIX style signals.]) -elif test "$octave_cv_signal_vintage" = "4.2bsd"; then -AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define if you have BSD style signals.]) -elif test "$octave_cv_signal_vintage" = svr3; then -AC_DEFINE(HAVE_USG_SIGHOLD, 1, [Define if you have System V Release 3 signals.]) -fi -]) -dnl -AC_DEFUN([OCTAVE_REINSTALL_SIGHANDLERS], -[AC_REQUIRE([AC_TYPE_SIGNAL]) -AC_REQUIRE([OCTAVE_SIGNAL_CHECK]) -AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked]) -AC_CACHE_VAL(octave_cv_must_reinstall_sighandlers, -[AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#include <signal.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -typedef RETSIGTYPE sigfunc(); -int nsigint; -#ifdef HAVE_POSIX_SIGNALS -sigfunc * -set_signal_handler(sig, handler) - int sig; - sigfunc *handler; -{ - struct sigaction act, oact; - act.sa_handler = handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigemptyset (&oact.sa_mask); - sigaction (sig, &act, &oact); - return (oact.sa_handler); -} -#else -#define set_signal_handler(s, h) signal(s, h) -#endif -RETSIGTYPE -sigint(s) - int s; -{ - nsigint++; -} -main() -{ - nsigint = 0; - set_signal_handler(SIGINT, sigint); - kill((int)getpid(), SIGINT); - kill((int)getpid(), SIGINT); - exit(nsigint != 2); -} -]])], - octave_cv_must_reinstall_sighandlers=no, - octave_cv_must_reinstall_sighandlers=yes, -if test "$octave_cv_signal_vintage" = svr3; then - octave_cv_must_reinstall_sighandlers=yes -else - octave_cv_must_reinstall_sighandlers=no -fi)]) -if test "$cross_compiling" = yes; then - AC_MSG_RESULT([$octave_cv_must_reinstall_sighandlers assumed for cross compilation]) -else - AC_MSG_RESULT([$octave_cv_must_reinstall_sighandlers]) -fi -if test "$octave_cv_must_reinstall_sighandlers" = yes; then - AC_DEFINE(MUST_REINSTALL_SIGHANDLERS,1,[Define if signal handlers must be reinstalled after they are called.]) -fi -]) -dnl dnl Check to see if C++ compiler needs the new friend template declaration dnl syntax. dnl
--- a/bootstrap.conf +++ b/bootstrap.conf @@ -32,6 +32,9 @@ readlink rename rmdir + sigaction + signal + sigprocmask stat stdint strftime
--- a/configure.ac +++ b/configure.ac @@ -1429,7 +1429,6 @@ ### Does the C compiler handle alloca() and const correctly? AC_FUNC_ALLOCA -AC_C_CONST ### See if we should use placement delete. @@ -1449,7 +1448,6 @@ ### Checks for header files. -AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_SYS_WAIT @@ -1691,7 +1689,6 @@ AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev]) -AC_STRUCT_TM AC_STRUCT_TIMEZONE AC_FUNC_CLOSEDIR_VOID @@ -1724,7 +1721,6 @@ ### Signal stuff. -AC_TYPE_SIGNAL AC_CHECK_DECLS([sys_siglist], [], [], [#include <signal.h> /* NetBSD declares sys_siglist in unistd.h. */ @@ -1732,11 +1728,6 @@ # include <unistd.h> #endif ]) -OCTAVE_SIGNAL_CHECK -OCTAVE_REINSTALL_SIGHANDLERS -if test "$ac_cv_type_signal" = "void"; then - AC_DEFINE(RETSIGTYPE_IS_VOID, 1, [Define if this if RETSIGTYPE is defined to be void. Needed because preprocessor comparisons to void fail on some systems.]) -fi ### A system dependent kluge or two.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,10 @@ 2010-02-02 John W. Eaton <jwe@octave.org> * octave.cc (octave_main): Assume we have atexit. + * sighandlers.h, sighandlers.cc: Delete conditional definition + of RETSIGTYPE. Replace all uses of RETSIGTYPE with void. + (MAYBE_REINSTALL_SIGHANDLER, SIGHANDLER_RETURN): + Delete macros and all uses. 2010-02-01 Jaroslav Hajek <highegg@gmail.com>
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -71,21 +71,6 @@ // Similar to Vsighup_dumps_octave_core, but for SIGTERM signal. static bool Vsigterm_dumps_octave_core = true; -#if defined (RETSIGTYPE_IS_VOID) -#define SIGHANDLER_RETURN(status) return -#else -#define SIGHANDLER_RETURN(status) return status -#endif - -#if defined (MUST_REINSTALL_SIGHANDLERS) -#define MAYBE_REINSTALL_SIGHANDLER(sig, handler) \ - octave_set_signal_handler (sig, handler) -#define REINSTALL_USES_SIG 1 -#else -#define MAYBE_REINSTALL_SIGHANDLER(sig, handler) \ - do { } while (0) -#endif - #if defined (__EMX__) #define MAYBE_ACK_SIGNAL(sig) \ octave_set_signal_handler (sig, SIG_ACK) @@ -188,7 +173,6 @@ octave_set_signal_handler (int sig, sig_handler *handler, bool restart_syscalls) { -#if defined (HAVE_POSIX_SIGNALS) struct sigaction act, oact; act.sa_handler = handler; @@ -212,23 +196,18 @@ sigaction (sig, &act, &oact); return oact.sa_handler; -#else - return signal (sig, handler); -#endif } -static RETSIGTYPE +static void generic_sig_handler (int sig) { my_friendly_exit (strsignal (sig), sig); - - SIGHANDLER_RETURN (0); } // Handle SIGCHLD. #ifdef SIGCHLD -static RETSIGTYPE +static void sigchld_handler (int /* sig */) { volatile octave_interrupt_handler saved_interrupt_handler @@ -265,22 +244,16 @@ #endif MAYBE_ACK_SIGNAL (SIGCHLD); - - MAYBE_REINSTALL_SIGHANDLER (SIGCHLD, sigchld_handler); - - SIGHANDLER_RETURN (0); } #endif /* defined(SIGCHLD) */ #ifdef SIGFPE #if defined (__alpha__) -static RETSIGTYPE +static void sigfpe_handler (int /* sig */) { MAYBE_ACK_SIGNAL (SIGFPE); - MAYBE_REINSTALL_SIGHANDLER (SIGFPE, sigfpe_handler); - if (can_interrupt && octave_interrupt_state >= 0) { octave_signal_caught = 1; @@ -289,20 +262,16 @@ octave_interrupt_state++; } - - SIGHANDLER_RETURN (0); } #endif /* defined(__alpha__) */ #endif /* defined(SIGFPE) */ #if defined (SIGHUP) || defined (SIGTERM) -static RETSIGTYPE +static void sig_hup_or_term_handler (int sig) { MAYBE_ACK_SIGNAL (sig); - MAYBE_REINSTALL_SIGHANDLER (sig, sig_hup_or_term_handler); - switch (sig) { #if defined (SIGHUP) @@ -328,23 +297,17 @@ } clean_up_and_exit (0); - - SIGHANDLER_RETURN (0); } #endif #if 0 #if defined (SIGWINCH) -static RETSIGTYPE +static void sigwinch_handler (int /* sig */) { MAYBE_ACK_SIGNAL (SIGWINCH); - MAYBE_REINSTALL_SIGHANDLER (SIGWINCH, sigwinch_handler); - command_editor::resize_terminal (); - - SIGHANDLER_RETURN (0); } #endif #endif @@ -411,13 +374,11 @@ } -static RETSIGTYPE +static void sigint_handler (int sig) { MAYBE_ACK_SIGNAL (sig); - MAYBE_REINSTALL_SIGHANDLER (sig, sigint_handler); - #ifdef USE_W32_SIGINT if (w32_in_main_thread ()) user_abort (strsignal (sig), sig); @@ -426,18 +387,14 @@ #else user_abort (strsignal (sig), sig); #endif - - SIGHANDLER_RETURN (0); } #ifdef SIGPIPE -static RETSIGTYPE +static void sigpipe_handler (int /* sig */) { MAYBE_ACK_SIGNAL (SIGPIPE); - MAYBE_REINSTALL_SIGHANDLER (SIGPIPE, sigpipe_handler); - octave_signal_caught = 1; octave_signals_caught[SIGPIPE] = true; @@ -446,8 +403,6 @@ if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0) octave_interrupt_state++; - - SIGHANDLER_RETURN (0); } #endif /* defined(SIGPIPE) */
--- a/src/sighandlers.h +++ b/src/sighandlers.h @@ -45,11 +45,8 @@ #include "base-list.h" // Signal handler return type. -#ifndef RETSIGTYPE -#define RETSIGTYPE void -#endif #ifndef BADSIG -#define BADSIG (RETSIGTYPE (*)(int))-1 +#define BADSIG (void (*)(int))-1 #endif #define BLOCK_SIGNAL(sig, nvar, ovar) \ @@ -66,15 +63,10 @@ #define SIGCHLD SIGCLD #endif -#if defined (HAVE_POSIX_SIGNALS) #define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar) #define UNBLOCK_CHILD(ovar) sigprocmask (SIG_SETMASK, &ovar, 0) -#else -#define BLOCK_CHILD(nvar, ovar) ovar = sigblock (sigmask (SIGCHLD)) -#define UNBLOCK_CHILD(ovar) sigsetmask (ovar) -#endif -typedef RETSIGTYPE sig_handler (int); +typedef void sig_handler (int); // FIXME -- the data should probably be private...