From 44f7cb712cb2b6892cb1596a3d3d9e37e0de5448 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Tue, 17 Mar 2020 12:32:34 +0100 Subject: [PATCH] gnrc_netif: add GNRC_NETIF_SINGLE macro --- sys/include/net/gnrc/netif/conf.h | 12 ++++++++++++ sys/net/gnrc/netif/gnrc_netif.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/include/net/gnrc/netif/conf.h b/sys/include/net/gnrc/netif/conf.h index 916f823501..b5ddb6c1f5 100644 --- a/sys/include/net/gnrc/netif/conf.h +++ b/sys/include/net/gnrc/netif/conf.h @@ -29,6 +29,18 @@ extern "C" { #endif +/** + * @brief Single interface optimizations + * + * Define to 1 to allow GNRC optimizations when only one interface + * is available. + * + * @note This MUST NOT be enabled if there's more than one interface. + */ +#if DOXYGEN +#define GNRC_NETIF_SINGLE +#endif + /** * @brief Default priority for network interface threads */ diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 7b972a9027..090fa02d12 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -49,9 +49,9 @@ int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize, char prio { int res; - if (IS_ACTIVE(DEVELHELP) && IS_ACTIVE(GNRC_NETIF_SINGLE) && netif_iter(NULL)) { - LOG_WARNING("gnrc_netif: GNRC_NETIF_SINGLE set but more than one " - "interface is being registered."); + if (IS_ACTIVE(DEVELHELP) && gnrc_netif_highlander() && netif_iter(NULL)) { + LOG_WARNING("gnrc_netif: gnrc_netif_highlander() returned true but " + "more than one interface is being registered.\n"); assert(netif_iter(NULL) == NULL); } rmutex_init(&netif->mutex);