summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/time.h1
-rw-r--r--src/thread/thrd_sleep.c3
-rw-r--r--src/time/clock_nanosleep.c10
-rw-r--r--src/time/nanosleep.c2
4 files changed, 11 insertions, 5 deletions
diff --git a/src/include/time.h b/src/include/time.h
index 24c87973..cbabde47 100644
--- a/src/include/time.h
+++ b/src/include/time.h
@@ -4,6 +4,7 @@
#include "../../include/time.h"
hidden int __clock_gettime(clockid_t, struct timespec *);
+hidden int __clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
hidden char *__asctime_r(const struct tm *, char *);
hidden struct tm *__gmtime_r(const time_t *restrict, struct tm *restrict);
diff --git a/src/thread/thrd_sleep.c b/src/thread/thrd_sleep.c
index e8dfe400..97de5345 100644
--- a/src/thread/thrd_sleep.c
+++ b/src/thread/thrd_sleep.c
@@ -1,10 +1,11 @@
#include <threads.h>
+#include <time.h>
#include <errno.h>
#include "syscall.h"
int thrd_sleep(const struct timespec *req, struct timespec *rem)
{
- int ret = __syscall(SYS_nanosleep, req, rem);
+ int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem);
switch (ret) {
case 0: return 0;
case -EINTR: return -1; /* value specified by C11 */
diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c
index 32f0c07e..1174f510 100644
--- a/src/time/clock_nanosleep.c
+++ b/src/time/clock_nanosleep.c
@@ -2,8 +2,12 @@
#include <errno.h>
#include "syscall.h"
-int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
+int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
{
- int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
- return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
+ if (clk == CLOCK_THREAD_CPUTIME_ID) return EINVAL;
+ if (clk == CLOCK_REALTIME && !flags)
+ return -__syscall_cp(SYS_nanosleep, req, rem);
+ return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
}
+
+weak_alias(__clock_nanosleep, clock_nanosleep);
diff --git a/src/time/nanosleep.c b/src/time/nanosleep.c
index 1e6f3922..bc9f7895 100644
--- a/src/time/nanosleep.c
+++ b/src/time/nanosleep.c
@@ -3,5 +3,5 @@
int nanosleep(const struct timespec *req, struct timespec *rem)
{
- return syscall_cp(SYS_nanosleep, req, rem);
+ return __syscall_ret(-__clock_nanosleep(CLOCK_REALTIME, 0, req, rem));
}