summaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/posix-timer.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/posix/posix-timer.c
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/posix/posix-timer.c')
-rw-r--r--lib/mlibc/tests/posix/posix-timer.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/lib/mlibc/tests/posix/posix-timer.c b/lib/mlibc/tests/posix/posix-timer.c
deleted file mode 100644
index d097818..0000000
--- a/lib/mlibc/tests/posix/posix-timer.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <assert.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
-
-int main() {
- struct sigevent evp;
- memset(&evp, 0, sizeof(evp));
-
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGUSR1);
- sigprocmask(SIG_BLOCK, &set, 0);
- evp.sigev_notify = SIGEV_SIGNAL;
- evp.sigev_signo = SIGUSR1;
-
- struct timeval start;
- gettimeofday(&start, NULL);
-
- timer_t timer;
- if (timer_create(CLOCK_MONOTONIC, &evp, &timer)) {
- perror("timer_create");
- exit(1);
- }
-
- struct itimerspec spec;
- memset(&spec, 0, sizeof(spec));
- spec.it_value.tv_sec = 1;
- spec.it_value.tv_nsec = 0;
-
- int sig;
- timer_settime(timer, 0, &spec, NULL);
- sigwait(&set, &sig);
-
- struct timeval end;
- gettimeofday(&end, NULL);
- timer_delete(timer);
-
- double diff = end.tv_sec - start.tv_sec;
- diff += (end.tv_usec - start.tv_usec) / 1000000.0;
- assert(diff >= 1.0);
-
- return 0;
-}