diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2008-01-20 12:54:48 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-01-28 17:21:17 -0500 |
commit | f3fe866d59d707c7a2bba0b23add078e19edb3dc (patch) | |
tree | e255f81f9401adcaffc101af20ecf54bba033479 /include/linux | |
parent | 01ba2bdc6b639764745ff678caf3fb9e5bcd745a (diff) |
compiler.h: introduce __section()
Add a new helper: __section() that makes a section definition
much shorter and more readable.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/compiler.h | 5 | ||||
-rw-r--r-- | include/linux/init.h | 26 |
2 files changed, 18 insertions, 13 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index c68b67b86ef..e0114a61268 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -175,4 +175,9 @@ extern void __chk_io_ptr(const volatile void __iomem *); | |||
175 | #define __cold | 175 | #define __cold |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | /* Simple shorthand for a section definition */ | ||
179 | #ifndef __section | ||
180 | # define __section(S) __attribute__ ((__section__(#S))) | ||
181 | #endif | ||
182 | |||
178 | #endif /* __LINUX_COMPILER_H */ | 183 | #endif /* __LINUX_COMPILER_H */ |
diff --git a/include/linux/init.h b/include/linux/init.h index 5141381a752..99807681840 100644 --- a/include/linux/init.h +++ b/include/linux/init.h | |||
@@ -40,10 +40,10 @@ | |||
40 | 40 | ||
41 | /* These are for everybody (although not all archs will actually | 41 | /* These are for everybody (although not all archs will actually |
42 | discard it in modules) */ | 42 | discard it in modules) */ |
43 | #define __init __attribute__ ((__section__ (".init.text"))) __cold | 43 | #define __init __section(.init.text) __cold |
44 | #define __initdata __attribute__ ((__section__ (".init.data"))) | 44 | #define __initdata __section(.init.data) |
45 | #define __exitdata __attribute__ ((__section__(".exit.data"))) | 45 | #define __exitdata __section(.exit.data) |
46 | #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) | 46 | #define __exit_call __attribute_used__ __section(.exitcall.exit) |
47 | 47 | ||
48 | /* modpost check for section mismatches during the kernel build. | 48 | /* modpost check for section mismatches during the kernel build. |
49 | * A section mismatch happens when there are references from a | 49 | * A section mismatch happens when there are references from a |
@@ -55,14 +55,14 @@ | |||
55 | * the init/exit section (code or data) is valid and will teach modpost | 55 | * the init/exit section (code or data) is valid and will teach modpost |
56 | * not to issue a warning. | 56 | * not to issue a warning. |
57 | * The markers follow same syntax rules as __init / __initdata. */ | 57 | * The markers follow same syntax rules as __init / __initdata. */ |
58 | #define __init_refok noinline __attribute__ ((__section__ (".text.init.refok"))) | 58 | #define __init_refok noinline __section(.text.init.refok) |
59 | #define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) | 59 | #define __initdata_refok __section(.data.init.refok) |
60 | #define __exit_refok noinline __attribute__ ((__section__ (".exit.text.refok"))) | 60 | #define __exit_refok noinline __section(.exit.text.refok) |
61 | 61 | ||
62 | #ifdef MODULE | 62 | #ifdef MODULE |
63 | #define __exit __attribute__ ((__section__(".exit.text"))) __cold | 63 | #define __exit __section(.exit.text) __cold |
64 | #else | 64 | #else |
65 | #define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold | 65 | #define __exit __attribute_used__ __section(.exit.text) __cold |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | /* For assembly routines */ | 68 | /* For assembly routines */ |
@@ -142,11 +142,11 @@ void prepare_namespace(void); | |||
142 | 142 | ||
143 | #define console_initcall(fn) \ | 143 | #define console_initcall(fn) \ |
144 | static initcall_t __initcall_##fn \ | 144 | static initcall_t __initcall_##fn \ |
145 | __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn | 145 | __attribute_used__ __section(.con_initcall.init)=fn |
146 | 146 | ||
147 | #define security_initcall(fn) \ | 147 | #define security_initcall(fn) \ |
148 | static initcall_t __initcall_##fn \ | 148 | static initcall_t __initcall_##fn \ |
149 | __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn | 149 | __attribute_used__ __section(.security_initcall.init) = fn |
150 | 150 | ||
151 | struct obs_kernel_param { | 151 | struct obs_kernel_param { |
152 | const char *str; | 152 | const char *str; |
@@ -164,7 +164,7 @@ struct obs_kernel_param { | |||
164 | static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ | 164 | static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ |
165 | static struct obs_kernel_param __setup_##unique_id \ | 165 | static struct obs_kernel_param __setup_##unique_id \ |
166 | __attribute_used__ \ | 166 | __attribute_used__ \ |
167 | __attribute__((__section__(".init.setup"))) \ | 167 | __section(.init.setup) \ |
168 | __attribute__((aligned((sizeof(long))))) \ | 168 | __attribute__((aligned((sizeof(long))))) \ |
169 | = { __setup_str_##unique_id, fn, early } | 169 | = { __setup_str_##unique_id, fn, early } |
170 | 170 | ||
@@ -242,7 +242,7 @@ void __init parse_early_param(void); | |||
242 | #endif | 242 | #endif |
243 | 243 | ||
244 | /* Data marked not to be saved by software suspend */ | 244 | /* Data marked not to be saved by software suspend */ |
245 | #define __nosavedata __attribute__ ((__section__ (".data.nosave"))) | 245 | #define __nosavedata __section(.data.nosave) |
246 | 246 | ||
247 | /* This means "can be init if no module support, otherwise module load | 247 | /* This means "can be init if no module support, otherwise module load |
248 | may call it." */ | 248 | may call it." */ |