linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: linux-modules@vger.kernel.org
Cc: Joe Buehler <aspam@cox.net>,
	Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Subject: [PATCH 2/3] shared: fix UNIQ definition
Date: Fri, 18 Dec 2020 08:02:08 -0800	[thread overview]
Message-ID: <20201218160209.4037174-3-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20201218160209.4037174-1-lucas.demarchi@intel.com>

We need a macro indirection for UNIQ to work. Otherwise it won't be
unique at all since it will just append "UNIQ" to the name:

In file included from testsuite/test-init.c:30:
testsuite/testsuite.h:142:27: error: redefinition of ‘stest_load_resourcesUNIQ’
---
 shared/macro.h        | 7 +++++--
 testsuite/testsuite.h | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/shared/macro.h b/shared/macro.h
index 4fc5405..b59f7dc 100644
--- a/shared/macro.h
+++ b/shared/macro.h
@@ -45,9 +45,14 @@
 	})
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
+
 #define XSTRINGIFY(x) #x
 #define STRINGIFY(x) XSTRINGIFY(x)
 
+#define XCONCATENATE(x, y) x ## y
+#define CONCATENATE(x, y) XCONCATENATE(x, y)
+#define UNIQ(x) CONCATENATE(x, __COUNTER__)
+
 /* Temporaries for importing index handling */
 #define NOFAIL(x) (x)
 #define fatal(x...) do { } while (0)
@@ -69,5 +74,3 @@
 #define noreturn __attribute__((noreturn))
 #endif
 #endif
-
-#define UNIQ __COUNTER__
diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h
index 7ed96bf..f190249 100644
--- a/testsuite/testsuite.h
+++ b/testsuite/testsuite.h
@@ -139,7 +139,7 @@ int test_run(const struct test *t);
 
 /* Test definitions */
 #define DEFINE_TEST(_name, ...) \
-	static const struct test s##_name##UNIQ \
+	static const struct test UNIQ(s##_name) \
 	__attribute__((used, section("kmod_tests"), aligned(8))) = { \
 		.name = #_name, \
 		.func = _name, \
-- 
2.29.2


  parent reply	other threads:[~2020-12-18 16:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18 16:02 [PATCH 0/3] Fix kmod_load_resources without modules.builtin.modinfo Lucas De Marchi
2020-12-18 16:02 ` [PATCH 1/3] depmod: unconditionally write builtin.alias.bin Lucas De Marchi
2020-12-18 16:02 ` Lucas De Marchi [this message]
2020-12-18 16:02 ` [PATCH 3/3] testsuite: add test for empty modules.builtin.aliases.bin Lucas De Marchi
2020-12-28  1:04 ` [PATCH 0/3] Fix kmod_load_resources without modules.builtin.modinfo Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201218160209.4037174-3-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=aspam@cox.net \
    --cc=linux-modules@vger.kernel.org \
    --cc=yauheni.kaliuta@redhat.com \
    --subject='Re: [PATCH 2/3] shared: fix UNIQ definition' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).