From 1d3132c08fd8600f8b1e680e6d15db26663fccca Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 31 Oct 2012 11:33:50 +0400 Subject: [PATCH] Clarify of sig_atomic_t usage (got from Mutt). Signed-off-by: Andrew Borodin --- configure.ac | 34 ++++++++++++++++++++++++++++++++++ lib/global.h | 2 +- lib/tty/tty.c | 2 +- lib/vfs/netutil.c | 2 +- lib/vfs/netutil.h | 2 +- src/execute.c | 2 +- 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 066cc0449..71ef7d9bd 100644 --- a/configure.ac +++ b/configure.ac @@ -186,6 +186,40 @@ AC_TYPE_UID_T AC_STRUCT_ST_BLOCKS AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev]) +AH_TEMPLATE([sig_atomic_t], + [/* Define to `int' if doesn't define.]) +AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T], + [Some systems declare sig_atomic_t as volatile, some others -- no. + This define will have value `sig_atomic_t' or + `volatile sig_atomic_t' accordingly.]) + +AC_MSG_CHECKING(for sig_atomic_t in signal.h) +AC_EGREP_HEADER(sig_atomic_t,signal.h, + [ + ac_cv_type_sig_atomic_t=yes; + AC_EGREP_HEADER(volatile.*sig_atomic_t, + signal.h, + [ + is_sig_atomic_t_volatile=yes; + AC_MSG_RESULT([yes, volatile]) + ], + [ + is_sig_atomic_t_volatile=no; + AC_MSG_RESULT([yes, non volatile]) + ]) + ], + [ + AC_MSG_RESULT(no) + AC_CHECK_TYPE(sig_atomic_t, int) + is_sig_atomic_t_volatile=no + ]) +if test $is_sig_atomic_t_volatile = 'yes' +then + AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t) +else + AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t]) +fi + dnl ############################################################################ dnl Check for functions diff --git a/lib/global.h b/lib/global.h index a4767b214..580ec0673 100644 --- a/lib/global.h +++ b/lib/global.h @@ -265,7 +265,7 @@ typedef struct gboolean alternate_plus_minus; /* Set if the window has changed it's size */ - volatile sig_atomic_t winch_flag; + SIG_ATOMIC_VOLATILE_T winch_flag; } tty; struct diff --git a/lib/tty/tty.c b/lib/tty/tty.c index 54756f9f9..564837ef7 100644 --- a/lib/tty/tty.c +++ b/lib/tty/tty.c @@ -62,7 +62,7 @@ int mc_tty_frm[MC_TTY_FRM_MAX]; /*** file scope variables ************************************************************************/ -static volatile sig_atomic_t got_interrupt = 0; +static SIG_ATOMIC_VOLATILE_T got_interrupt = 0; /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/vfs/netutil.c b/lib/vfs/netutil.c index cd51906cb..6d6ed6660 100644 --- a/lib/vfs/netutil.c +++ b/lib/vfs/netutil.c @@ -36,7 +36,7 @@ /*** global variables ****************************************************************************/ -volatile sig_atomic_t got_sigpipe = 0; +SIG_ATOMIC_VOLATILE_T got_sigpipe = 0; /*** file scope macro definitions ****************************************************************/ diff --git a/lib/vfs/netutil.h b/lib/vfs/netutil.h index 18fdbc283..9a1274584 100644 --- a/lib/vfs/netutil.h +++ b/lib/vfs/netutil.h @@ -16,7 +16,7 @@ /*** global variables defined in .c file *********************************************************/ -extern volatile sig_atomic_t got_sigpipe; +extern SIG_ATOMIC_VOLATILE_T got_sigpipe; /*** declarations of public functions ************************************************************/ diff --git a/src/execute.c b/src/execute.c index ba1b0c6dd..5d4f250e3 100644 --- a/src/execute.c +++ b/src/execute.c @@ -319,7 +319,7 @@ toggle_panels (void) vfs_path_t **new_dir_p; #endif /* ENABLE_SUBSHELL */ - volatile sig_atomic_t was_sigwinch = 0; + SIG_ATOMIC_VOLATILE_T was_sigwinch = 0; channels_down (); disable_mouse (); -- 2.11.4.GIT