|
Message-ID: <20201227184032.22413-15-alobakin@pm.me> Date: Sun, 27 Dec 2020 18:42:34 +0000 From: Alexander Lobakin <alobakin@...me> To: Rich Felker <dalias@...ifal.cx>, musl@...ts.openwall.com Cc: Alexander Lobakin <alobakin@...me> Subject: [PATCH 15/18] semtimedop: prefer time64 variant of semtimedop 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 ipc syscall only as a last chance. Signed-off-by: Alexander Lobakin <alobakin@...me> --- src/ipc/semtimedop.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ipc/semtimedop.c b/src/ipc/semtimedop.c index 1632e7b03f38..703bf0cd6f4d 100644 --- a/src/ipc/semtimedop.c +++ b/src/ipc/semtimedop.c @@ -15,21 +15,21 @@ int semtimedop(int id, struct sembuf *buf, size_t n, const struct timespec *ts) { + int r = -ENOSYS; #ifdef SYS_semtimedop_time64 time_t s = ts ? ts->tv_sec : 0; long ns = ts ? ts->tv_nsec : 0; - int r = -ENOSYS; - if (NO_TIME32 || !IS32BIT(s)) - r = __syscall(SYS_semtimedop_time64, id, buf, n, - ts ? ((long long[]){s, ns}) : 0); + r = __syscall(SYS_semtimedop_time64, id, buf, n, + ts ? ((long long[]){s, ns}) : 0); if (NO_TIME32 || r!=-ENOSYS) return __syscall_ret(r); ts = ts ? (void *)(long[]){CLAMP(s), ns} : 0; #endif -#if defined(SYS_ipc) - return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts); -#elif defined(SYS_semtimedop) - return syscall(SYS_semtimedop, id, buf, n, ts); -#else - return __syscall_ret(-ENOSYS); +#ifdef SYS_semtimedop + r = __syscall(SYS_semtimedop, id, buf, n, ts); +#endif +#ifdef SYS_ipc + if (r == -ENOSYS) + r = __syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts); #endif + return __syscall_ret(r); } -- 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.