* [PATCH] __cat and __unique_id in stringify.h
@ 2003-06-12 6:41 Rusty Russell
2003-06-12 9:29 ` Jörn Engel
0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2003-06-12 6:41 UTC (permalink / raw)
To: torvalds; +Cc: trivial, linux-kernel
__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.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .26569-linux-2.5.70-bk16/include/linux/module.h .26569-linux-2.5.70-bk16.updated/include/linux/module.h
--- .26569-linux-2.5.70-bk16/include/linux/module.h 2003-06-12 09:58:02.000000000 +1000
+++ .26569-linux-2.5.70-bk16.updated/include/linux/module.h 2003-06-12 16:19:16.000000000 +1000
@@ -55,10 +55,8 @@ search_extable(const struct exception_ta
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) \
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .26569-linux-2.5.70-bk16/include/linux/stringify.h .26569-linux-2.5.70-bk16.updated/include/linux/stringify.h
--- .26569-linux-2.5.70-bk16/include/linux/stringify.h 2003-01-02 12:25:36.000000000 +1100
+++ .26569-linux-2.5.70-bk16.updated/include/linux/stringify.h 2003-06-12 16:32:17.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 */
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] __cat and __unique_id in stringify.h
2003-06-12 6:41 [PATCH] __cat and __unique_id in stringify.h Rusty Russell
@ 2003-06-12 9:29 ` Jörn Engel
0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2003-06-12 9:29 UTC (permalink / raw)
To: Rusty Russell; +Cc: torvalds, trivial, linux-kernel
On Thu, 12 June 2003 16:41:53 +1000, Rusty Russell wrote:
> +/* Paste two tokens together. */
> +#define ___cat(a,b) a ## b
> +#define __cat(a,b) ___cat(a,b)
It might be a bit too easy to type ___cat instead of __cat. If you
use ___cat___ or something similar, there might be less problems
caused by typing problems.
Jörn
--
With a PC, I always felt limited by the software available. On Unix,
I am limited only by my knowledge.
-- Peter J. Schoenster
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-06-12 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-12 6:41 [PATCH] __cat and __unique_id in stringify.h Rusty Russell
2003-06-12 9:29 ` Jörn Engel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.