summaryrefslogtreecommitdiff
path: root/src/atimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/atimer.c')
-rw-r--r--src/atimer.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/atimer.c b/src/atimer.c
index 060dead9b17..34731920af5 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
-#include <signal.h>
#include <stdio.h>
#include <setjmp.h>
#include "lisp.h"
@@ -51,8 +50,24 @@ int pending_atimers;
/* Block/unblock SIGALRM. */
-#define BLOCK_ATIMERS sigblock (sigmask (SIGALRM))
-#define UNBLOCK_ATIMERS sigunblock (sigmask (SIGALRM))
+static void
+sigmask_atimers (int how)
+{
+ sigset_t blocked;
+ sigemptyset (&blocked);
+ sigaddset (&blocked, SIGALRM);
+ pthread_sigmask (how, &blocked, 0);
+}
+static void
+block_atimers (void)
+{
+ sigmask_atimers (SIG_BLOCK);
+}
+static void
+unblock_atimers (void)
+{
+ sigmask_atimers (SIG_UNBLOCK);
+}
/* Function prototypes. */
@@ -109,7 +124,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn,
t->fn = fn;
t->client_data = client_data;
- BLOCK_ATIMERS;
+ block_atimers ();
/* Compute the timer's expiration time. */
switch (type)
@@ -130,7 +145,7 @@ start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn,
/* Insert the timer in the list of active atimers. */
schedule_atimer (t);
- UNBLOCK_ATIMERS;
+ unblock_atimers ();
/* Arrange for a SIGALRM at the time the next atimer is ripe. */
set_alarm ();
@@ -146,7 +161,7 @@ cancel_atimer (struct atimer *timer)
{
int i;
- BLOCK_ATIMERS;
+ block_atimers ();
for (i = 0; i < 2; ++i)
{
@@ -173,7 +188,7 @@ cancel_atimer (struct atimer *timer)
}
}
- UNBLOCK_ATIMERS;
+ unblock_atimers ();
}
@@ -204,7 +219,7 @@ append_atimer_lists (struct atimer *list_1, struct atimer *list_2)
void
stop_other_atimers (struct atimer *t)
{
- BLOCK_ATIMERS;
+ block_atimers ();
if (t)
{
@@ -229,7 +244,7 @@ stop_other_atimers (struct atimer *t)
stopped_atimers = append_atimer_lists (atimers, stopped_atimers);
atimers = t;
- UNBLOCK_ATIMERS;
+ unblock_atimers ();
}
@@ -244,7 +259,7 @@ run_all_atimers (void)
struct atimer *t = atimers;
struct atimer *next;
- BLOCK_ATIMERS;
+ block_atimers ();
atimers = stopped_atimers;
stopped_atimers = NULL;
@@ -255,7 +270,7 @@ run_all_atimers (void)
t = next;
}
- UNBLOCK_ATIMERS;
+ unblock_atimers ();
}
}
@@ -397,9 +412,9 @@ do_pending_atimers (void)
{
if (pending_atimers)
{
- BLOCK_ATIMERS;
+ block_atimers ();
run_timers ();
- UNBLOCK_ATIMERS;
+ unblock_atimers ();
}
}
@@ -412,7 +427,9 @@ turn_on_atimers (bool on)
{
if (on)
{
- signal (SIGALRM, deliver_alarm_signal);
+ struct sigaction action;
+ emacs_sigaction_init (&action, deliver_alarm_signal);
+ sigaction (SIGALRM, &action, 0);
set_alarm ();
}
else
@@ -423,8 +440,10 @@ turn_on_atimers (bool on)
void
init_atimer (void)
{
+ struct sigaction action;
free_atimers = stopped_atimers = atimers = NULL;
pending_atimers = 0;
/* pending_signals is initialized in init_keyboard.*/
- signal (SIGALRM, deliver_alarm_signal);
+ emacs_sigaction_init (&action, deliver_alarm_signal);
+ sigaction (SIGALRM, &action, 0);
}