aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan O'Rear <sorear@fastmail.com>2020-09-03 03:33:10 -0400
committerRich Felker <dalias@aerifal.cx>2022-05-01 23:25:21 -0400
commit12a757b3219408c5f96fd5b9daa5c551944337ee (patch)
tree60112a3a1c928feae147cd5e520593ff051133a7 /src
parent41149ea8c7a6f28a1c60478fe7f6b9552aa39e3b (diff)
downloadmusl-12a757b3219408c5f96fd5b9daa5c551944337ee.tar.gz
musl-12a757b3219408c5f96fd5b9daa5c551944337ee.tar.xz
musl-12a757b3219408c5f96fd5b9daa5c551944337ee.zip
only fallback to gettimeofday/settimeofday syscalls if they exist
riscv32 and future architectures only provide the clock_ functions.
Diffstat (limited to 'src')
-rw-r--r--src/time/clock_gettime.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index 3e1d0975..c7e66a51 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -80,10 +80,12 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
return __syscall_ret(r);
long ts32[2];
r = __syscall(SYS_clock_gettime, clk, ts32);
+#ifdef SYS_gettimeofday
if (r==-ENOSYS && clk==CLOCK_REALTIME) {
r = __syscall(SYS_gettimeofday, ts32, 0);
ts32[1] *= 1000;
}
+#endif
if (!r) {
ts->tv_sec = ts32[0];
ts->tv_nsec = ts32[1];
@@ -92,6 +94,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
return __syscall_ret(r);
#else
r = __syscall(SYS_clock_gettime, clk, ts);
+#ifdef SYS_gettimeofday
if (r == -ENOSYS) {
if (clk == CLOCK_REALTIME) {
__syscall(SYS_gettimeofday, ts, 0);
@@ -100,6 +103,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
}
r = -EINVAL;
}
+#endif
return __syscall_ret(r);
#endif
}