| 1 | #ifndef _LINUX_INIT_H
|
|---|
| 2 | #define _LINUX_INIT_H
|
|---|
| 3 |
|
|---|
| 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
|
|---|
| 9 | *
|
|---|
| 10 | * Usage:
|
|---|
| 11 | * For functions:
|
|---|
| 12 | *
|
|---|
| 13 | * You should add __init immediately before the function name, like:
|
|---|
| 14 | *
|
|---|
| 15 | * static void __init initme(int x, int y)
|
|---|
| 16 | * {
|
|---|
| 17 | * extern int z; z = x * y;
|
|---|
| 18 | * }
|
|---|
| 19 | *
|
|---|
| 20 | * If the function has a prototype somewhere, you can also add
|
|---|
| 21 | * __init between closing brace of the prototype and semicolon:
|
|---|
| 22 | *
|
|---|
| 23 | * extern int initialize_foobar_device(int, int, int) __init;
|
|---|
| 24 | *
|
|---|
| 25 | * For initialized data:
|
|---|
| 26 | * You should insert __initdata between the variable name and equal
|
|---|
| 27 | * sign followed by value, e.g.:
|
|---|
| 28 | *
|
|---|
| 29 | * static int init_variable __initdata = 0;
|
|---|
| 30 | * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
|
|---|
| 31 | *
|
|---|
| 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.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef MODULE
|
|---|
| 37 |
|
|---|
| 38 | #ifndef __ASSEMBLY__
|
|---|
| 39 |
|
|---|
| 40 | /*
|
|---|
| 41 | * Used for kernel command line parameter setup
|
|---|
| 42 | */
|
|---|
| 43 | struct kernel_param {
|
|---|
| 44 | const char *str;
|
|---|
| 45 | int (*setup_func)(char *);
|
|---|
| 46 | };
|
|---|
| 47 |
|
|---|
| 48 | extern struct kernel_param __setup_start, __setup_end;
|
|---|
| 49 |
|
|---|
| 50 | #define __setup(str, fn) \
|
|---|
| 51 | static char __setup_str_##fn[] __initdata = str; \
|
|---|
| 52 | static struct kernel_param __setup_##fn __initsetup = { __setup_str_##fn, fn }
|
|---|
| 53 |
|
|---|
| 54 | #endif /* __ASSEMBLY__ */
|
|---|
| 55 |
|
|---|
| 56 | /*
|
|---|
| 57 | * Used for initialization calls..
|
|---|
| 58 | */
|
|---|
| 59 | typedef int (*initcall_t)(void);
|
|---|
| 60 | typedef void (*exitcall_t)(void);
|
|---|
| 61 |
|
|---|
| 62 | #define __initcall(fn) \
|
|---|
| 63 | initcall_t __initcall_##fn = fn
|
|---|
| 64 |
|
|---|
| 65 | #define __exitcall(fn) \
|
|---|
| 66 | exitcall_t __exitcall_##fn = fn
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | /*
|
|---|
| 70 | * Mark functions and data as being only used at initialization
|
|---|
| 71 | * or exit time.
|
|---|
| 72 | */
|
|---|
| 73 | #define __init
|
|---|
| 74 | #define __exit
|
|---|
| 75 | #define __initdata
|
|---|
| 76 | #define __exitdata
|
|---|
| 77 | #define __initsetup
|
|---|
| 78 | //#define __init_call
|
|---|
| 79 | #define __devinitdata
|
|---|
| 80 | #define __devinit
|
|---|
| 81 | #define __devexit
|
|---|
| 82 |
|
|---|
| 83 | /* For assembly routines */
|
|---|
| 84 | #define __INIT
|
|---|
| 85 | #define __FINIT
|
|---|
| 86 | #define __INITDATA
|
|---|
| 87 |
|
|---|
| 88 | #define module_init(x) __initcall(x);
|
|---|
| 89 | #define module_exit(x) __exitcall(x);
|
|---|
| 90 |
|
|---|
| 91 | #define extern_module_init(x) extern initcall_t __initcall_##x;
|
|---|
| 92 | #define extern_module_exit(x) extern exitcall_t __exitcall_##x;
|
|---|
| 93 |
|
|---|
| 94 | #else
|
|---|
| 95 |
|
|---|
| 96 | #define __init
|
|---|
| 97 | #define __exit
|
|---|
| 98 | #define __initdata
|
|---|
| 99 | #define __exitdata
|
|---|
| 100 | //#define __initcall
|
|---|
| 101 | /* For assembly routines */
|
|---|
| 102 | #define __INIT
|
|---|
| 103 | #define __FINIT
|
|---|
| 104 | #define __INITDATA
|
|---|
| 105 | #define __devinitdata
|
|---|
| 106 | #define __devinit
|
|---|
| 107 | #define __devexit
|
|---|
| 108 |
|
|---|
| 109 | /*
|
|---|
| 110 | * Used for initialization calls..
|
|---|
| 111 | */
|
|---|
| 112 | typedef int (*initcall_t)(void);
|
|---|
| 113 | typedef void (*exitcall_t)(void);
|
|---|
| 114 |
|
|---|
| 115 | #define __initcall(fn) \
|
|---|
| 116 | initcall_t __initcall_##fn = fn
|
|---|
| 117 |
|
|---|
| 118 | #define __exitcall(fn) \
|
|---|
| 119 | exitcall_t __exitcall_##fn = fn
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | #define module_init(x) __initcall(x);
|
|---|
| 123 | #define module_exit(x) __exitcall(x);
|
|---|
| 124 |
|
|---|
| 125 | #define extern_module_init(x) extern initcall_t __initcall_##x;
|
|---|
| 126 | #define extern_module_exit(x) extern exitcall_t __exitcall_##x;
|
|---|
| 127 |
|
|---|
| 128 | #define __setup(str,func) /* nothing */
|
|---|
| 129 |
|
|---|
| 130 | #endif
|
|---|
| 131 |
|
|---|
| 132 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
|
|---|
| 133 | #define __initlocaldata __initdata
|
|---|
| 134 | #else
|
|---|
| 135 | #define __initlocaldata
|
|---|
| 136 | #endif
|
|---|
| 137 |
|
|---|
| 138 | #define __devexit_p(x) x
|
|---|
| 139 |
|
|---|
| 140 | #endif /* _LINUX_INIT_H */
|
|---|