From 6e36351faf5b69a0bfb8235b3b06f8b2c24e5547 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 10 Aug 2018 22:39:11 +0200 Subject: Multiarch handling in different constructor macros This significantly reduces need for ... in multiarch code. Simply constructor macros will jost create static unused entry if CLIB_MARCH_VARIANT is defined and that will be optimized out by compiler. Change-Id: I17d1c4ac0c903adcfadaa4a07de1b854c7ab14ac Signed-off-by: Damjan Marion --- src/vnet/interface.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/vnet/interface.h') diff --git a/src/vnet/interface.h b/src/vnet/interface.h index e9adfe84cbf..b34d19c55ef 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -108,6 +108,7 @@ typedef struct _vnet_interface_function_list_elt clib_error_t *(*fp) (struct vnet_main_t * vnm, u32 if_index, u32 flags); } _vnet_interface_function_list_elt_t; +#ifndef CLIB_MARCH_VARIANT #define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p) \ \ static void __vnet_interface_function_init_##tag##_##f (void) \ @@ -146,6 +147,12 @@ static void __vnet_interface_function_deinit_##tag##_##f (void) \ next = next->next_interface_function; \ } \ } +#else +/* create unused pointer to silence compiler warnings and get whole + function optimized out */ +#define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p) \ +static __clib_unused void * __clib_unused_##f = f; +#endif #define _VNET_INTERFACE_FUNCTION_DECL(f,tag) \ _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,VNET_ITF_FUNC_PRIORITY_LOW) @@ -248,6 +255,7 @@ typedef struct _vnet_device_class vnet_interface_set_mac_address_function_t *mac_addr_change_function; } vnet_device_class_t; +#ifndef CLIB_MARCH_VARIANT #define VNET_DEVICE_CLASS(x,...) \ __VA_ARGS__ vnet_device_class_t x; \ static void __vnet_add_device_class_registration_##x (void) \ @@ -267,6 +275,12 @@ static void __vnet_rm_device_class_registration_##x (void) \ &x, next_class_registration); \ } \ __VA_ARGS__ vnet_device_class_t x +#else +/* create unused pointer to silence compiler warnings and get whole + function optimized out */ +#define VNET_DEVICE_CLASS(x,...) \ +static __clib_unused vnet_device_class_t __clib_unused_##x +#endif #define VNET_DEVICE_CLASS_TX_FN(devclass) \ uword CLIB_MARCH_SFX (devclass##_tx_fn)(); \ -- cgit 1.2.3-korg