diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/time/clock_settime.c | |
parent | Initial commit. (diff) | |
download | wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/time/clock_settime.c')
-rw-r--r-- | libc-top-half/musl/src/time/clock_settime.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/time/clock_settime.c b/libc-top-half/musl/src/time/clock_settime.c new file mode 100644 index 0000000..1004ed1 --- /dev/null +++ b/libc-top-half/musl/src/time/clock_settime.c @@ -0,0 +1,24 @@ +#include <time.h> +#include <errno.h> +#include "syscall.h" + +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + +int clock_settime(clockid_t clk, const struct timespec *ts) +{ +#ifdef SYS_clock_settime64 + time_t s = ts->tv_sec; + long ns = ts->tv_nsec; + int r = -ENOSYS; + if (SYS_clock_settime == SYS_clock_settime64 || !IS32BIT(s)) + r = __syscall(SYS_clock_settime64, clk, + ((long long[]){s, ns})); + if (SYS_clock_settime == SYS_clock_settime64 || r!=-ENOSYS) + return __syscall_ret(r); + if (!IS32BIT(s)) + return __syscall_ret(-ENOTSUP); + return syscall(SYS_clock_settime, clk, ((long[]){s, ns})); +#else + return syscall(SYS_clock_settime, clk, ts); +#endif +} |