implement the remaining clock_* interfaces
authorRich Felker <dalias@aerifal.cx>
Sat, 19 Feb 2011 17:43:56 +0000 (12:43 -0500)
committerRich Felker <dalias@aerifal.cx>
Sat, 19 Feb 2011 17:43:56 +0000 (12:43 -0500)
src/time/clock_getcpuclockid.c [new file with mode: 0644]
src/time/clock_getres.c [new file with mode: 0644]
src/time/clock_gettime.c
src/time/clock_nanosleep.c [new file with mode: 0644]
src/time/clock_settime.c [new file with mode: 0644]

diff --git a/src/time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c
new file mode 100644 (file)
index 0000000..723840b
--- /dev/null
@@ -0,0 +1,11 @@
+#include <time.h>
+#include <errno.h>
+#include <unistd.h>
+#include "syscall.h"
+
+int clock_getcpuclockid(pid_t pid, clockid_t *clk)
+{
+       if (pid && pid != getpid()) return EPERM;
+       *clk = CLOCK_PROCESS_CPUTIME_ID;
+       return 0;
+}
diff --git a/src/time/clock_getres.c b/src/time/clock_getres.c
new file mode 100644 (file)
index 0000000..e86a1ee
--- /dev/null
@@ -0,0 +1,8 @@
+#define SYSCALL_RETURN_ERRNO
+#include <time.h>
+#include "syscall.h"
+
+int clock_getres(clockid_t clk, struct timespec *ts)
+{
+       return syscall2(__NR_clock_getres, clk, (long)ts);
+}
index dab09d50cfc49af32433caa890218301549aa220..6b880a068ef27c5efb9be42392b096a3a1e1a4b0 100644 (file)
@@ -1,3 +1,4 @@
+#define SYSCALL_RETURN_ERRNO
 #include <time.h>
 #include "syscall.h"
 
diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
new file mode 100644 (file)
index 0000000..c5646de
--- /dev/null
@@ -0,0 +1,8 @@
+#define SYSCALL_RETURN_ERRNO
+#include <time.h>
+#include "syscall.h"
+
+int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
+{
+       return syscall4(__NR_clock_nanosleep, clk, flags, (long)req, (long)rem);
+}
diff --git a/src/time/clock_settime.c b/src/time/clock_settime.c
new file mode 100644 (file)
index 0000000..e880fb3
--- /dev/null
@@ -0,0 +1,8 @@
+#define SYSCALL_RETURN_ERRNO
+#include <time.h>
+#include "syscall.h"
+
+int clock_settime(clockid_t clk, const struct timespec *ts)
+{
+       return syscall2(__NR_clock_settime, clk, (long)ts);
+}