From patchwork Sat Dec 21 14:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13917862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 029C1E7718B for ; Sat, 21 Dec 2024 14:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=42nHtuwnLJ/KXr2DDIt5jQsrmasmHL+IZZIbu3GDnU8=; b=1uaz65qHzMSGZV j0/PMK2pOzh+UUq2f2HWJ7NnjKPUhJE2ETTttDJ7/hGvAmFO9VOAXsEvtqCX/AusF44UPInMna1/L XhITGZaHi2QxrsvSdc20RNDUaRXeR2+Gnxf7+6UomKoF6zWIZbVhgrQDBquVYMmcHnS7BBwp89Nhj QyhjWgJN6ACBm+ESdV+r4dYvT5X70xlqBLKF9esXKlp3QFrVnO1NZPztWdMIiZReEabdsgdUdzJiZ NDbyc1qHN/md2S6wERGty0717XZWHIIeakodUycF7+yqgR9jIFemmCF7hAUYNP8FZJt3v1YXNnjEi ZOJgiCFZ9YECk0EQL84Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tP0if-000000074je-27AJ; Sat, 21 Dec 2024 14:44:41 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tP0ib-000000074gT-2Kvm for linux-riscv@lists.infradead.org; Sat, 21 Dec 2024 14:44:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734792272; bh=nlgKA1aWXtMZ4vLJ+M3UslYSVWgrW4lQ46FIgxLbuk0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KT0linBfSK3yb1tVBfOsrUo0Qmsy5DtV5NcKzkVfQADhnVJN5E0BXAJCApmsPsHr3 zVQ0RXn1dybDs65olAHAF0Rn8yy9IR9JJcg+jYFJGtfGw1QqslTzaN5dc1I3IX/PcO i5EQl6N4KZ5WUhbhi1y94htVb3UCXl/uEKsEVeZA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 21 Dec 2024 15:44:28 +0100 Subject: [PATCH 1/6] tools/nolibc: add support for waitid() MIME-Version: 1.0 Message-Id: <20241221-nolibc-rv32-v1-1-d9ef6dab7c63@weissschuh.net> References: <20241221-nolibc-rv32-v1-0-d9ef6dab7c63@weissschuh.net> In-Reply-To: <20241221-nolibc-rv32-v1-0-d9ef6dab7c63@weissschuh.net> To: Willy Tarreau , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734792271; l=1451; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=nlgKA1aWXtMZ4vLJ+M3UslYSVWgrW4lQ46FIgxLbuk0=; b=Ig+cd8xPaVLdOY8TmrPbOeWu/tTdW9wbIV95eO+fM2u8WdX0eUj3Ua2COzeHZgYnv1GPCWsmN o6sEOaa5ANfBUMHGbBZVGucYzVcpNMAel6JpLdzkUuzwQvKrCwZnr79 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241221_064437_743969_82315399 X-CRM114-Status: UNSURE ( 6.30 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org waitid() is the modern variant of the family of wait-like syscalls. Some architectures have dropped support for wait(), wait4() and waitpid() but all of them support waitid(). It is more flexible and easier to use than the older ones. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 7b82bc3cf107439a3f09f98b99d4d540ffb9ba2a..d4a5c2399a66b200ebf7ab249569cce2285481a5 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "arch.h" #include "errno.h" @@ -1225,6 +1226,23 @@ pid_t waitpid(pid_t pid, int *status, int options) } +/* + * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); + */ + +static __attribute__((unused)) +int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage) +{ + return my_syscall5(__NR_waitid, which, pid, infop, options, rusage); +} + +static __attribute__((unused)) +int waitid(int which, pid_t pid, siginfo_t *infop, int options) +{ + return __sysret(sys_waitid(which, pid, infop, options, NULL)); +} + + /* * ssize_t write(int fd, const void *buf, size_t count); */