[WIP] automatically set GNRC_NETIF_NUMOF#12308
[WIP] automatically set GNRC_NETIF_NUMOF#12308benpicco wants to merge 2 commits intoRIOT-OS:masterfrom
Conversation
The preprocessor is not able to do arithmetic using the sizeof() operator. Instead, let the compiler evaluate the constant, the result should be the same.
2e2baaa to
66be16f
Compare
| #define STM32_ETH_NUM (0) | ||
| #endif | ||
|
|
||
| #define GNRC_NETIF_NUMOF (AT86RF2XX_NUM + CC2420_NUM + KW2XRF_NUM + MRF24J40_NUM \ |
There was a problem hiding this comment.
What about modules esp_now, esp_wifi and esp_eth? All of them provide a separate netif.
There was a problem hiding this comment.
Will add those!
Why are they not initialized in sys/auto_init/netif/?
There was a problem hiding this comment.
The initialization of these netdevs is called as for other drivers in sys/auto_init/auto_init.c
RIOT/sys/auto_init/auto_init.c
Lines 244 to 259 in 3779635
The difference is, that the implementations of the auto_init_* functions are not placed in separate files in sys/auto_init/netif but in cpu/esp*/esp_*/esp_*_netdev.c. The reason is that these netdevs are platform specific and shouldn't be placed in a common place.
There was a problem hiding this comment.
I see! But stm32_eth and nrf802154 are platform specific too…
There was a problem hiding this comment.
Yes. The question is whether we should move the auto_init_esp_* code to sys/auto_init/netif or whether we should leave it as it is.
| #define STM32_ETH_NUM (0) | ||
| #endif | ||
|
|
||
| #define GNRC_NETIF_NUMOF (AT86RF2XX_NUM + CC2420_NUM + KW2XRF_NUM + MRF24J40_NUM \ |
There was a problem hiding this comment.
What about defining a generic NETIF_NUMOF here and make GNRC use that? so we could keep this stack agnostic
Contribution description
Currently,
GNRC_NETIF_NUMOFhas to be set manually.This PR changes that so that each network interface will increment
GNRC_NETIF_NUMOFat compile-time.Since
GNRC_NETIF_NUMOFnow consists of0 + 0 + sizeof(…) + 0 + sizeof(…) + …the processor can not evaluate it anymore. This is not a problem since the compiler will see the same job if it sees anif (0).But as a prerequisite, many
#if (GNRC_NETIF_NUMOF > 0)had to be changed intoif (GNRC_NETIF_NUMOF > 0).As expected, code size did not increase.
Testing procedure
Check if everything still works, especially examples/tests that define
GNRC_NETIF_NUMOF := 2Issues/PRs references
#11979
#9903