X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Finit.h;h=a9367697a85f340d2dce283d6233396d8cb494c4;hb=98afc711c517ee860a2259ae18d496abd3416ba6;hp=1eddbb13d5af956d20000a3be131742ccc3f9377;hpb=72d2c4f3718ba5293e9e0fa8726406ee7d9f3940;p=vpp.git diff --git a/src/vlib/init.h b/src/vlib/init.h index 1eddbb13d5a..a9367697a85 100644 --- a/src/vlib/init.h +++ b/src/vlib/init.h @@ -81,20 +81,22 @@ typedef struct vlib_config_function_runtime_t #define VLIB_REMOVE_FROM_LINKED_LIST(first,p,next) \ { \ + ASSERT (first); \ if (first == p) \ first = (p)->next; \ else \ { \ __typeof__ (p) current = first; \ - while (current->next) \ - { \ - if (current->next == p) \ - { \ - current->next = current->next->next; \ - break; \ - } \ - current = current->next; \ - } \ + while (current->next) \ + { \ + if (current->next == p) \ + { \ + current->next = current->next->next; \ + break; \ + } \ + current = current->next; \ + } \ + ASSERT (current); \ } \ } @@ -113,6 +115,7 @@ typedef struct vlib_config_function_runtime_t /* Declaration is global (e.g. not static) so that init functions can be called from other modules to resolve init function depend. */ +#ifndef CLIB_MARCH_VARIANT #define VLIB_DECLARE_INIT_FUNCTION(x, tag) \ vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \ static void __vlib_add_##tag##_function_##x (void) \ @@ -150,6 +153,12 @@ static void __vlib_rm_##tag##_function_##x (void) \ next = next->next_init_function; \ } \ } +#else +/* create unused pointer to silence compiler warnings and get whole + function optimized out */ +#define VLIB_DECLARE_INIT_FUNCTION(x, tag) \ +static __clib_unused void * __clib_unused_##tag##_##x = x; +#endif #define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init) #define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init) @@ -159,6 +168,7 @@ static void __vlib_rm_##tag##_function_##x (void) \ #define VLIB_MAIN_LOOP_EXIT_FUNCTION(x) \ VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit) +#ifndef CLIB_MARCH_VARIANT #define VLIB_CONFIG_FUNCTION(x,n,...) \ __VA_ARGS__ vlib_config_function_runtime_t \ VLIB_CONFIG_FUNCTION_SYMBOL(x); \ @@ -189,7 +199,20 @@ static void __vlib_rm_config_function_##x (void) \ .function = x, \ .is_early = 0, \ } +#else +/* create unused pointer to silence compiler warnings and get whole + function optimized out */ +#define VLIB_CONFIG_FUNCTION(x,n,...) \ + static __clib_unused vlib_config_function_runtime_t \ + VLIB_CONFIG_FUNCTION_SYMBOL (__clib_unused_##x) \ + = { \ + .name = n, \ + .function = x, \ + .is_early = 0, \ + } +#endif +#ifndef CLIB_MARCH_VARIANT #define VLIB_EARLY_CONFIG_FUNCTION(x,n,...) \ __VA_ARGS__ vlib_config_function_runtime_t \ VLIB_CONFIG_FUNCTION_SYMBOL(x); \ @@ -220,6 +243,18 @@ static void __vlib_rm_config_function_##x (void) \ .function = x, \ .is_early = 1, \ } +#else +/* create unused pointer to silence compiler warnings and get whole + function optimized out */ +#define VLIB_EARLY_CONFIG_FUNCTION(x,n,...) \ + static __clib_unused vlib_config_function_runtime_t \ + VLIB_CONFIG_FUNCTION_SYMBOL (__clib_unused_##x) \ + = { \ + .name = n, \ + .function = x, \ + .is_early = 1, \ + } +#endif /* Call given init function: used for init function dependencies. */ #define vlib_call_init_function(vm, x) \