40 #ifndef included_vlib_init_h 41 #define included_vlib_init_h 53 typedef struct _vlib_init_function_list_elt {
54 struct _vlib_init_function_list_elt * next_init_function;
56 } _vlib_init_function_list_elt_t;
80 #define _VLIB_INIT_FUNCTION_SYMBOL(x, type) \ 81 _vlib_##type##_function_##x 83 #define VLIB_INIT_FUNCTION_SYMBOL(x) \ 84 _VLIB_INIT_FUNCTION_SYMBOL(x, init) 85 #define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x) \ 86 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter) 87 #define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL(x) \ 88 _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit) 89 #define VLIB_CONFIG_FUNCTION_SYMBOL(x) \ 90 _VLIB_INIT_FUNCTION_SYMBOL(x, config) 95 #define VLIB_DECLARE_INIT_FUNCTION(x, tag) \ 96 vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \ 97 static void __vlib_add_##tag##_function_##x (void) \ 98 __attribute__((__constructor__)) ; \ 99 static void __vlib_add_##tag##_function_##x (void) \ 101 vlib_main_t * vm = vlib_get_main(); \ 102 static _vlib_init_function_list_elt_t _vlib_init_function; \ 103 _vlib_init_function.next_init_function \ 104 = vm->tag##_function_registrations; \ 105 vm->tag##_function_registrations = &_vlib_init_function; \ 106 _vlib_init_function.f = &x; \ 109 #define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init) 111 #define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \ 112 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter) 113 #define VLIB_MAIN_LOOP_EXIT_FUNCTION(x) \ 114 VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit) 116 #define VLIB_CONFIG_FUNCTION(x,n,...) \ 117 __VA_ARGS__ vlib_config_function_runtime_t \ 118 VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 119 static void __vlib_add_config_function_##x (void) \ 120 __attribute__((__constructor__)) ; \ 121 static void __vlib_add_config_function_##x (void) \ 123 vlib_main_t * vm = vlib_get_main(); \ 124 VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration \ 125 = vm->config_function_registrations; \ 126 vm->config_function_registrations \ 127 = &VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 129 vlib_config_function_runtime_t \ 130 VLIB_CONFIG_FUNCTION_SYMBOL (x) \ 137 #define VLIB_EARLY_CONFIG_FUNCTION(x,n,...) \ 138 __VA_ARGS__ vlib_config_function_runtime_t \ 139 VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 140 static void __vlib_add_config_function_##x (void) \ 141 __attribute__((__constructor__)) ; \ 142 static void __vlib_add_config_function_##x (void) \ 144 vlib_main_t * vm = vlib_get_main(); \ 145 VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration \ 146 = vm->config_function_registrations; \ 147 vm->config_function_registrations \ 148 = &VLIB_CONFIG_FUNCTION_SYMBOL(x); \ 150 vlib_config_function_runtime_t \ 151 VLIB_CONFIG_FUNCTION_SYMBOL (x) \ 159 #define vlib_call_init_function(vm, x) \ 161 extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x); \ 162 vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x); \ 163 clib_error_t * _error = 0; \ 164 if (! hash_get (vm->init_functions_called, _f)) \ 166 hash_set1 (vm->init_functions_called, _f); \ 173 #define vlib_mark_init_function_complete(vm, x) \ 175 extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x); \ 176 vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x); \ 177 hash_set1 (vm->init_functions_called, _f); \ 180 #define vlib_call_post_graph_init_function(vm, x) \ 182 extern vlib_init_function_t * VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \ 183 vlib_init_function_t * _f = VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \ 184 clib_error_t * _error = 0; \ 185 if (! hash_get (vm->init_functions_called, _f)) \ 187 hash_set1 (vm->init_functions_called, _f); \ 193 #define vlib_call_config_function(vm, x) \ 195 vlib_config_function_runtime_t * _r; \ 196 clib_error_t * _error = 0; \ 197 extern vlib_config_function_runtime_t \ 198 VLIB_CONFIG_FUNCTION_SYMBOL (x); \ 200 _r = &VLIB_CONFIG_FUNCTION_SYMBOL (x); \ 201 if (! hash_get (vm->init_functions_called, _r->function)) \ 203 hash_set1 (vm->init_functions_called, _r->function); \ 204 _error = _r->function (vm, &_r->input); \ 218 _vlib_init_function_list_elt_t *head,
221 #define foreach_vlib_module_reference \ 226 #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