diff --git a/src/include/compiler.h b/src/include/compiler.h index 16165b369..738655afa 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -191,6 +191,14 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL ); */ #define __weak __attribute__ (( weak, noinline )) +/** Prevent a function from being optimized away without inlining + * + * Calls to functions with void return type that contain no code in their body + * may be removed by gcc's optimizer even when inlining is inhibited. Placing + * this macro in the body of the function prevents that from occurring. + */ +#define __keepme asm(""); + #endif /** @defgroup dbg Debugging infrastructure diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index fb62bef53..77d465453 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -1389,7 +1389,7 @@ static struct sockaddr dhcp_peer = { /** * Get cached DHCPACK where none exists */ -__weak void get_cached_dhcpack ( void ) {} +__weak void get_cached_dhcpack ( void ) { __keepme } /** * Start DHCP state machine on a network device