mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Trivial Russell <rusty@rustcorp.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: [TRIVIAL] __cat and __unique_id in stringify.h
Date: Mon, 07 Jul 2003 17:57:03 +1000	[thread overview]
Message-ID: <20030707080051.E23832C35F@lists.samba.org> (raw)

From:  Rusty Russell <rusty@rustcorp.com.au>

  __cat() to paste tokens could be used in a few places, and
  __unique_id() is useful for module.h.
  
  Linus, please apply,
  Rusty.
  --
    Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
  
  Name: Centralize token pasting and generation of unique IDs
  Author: Rusty Russell
  Status: Tested on 2.5.70-bk13
  
  D: Add __cat(a,b) to implement token pasting to stringify.h.  To
  D: generate unique names, __unique_id(stem) is implemented (it'd be
  D: nice to have a gcc extension to give a unique identifier).  Change
  D: module.h to use them.
  

--- trivial-2.5.74-bk4/include/linux/module.h.orig	2003-07-07 17:36:52.000000000 +1000
+++ trivial-2.5.74-bk4/include/linux/module.h	2003-07-07 17:36:52.000000000 +1000
@@ -55,10 +55,8 @@
 	       unsigned long value);
 
 #ifdef MODULE
-#define ___module_cat(a,b) __mod_ ## a ## b
-#define __module_cat(a,b) ___module_cat(a,b)
 #define __MODULE_INFO(tag, name, info)					  \
-static const char __module_cat(name,__LINE__)[]				  \
+static const char __unique_id(name)[]					  \
   __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
 
 #define MODULE_GENERIC_TABLE(gtype,name)			\
--- trivial-2.5.74-bk4/include/linux/stringify.h.orig	2003-07-07 17:36:52.000000000 +1000
+++ trivial-2.5.74-bk4/include/linux/stringify.h	2003-07-07 17:36:52.000000000 +1000
@@ -9,4 +9,11 @@
 #define __stringify_1(x)	#x
 #define __stringify(x)		__stringify_1(x)
 
+/* Paste two tokens together. */
+#define ___cat(a,b) a ## b
+#define __cat(a,b) ___cat(a,b)
+
+/* Try to give a unique identifier: this comes close, iff used as static. */
+#define __unique_id(stem) \
+	__cat(__cat(__uniq,stem),__cat(__LINE__,KBUILD_BASENAME))
 #endif	/* !__LINUX_STRINGIFY_H */
-- 
  What is this? http://www.kernel.org/pub/linux/kernel/people/rusty/trivial/
  Don't blame me: the Monkey is driving
  File: Rusty Russell <rusty@rustcorp.com.au>: [PATCH] __cat and __unique_id in stringify.h

                 reply	other threads:[~2003-07-07  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030707080051.E23832C35F@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®