fix wrong sigaction syscall ABI on mips*, or1k, microblaze, riscv64
[musl] / src / time / clock_settime.c
1 #include <time.h>
2 #include <errno.h>
3 #include "syscall.h"
4
5 #define IS32BIT(x) !((x)+0x80000000ULL>>32)
6
7 int clock_settime(clockid_t clk, const struct timespec *ts)
8 {
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
22         return syscall(SYS_clock_settime, clk, ts);
23 #endif
24 }