mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
only fallback to gettimeofday/settimeofday syscalls if they exist
riscv32 and future architectures only provide the clock_ functions.
This commit is contained in:
parent
41149ea8c7
commit
12a757b321
1 changed files with 4 additions and 0 deletions
|
@ -80,10 +80,12 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
|
||||||
return __syscall_ret(r);
|
return __syscall_ret(r);
|
||||||
long ts32[2];
|
long ts32[2];
|
||||||
r = __syscall(SYS_clock_gettime, clk, ts32);
|
r = __syscall(SYS_clock_gettime, clk, ts32);
|
||||||
|
#ifdef SYS_gettimeofday
|
||||||
if (r==-ENOSYS && clk==CLOCK_REALTIME) {
|
if (r==-ENOSYS && clk==CLOCK_REALTIME) {
|
||||||
r = __syscall(SYS_gettimeofday, ts32, 0);
|
r = __syscall(SYS_gettimeofday, ts32, 0);
|
||||||
ts32[1] *= 1000;
|
ts32[1] *= 1000;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!r) {
|
if (!r) {
|
||||||
ts->tv_sec = ts32[0];
|
ts->tv_sec = ts32[0];
|
||||||
ts->tv_nsec = ts32[1];
|
ts->tv_nsec = ts32[1];
|
||||||
|
@ -92,6 +94,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
|
||||||
return __syscall_ret(r);
|
return __syscall_ret(r);
|
||||||
#else
|
#else
|
||||||
r = __syscall(SYS_clock_gettime, clk, ts);
|
r = __syscall(SYS_clock_gettime, clk, ts);
|
||||||
|
#ifdef SYS_gettimeofday
|
||||||
if (r == -ENOSYS) {
|
if (r == -ENOSYS) {
|
||||||
if (clk == CLOCK_REALTIME) {
|
if (clk == CLOCK_REALTIME) {
|
||||||
__syscall(SYS_gettimeofday, ts, 0);
|
__syscall(SYS_gettimeofday, ts, 0);
|
||||||
|
@ -100,6 +103,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
|
||||||
}
|
}
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return __syscall_ret(r);
|
return __syscall_ret(r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue