From patchwork Thu Oct 1 23:12:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1375503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oo8G2nF7; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C2TSb0jsgz9sTr for ; Fri, 2 Oct 2020 09:13:13 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 969ED3C6B46 for ; Fri, 2 Oct 2020 01:13:06 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 4FB353C295C for ; Fri, 2 Oct 2020 01:13:04 +0200 (CEST) Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id C6EEE1A00FF3 for ; Fri, 2 Oct 2020 01:13:03 +0200 (CEST) Received: by mail-wr1-x441.google.com with SMTP id w5so494201wrp.8 for ; Thu, 01 Oct 2020 16:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G3g2E+9JUqJenHz1kRtN7tuiTmUE47H7P1ZfksuSG1s=; b=oo8G2nF7Tacwv3/+B1Ht1evGkkckeATZhpkFMmveE1bGVC3RBllliyo0J4x1O7QBNS u5h2IymdeL8dtrylkDAGSMingLVIqEX+Y7LW8LPMcTR5HVGSABVbJAyK6YvieiK+H8OQ 1wOrVNDDWUipdKc6nQswdjwt4+S2fJNT3Itk0VsiF/+jftUL7msY587Uv0/gokIXRqon NmldgRpI2N8jtEgWYMTHZJEhEJUOJVOmjhkvunaZQe89NUuoOyZABX52PVGyRmaRMQ4w sJ4c7WO4TqSdx144Ukh8vjGtakuqVIvnGxQH+F+0Z7BIgS9L1xbb1WNj3NXAOVDvzuPe DJxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G3g2E+9JUqJenHz1kRtN7tuiTmUE47H7P1ZfksuSG1s=; b=XFHKo9+RKV6rwpaXM9PwLhn1vJuZ10i7m6jcR2DzyzefMe8thFF/5nlKQPfx5GlCbB S7dlDSatPso+LdWEebiMhqQ7wkrLeGP/wiUehSXVgLec4OV8Z2tEVOW+D9snTQhFNmlX BFkCrkYjvqndY5kpcYzmcXf97g+RcRLkkSKpcAA8UFmxkV/fgQqSQZeTNJ+GBoPr5OhN 68PENhlqPUMIizwcJgrEV3INDcizd7DsgNLzgtnZORmO7C1By6o3prHxeRQQO6aMx5WC cUSCH9/rLMRtjnypNKObQj90JtK1RCO6+2Hr8Q12vJwWnRT5Pw7tZmx0xig+zngwc9Rj GfMg== X-Gm-Message-State: AOAM5333bSx43ZUSjKKtMhUzqUTBAukzgHD6sLb684BJxFxjGAw3NV3+ wKLmby9OhhTnEPC8vugKBtEKBzIUhabiMw== X-Google-Smtp-Source: ABdhPJwRe2StSGV0zz3j2dMdpV6CSy/ZXREPF7MaDoQ5nAfc+7zSTsOe8rmdZ/mIX4oD3X9eT6gw4w== X-Received: by 2002:adf:e9c1:: with SMTP id l1mr11556483wrn.68.1601593983131; Thu, 01 Oct 2020 16:13:03 -0700 (PDT) Received: from dell5510.suse.de ([62.201.25.198]) by smtp.gmail.com with ESMTPSA id w7sm1962247wmc.43.2020.10.01.16.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 16:13:02 -0700 (PDT) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 2 Oct 2020 01:12:56 +0200 Message-Id: <20201001231256.6930-1-petr.vorel@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [RFC PATCH 1/1] lapi: Add sysinfo.h to fix build with MUSL libc X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The reason is to avoid indirect include when using some UAPI headers: or others -> -> This indirect include causes on MUSL redefinition of struct sysinfo when included both and some of UAPI headers: In file included from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5, from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11: x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here Signed-off-by: Petr Vorel --- Hi, another MUSL specific workaround. I'm ok if we don't want to accept it. I also sent patch to kernel, but don't think it will be accepted. https://lore.kernel.org/linux-api/20201001211942.13336-1-petr.vorel@gmail.com/T/#me9d7d385157ec5f6288bae77d738a96c12ab8ca7 Kind regards, Petr include/lapi/sysinfo.h | 22 +++++++++++++++++++ include/tst_safe_macros.h | 2 +- lib/safe_macros.c | 2 +- lib/tst_memutils.c | 2 +- testcases/kernel/mem/mtest01/mtest01.c | 2 +- testcases/kernel/syscalls/madvise/madvise06.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo01.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo02.c | 2 +- testcases/kernel/syscalls/sysinfo/sysinfo03.c | 2 +- 9 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 include/lapi/sysinfo.h diff --git a/include/lapi/sysinfo.h b/include/lapi/sysinfo.h new file mode 100644 index 000000000..d0e0e93d7 --- /dev/null +++ b/include/lapi/sysinfo.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Petr Vorel + */ + +#ifndef SYSINFO_H__ + +/* + * Don't use as it breaks build MUSL toolchain. + * Use instead. + * + * Some kernel UAPI headers do indirect include: + * or others -> -> + * + * This indirect include causes on MUSL redefinition of struct sysinfo when + * included both and some of UAPI headers: + */ +#include + +#define SYSINFO_H__ + +#endif /* SYSINFO_H__ */ diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 053c3bcf9..61ea2076d 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/safe_macros.c b/lib/safe_macros.c index 4f48d7529..d8ee03dae 100644 --- a/lib/safe_macros.c +++ b/lib/safe_macros.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include "test.h" #include "safe_macros.h" +#include "lapi/sysinfo.h" char *safe_basename(const char *file, const int lineno, void (*cleanup_fn) (void), char *path) diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c index f134d90c9..647db951e 100644 --- a/lib/tst_memutils.c +++ b/lib/tst_memutils.c @@ -5,11 +5,11 @@ #include #include -#include #include #define TST_NO_DEFAULT_MAIN #include "tst_test.h" +#include "lapi/sysinfo.h" #define BLOCKSIZE (16 * 1024 * 1024) diff --git a/testcases/kernel/mem/mtest01/mtest01.c b/testcases/kernel/mem/mtest01/mtest01.c index f08d3943f..9b4d856f8 100644 --- a/testcases/kernel/mem/mtest01/mtest01.c +++ b/testcases/kernel/mem/mtest01/mtest01.c @@ -20,7 +20,6 @@ */ #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include "lapi/abisize.h" +#include "lapi/sysinfo.h" #include "tst_test.h" #define FIVE_HUNDRED_MB (500ULL*1024*1024) diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c index f76f3f6aa..b2613670b 100644 --- a/testcases/kernel/syscalls/madvise/madvise06.c +++ b/testcases/kernel/syscalls/madvise/madvise06.c @@ -24,8 +24,8 @@ #include #include #include -#include #include "tst_test.h" +#include "lapi/sysinfo.h" #define CHUNK_SZ (400*1024*1024L) #define CHUNK_PAGES (CHUNK_SZ / pg_sz) diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo01.c b/testcases/kernel/syscalls/sysinfo/sysinfo01.c index 2ea44a2be..a95066bf5 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo01.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo01.c @@ -69,9 +69,9 @@ #include #include #include -#include #include "test.h" +#include "lapi/sysinfo.h" void setup(); void cleanup(); diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo02.c b/testcases/kernel/syscalls/sysinfo/sysinfo02.c index 678b8f1d3..5ce65d20e 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo02.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo02.c @@ -65,10 +65,10 @@ #include #include #include -#include #include #include "test.h" +#include "lapi/sysinfo.h" #define INVALID_ADDRESS ((uintptr_t)-1) diff --git a/testcases/kernel/syscalls/sysinfo/sysinfo03.c b/testcases/kernel/syscalls/sysinfo/sysinfo03.c index af7cb6421..3b61a05b1 100644 --- a/testcases/kernel/syscalls/sysinfo/sysinfo03.c +++ b/testcases/kernel/syscalls/sysinfo/sysinfo03.c @@ -13,9 +13,9 @@ */ -#include #include "lapi/namespaces_constants.h" #include "lapi/posix_clocks.h" +#include "lapi/sysinfo.h" #include "tst_test.h" static int offsets[] = {