Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4990495rwl; Tue, 28 Mar 2023 14:29:30 -0700 (PDT) X-Google-Smtp-Source: AKy350Yynmao9wqVW15bPMMdE1txjSVVVot6JCrEAuuLQYyEirpm6NFzLpgRD/Z9FIumEsydbNaI X-Received: by 2002:a17:90b:1d10:b0:23f:2d2c:abd0 with SMTP id on16-20020a17090b1d1000b0023f2d2cabd0mr81685pjb.4.1680038969835; Tue, 28 Mar 2023 14:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680038969; cv=none; d=google.com; s=arc-20160816; b=zVc7VzHJ4grW4xgW6xS60pabMyXs/7ScxLDlclvDryC9VUONMrjZXl3QOrlVkUw7Ot GXoizaFB3GZ8Ihq135BLF//WFmIyXN3Wj0hzti6AH3eRu99DkU893WDGwRhFCnFNe1fu FhDtXSSqobsv+GVyI9B8c0PnVV3St6IVK8DbkGrYbv5W87wbwFvScTRpAB0zlz49sa4e v8MNd6WnIqiQNdy1RcTZgSwqX0rCK5/onPfAhE6FpKLWtX3vyKZHQDXOKoRmM1zD1HAX lllnMyKosuf1qvbpuQHIx+HEDGTP9s8blmtV1aGnWut0kwrGxqFubxVh4JhZQWi58uhj RhdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from; bh=91T31NneDiaZmiY1/OUJAeXNbyanC8xzj6xQ1SHeju0=; b=IWjVB36p0pwO2rHXcJnCgvX2kqACHwvXaypl/MWCvt0sCkoKDVAVDGafF+wz5FMu/a hE3ynm6fnzxQafAhUh3AWYZ8IXmwS9w1PKcoqWG7UpHMwfprIWsDGPhD0Qh8TkVzDWP0 d/QN+Itm8DToxnbg1l+oUcMKLlePA476qeaiRPppbZDVmUr1fbTZLoIcLFe/QQJwDufF 7yh8+S5Ale0scZGoASq/1G2emV3w0vrYLsfTl+sVRWhxE5ZnDZV1F+ouHi7zZctQvlO/ pinDax3OKrbPDH8yZnojpJJze+kYmLkSaG8lsMHKRotWoX43+NWFSb+DCr9xTiLGkfMc QQ8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=FUmw3S4k; 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 z7-20020a17090a66c700b002407c936aafsi26974pjl.33.2023.03.28.14.29.17; Tue, 28 Mar 2023 14:29:29 -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; dkim=pass header.i=@weissschuh.net header.s=mail header.b=FUmw3S4k; 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 S229787AbjC1VHq (ORCPT + 99 others); Tue, 28 Mar 2023 17:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbjC1VHp (ORCPT ); Tue, 28 Mar 2023 17:07:45 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC5E95; Tue, 28 Mar 2023 14:07:44 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1680037663; bh=8ux9UHqbqpMOlAJI+ZJEgyqwQHWiMyZYCque8yHWZRU=; h=From:Date:Subject:To:Cc:From; b=FUmw3S4kxf8Zu1dS5Ws4Tp4ii5oEjdIBQ+ojpDYFC2bIa17ajXjBsNZQyJuWs7ux3 LuzYPEyGZCu+00czxmpthEIcPZrjMG8/aWb0Y3gy3Fk8WvEJCj9y8s2pbenkfMvU8u hi8a+FFSZ1oK0qP5wQloXaO15f9VJATiOyh5ZyPU= Date: Tue, 28 Mar 2023 21:07:35 +0000 Subject: [PATCH] tools/nolibc: validate C99 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230328-nolibc-c99-v1-1-a8302fb19f19@weissschuh.net> X-B4-Tracking: v=1; b=H4sIABZXI2QC/x2NQQqDMBAAvyJ7dsEmURq/Ih6SdK0LYZWEFkH8u 4vHGRjmhEqFqcLYnFDoz5U3UXi1DaQ1yJeQP8pgOmM7a94oW+aYMHmPvV+co+D6wQ6gQQyVMJY gadVEfjmr3AstfDyHab6uG/jq3HRxAAAA To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1680037661; l=2491; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8ux9UHqbqpMOlAJI+ZJEgyqwQHWiMyZYCque8yHWZRU=; b=slWT4JgbJIqg7PxtMlqRH7dZbvh2R8m8ZhplDChXZgWmAzzPJJ4HCLnldGH8XlOUtDDAEFQa9 3c3lcSWSWAQBnKyD3WrE5bApCjn/4LMzEil0pnOLAo+MJGngGJzuYPV X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Most of the code was migrated to C99-conformant __asm__ statements before. It seems string.h was missed. Fix string.h and also validate during build that nolibc stays within C99. Signed-off-by: Thomas Weißschuh --- This patch is based on the "dev" branch of the RCU tree. --- tools/include/nolibc/string.h | 4 ++-- tools/testing/selftests/nolibc/Makefile | 2 +- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index fffdaf6ff467..0c2e06c7c477 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -90,7 +90,7 @@ void *memset(void *dst, int b, size_t len) while (len--) { /* prevent gcc from recognizing memset() here */ - asm volatile(""); + __asm__ volatile(""); *(p++) = b; } return dst; @@ -139,7 +139,7 @@ size_t strlen(const char *str) size_t len; for (len = 0; str[len]; len++) - asm(""); + __asm__(""); return len; } diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index bbce57420465..55efcb1011cb 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -83,7 +83,7 @@ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 -CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ +CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c99 \ $(call cc-option,-fno-stack-protector) \ $(CFLAGS_STKP_$(ARCH)) $(CFLAGS_$(ARCH)) LDFLAGS := -s diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 47013b78972e..932b2c7b0ce3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -895,7 +895,7 @@ int main(int argc, char **argv, char **envp) #else else if (ioperm(0x501, 1, 1) == 0) #endif - asm volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); + __asm__ volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); /* if it does nothing, fall back to the regular panic */ #endif } --- base-commit: a5333c037de823912dd20e933785c63de7679e64 change-id: 20230328-nolibc-c99-59f44ea45636 Best regards, -- Thomas Weißschuh