diff options
author | Damjan Marion <damarion@cisco.com> | 2018-08-10 22:39:11 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-08-13 14:33:54 +0000 |
commit | 6e36351faf5b69a0bfb8235b3b06f8b2c24e5547 (patch) | |
tree | 512c92bda1a48604fbfbc7bbbb1e4b613cdba614 /src/vnet/interface.h | |
parent | 3bf6c2bfe59be62169a1245340722481b0b53870 (diff) |
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 <damarion@cisco.com>
Diffstat (limited to 'src/vnet/interface.h')
-rw-r--r-- | src/vnet/interface.h | 14 |
1 files changed, 14 insertions, 0 deletions
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)(); \ |