diff options
Diffstat (limited to 'common/ve-signal.c')
-rw-r--r-- | common/ve-signal.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/common/ve-signal.c b/common/ve-signal.c index 76f7ed4e..2492b2ff 100644 --- a/common/ve-signal.c +++ b/common/ve-signal.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Signal routines * @@ -11,7 +11,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -34,127 +34,127 @@ typedef struct _SignalSource SignalSource; struct _SignalSource { - GSource source; + GSource source; - int signal; - guint8 index; - guint8 shift; + int signal; + guint8 index; + guint8 shift; }; -static guint32 signals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +static guint32 signals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static gboolean ve_signal_prepare (GSource *source, - int *timeout) + int *timeout) { - SignalSource *ss = (SignalSource *)source; + SignalSource *ss = (SignalSource *)source; - return signals_notified[ss->index] & (1 << ss->shift); + return signals_notified[ss->index] & (1 << ss->shift); } static gboolean ve_signal_check (GSource *source) { - SignalSource *ss = (SignalSource *)source; + SignalSource *ss = (SignalSource *)source; - return signals_notified[ss->index] & (1 << ss->shift); + return signals_notified[ss->index] & (1 << ss->shift); } static gboolean ve_signal_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data) + GSourceFunc callback, + gpointer user_data) { - SignalSource *ss = (SignalSource *)source; + SignalSource *ss = (SignalSource *)source; - signals_notified[ss->index] &= ~(1 << ss->shift); + signals_notified[ss->index] &= ~(1 << ss->shift); - return ((VeSignalFunc)callback) (ss->signal, user_data); + return ((VeSignalFunc)callback) (ss->signal, user_data); } static GSourceFuncs signal_funcs = { - ve_signal_prepare, - ve_signal_check, - ve_signal_dispatch + ve_signal_prepare, + ve_signal_check, + ve_signal_dispatch }; guint -ve_signal_add (int signal, - VeSignalFunc function, - gpointer data) +ve_signal_add (int signal, + VeSignalFunc function, + gpointer data) { - return ve_signal_add_full (G_PRIORITY_DEFAULT, signal, function, data, NULL); + return ve_signal_add_full (G_PRIORITY_DEFAULT, signal, function, data, NULL); } guint ve_signal_add_full (int priority, - int signal, - VeSignalFunc function, - gpointer data, - GDestroyNotify destroy) + int signal, + VeSignalFunc function, + gpointer data, + GDestroyNotify destroy) { - GSource *source; - SignalSource *ss; - guint s = 128 + signal; + GSource *source; + SignalSource *ss; + guint s = 128 + signal; - g_return_val_if_fail (function != NULL, 0); + g_return_val_if_fail (function != NULL, 0); - source = g_source_new (&signal_funcs, sizeof (SignalSource)); - ss = (SignalSource *)source; + source = g_source_new (&signal_funcs, sizeof (SignalSource)); + ss = (SignalSource *)source; - ss->signal = signal; - ss->index = s / 32; - ss->shift = s % 32; + ss->signal = signal; + ss->index = s / 32; + ss->shift = s % 32; - g_assert (ss->index < 8); + g_assert (ss->index < 8); - g_source_set_priority (source, priority); - g_source_set_callback (source, (GSourceFunc)function, data, destroy); - g_source_set_can_recurse (source, TRUE); + g_source_set_priority (source, priority); + g_source_set_callback (source, (GSourceFunc)function, data, destroy); + g_source_set_can_recurse (source, TRUE); - return g_source_attach (source, NULL); + return g_source_attach (source, NULL); } void ve_signal_notify (int signal) { - guint index, shift; - guint s = 128 + signal; + guint index, shift; + guint s = 128 + signal; - index = s / 32; - shift = s % 32; + index = s / 32; + shift = s % 32; - g_assert (index < 8); + g_assert (index < 8); - signals_notified[index] |= 1 << shift; + signals_notified[index] |= 1 << shift; - g_main_context_wakeup (NULL); + g_main_context_wakeup (NULL); } gboolean ve_signal_was_notified (int signal) { - guint index, shift; - guint s = 128 + signal; + guint index, shift; + guint s = 128 + signal; - index = s / 32; - shift = s % 32; + index = s / 32; + shift = s % 32; - g_assert (index < 8); + g_assert (index < 8); - return ((signals_notified[index]) & (1 << shift)) ? TRUE : FALSE; + return ((signals_notified[index]) & (1 << shift)) ? TRUE : FALSE; } void ve_signal_unnotify (int signal) { - guint index, shift; - guint s = 128 + signal; + guint index, shift; + guint s = 128 + signal; - index = s / 32; - shift = s % 32; + index = s / 32; + shift = s % 32; - g_assert (index < 8); + g_assert (index < 8); - signals_notified[index] &= ~(1 << shift); + signals_notified[index] &= ~(1 << shift); } |