initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / um / include / init.h
blobf1d82e025cade75a8157a3e398c9975599f04bbf
1 #ifndef _LINUX_UML_INIT_H
2 #define _LINUX_UML_INIT_H
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
10 * Usage:
11 * For functions:
13 * You should add __init immediately before the function name, like:
15 * static void __init initme(int x, int y)
16 * {
17 * extern int z; z = x * y;
18 * }
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 * Don't forget to initialize data not at file scope, i.e. within a function,
33 * as gcc otherwise puts the data into the bss section and not into the init
34 * section.
36 * Also note, that this data cannot be "const".
39 #ifndef _LINUX_INIT_H
40 typedef int (*initcall_t)(void);
41 typedef void (*exitcall_t)(void);
43 #define __init __attribute__ ((__section__ (".text.init")))
44 #define __exit __attribute__ ((unused, __section__(".text.exit")))
45 #define __initdata __attribute__ ((__section__ (".data.init")))
47 #endif
49 #ifndef MODULE
50 struct uml_param {
51 const char *str;
52 int (*setup_func)(char *, int *);
55 extern initcall_t __uml_initcall_start, __uml_initcall_end;
56 extern initcall_t __uml_postsetup_start, __uml_postsetup_end;
57 extern const char *__uml_help_start, *__uml_help_end;
58 #endif
60 #define __uml_initcall(fn) \
61 static initcall_t __uml_initcall_##fn __uml_init_call = fn
63 #define __uml_exitcall(fn) \
64 static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn
66 extern struct uml_param __uml_setup_start, __uml_setup_end;
68 #define __uml_postsetup(fn) \
69 static initcall_t __uml_postsetup_##fn __uml_postsetup_call = fn
71 #define __non_empty_string(dummyname,string) \
72 struct __uml_non_empty_string_struct_##dummyname \
73 { \
74 char _string[sizeof(string)-2]; \
77 #ifndef MODULE
78 #define __uml_setup(str, fn, help...) \
79 __non_empty_string(fn ##_setup, str); \
80 __uml_help(fn, help); \
81 static char __uml_setup_str_##fn[] __initdata = str; \
82 static struct uml_param __uml_setup_##fn __uml_init_setup = { __uml_setup_str_##fn, fn }
83 #else
84 #define __uml_setup(str, fn, help...) \
86 #endif
88 #define __uml_help(fn, help...) \
89 __non_empty_string(fn ##__help, help); \
90 static char __uml_help_str_##fn[] __initdata = help; \
91 static const char *__uml_help_##fn __uml_setup_help = __uml_help_str_##fn
94 * Mark functions and data as being only used at initialization
95 * or exit time.
97 #define __uml_init_setup __attribute__ ((unused,__section__ (".uml.setup.init")))
98 #define __uml_setup_help __attribute__ ((unused,__section__ (".uml.help.init")))
99 #define __uml_init_call __attribute__ ((unused,__section__ (".uml.initcall.init")))
100 #define __uml_postsetup_call __attribute__ ((unused,__section__ (".uml.postsetup.init")))
101 #define __uml_exit_call __attribute__ ((unused,__section__ (".uml.exitcall.exit")))
103 #endif /* _LINUX_UML_INIT_H */
106 * Overrides for Emacs so that we follow Linus's tabbing style.
107 * Emacs will notice this stuff at the end of the file and automatically
108 * adjust the settings for this buffer only. This must remain at the end
109 * of the file.
110 * ---------------------------------------------------------------------------
111 * Local variables:
112 * c-file-style: "linux"
113 * End: