|
Message-ID: <20201227184032.22413-5-alobakin@pm.me> Date: Sun, 27 Dec 2020 18:41:16 +0000 From: Alexander Lobakin <alobakin@...me> To: Rich Felker <dalias@...ifal.cx>, musl@...ts.openwall.com Cc: Alexander Lobakin <alobakin@...me> Subject: [PATCH 05/18] clock_nanosleep: prefer time64 variant if available Instead of using time64 variant "only when needed", use it as a default and fallback to time32 only on -ENOSYS. Also use deprecated nanosleep only as a last chance. Signed-off-by: Alexander Lobakin <alobakin@...me> --- src/time/clock_nanosleep.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/time/clock_nanosleep.c b/src/time/clock_nanosleep.c index e195499cc072..ea090eb8c313 100644 --- a/src/time/clock_nanosleep.c +++ b/src/time/clock_nanosleep.c @@ -11,27 +11,29 @@ int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, stru #ifdef SYS_clock_nanosleep_time64 time_t s = req->tv_sec; long ns = req->tv_nsec; - int r = -ENOSYS; - if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || !IS32BIT(s)) - r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags, - ((long long[]){s, ns}), rem); + int r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags, + ((long long[]){s, ns}), rem); if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || r!=-ENOSYS) return -r; long long extra = s - CLAMP(s); long ts32[2] = { CLAMP(s), ns }; - if (clk == CLOCK_REALTIME && !flags) + r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32); +#ifdef SYS_nanosleep + if (r == -ENOSYS && clk == CLOCK_REALTIME && !flags) r = __syscall_cp(SYS_nanosleep, &ts32, &ts32); - else - r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32); +#endif if (r==-EINTR && rem && !(flags & TIMER_ABSTIME)) { rem->tv_sec = ts32[0] + extra; rem->tv_nsec = ts32[1]; } return -r; #else - if (clk == CLOCK_REALTIME && !flags) - return -__syscall_cp(SYS_nanosleep, req, rem); - return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); + int r = __syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); +#ifdef SYS_nanosleep + if (r == -ENOSYS && clk == CLOCK_REALTIME && !flags) + r = __syscall_cp(SYS_nanosleep, req, rem); +#endif + return -r; #endif } -- 2.29.2
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.