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 * Depricated: you can surround the whole function declaration
21 * just before function body into __initfunc() macro, like:
23 * __initfunc (static void initme(int x, int y))
25 * extern int z; z = x * y;
28 * If the function has a prototype somewhere, you can also add
29 * __init between closing brace of the prototype and semicolon:
31 * extern int initialize_foobar_device(int, int, int) __init;
33 * For initialized data:
34 * You should insert __initdata between the variable name and equal
35 * sign followed by value, e.g.:
37 * static int init_variable __initdata = 0;
38 * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
40 * For initialized data not at file scope, i.e. within a function,
41 * you should use __initlocaldata instead, due to a bug in GCC 2.7.
45 * Disable the __initfunc macros if a file that is a part of a
46 * module attempts to use them. We do not want to interfere
47 * with module linking.
53 * Used for initialization calls..
55 typedef int (*initcall_t
)(void);
57 extern initcall_t __initcall_start
, __initcall_end
;
59 #define __initcall(fn) \
60 static initcall_t __initcall_##fn __init_call = fn
63 * Used for kernel command line parameter setup
67 int (*setup_func
)(char *);
70 extern struct kernel_param __setup_start
, __setup_end
;
72 #define __setup(str, fn) \
73 static char __setup_str_##fn[] __initdata = str; \
74 static struct kernel_param __setup_##fn __initsetup = { __setup_str_##fn, fn }
77 * Mark functions and data as being only used at initialization
80 #define __init __attribute__ ((__section__ (".text.init")))
81 #define __exit __attribute__ ((unused, __section__(".text.init")))
82 #define __initdata __attribute__ ((__section__ (".data.init")))
83 #define __exitdata __attribute__ ((unused, __section__ (".data.init")))
84 #define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
85 #define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
87 #define __initfunc(__arginit) \
91 /* For assembly routines */
92 #define __INIT .section ".text.init","ax"
93 #define __FINIT .previous
94 #define __INITDATA .section ".data.init","aw"
96 #define module_init(x) __initcall(x);
97 #define module_exit(x) /* nothing */
105 #define __initfunc(__arginit) __arginit
107 /* For assembly routines */
112 /* Not sure what version aliases were introduced in, but certainly in 2.95. */
113 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
114 #define module_init(x) int init_module(void) __attribute__((alias(#x)));
115 #define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
117 #define module_init(x) int init_module(void) { return x(); }
118 #define module_exit(x) void cleanup_module(void) { x(); }
123 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
124 #define __initlocaldata __initdata
126 #define __initlocaldata