]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/src/time/clock_settime.c
Update to musl 1.1.24.
[wasi-libc.git] / libc-top-half / musl / src / time / clock_settime.c
CommitLineData
320054e8 1#include <time.h>
79a9b408 2#include <errno.h>
320054e8
DG
3#include "syscall.h"
4
79a9b408
DG
5#define IS32BIT(x) !((x)+0x80000000ULL>>32)
6
320054e8
DG
7int clock_settime(clockid_t clk, const struct timespec *ts)
8{
79a9b408
DG
9#ifdef SYS_clock_settime64
10 time_t s = ts->tv_sec;
11 long ns = ts->tv_nsec;
12 int r = -ENOSYS;
13 if (SYS_clock_settime == SYS_clock_settime64 || !IS32BIT(s))
14 r = __syscall(SYS_clock_settime64, clk,
15 ((long long[]){s, ns}));
16 if (SYS_clock_settime == SYS_clock_settime64 || r!=-ENOSYS)
17 return __syscall_ret(r);
18 if (!IS32BIT(s))
19 return __syscall_ret(-ENOTSUP);
20 return syscall(SYS_clock_settime, clk, ((long[]){s, ns}));
21#else
320054e8 22 return syscall(SYS_clock_settime, clk, ts);
79a9b408 23#endif
320054e8 24}