Name: Centralize token pasting and generation of unique IDs Author: Rusty Russell Status: Tested on 2.5.70-bk13 Add __cat(a,b) to implement token pasting to stringify.h. To generate unique names, __unique_id(stem) is implemented (it'd be nice to have a gcc extension to give a unique identifier). Change module.h to use them. Index: linux-2.6.10-rc1-bk12-Module/include/linux/stringify.h =================================================================== --- linux-2.6.10-rc1-bk12-Module.orig/include/linux/stringify.h 2003-09-21 17:27:45.000000000 +1000 +++ linux-2.6.10-rc1-bk12-Module/include/linux/stringify.h 2004-11-03 12:11:16.858014592 +1100 @@ -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 */ Index: linux-2.6.10-rc1-bk12-Module/include/linux/module.h =================================================================== --- linux-2.6.10-rc1-bk12-Module.orig/include/linux/module.h 2004-11-03 12:11:09.630113400 +1100 +++ linux-2.6.10-rc1-bk12-Module/include/linux/module.h 2004-11-03 12:12:58.187610152 +1100 @@ -72,10 +72,8 @@ extern struct subsystem module_subsys; #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_used__ \ __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info