From patchwork Sun Dec 26 10:36:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 49258 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0770B3858411 for ; Sun, 26 Dec 2021 10:37:11 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by sourceware.org (Postfix) with ESMTPS id CF2F93858D39 for ; Sun, 26 Dec 2021 10:36:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF2F93858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bootlin.com Received: (Authenticated sender: thomas.petazzoni@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 77634FF804; Sun, 26 Dec 2021 10:36:57 +0000 (UTC) From: Thomas Petazzoni To: libc-alpha@sourceware.org Subject: [PATCH] sysdeps/unix/sysv/linux/microblaze/pselect32.c: add missing implementation when !__ASSUME_TIME64_SYSCALLS Date: Sun, 26 Dec 2021 11:36:53 +0100 Message-Id: <20211226103653.661763-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In commit a92f4e6299fe0e3cb6f77e79de00817aece501ce ("linux: Add time64 pselect support"), a Microblaze specific implementation of __pselect32() was added to cover the case of kernels < 3.15 which lack the pselect6 system call. This new file sysdeps/unix/sysv/linux/microblaze/pselect32.c takes precedence over the default implementation sysdeps/unix/sysv/linux/pselect32.c. However sysdeps/unix/sysv/linux/pselect32.c provides an implementation of __pselect32() which is needed when __ASSUME_TIME64_SYSCALLS is not defined. On Microblaze, which is a 32-bit architecture, __ASSUME_TIME64_SYSCALLS is only true for kernels >= 5.1. Due to sysdeps/unix/sysv/linux/microblaze/pselect32.c taking precedence over sysdeps/unix/sysv/linux/pselect32.c, it means that when we are with a kernel >= 3.15 but < 5.1, we need a __pselect32() implementation, but sysdeps/unix/sysv/linux/microblaze/pselect32.c doesn't provide it, and sysdeps/unix/sysv/linux/pselect32.c which would provide it is not compiled in. This causes the following build failure on Microblaze with for example Linux kernel headers 4.9: /home/thomas/buildroot/buildroot/output/host/lib/gcc/microblazeel-buildroot-linux-gnu/10.3.0/../../../../microblazeel-buildroot-linux-gnu/bin/ld: /home/thomas/buildroot/buildroot/output/build/glibc-2.34-9-g9acab0bba6a5a57323b1f94bf95b21618a9e5aa4/build/libc_pic.os: in function `__pselect64': (.text+0x120b44): undefined reference to `__pselect32' collect2: error: ld returned 1 exit status To fix this, we take a crude approach: replicate in sysdeps/unix/sysv/linux/microblaze/pselect32.c the !__ASSUME_TIME64_SYSCALLS implementation that is already in sysdeps/unix/sysv/linux/pselect32.c. Signed-off-by: Thomas Petazzoni --- .../unix/sysv/linux/microblaze/pselect32.c | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/microblaze/pselect32.c b/sysdeps/unix/sysv/linux/microblaze/pselect32.c index 70b7b52a48..6b6b3e8a2e 100644 --- a/sysdeps/unix/sysv/linux/microblaze/pselect32.c +++ b/sysdeps/unix/sysv/linux/microblaze/pselect32.c @@ -22,7 +22,25 @@ #include #include -#ifndef __ASSUME_PSELECT +#if !defined(__ASSUME_TIME64_SYSCALLS) +int +__pselect32 (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct __timespec64 *timeout, + const sigset_t *sigmask) +{ + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + ts32 = valid_timespec64_to_timespec (*timeout); + pts32 = &ts32; + } + + return SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, + pts32, + ((__syscall_ulong_t[]){ (uintptr_t) sigmask, + __NSIG_BYTES })); +} +#elif !defined(__ASSUME_PSELECT) int __pselect32 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct __timespec64 *timeout, @@ -57,4 +75,4 @@ __pselect32 (int nfds, fd_set *readfds, fd_set *writefds, return ret; } -#endif /* __ASSUME_PSELECT */ +#endif