summaryrefslogtreecommitdiffstats
path: root/tests/sighook.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-10-10 10:24:27 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-10-10 11:18:06 -0400
commitf6f0613b47ff731ad8c65ec90d12e643d3e27c55 (patch)
tree82c1e7f7b3c2dd663a22701ad02a94b05bb25f22 /tests/sighook.c
parent881d590d23730fff6bf8f37e10d998226180cd65 (diff)
downloadbfs-f6f0613b47ff731ad8c65ec90d12e643d3e27c55.tar.xz
tests/sighook: Use the new xtimer_start() API
Diffstat (limited to 'tests/sighook.c')
-rw-r--r--tests/sighook.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/sighook.c b/tests/sighook.c
index aa01c36..d785a55 100644
--- a/tests/sighook.c
+++ b/tests/sighook.c
@@ -4,14 +4,14 @@
#include "tests.h"
#include "atomic.h"
-#include "thread.h"
#include "sighook.h"
+#include "thread.h"
+#include "xtime.h"
#include <stddef.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
-#include <sys/time.h>
/** Counts SIGALRM deliveries. */
static atomic size_t count = 0;
@@ -61,10 +61,9 @@ void check_sighook(void) {
}
// Create a timer that sends SIGALRM every 100 microseconds
- struct itimerval ival = {0};
- ival.it_value.tv_usec = 100;
- ival.it_interval.tv_usec = 100;
- if (!bfs_echeck(setitimer(ITIMER_REAL, &ival, NULL) == 0)) {
+ struct timespec ival = { .tv_nsec = 100 * 1000 };
+ struct timer *timer = xtimer_start(&ival);
+ if (!bfs_echeck(timer)) {
goto unhook;
}
@@ -104,8 +103,7 @@ void check_sighook(void) {
bfs_echeck(errno == 0, "pthread_sigmask()");
untime:
// Stop the timer
- ival.it_value.tv_usec = 0;
- bfs_echeck(setitimer(ITIMER_REAL, &ival, NULL) == 0);
+ xtimer_stop(timer);
unhook:
// Unregister the SIGALRM hook
sigunhook(hook);