summaryrefslogtreecommitdiff
path: root/src/time/timer_delete.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-29 13:01:25 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-29 13:01:25 -0400
commit80c4dcd2535a2d7f01eb539b0358dc51b0c0e122 (patch)
tree45bd30741a6f37bd0191467663dfbe5fb108c471 /src/time/timer_delete.c
parentbf619d82c82052741323aa63c107fbd346c8aaba (diff)
downloadmusl-80c4dcd2535a2d7f01eb539b0358dc51b0c0e122.tar.gz
musl-80c4dcd2535a2d7f01eb539b0358dc51b0c0e122.tar.bz2
musl-80c4dcd2535a2d7f01eb539b0358dc51b0c0e122.tar.xz
musl-80c4dcd2535a2d7f01eb539b0358dc51b0c0e122.zip
implement POSIX timers
this implementation is superior to the glibc/nptl implementation, in that it gives true realtime behavior. there is no risk of timer expiration events being lost due to failed thread creation or failed malloc, because the thread is created as time creation time, and reused until the timer is deleted.
Diffstat (limited to 'src/time/timer_delete.c')
-rw-r--r--src/time/timer_delete.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/time/timer_delete.c b/src/time/timer_delete.c
new file mode 100644
index 00000000..d7c7670f
--- /dev/null
+++ b/src/time/timer_delete.c
@@ -0,0 +1,12 @@
+#include <time.h>
+#include "pthread_impl.h"
+
+int timer_delete(timer_t t)
+{
+ if (t->thread) pthread_cancel(t->thread);
+ else {
+ if (t->timerid >= 0) __syscall(SYS_timer_delete, t->timerid);
+ free(t);
+ }
+ return 0;
+}