From 4998b90395233724860e9546d7fa2f3fb034f9f0 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 15 May 2020 10:26:37 +0200 Subject: [PATCH] gnrc/udp: Configure queue size with exponent This changes the configuration macro to be the exponent of 2^n, as the message queue size needs to be always power of 2. --- sys/include/net/gnrc/udp.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sys/include/net/gnrc/udp.h b/sys/include/net/gnrc/udp.h index 2b19e98876..37528d87e8 100644 --- a/sys/include/net/gnrc/udp.h +++ b/sys/include/net/gnrc/udp.h @@ -33,10 +33,19 @@ extern "C" { #endif /** - * @brief Default message queue size for the UDP thread + * @defgroup net_gnrc_udp_conf GNRC UDP compile configurations + * @ingroup net_gnrc_conf + * @{ */ -#ifndef GNRC_UDP_MSG_QUEUE_SIZE -#define GNRC_UDP_MSG_QUEUE_SIZE (8U) +/** + * @brief Default message queue size for the UDP thread (as exponent of 2^n). + * + * As the queue size ALWAYS needs to be power of two, this option + * represents the exponent of 2^n, which will be used as the size of + * the queue. + */ +#ifndef CONFIG_GNRC_UDP_MSG_QUEUE_SIZE_EXP +#define CONFIG_GNRC_UDP_MSG_QUEUE_SIZE_EXP (3U) #endif /** @@ -52,6 +61,14 @@ extern "C" { #ifndef GNRC_UDP_STACK_SIZE #define GNRC_UDP_STACK_SIZE (THREAD_STACKSIZE_DEFAULT) #endif +/** @} */ + +/** + * @brief Message queue size to use for the UDP thread. + */ +#ifndef GNRC_UDP_MSG_QUEUE_SIZE +#define GNRC_UDP_MSG_QUEUE_SIZE (1 << CONFIG_GNRC_UDP_MSG_QUEUE_SIZE_EXP) +#endif /** * @brief Calculate the checksum for the given packet