40 #ifndef included_vlib_init_h 41 #define included_vlib_init_h 53 typedef struct _vlib_init_function_list_elt
55 struct _vlib_init_function_list_elt *next_init_function;
57 } _vlib_init_function_list_elt_t;
82 #define _VLIB_INIT_FUNCTION_SYMBOL(x, type) \ 83 _vlib_##type##_function_##x 85 #define VLIB_INIT_FUNCTION_SYMBOL(x) \ 86 _VLIB_INIT_FUNCTION_SYMBOL(x, init) 87 #define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x) \ 88 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter) 89 #define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL(x) \ 90 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit) 91 #define VLIB_CONFIG_FUNCTION_SYMBOL(x) \ 92 _VLIB_INIT_FUNCTION_SYMBOL(x, config) 97 #define VLIB_DECLARE_INIT_FUNCTION(x, tag) \ 98 vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \ 99 static void __vlib_add_##tag##_function_##x (void) \ 100 __attribute__((__constructor__)) ; \ 101 static void __vlib_add_##tag##_function_##x (void) \ 103 vlib_main_t * vm = vlib_get_main(); \ 104 static _vlib_init_function_list_elt_t _vlib_init_function; \ 105 _vlib_init_function.next_init_function \ 106 = vm->tag##_function_registrations; \ 107 vm->tag##_function_registrations = &_vlib_init_function; \ 108 _vlib_init_function.f = &x; \ 111 #define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init) 112 #define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init) 114 #define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \ 115 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter) 116 #define VLIB_MAIN_LOOP_EXIT_FUNCTION(x) \ 117 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit) 119 #define VLIB_CONFIG_FUNCTION(x,n,...) \ 120 __VA_ARGS__ vlib_config_function_runtime_t \ 121 VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 122 static void __vlib_add_config_function_##x (void) \ 123 __attribute__((__constructor__)) ; \ 124 static void __vlib_add_config_function_##x (void) \ 126 vlib_main_t * vm = vlib_get_main(); \ 127 VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration \ 128 = vm->config_function_registrations; \ 129 vm->config_function_registrations \ 130 = &VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 132 vlib_config_function_runtime_t \ 133 VLIB_CONFIG_FUNCTION_SYMBOL (x) \ 140 #define VLIB_EARLY_CONFIG_FUNCTION(x,n,...) \ 141 __VA_ARGS__ vlib_config_function_runtime_t \ 142 VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 143 static void __vlib_add_config_function_##x (void) \ 144 __attribute__((__constructor__)) ; \ 145 static void __vlib_add_config_function_##x (void) \ 147 vlib_main_t * vm = vlib_get_main(); \ 148 VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration \ 149 = vm->config_function_registrations; \ 150 vm->config_function_registrations \ 151 = &VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 153 vlib_config_function_runtime_t \ 154 VLIB_CONFIG_FUNCTION_SYMBOL (x) \ 162 #define vlib_call_init_function(vm, x) \ 164 extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x); \ 165 vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x); \ 166 clib_error_t * _error = 0; \ 167 if (! hash_get (vm->init_functions_called, _f)) \ 169 hash_set1 (vm->init_functions_called, _f); \ 176 #define vlib_mark_init_function_complete(vm, x) \ 178 extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x); \ 179 vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x); \ 180 hash_set1 (vm->init_functions_called, _f); \ 183 #define vlib_call_post_graph_init_function(vm, x) \ 185 extern vlib_init_function_t * VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \ 186 vlib_init_function_t * _f = VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \ 187 clib_error_t * _error = 0; \ 188 if (! hash_get (vm->init_functions_called, _f)) \ 190 hash_set1 (vm->init_functions_called, _f); \ 196 #define vlib_call_config_function(vm, x) \ 198 vlib_config_function_runtime_t * _r; \ 199 clib_error_t * _error = 0; \ 200 extern vlib_config_function_runtime_t \ 201 VLIB_CONFIG_FUNCTION_SYMBOL (x); \ 203 _r = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \ 204 if (! hash_get (vm->init_functions_called, _r->function)) \ 206 hash_set1 (vm->init_functions_called, _r->function); \ 207 _error = _r->function (vm, &_r->input); \ 221 _vlib_init_function_list_elt_t *
222 head,
int call_once);
224 #define foreach_vlib_module_reference \ 229 #define _(x) void vlib_##x##_reference (void); clib_error_t * vlib_call_all_main_loop_exit_functions(struct vlib_main_t *vm)
#define foreach_vlib_module_reference
clib_error_t * vlib_call_all_init_functions(struct vlib_main_t *vm)
clib_error_t *( vlib_config_function_t)(struct vlib_main_t *vm, unformat_input_t *input)
clib_error_t * vlib_call_init_exit_functions(struct vlib_main_t *vm, _vlib_init_function_list_elt_t *head, int call_once)
clib_error_t *( vlib_init_function_t)(struct vlib_main_t *vm)
struct vlib_config_function_runtime_t vlib_config_function_runtime_t
clib_error_t * vlib_call_all_config_functions(struct vlib_main_t *vm, unformat_input_t *input, int is_early)
clib_error_t * vlib_call_all_main_loop_enter_functions(struct vlib_main_t *vm)
struct vlib_config_function_runtime_t * next_registration