summaryrefslogtreecommitdiffstats
path: root/librt/timer_gettime.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2005-01-11 09:41:40 +0000
committerEric Andersen <andersen@codepoet.org>2005-01-11 09:41:40 +0000
commit50a6ac7fb90ad4008b354ff8e72c6ce511dbeb3a (patch)
treebbfa2262a83889c6aeed9e9017df8517536e3b4a /librt/timer_gettime.c
parent45a95a466117aee2cd60f97be8310b6a04197244 (diff)
downloaduClibc-alpine-50a6ac7fb90ad4008b354ff8e72c6ce511dbeb3a.tar.bz2
uClibc-alpine-50a6ac7fb90ad4008b354ff8e72c6ce511dbeb3a.tar.xz
Patch from Paul Mundt (lethal) adding an initial librt implementation.
I then reworked the syscall handling and made minor cleanups. With luck I've not completely broken his patch...
Diffstat (limited to 'librt/timer_gettime.c')
-rw-r--r--librt/timer_gettime.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/librt/timer_gettime.c b/librt/timer_gettime.c
new file mode 100644
index 000000000..32e35eb05
--- /dev/null
+++ b/librt/timer_gettime.c
@@ -0,0 +1,26 @@
+/*
+ * timer_gettime.c - get the timer value.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_gettime
+
+#define __NR___syscall_timer_gettime __NR_timer_gettime
+static inline _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid, void *, value);
+
+/* Get the amount of time left on a timer */
+int timer_gettime(timer_t timerid, struct itimerspec *value)
+{
+ struct timer *kt = (struct timer *) timerid;
+
+ /* Get timeout from the kernel */
+ return __syscall_timer_gettime(kt->ktimerid, value);
+}
+
+#endif