From patchwork Wed May 24 17:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254381 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F22ADC77B7C for ; Wed, 24 May 2023 17:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbjEXRlS (ORCPT ); Wed, 24 May 2023 13:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjEXRlQ (ORCPT ); Wed, 24 May 2023 13:41:16 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA49E119; Wed, 24 May 2023 10:41:14 -0700 (PDT) X-QQ-mid: bizesmtp85t1684950069tkbe1e2d Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:41:08 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: ymkv9EwBIzIqdJHXz1tqkq1Xg/DZPmkYs3TYAOpX5T7lHwTwTwis4rf2mwKFE ieDnbszxtjK2OAL7YE2gUPRLdWypPjkjaRhPGXRbx5dlmtZiULOtw7P7XD2aTb7WChN22gt +p+oJOz/ld1s36+Y5HLYRZ+6j9LYEwPb7u1+5HMIWWZtn5+fAK+Dxry+5TJZmF/TQ5AW9Xz CRyBs923a/CV3bsZPZtqThtsORSKPAtHO9jdjXmQVwKAIDSffJdR9hO5v6QRIlHdL/Clvs8 1zHRswgNcSBP8wNh+2l4cYYjDr62+2dRdZBMuwaM5EmTdiDFcskXJ7PO74thD79yjH1VQbI +AcdX1ozF9N8Op3VjzWCAWk59keifaWIKuiJNGj/RqMBsPMFJpwSzkswbimyA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4465477485056657340 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 01/13] Revert "tools/nolibc: riscv: Support __NR_llseek for rv32" Date: Thu, 25 May 2023 01:41:06 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This reverts commit d2c3acba6d66 to prepare for a whole new patch later. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/std.h | 1 - tools/include/nolibc/sys.h | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 83c0b0cb9564..933bc0be7e1c 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -32,6 +32,5 @@ typedef signed long off_t; typedef signed long blksize_t; typedef signed long blkcnt_t; typedef signed long time_t; -typedef long long loff_t; #endif /* _NOLIBC_STD_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 7874062bea95..d5792a5de70b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -671,26 +671,7 @@ int link(const char *old, const char *new) static __attribute__((unused)) off_t sys_lseek(int fd, off_t offset, int whence) { -#ifdef __NR_lseek return my_syscall3(__NR_lseek, fd, offset, whence); -#elif defined(__NR_llseek) - loff_t res; - off_t retval; - - int rc = my_syscall5(__NR_llseek, fd, (long) (((uint64_t) (offset)) >> 32), (long) offset, &res, whence); - - if (rc) - return rc; - - retval = (off_t) res; - if (retval == res) - return retval; - - SET_ERRNO(EOVERFLOW); - return (off_t) -1; -#else -#error Neither __NR_lseek nor __NR_llseek defined, cannot implement sys_lseek() -#endif } static __attribute__((unused)) From patchwork Wed May 24 17:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254383 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0D93C77B7A for ; Wed, 24 May 2023 17:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235902AbjEXRpZ (ORCPT ); Wed, 24 May 2023 13:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235823AbjEXRpY (ORCPT ); Wed, 24 May 2023 13:45:24 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379E6199; Wed, 24 May 2023 10:44:46 -0700 (PDT) X-QQ-mid: bizesmtp91t1684950270tlg7ezy2 Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:44:28 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: YHTLUubWl265u2CW07wSJel+EACR98RM0Pu/0O4blCZfhRit2TQxF4jHhzYnx v61kmJUoir0VmxZ6Toueb+Uoxb0G4MLbtFWhJscPkTd/ViqkMef29uaIfE/g6WP5lJ7rRfk McLHsbRwJ5BwzlNH57jJvOe1CV0krfEglM2yPp/8wcmTYbTxq18j59iXQz8qGIeq5yL1T9Q WW0bT85CJqGkxxUwa4LGIfeepiP39SXOprgJaMT/eYzjNCEQkkbTaPO0NZjZTBt1uCJ6Pld C7jxnIh/s3fTQ892Zm9i+o1dPxTd1O4JTij6hXUHEo6n1/sQgKv47QbSpZtAWLH9sPJAdit 39unhhO/LTzsyLAyvK1Qhpo9SxeshLvC4yl9NKX9i1jmGuHseYSU9G2YL1wCg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16112400908867292209 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 02/13] Revert "selftests/nolibc: Fix up compile error for rv32" Date: Thu, 25 May 2023 01:44:26 +0800 Message-Id: <9cf5f91b2bc3d387231768349ea60f1091db4654.1684949267.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This reverts commit 606343b7478 to prepare for a whole new patch later. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6e0a4dbe321e..c570bb848c1a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -596,7 +596,7 @@ int run_syscall(int min, int max) CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getpid()); break; - CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_read, -1, &tmp, 1), -1, EBADF); break; + CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ From patchwork Wed May 24 17:46:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254384 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47652C77B7C for ; Wed, 24 May 2023 17:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231373AbjEXRrl (ORCPT ); Wed, 24 May 2023 13:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236143AbjEXRrk (ORCPT ); Wed, 24 May 2023 13:47:40 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E49E69; Wed, 24 May 2023 10:47:09 -0700 (PDT) X-QQ-mid: bizesmtp74t1684950423t77e0lrx Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:47:01 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: znfcQSa1hKZBlxy494Gp/CUTxDNxeJi9g6MNrUFAmf11ZBmaQQlpsB9yjSoP9 kCNyyfNK4LVYRCC+QxI5nml5abQCRTMKoiHD1uZbPRTZ1RzErA2+ejZ5gCTE4aaBmHm5bj/ ZQ1bgyUYryKHFl0PJWO5ymVDxnE2EuM41izSnz1UsJHmnDxwhtoG9KaU3OBjNXlgs+zbNtw 5i9MDjM0WHVF2a96ojpLDypn3LHo2HPKKA40Q0jjS2qTrMgN6Fci78eZmVfBjVwe6Rx4Pj+ NvUiNs0b9UznWltOOMBCnR8UPvdOzT4vkcsKKbIerPec1+SV01TSUsBd4hWFiKtvEnBRr9S KVY5EDSIESXpdffOq9gmaBnmtPOtzRkYz4oX4hJkkwSFjsyihUHNRYIIYhw7Um6ZkKDhbVj X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10920217601069788465 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 03/13] selftests/nolibc: print name instead of number for EOVERFLOW Date: Thu, 25 May 2023 01:46:54 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org EOVERFLOW will be used in the coming time64 syscalls support. Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index c570bb848c1a..227ef2a3ebba 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -106,6 +106,7 @@ const char *errorname(int err) CASE_ERR(EDOM); CASE_ERR(ERANGE); CASE_ERR(ENOSYS); + CASE_ERR(EOVERFLOW); default: return itoa(err); } From patchwork Wed May 24 17:48:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254422 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E5DAC77B7C for ; Wed, 24 May 2023 17:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236312AbjEXRuB (ORCPT ); Wed, 24 May 2023 13:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbjEXRt6 (ORCPT ); Wed, 24 May 2023 13:49:58 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A085F122; Wed, 24 May 2023 10:49:54 -0700 (PDT) X-QQ-mid: bizesmtp84t1684950589taqcvbsf Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:49:48 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: uGhnJwy6xZIUNwFWUkTcVZC7g8QNyKiY+XzJriACbUL4oqMszlNtgYpAkhLex cwihvRwjjgmsdDZeCDPBF1DQ938pSja9bqh13OBnuTww50GACW6NmZRGD621FTL2iQ3QVmZ 3HkI3ZEvZW3yLng05TVWCIwUhYuPiSBwb0uYCZ2D0qnkqyOSDmeRKNiGa4kRHpIhHm7YHPU M+DcW0gUtbzTW69JkDGyC5dTxiYptZzlvCJn1XJGMlllb0F9TAExPLOZnvDJwVcyv4oUI5Y ue15DAsGTU3Ke9lTyUtaRF1ixOTRnyGTK0aokkIreZiU8hdYxCiI4zKZzp6KpnUehGaYkIe EmHYz1QP6NJqwxJyJLXzjh4+56x/vuIlsuhL/BW/dMwVCVkSckCr2+nK3wZ+NdVB6t/VW7q X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17354439834397082086 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 04/13] selftests/nolibc: syscall_args: use __NR_statx for rv32 Date: Thu, 25 May 2023 01:48:11 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When compile nolibc-test.c for rv32, we got such error: tools/testing/selftests/nolibc/nolibc-test.c:599:57: error: ‘__NR_fstat’ undeclared (first use in this function) 599 | CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; The generic include/uapi/asm-generic/unistd.h used by rv32 doesn't support __NR_fstat, use __NR_statx instead: Running test 'syscall' 69 syscall_noargs = 1 [OK] 70 syscall_args = -1 EFAULT [OK] As tools/include/nolibc/sys.h shows, __NR_statx is either not supported by all platforms, so, both __NR_fstat and __NR_statx are required. Btw, the latest riscv libc6-dev package is required, otherwise, we would also get such error: In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452, from /usr/riscv64-linux-gnu/include/features.h:461, from /usr/riscv64-linux-gnu/include/bits/libc-header-start.h:33, from /usr/riscv64-linux-gnu/include/limits.h:26, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:194, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/syslimits.h:7, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:34, from /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/nolibc-test.c:6: /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported" The glibc commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error, so, glibc >= 2.33 (who includes this commit) is required. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 227ef2a3ebba..c86ff6018c7f 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -501,6 +501,17 @@ static int test_fork(void) } } +static int test_syscall_args(void) +{ +#ifdef __NR_fstat + return syscall(__NR_fstat, 0, NULL); +#elif defined(__NR_statx) + return syscall(__NR_statx, 0, NULL, 0, 0, NULL); +#else +#error Neither __NR_fstat nor __NR_statx defined, cannot implement syscall_args test +#endif +} + /* Run syscall tests between IDs and . * Return 0 on success, non-zero on failure. */ @@ -597,7 +608,7 @@ int run_syscall(int min, int max) CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getpid()); break; - CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; + CASE_TEST(syscall_args); EXPECT_SYSER(1, test_syscall_args(), -1, EFAULT); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ From patchwork Wed May 24 17:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254423 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E183C77B7A for ; Wed, 24 May 2023 17:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjEXRvf (ORCPT ); Wed, 24 May 2023 13:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbjEXRvb (ORCPT ); Wed, 24 May 2023 13:51:31 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5C38119; Wed, 24 May 2023 10:51:26 -0700 (PDT) X-QQ-mid: bizesmtp74t1684950681t6yn0ug4 Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:51:20 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: XBN7tc9DADIjgXxH3TLgSj0VxrQrlL8zhmh+je68CBXjsGiccEXwXly8k6tY2 sC6ZTFBT/sSxaXpDpmnl0LuhIAIGbtTvL5iSFY/1OirQIpXra0UPbmdM27b0Too6T6HMjnI SfX8v6h6fpBl9pr85gssp4sQRvlDlefaiz21KSWLsuDAH+5hlMhyWQ9dJJ0jaTZjmnUgZTl WfBb83pbAN6Y2MHZ0Z1N0713TbxSUgJgxPdTE5p4QCAwVJzfrLjfM+rchc1rauuUwS9ZL2Q +zzJYhPPZycNK74ty8mb/+lulh9ITcXDtfNrrrTrPvtIKDqUWa71PYM6R8Zc7w8Tx+dB1h5 gc0kJfc4Uo+Z7HG2jUcWLfat5YfgHjhNbNwJaOt7iBXLsZ1r9c10EoJ9fC8kA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9362597726359131940 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 05/13] selftests/nolibc: riscv: customize makefile for rv32 Date: Thu, 25 May 2023 01:50:57 +0800 Message-Id: <7adb27a7c56dd06d782710a5f684ea6263900f98.1684949268.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org both riscv64 and riscv32 have the same ARCH value, it is riscv, the default defconfig enables 64bit, to support riscv32, let's allow pass "ARCH=riscv32" or "ARCH=riscv CONFIG_32BIT=1" to customize riscv32 setting. Note: glibc >= 2.33 is required to avoid a bug of the old bits/wordsize.h. /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported" This can not pass compile, several time64 syscalls are still missing. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 47c3c89092e4..9adc8944dd80 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -14,6 +14,12 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +# Allow pass ARCH=riscv|riscv32|riscv64, riscv implies riscv64 +ifneq ($(findstring xriscv,x$(ARCH)),) + CONFIG_32BIT := $(if $(findstring 32x,$(ARCH)x),1) + override ARCH := riscv +endif + # kernel image names by architecture IMAGE_i386 = arch/x86/boot/bzImage IMAGE_x86_64 = arch/x86/boot/bzImage @@ -34,7 +40,7 @@ DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig -DEFCONFIG_riscv = defconfig +DEFCONFIG_riscv = $(if $(CONFIG_32BIT),rv32_defconfig,defconfig) DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig DEFCONFIG = $(DEFCONFIG_$(ARCH)) @@ -49,7 +55,7 @@ QEMU_ARCH_x86 = x86_64 QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig -QEMU_ARCH_riscv = riscv64 +QEMU_ARCH_riscv = $(if $(CONFIG_32BIT),riscv32,riscv64) QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 QEMU_ARCH = $(QEMU_ARCH_$(ARCH)) @@ -76,6 +82,7 @@ else Q=@ endif +CFLAGS_riscv = $(if $(CONFIG_32BIT),-march=rv32im -mabi=ilp32) CFLAGS_s390 = -m64 CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ From patchwork Wed May 24 17:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254424 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72D5BC77B7A for ; Wed, 24 May 2023 17:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236367AbjEXRxT (ORCPT ); Wed, 24 May 2023 13:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236347AbjEXRxS (ORCPT ); Wed, 24 May 2023 13:53:18 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC982119; Wed, 24 May 2023 10:53:16 -0700 (PDT) X-QQ-mid: bizesmtp71t1684950791tp8m1e4l Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:53:10 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 7jw2iSiCazqOcSM2MVgG4xMJ96kdb0v9csKqpcqqtj1u7+0ZkGV3bSXiAUJcM aPAdZ6wZXqVvTeOt/M4goYfpVARuW8z6EguvDuAJLX/NMvw9T9A3DVvTtgOUPKl1YALRxBS TdLGLYANVLa841J7A+shvQ0d56mm3F+wZ2zfuMB4lB4eq2tK9eIeOca6d4tS+HIqWRd4Lr0 0CL0rD9Hk+708Xu1EYn2Ak3UMQlVPaHi14GgDDo8Tzi8zkdMP4S8OGl/mV4JGQvjMcYYFzY 5U0oHA1KcUDOfkfEGRI0VTMWnd1DPmcYH2nY7flo325+orDVrm0s9NfMyRhzR4T84rIEw17 27UMTVpM1ghVZtFwUpljIeOYNo9xmcTklQXF3dzYwF1eVQVUSdDO0Xd9JD7qA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2012140808971303429 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 06/13] selftests/nolibc: allow specify a bios for qemu Date: Thu, 25 May 2023 01:52:29 +0800 Message-Id: <63bee74a7b3754a1b0e82bc57de52c18d2de003d.1684949268.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org riscv qemu has a builtin bios (opensbi), but it may not match the latest kernel and some old versions may hang during boot, let's allow user pass a newer version to qemu via the -bios option. we can use it like this: $ make run BIOS=/path/to/new-bios ... Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 9adc8944dd80..9213763ab3b6 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -70,7 +70,8 @@ QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" -QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) +QEMU_ARGS_BIOS = $(if $(BIOS),-bios $(BIOS)) +QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_BIOS) # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. From patchwork Wed May 24 17:54:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254429 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA8E3C77B7C for ; Wed, 24 May 2023 17:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235265AbjEXRyk (ORCPT ); Wed, 24 May 2023 13:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjEXRyj (ORCPT ); Wed, 24 May 2023 13:54:39 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7131BB6; Wed, 24 May 2023 10:54:36 -0700 (PDT) X-QQ-mid: bizesmtp63t1684950871teid7j3l Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:54:30 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: ILHsT53NKPiQNaLNfvtQg60iCEjU86KTaag2QHiPU3ih6Rb4YpBvqJza1CLGu LpFlDQrCd1CzUUzmNws22YxZUV8d6W8jYPZ2nrEDEaDmsZpm8iPmoW9lOOfcyOqguLm1+zY 2K7WSkALc/5XCjQUw2A2znLCN1tjC1H9y9lzWCm0I/PH1PsorxoBge3kGufcq0lhKqef5e+ CVmpEhsvbuFluOifXkdyczY4POc8Y4WJ4pvpPA80rp4wtPUOpsnYC4ZwPE+ZmXe13mDpm5R oYI+sqLkgRmeyX24IgJ2tlqgWzMkjR5iyKIG0UMIDDV0BFXbEJZqwkNZiE2lhmIzdCQFt3r amaHK22+U+HoGiOcPDSAkQo8WB4QmfyssStP9B443w1uR+/5UunbTM1SORuiw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11833202980194447425 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 07/13] selftests/nolibc: remove the duplicated gettimeofday_bad2 Date: Thu, 25 May 2023 01:54:19 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index c86ff6018c7f..a9c07018ac9d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -575,7 +575,6 @@ int run_syscall(int min, int max) #ifdef NOLIBC CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; - CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; #endif CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Wed May 24 17:55:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254430 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43A20C77B7A for ; Wed, 24 May 2023 17:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbjEXR4Y (ORCPT ); Wed, 24 May 2023 13:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjEXR4X (ORCPT ); Wed, 24 May 2023 13:56:23 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10F7D3; Wed, 24 May 2023 10:56:21 -0700 (PDT) X-QQ-mid: bizesmtp83t1684950976taj01xsk Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:56:14 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 3M0okmaRx3heRPkZGAvThL5q8yJbl4iq2g+n/V08QcrkuDixKCO+Kd5/chZ81 RzQT/uozjLZp+bJTDwM4DrjefAVoP6YAkePF7XNpTK/nJeuf9WQLmw0zG25rrehB1prqfgh Mxe/FZ2oQE83jxi0IwkPYBpg1nhziKdy250rcb2fxzd2Y14WfvDQutJBG35HFVq8BnVLs7O P8KDx0A/JpQyxXInpBxAh2ptKYxoEApcMkJMZmv56mSHAl/oZrtg2VYwPJm4gT9nt9jEq1L c4eGTgncEQWLJLlWkWX99AdeN6dGvF7IcjRuEmGdHroUaPPPUybeEoz2wiy/oTiy6tvnQ3v Dn5Dy/0Ii+6Wiu+MMEXg7lf4YzUemtxh5Zhk5Dp+Tsn/rDdZtH0dxeEjPUGUQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1222464122104175739 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 08/13] tools/nolibc: sys_lseek: riscv: use __NR_llseek for rv32 Date: Thu, 25 May 2023 01:55:39 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org riscv uses the generic include/uapi/asm-generic/unistd.h, it has code like this: #if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT) #define __NR_lseek __NR3264_lseek #else #define __NR_llseek __NR3264_lseek #endif There is no __NR_lseek for rv32, use __NR_llseek instead. This code is based on sysdeps/unix/sysv/linux/lseek.c of glibc. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau --- tools/include/nolibc/std.h | 1 + tools/include/nolibc/sys.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 933bc0be7e1c..83c0b0cb9564 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -32,5 +32,6 @@ typedef signed long off_t; typedef signed long blksize_t; typedef signed long blkcnt_t; typedef signed long time_t; +typedef long long loff_t; #endif /* _NOLIBC_STD_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index d5792a5de70b..0ff77c0a06d7 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -671,7 +671,25 @@ int link(const char *old, const char *new) static __attribute__((unused)) off_t sys_lseek(int fd, off_t offset, int whence) { +#ifdef __NR_lseek return my_syscall3(__NR_lseek, fd, offset, whence); +#elif defined(__NR_llseek) + loff_t result; + off_t retval; + int ret; + + ret = my_syscall5(__NR_llseek, fd, (long) (((uint64_t) (offset)) >> 32), (long) offset, &result, whence); + if (ret) + return ret; + + retval = (off_t) result; + if (retval != result) + return -EOVERFLOW; + + return retval; +#else +#error Neither __NR_lseek nor __NR_llseek defined, cannot implement sys_lseek() +#endif } static __attribute__((unused)) From patchwork Wed May 24 17:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254431 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643CBC77B7C for ; Wed, 24 May 2023 17:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236442AbjEXR5k (ORCPT ); Wed, 24 May 2023 13:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbjEXR5j (ORCPT ); Wed, 24 May 2023 13:57:39 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76BA398; Wed, 24 May 2023 10:57:36 -0700 (PDT) X-QQ-mid: bizesmtp69t1684951051toedm1f2 Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:57:30 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 1U/NVTUyJNR0Bdf3bNTIg9tVMMQ36KW+m0gOe7QYfuSjie+syXUksgUIyPwT9 XfFw8T5ZcY0Gquio8enXfYroGAwnsHycofnfTqboltbdqCDUUnRUVfDdQvLU4WvGApwZDmN bAN6znioI8PEsk337ISXWj6upRE/YjYx52ag3fsAJyiq4tZ26fjpekhGMHr/nYoxUoDKTYU 6S9Cj0J1aASneoJI34cnjcZTI00YRCWzxAihgavquQbYb9F5spPI4fNfgj/l9yZIVq6KWXo a6u2uupdH0bFQEDqTZhEIceDjXFL2DwMqyhdHjNld9/7nfjCGEzUsIU/oflxOuhOMH7GnTA mW8SbP+DccbvKioNg2HMYwFQW6yUW75OfYEsj38yT1ZpwZ2SpCTFlWISeGvAQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 7132561189251988013 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 09/13] tools/nolibc: sys_poll: riscv: use __NR_ppoll_time64 for rv32 Date: Thu, 25 May 2023 01:57:24 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no __NR_ppoll after kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), use __NR_ppoll_time64 instead. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/std.h | 1 + tools/include/nolibc/sys.h | 7 ++++++- tools/include/nolibc/types.h | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 83c0b0cb9564..221385c0e823 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -32,6 +32,7 @@ typedef signed long off_t; typedef signed long blksize_t; typedef signed long blkcnt_t; typedef signed long time_t; +typedef long long time64_t; typedef long long loff_t; #endif /* _NOLIBC_STD_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 0ff77c0a06d7..08d38175bd7b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -923,8 +923,13 @@ int pivot_root(const char *new, const char *old) static __attribute__((unused)) int sys_poll(struct pollfd *fds, int nfds, int timeout) { -#if defined(__NR_ppoll) +#if defined(__NR_ppoll) || defined(__NR_ppoll_time64) +#ifdef __NR_ppoll struct timespec t; +#else + struct timespec64 t; +#define __NR_ppoll __NR_ppoll_time64 +#endif if (timeout >= 0) { t.tv_sec = timeout / 1000; diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 15b0baffd336..ee914391439c 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -203,6 +203,12 @@ struct stat { time_t st_ctime; /* time of last status change */ }; +/* needed by time64 syscalls */ +struct timespec64 { + time64_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + /* WARNING, it only deals with the 4096 first majors and 256 first minors */ #define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff))) #define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff)) From patchwork Wed May 24 17:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254432 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 005D6C77B7C for ; Wed, 24 May 2023 17:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbjEXR6y (ORCPT ); Wed, 24 May 2023 13:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjEXR6y (ORCPT ); Wed, 24 May 2023 13:58:54 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A613098; Wed, 24 May 2023 10:58:52 -0700 (PDT) X-QQ-mid: bizesmtp74t1684951127tibius57 Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 01:58:46 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 3M0okmaRx3j5XLeAsUaE/DkfZWFl5CmfKZrVp7OoqgrEw0wk0brdmyrXBI5zN NpWpiQQzR4ct/fvme1WqRNqVlEyVp0V3y4gZ4FVeqTORPQSaNUNIVU8zXT0xSs7UvR82pAU piv68CfZe0vXIJ/2ZF6hgetaWwXz2z51mbzLshvXJcW7SEUTAlpAm6OUnZxrq622N8BIfRE rDg0PT1ere6yY0p/7uVW7DoOggF8vXvKxIkzNa5uthRTIAHlaGXdikv0yyDo/nKhqjaY8wB xM8nuDYA1NVSgtnqjG5mLKnJKA5+CugBcPb4GxOb/Cf9R0iXc0GBZQyP2drBsZnEkynxhd2 FNSa53ww7eKmKY/+W9ATQKkdLd8ZWHT7fLYAKgSZ0Xfzj1+35PgLCcy6Q4s3Q== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4532114979322601860 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 10/13] tools/nolibc: ppoll/ppoll_time64: add a missing argument Date: Thu, 25 May 2023 01:58:39 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The ppoll and ppoll_time64 syscalls have 5 arguments, but we only provide 4, align with kernel and add the missing sigsetsize argument. Because the sigmask is NULL, the last sigsetsize argument is ignored, keep it as 0 here is safe enough. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 08d38175bd7b..c0335a84f880 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -935,7 +935,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_sec = timeout / 1000; t.tv_nsec = (timeout % 1000) * 1000000; } - return my_syscall4(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL); + return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else From patchwork Wed May 24 17:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254436 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78CFEC77B7A for ; Wed, 24 May 2023 18:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbjEXSBS (ORCPT ); Wed, 24 May 2023 14:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjEXSBR (ORCPT ); Wed, 24 May 2023 14:01:17 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6610898; Wed, 24 May 2023 11:01:14 -0700 (PDT) X-QQ-mid: bizesmtp75t1684951269t67ndppu Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 02:01:08 +0800 (CST) X-QQ-SSF: 01200000000000D0V000B00A0000000 X-QQ-FEAT: hoArX50alxHX1mYOrihcB1iZGA+cMKRF18+VTtXY99N55mVqxxcNdy0jsu7Jz AcFGpT9by4v33/v8k6d71SGSNut3w5M1Y55V4QKFnuqDFz4e83jelIWCnwnh7ZZM/sT3E7F z6uTpi+OMP1Z7jyvBEXLGAs4F6CizZ4L8XY7TfsyP2p/AFUjdFPl7T1OArgl97XQgJkh/6Y UFvN8POwUkaWKQhBkorPnFG0okEi1/pIjfr9VCs/vFUjAG/lqDuM5K9BE9462Br2voypj0+ KqU2y/d9dGgUBYc8VJyjXbBM9c6PjzUS1OidPVawQduEJIza/o8yXXFRHqHoIzmrt3APMEb gsgqua+2O/NyW4ZeCqKXTDW6FjzPqNY0tBIaYOff9EXpYK8gO+mip2Uh9tHJw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4020491424755662603 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 11/13] tools/nolibc: sys_select: riscv: use __NR_pselect6_time64 for rv32 Date: Thu, 25 May 2023 01:59:55 +0800 Message-Id: <9359ab11b52ef7c1799337f475e1e27c0cb00e3b.1684949268.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no __NR_pselect6 after kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), use __NR_pselect6_time64 instead. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index c0335a84f880..00c7197dcd50 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1041,8 +1041,13 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva struct timeval *t; } arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout }; return my_syscall1(__NR_select, &arg); -#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6) +#elif defined(__ARCH_WANT_SYS_PSELECT6) && (defined(__NR_pselect6) || defined(__NR_pselect6_time64)) +#ifdef __NR_pselect6 struct timespec t; +#else + struct timespec64 t; +#define __NR_pselect6 __NR_pselect6_time64 +#endif if (timeout) { t.tv_sec = timeout->tv_sec; From patchwork Wed May 24 18:02:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254437 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20CC3C77B7A for ; Wed, 24 May 2023 18:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236596AbjEXSCd (ORCPT ); Wed, 24 May 2023 14:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236522AbjEXSCc (ORCPT ); Wed, 24 May 2023 14:02:32 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E189130; Wed, 24 May 2023 11:02:29 -0700 (PDT) X-QQ-mid: bizesmtp77t1684951344tml8b7ly Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 02:02:21 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: Xz3VOcA7Mr0KaqdkQOpzZ+GPBYPXJApKLC+NLroSL35n8g1DvXnk4MI0nnhSq eCA8abIJEj5/MMX0E0nOiq1r3tRW1Dzuj8kKIhMISCxuR2R+vSH+y9iUTtbM2YLkEZQFbl4 Gwj6XvvvAj46eYzyPG97x4/H3sFl0piFoY4Qhzz2TCtETlBg073vgdEKgIponO7WU5ihXTG 7USD/hZHC2KRfmWeEOarJtk8QF/O+zSJAue55HVToyJnWjy0g89EeUu6x7BvEne9Q56B8z+ H1qfJhUBHAXsIGNQEAnBLXLdMPINADkwqTscOIIy4rgBZdHW6p9iKZ9pgDu/AIDCanwCLue Hp87XNtP5SGMjLlCeXCoFJZ6Z7QZPlB5zQMCyidc1VKdP9xYKKKx3ND7Gh9AA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6618908142304380197 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 12/13] tools/nolibc: sys_wait4: riscv: use __NR_waitid for rv32 Date: Thu, 25 May 2023 02:02:17 +0800 Message-Id: <7a55e771c3cacf2e5b1a4750efac747289dbc54b.1684949268.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no __NR_wait4 after kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), use __NR_waitid instead. This code is based on sysdeps/unix/sysv/linux/wait4.c of glibc. Notes: The kernel wait4 syscall has the 'pid == INT_MIN' path and returns -ESRCH, but the kernel waitid syscall has no such path, to let this __NR_waitid based sys_wait4 has the same return value and pass the 'waitpid_min' test, we emulate such path in our new nolibc __NR_waitid branch. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 54 ++++++++++++++++++++++++++++++++++++ tools/include/nolibc/types.h | 15 +++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 00c7197dcd50..2642b380c6aa 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -12,6 +12,7 @@ /* system includes */ #include +#include /* for siginfo_t */ #include /* for SIGCHLD */ #include #include @@ -1333,7 +1334,60 @@ int unlink(const char *path) static __attribute__((unused)) pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) { +#ifdef __NR_wait4 return my_syscall4(__NR_wait4, pid, status, options, rusage); +#elif defined(__NR_waitid) + siginfo_t infop; + int idtype = P_PID; + int ret; + + /* emulate the 'pid == INT_MIN' path of wait4 */ + if (pid == INT_MIN) + return -ESRCH; + + if (pid < -1) { + idtype = P_PGID; + pid *= -1; + } else if (pid == -1) { + idtype = P_ALL; + } else if (pid == 0) { + idtype = P_PGID; + } + + options |= WEXITED; + + ret = my_syscall5(__NR_waitid, idtype, pid, &infop, options, rusage); + if (ret < 0) + return ret; + + if (status) { + switch (infop.si_code) { + case CLD_EXITED: + *status = W_EXITCODE(infop.si_status, 0); + break; + case CLD_DUMPED: + *status = __WCOREFLAG | infop.si_status; + break; + case CLD_KILLED: + *status = infop.si_status; + break; + case CLD_TRAPPED: + case CLD_STOPPED: + *status = W_STOPCODE(infop.si_status); + break; + case CLD_CONTINUED: + *status = __W_CONTINUED; + break; + default: + *status = 0; + break; + } + } + + return infop.si_pid; +#else +#error Neither __NR_wait4 nor __NR_waitid defined, cannot implement sys_wait4() +#endif } static __attribute__((unused)) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index ee914391439c..c4f95c267607 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -92,8 +92,21 @@ #define WTERMSIG(status) ((status) & 0x7f) #define WIFSIGNALED(status) ((status) - 1 < 0xff) -/* waitpid() flags */ +/* waitpid() and waitid() flags */ #define WNOHANG 1 +#define WEXITED 0x00000004 + +/* first argument for waitid() */ +#define P_ALL 0 +#define P_PID 1 +#define P_PGID 2 +#define P_PIDFD 3 + +/* Macros used on waitid's status setting */ +#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#define W_STOPCODE(sig) ((sig) << 8 | 0x7f) +#define __W_CONTINUED 0xffff +#define __WCOREFLAG 0x80 /* standard exit() codes */ #define EXIT_SUCCESS 0 From patchwork Wed May 24 18:03:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13254438 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 036A9C77B7C for ; Wed, 24 May 2023 18:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjEXSDp (ORCPT ); Wed, 24 May 2023 14:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjEXSDo (ORCPT ); Wed, 24 May 2023 14:03:44 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C082B6; Wed, 24 May 2023 11:03:41 -0700 (PDT) X-QQ-mid: bizesmtp78t1684951416tb3pz334 Received: from linux-lab-host.localdomain ( [116.30.125.36]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 25 May 2023 02:03:35 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: znfcQSa1hKahN1m9MXihhsfaKEggHvIyA5/pTK2SaWBMBZDnB/qZVYB9hhaeW CtThDB38b2eIGVPxEtHTZ/aQx/m+LDrbyyqaUCEQjb3UrqG8e6vmoo+YN9ez5R3jAa+ctud hvf6+/GoNail8IsTWRntTm/VesMGwdeFQrjRCv9wgfeqGxpgfAXNzkEbm39kA+CQ13SCWiE iowUfkUtPUrUPEHv1pYfm9xxUrsV9UR/X3MRXjJ4GFhpHfjlERqt1laG9cY/MuPEBPIPVse G6RO3Z7tTbo4v1LfUw+MGPlMNWQaDMO/oUPriwjPaOHCEtWdRGHW+OdwyxBTwFSMSP/o1qi MlHUfX46tdBlGm7LLQfYMG6eXe10fkgOsXkruJqOw4zHZuAjYDpIHkDjpGh47G+lEvpB/RZ X-QQ-GoodBg: 0 X-BIZMAIL-ID: 13367086140274863961 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com, thomas@t-8ch.de Subject: [PATCH 13/13] tools/nolibc: sys_gettimeofday: riscv: use __NR_clock_gettime64 for rv32 Date: Thu, 25 May 2023 02:03:32 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no __NR_gettimeofday and __NR_clock_gettime after kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), use __NR_clock_gettime64 instead. This code is based on src/time/gettimeofday.c of musl and sysdeps/unix/sysv/linux/clock_gettime.c of glibc. Both __NR_clock_gettime and __NR_clock_gettime64 are added for sys_gettimeofday() for they share most of the code. Notes: * Both tv and tz are not directly passed to kernel clock_gettime* syscalls, so, it isn't able to check the pointer automatically with the get_user/put_user helpers just like kernel gettimeofday syscall does. instead, we emulate (but not completely) such checks in our new __NR_clock_gettime* branch of nolibc. * kernel clock_gettime* syscalls can not get tz info, just like musl and glibc do, we set tz to zero to avoid a random number. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 2642b380c6aa..ad38cc3856be 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -26,6 +26,7 @@ #include "arch.h" #include "errno.h" +#include "string.h" #include "types.h" @@ -51,6 +52,11 @@ * should not be placed here. */ +/* + * This is the first address past the end of the text segment (the program code). + */ + +extern char etext; /* * int brk(void *addr); @@ -554,7 +560,47 @@ long getpagesize(void) static __attribute__((unused)) int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { +#ifdef __NR_gettimeofday return my_syscall2(__NR_gettimeofday, tv, tz); +#elif defined(__NR_clock_gettime) || defined(__NR_clock_gettime64) +#ifdef __NR_clock_gettime + struct timespec ts; +#else + struct timespec64 ts; +#define __NR_clock_gettime __NR_clock_gettime64 +#endif + int ret; + + /* make sure tv pointer is at least after code segment */ + if (tv != NULL && (char *)tv <= &etext) + return -EFAULT; + + /* set tz to zero to avoid random number */ + if (tz != NULL) { + if ((char *)tz > &etext) + memset(tz, 0, sizeof(struct timezone)); + else + return -EFAULT; + } + + if (tv == NULL) + return 0; + + ret = my_syscall2(__NR_clock_gettime, CLOCK_REALTIME, &ts); + if (ret) + return ret; + + tv->tv_sec = (time_t) ts.tv_sec; +#ifdef __NR_clock_gettime64 + if (tv->tv_sec != ts.tv_sec) + return -EOVERFLOW; +#endif + + tv->tv_usec = ts.tv_nsec / 1000; + return 0; +#else +#error None of __NR_gettimeofday, __NR_clock_gettime and __NR_clock_gettime64 defined, cannot implement sys_gettimeofday() +#endif } static __attribute__((unused))