Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3260077rwd; Sat, 3 Jun 2023 01:43:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49ub85bqBu6uPdQ2lWu+eUWxWtcv2eQ8Eq1iH6JAvsmloToXOYnyrM3MZiDwwumJqr9iQI X-Received: by 2002:a05:6358:7208:b0:123:57ad:62b6 with SMTP id h8-20020a056358720800b0012357ad62b6mr17017705rwa.0.1685781815822; Sat, 03 Jun 2023 01:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685781815; cv=none; d=google.com; s=arc-20160816; b=JId7HBDvHqlo5Ud2KWPEvnKJ71sDXXDA4TzCXD7yGQU2S47lAHWQhNtytjpXdBDCNr snWqEF2CCB+uBkskOUND1XfSmmvFdk7htnXaJH3dV3JXEddsk2M3bSaRNRex70o1rhqL 5ESkcc4WGMVqC7meBmrI/beKD3MK6iq4uUEXwytzEWBgJlFF7QmzH39x7eOaphzBVVqD x5uRcfQiZEuOcSzFkJAyryIqip1pUgv3l5K4PxxbhjtRH7Ejm6B4tvaBdGBIw029qz2i niQM9YhJzSEWYMPxIhP1lGtyGUdGcJdptH/85QND45VSknwtBJ56lja8LppA3GSrlCim D7Gw== 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=UeC7kns3fceygfbYqnH05GobhOKKEfQO6g+ftP1/kFc=; b=uJnujJqhcWpafRxjrx14uVssBj1QetbiI0fW4R391zNsGFExyeYBTmdrfAJp+HgVka EnokKD0o9ZWGHzqRyVQoVYkBwY+TFWKFB43E75iT1mdtE+3eOBQO96yQgqazqfUO10YE uUM96VxA4TIq/CSQ4UxRfKj0NSvvYKaaOTocpi41ivN6AF5Jh3qcMXj5g0npE+FItRdR lUYKOBHM09Z7YO7ks7zQ6DCDd1NI/iyblTg8ugKByjReqjRyyKcOyonzg0MHR2q/QSgF dfeBb87p8Rszf8BfEETC7oxJzoAadZk1I5UJWccCzE9Un2i06COz6cuptEmCswbObxb7 DwzA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020a17090ad35300b0025088014281si2458389pjx.84.2023.06.03.01.43.24; Sat, 03 Jun 2023 01:43:35 -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 S234096AbjFCIHQ (ORCPT + 99 others); Sat, 3 Jun 2023 04:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIHP (ORCPT ); Sat, 3 Jun 2023 04:07:15 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C201B3; Sat, 3 Jun 2023 01:07:13 -0700 (PDT) X-QQ-mid: bizesmtp69t1685779624txgoo497 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:07:03 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: jGGC4gWX7WHvWPvSTOy/Lb7c8eVQpIcZemPq3PNoP6Btk/BRzXuaFdwjgIiSQ W6WK+idd8OnQM2tBuGBsUB5beRI5q0M/Pseeq9EajJLxpVMERzq4SbzdXJeAMmnvk+RDf2P TZjyzttZ1Ehh6oddMbwBEiGZTqJ3qpRAtwBtvGt7chZQ8i8xgDj4SqHU8eUwv9wDgpEEjHY lnJU4TMdKXxJGfhwX6qivcyJSXse9hUWqH6YasFJrCeSsBTuQ8ETIo6vk2yikQ6VuH4V1L8 8se4qXCohhtmlaq4NYQoptvpaNs/qDVEi7JnyngIyi42FDB3nAsGKDq6CHusQPKWdlA7tCc LEgI7y4TMRHR9CVXYEeCIxiSgqOv5XthjaPtZWt2q0Hdr/vnY4EdwGsTfpjFPpZORhVhBp5 K+cfJACxuF4= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18271478634976400800 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, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PATCH v3 05/12] selftests/nolibc: not include limits.h for nolibc Date: Sat, 3 Jun 2023 16:06:57 +0800 Message-Id: <0aa3b57a44b0922a118dda503a9bbb2e49125f96.1685777982.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_MSPIKE_H3, 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 When compile nolibc-test.c with 2.31 glibc, we got 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" Glibc (>= 2.33) commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error. As suggested by Thomas, defining INT_MIN/INT_MAX for nolibc can remove the including of limits.h, and therefore no above error. of course, the other libcs still require limits.h, move it to the right place. The LONG_MIN/LONG_MAX are also defined too. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/09d60dc2-e298-4c22-8e2f-8375861bd9be@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/stdint.h | 14 ++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index c1ce4f5e0603..31a5264539ae 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -96,4 +96,18 @@ typedef uint64_t uintmax_t; #define UINT_FAST32_MAX SIZE_MAX #define UINT_FAST64_MAX SIZE_MAX +#ifndef INT_MIN +#define INT_MIN (-__INT_MAX__ - 1) +#endif +#ifndef INT_MAX +#define INT_MAX __INT_MAX__ +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-__LONG_MAX__ - 1) +#endif +#ifndef LONG_MAX +#define LONG_MAX __LONG_MAX__ +#endif + #endif /* _NOLIBC_STDINT_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 403f6255c177..2a2954cb7bef 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -2,9 +2,6 @@ #define _GNU_SOURCE -/* platform-specific include files coming from the compiler */ -#include - /* libc-specific include files * The program may be built in 3 ways: * $(CC) -nostdlib -include /path/to/nolibc.h => NOLIBC already defined @@ -39,6 +36,7 @@ #include #include #include +#include #endif #endif -- 2.25.1