From patchwork Sat Jun 3 09:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 102804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1548135vqr; Sat, 3 Jun 2023 02:09:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61U79q6eoe2palJhw4gd8GK/xdh8UmHCNg6CgA2HBuX8uRcLkzxRxcdnOG9gE175V6ZKIs X-Received: by 2002:a05:6808:2912:b0:397:fbe7:a0fb with SMTP id ev18-20020a056808291200b00397fbe7a0fbmr2924635oib.18.1685783386270; Sat, 03 Jun 2023 02:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685783386; cv=none; d=google.com; s=arc-20160816; b=jeh8jz3yJwSBFLK2DCNLtxQKV3mV7v6qqR7oaIjQ/Z4+SZOV++bxiuPNR2qpoGyEjV bFV8YTc5TgyiP27q8Fnu2FKNqlGTf0UBAcY7m1NhDvtu8cRk7atzUalahPOYTgZncnh0 Izky0brBD7exYa/iBg+MeGn/4isPVfa1HmHnbZH1mLUOnMJZyc8IL7gfFW//pXAMa/Un P0J0OUJWV1a0iCjY1LW81Jn8IMj79YETM4hWRI7o/183cB4Qzj9Bq5fh/hg9QaclBAoj DuXo6DlIAm8YDGnuIAU0ecDVLehcHaBF41Ljlf6fUe8dZj1YRyA07xuhXNGaFQt18mos 8BVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=c6cva5TZ8LCDBAb8XdnU0q5Wx9EGDmpqx4182XEDkSk=; b=LKsqHxV3cH0m8yi/uf07Gt/60229oVA82nUgUBSQZ0CNXmpdJo4WImG7Iev8sJayu9 tuPR1e+rcqg6VRQ7580+gzCMvxHnWxpW83Rcw0cBDh1IMLza5GSUY3mtGtajya28gk5l gJYTf/+4n2zfdjfFB6czmhCBxS8PC9Kdg/EnKb3MwP+o/Fl4dx6O2zdaO9bFOjkvZG5R XX5yUiPzWnh4rsRJW3Iu0xlH5PVUBRrYNFhEiKV9cNvO81ERABUqi68ZR1LLxTvZCeV9 V/DzmLbS3WdYvTrOuPIGCp16DxEPe4uw1rImZCnA6hfUHCYjHO9dvs0BsaQ8FstlXsA1 ijBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a170902ee4600b001afd000029bsi2194201plo.581.2023.06.03.02.09.34; Sat, 03 Jun 2023 02:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237107AbjFCJFC (ORCPT + 99 others); Sat, 3 Jun 2023 05:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjFCJFB (ORCPT ); Sat, 3 Jun 2023 05:05:01 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017F6E56; Sat, 3 Jun 2023 02:04:59 -0700 (PDT) X-QQ-mid: bizesmtp85t1685783090tuggc0mf Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 17:04:49 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: 7aHzntQn+UDHWzdTWpnJ/o+QEDhVowL/EH/i/fZBEdZqSAhhL5+pk34byH2Y5 kzLZBz9qzzO0LP7M+PHEtGEIMj8KpN0Glze3AWMa2ZIfxU/SvPwyc9Aa+8xPzPVir/sy1Aq KT3Zbu29n8BjDugTZ9m11vay+P3VJC2mSUwnJ4qxmYg4oTSyqLFXJgJ+WZPFXp993qh/a+Z zCdQJ/oTJCl6Q+WrnkmPUwenBidK5AngUE7qtZZvIDdjHmT03Us1ykhpzts22qNACVokfWX UEWPEo9i8QuM2Ge+WRNEkvl9tU5a/xj5WytSvIRNnldYygYj9PtwEo5FCjzizT0ZAQPHGK5 8qirc5kUl/BjHnumj7Hv6kkmRw0JMb+ifxJwUlYqlQ9HPJzHwKu2zfUKDBaW/uGb4mFlarp 2I9DDIpEOdw= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10955599285119131163 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 2/3] tools/nolibc: fix up undeclared syscall macros with #ifdef and -ENOSYS Date: Sat, 3 Jun 2023 17:04:17 +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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767672000016437281?= X-GMAIL-MSGID: =?utf-8?q?1767672000016437281?= Compiling nolibc for rv32 got such errors: nolibc/sysroot/riscv/include/sys.h: In function ‘sys_gettimeofday’: nolibc/sysroot/riscv/include/sys.h:557:21: error: ‘__NR_gettimeofday’ undeclared (first use in this function); did you mean ‘sys_gettimeofday’? 557 | return my_syscall2(__NR_gettimeofday, tv, tz); | ^~~~~~~~~~~~~~~~~ nolibc/sysroot/riscv/include/sys.h: In function ‘sys_lseek’: nolibc/sysroot/riscv/include/sys.h:675:21: error: ‘__NR_lseek’ undeclared (first use in this function) 675 | return my_syscall3(__NR_lseek, fd, offset, whence); | ^~~~~~~~~~ nolibc/sysroot/riscv/include/sys.h: In function ‘sys_wait4’: nolibc/sysroot/riscv/include/sys.h:1341:21: error: ‘__NR_wait4’ undeclared (first use in this function) 1341 | return my_syscall4(__NR_wait4, pid, status, options, rusage); If a syscall macro is not supported by a target platform, wrap it with '#ifdef' and 'return -ENOSYS' for the '#else' branch, which lets the other syscalls work as-is and allows developers to fix up the test failures reported by nolibc-test one by one later. This wraps all of the failed syscall macros with '#ifdef' and 'return -ENOSYS' for the '#else' branch, so, all of the undeclared failures are fixed. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/5e7d2adf-e96f-41ca-a4c6-5c87a25d4c9c@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 78c86f124335..5464f93e863e 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -554,7 +554,11 @@ 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); +#else + return -ENOSYS; +#endif } static __attribute__((unused)) @@ -672,7 +676,11 @@ 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); +#else + return -ENOSYS; +#endif } static __attribute__((unused)) @@ -1338,7 +1346,11 @@ 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); +#else + return -ENOSYS; +#endif } static __attribute__((unused))