4 /* These macros are used to mark some functions or
5 * initialized data (doesn't apply to uninitialized data)
6 * as `initialization' functions. The kernel can take this
7 * as hint that the function is used only during the initialization
8 * phase and free up used memory resources after
13 * You should add __init immediately before the function name, like:
15 * static void __init initme(int x, int y)
17 * extern int z; z = x * y;
20 * If the function has a prototype somewhere, you can also add
21 * __init between closing brace of the prototype and semicolon:
23 * extern int initialize_foobar_device(int, int, int) __init;
25 * For initialized data:
26 * You should insert __initdata between the variable name and equal
27 * sign followed by value, e.g.:
29 * static int init_variable __initdata = 0;
30 * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
32 * For initialized data not at file scope, i.e. within a function,
33 * you should use __initlocaldata instead, due to a bug in GCC 2.7.
41 * Used for initialization calls..
43 typedef int (*initcall_t
)(void);
45 extern initcall_t __initcall_start
, __initcall_end
;
47 #define __initcall(fn) \
48 static initcall_t __initcall_##fn __init_call = fn
51 * Used for kernel command line parameter setup
55 int (*setup_func
)(char *);
58 extern struct kernel_param __setup_start
, __setup_end
;
60 #define __setup(str, fn) \
61 static char __setup_str_##fn[] __initdata = str; \
62 static struct kernel_param __setup_##fn __initsetup = { __setup_str_##fn, fn }
64 #endif /* __ASSEMBLY__ */
67 * Mark functions and data as being only used at initialization
70 #define __init __attribute__ ((__section__ (".text.init")))
71 #define __exit __attribute__ ((unused, __section__(".text.init")))
72 #define __initdata __attribute__ ((__section__ (".data.init")))
73 #define __exitdata __attribute__ ((unused, __section__ (".data.init")))
74 #define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
75 #define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
77 /* For assembly routines */
78 #define __INIT .section ".text.init","ax"
79 #define __FINIT .previous
80 #define __INITDATA .section ".data.init","aw"
82 #define module_init(x) __initcall(x);
83 #define module_exit(x) /* nothing */
92 /* For assembly routines */
97 /* Not sure what version aliases were introduced in, but certainly in 2.95. */
98 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
99 #define module_init(x) int init_module(void) __attribute__((alias(#x)));
100 #define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
102 #define module_init(x) int init_module(void) { return x(); }
103 #define module_exit(x) void cleanup_module(void) { x(); }
108 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
109 #define __initlocaldata __initdata
111 #define __initlocaldata