From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 558 invoked from network); 27 Dec 2020 18:56:55 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 27 Dec 2020 18:56:55 -0000 Received: (qmail 24297 invoked by uid 550); 27 Dec 2020 18:56:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5814 invoked from network); 27 Dec 2020 18:42:23 -0000 Date: Sun, 27 Dec 2020 18:42:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1609094531; bh=yAUhiU0HJJ/n4YEp64/TcJS7YK/n6euqvNXIl34iy78=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=BAtrYausb4vBY4iD3Kzks3jzmq2B08hrGU2RGn0Nk1MwDZndgBpF1BqxMIExJOPWW MbJyuPZmchGCBKD8+yF+ceqpsrOFP3+ys10tOCxUlyR23aWyYODh7hz0XDDsJ94KgO LvoPCsuftlSPnLbqPgP36JdDLJ0JIeL4VFLbGMZCNbw4gYxyUin0seJibOxwyH7xOP OKo8J7ofcuGYUmkEuqPRuIHeMTDMAm7f72SiQtDO8Mz7wYg6Db0eCIMUOVpZu6evtP d7XwqUXxEKh9JTv9+hw9nV+m5wWNhqlaXwcarLUVca2uH25CSHHdCG5WL5FQKkQdEB tN3gHluhPxA9g== To: Rich Felker , musl@lists.openwall.com From: Alexander Lobakin Cc: Alexander Lobakin Message-ID: <20201227184032.22413-12-alobakin@pm.me> In-Reply-To: <20201227184032.22413-1-alobakin@pm.me> References: <20201227183842.22030-1-alobakin@pm.me> <20201227184032.22413-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [musl] [PATCH 12/18] poll, ppoll: prefer time64 variant of ppoll if available Instead of using time64 variant "only when needed", use it as a default and fallback to time32 only on -ENOSYS. Also use ppoll as a default for poll and fallback to poll only at last. Signed-off-by: Alexander Lobakin --- src/linux/ppoll.c | 8 +++----- src/select/poll.c | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/linux/ppoll.c b/src/linux/ppoll.c index e614600ab8b7..88a5b91a47b5 100644 --- a/src/linux/ppoll.c +++ b/src/linux/ppoll.c @@ -12,11 +12,9 @@ int ppoll(struct pollfd *fds, nfds_t n, const struct tim= espec *to, const sigset_ =09time_t s =3D to ? to->tv_sec : 0; =09long ns =3D to ? to->tv_nsec : 0; #ifdef SYS_ppoll_time64 -=09int r =3D -ENOSYS; -=09if (SYS_ppoll =3D=3D SYS_ppoll_time64 || !IS32BIT(s)) -=09=09r =3D __syscall_cp(SYS_ppoll_time64, fds, n, -=09=09=09to ? ((long long[]){s, ns}) : 0, -=09=09=09mask, _NSIG/8); +=09int r =3D __syscall_cp(SYS_ppoll_time64, fds, n, +=09=09to ? ((long long[]){s, ns}) : 0, +=09=09mask, _NSIG/8); =09if (SYS_ppoll =3D=3D SYS_ppoll_time64 || r !=3D -ENOSYS) =09=09return __syscall_ret(r); =09s =3D CLAMP(s); diff --git a/src/select/poll.c b/src/select/poll.c index c84c8a999ccc..e6b737081939 100644 --- a/src/select/poll.c +++ b/src/select/poll.c @@ -5,11 +5,24 @@ =20 int poll(struct pollfd *fds, nfds_t n, int timeout) { +=09time_t s =3D timeout >=3D 0 ? timeout / 1000 : 0; +=09long ns =3D timeout >=3D 0 ? timeout % 1000 * 1000000 : 0; +=09int r =3D -ENOSYS; +#ifdef SYS_ppoll_time64 +=09int r =3D __syscall_cp(SYS_ppoll_time64, fds, n, +=09=09timeout >=3D 0 ? ((long long[]){s, ns}) : 0, +=09=090, _NSIG / 8); +=09if (SYS_ppoll =3D=3D SYS_ppoll_time64 || r !=3D -ENOSYS) +=09=09return __syscall_ret(r); +#endif +#ifdef SYS_ppoll +=09r =3D __syscall_cp(SYS_ppoll, fds, n, +=09=09timeout >=3D 0 ? ((long[]){s, ns}) : 0, +=09=090, _NSIG / 8); +#endif #ifdef SYS_poll -=09return syscall_cp(SYS_poll, fds, n, timeout); -#else -=09return syscall_cp(SYS_ppoll, fds, n, timeout>=3D0 ? -=09=09&((struct timespec){ .tv_sec =3D timeout/1000, -=09=09.tv_nsec =3D timeout%1000*1000000 }) : 0, 0, _NSIG/8); +=09if (r =3D=3D -ENOSYS) +=09=09r =3D __syscall_cp(SYS_poll, fds, n, timeout); #endif +=09return __syscall_ret(r); } --=20 2.29.2