[glib] gmain: Use sig_atomic_t for list of pending Unix signals
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gmain: Use sig_atomic_t for list of pending Unix signals
- Date: Fri, 16 Mar 2012 21:10:58 +0000 (UTC)
commit 6833385c5a7a35e22bb549ad0e7f390031952945
Author: Colin Walters <walters verbum org>
Date: Tue Mar 13 14:49:04 2012 -0400
gmain: Use sig_atomic_t for list of pending Unix signals
Pointed out by: Simon McVittie <simon mcvittie collabora co uk>
https://bugzilla.gnome.org/show_bug.cgi?id=671997
configure.ac | 12 ++++++++++++
glib/gmain.c | 9 +++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 88a2011..f5197ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -577,6 +577,18 @@ AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)
+AC_CACHE_CHECK([for sig_atomic_t], ac_cv_type_sig_atomic_t,
+ [AC_TRY_LINK([#include <signal.h>
+ #include <sys/types.h>
+ sig_atomic_t val = 42;],
+ [return val == 42 ? 0 : 1],
+ ac_cv_type_sig_atomic_t=yes,
+ ac_cv_type_sig_atomic_t=no)])
+if test x$ac_cv_type_sig_atomic_t = xyes; then
+ AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
+ [Define if you have the 'sig_atomic_t' type.])
+fi
+
if test x$ac_cv_sizeof_long = x8 || test x$ac_cv_sizeof_long_long = x8 || test x$ac_cv_sizeof___int64 = x8 ; then
:
else
diff --git a/glib/gmain.c b/glib/gmain.c
index e37744a..077a935 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -388,8 +388,13 @@ static GMainContext *default_main_context;
/* UNIX signals work by marking one of these variables then waking the
* worker context to check on them and dispatch accordingly.
*/
-static volatile gchar unix_signal_pending[NSIG];
-static volatile gboolean any_unix_signal_pending;
+#ifdef HAVE_SIG_ATOMIC_T
+static volatile sig_atomic_t unix_signal_pending[NSIG];
+static volatile sig_atomic_t any_unix_signal_pending;
+#else
+static volatile int unix_signal_pending[NSIG];
+static volatile int any_unix_signal_pending;
+#endif
/* Guards all the data below */
G_LOCK_DEFINE_STATIC (unix_signal_lock);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]