From be387a25bd4a009bbb4c4dda47e353aaa3a5c8e7 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Jun 2024 21:47:56 +0200 Subject: [PATCH 1/5] sys/posix: Don't shadow on native This fixes compilation issues on musl, where the host POSIX headers don't mix well with RIOT's POSIX headers. This adds an conditional `#include_next ` to RIOT's `` header. --- sys/posix/include/sys/select.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sys/posix/include/sys/select.h b/sys/posix/include/sys/select.h index 8bf98f7c42..afe63aac15 100644 --- a/sys/posix/include/sys/select.h +++ b/sys/posix/include/sys/select.h @@ -29,6 +29,13 @@ #ifndef SYS_SELECT_H #define SYS_SELECT_H +#ifdef CPU_NATIVE +/* On native, system headers may depend on system's . Hence, + * include the real sys/select.h here. */ +__extension__ +#include_next +#endif + #include /* prevent cyclic dependency with newlib/picolibc's `sys/types.h` */ #if (defined(MODULE_NEWLIB) || defined(MODULE_PICOLIBC)) && !defined(CPU_ESP8266) @@ -43,6 +50,13 @@ extern "C" { #endif +/** + * @brief @ref core_thread_flags for POSIX select + */ +#define POSIX_SELECT_THREAD_FLAG (1U << 3) + +#ifndef CPU_NATIVE + /** * @addtogroup config_posix * @{ @@ -59,11 +73,6 @@ extern "C" { #endif /** @} */ -/** - * @brief @ref core_thread_flags for POSIX select - */ -#define POSIX_SELECT_THREAD_FLAG (1U << 3) - /* ESP's newlib has this already defined in `sys/types.h` */ #if !defined(CPU_ESP8266) /** @@ -164,6 +173,8 @@ static inline void FD_ZERO(fd_set *fdsetp) int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); +#endif /* CPU_NATIVE */ + #ifdef __cplusplus } #endif From 1582fdd571a111dec36ef4e2da3dc3eba82ea83f Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Jun 2024 21:56:29 +0200 Subject: [PATCH 2/5] drivers/at25xxx: s/PAGE_SIZE/AT25_PAGE_SIZE/ On musl, PAGE_SIZE has a different meaning. So add an AT25_ prefix to avoid a name clash. --- drivers/at25xxx/at25xxx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/at25xxx/at25xxx.c b/drivers/at25xxx/at25xxx.c index 6327d06899..1d7103cea3 100644 --- a/drivers/at25xxx/at25xxx.c +++ b/drivers/at25xxx/at25xxx.c @@ -37,7 +37,7 @@ #define min(a, b) ((a) > (b) ? (b) : (a)) #endif -#define PAGE_SIZE (dev->params.page_size) +#define AT25_PAGE_SIZE (dev->params.page_size) #define ADDR_LEN (AT25XXX_PARAM_ADDR_LEN) #define ADDR_MSK ((1UL << ADDR_LEN) - 1) @@ -85,12 +85,12 @@ static inline int _wait_until_eeprom_ready(const at25xxx_t *dev) static int _at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len) { - assert(offset < PAGE_SIZE); + assert(offset < AT25_PAGE_SIZE); /* write no more than to the end of the current page to prevent wrap-around */ - size_t remaining = PAGE_SIZE - offset; + size_t remaining = AT25_PAGE_SIZE - offset; len = min(len, remaining); - uint32_t pos = _pos(CMD_WRITE, page * PAGE_SIZE + offset); + uint32_t pos = _pos(CMD_WRITE, page * AT25_PAGE_SIZE + offset); /* wait for previous write to finish - may take up to 5 ms */ int res = _wait_until_eeprom_ready(dev); @@ -136,8 +136,8 @@ int at25xxx_write(const at25xxx_t *dev, uint32_t pos, const void *data, size_t l } /* page size is always a power of two */ - const uint32_t page_shift = bitarithm_msb(PAGE_SIZE); - const uint32_t page_mask = PAGE_SIZE - 1; + const uint32_t page_shift = bitarithm_msb(AT25_PAGE_SIZE); + const uint32_t page_mask = AT25_PAGE_SIZE - 1; uint32_t page = pos >> page_shift; uint32_t offset = pos & page_mask; @@ -214,8 +214,8 @@ int at25xxx_set(const at25xxx_t *dev, uint32_t pos, uint8_t val, size_t len) memset(data, val, sizeof(data)); /* page size is always a power of two */ - const uint32_t page_shift = bitarithm_msb(PAGE_SIZE); - const uint32_t page_mask = PAGE_SIZE - 1; + const uint32_t page_shift = bitarithm_msb(AT25_PAGE_SIZE); + const uint32_t page_mask = AT25_PAGE_SIZE - 1; uint32_t page = pos >> page_shift; uint32_t offset = pos & page_mask; From 70f57477129425f6a5e8b98ac6441f1ad9cf0520 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Jun 2024 21:57:43 +0200 Subject: [PATCH 3/5] core/native_shed: Fix compilation with musl On musl, `spu_set_t` is provided by system headers, so only provide that with glibc. --- core/include/native_sched.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/include/native_sched.h b/core/include/native_sched.h index 573b97095b..18c22191f5 100644 --- a/core/include/native_sched.h +++ b/core/include/native_sched.h @@ -30,6 +30,7 @@ extern "C" { #ifdef CPU_NATIVE #include +#if __GLIBC__ /* * Required to use some C++11 headers with g++ on the native board. */ @@ -39,6 +40,7 @@ typedef unsigned long int __cpu_mask; typedef struct { __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS]; } cpu_set_t; +#endif /** * @brief In all test the function has never been called, hence it is empty for now. From 21151691d7592eab77b55ffb30c98ce8f638483f Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Jun 2024 22:02:26 +0200 Subject: [PATCH 4/5] cpu/native: Fix C11 atomic sizes for musl musl and glibc have different types for fast atomic integers. This selects the correct size depending on the used library. --- cpu/native/include/c11_atomics_compat_cpu.hpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cpu/native/include/c11_atomics_compat_cpu.hpp b/cpu/native/include/c11_atomics_compat_cpu.hpp index c83f32617a..d5a01a003a 100644 --- a/cpu/native/include/c11_atomics_compat_cpu.hpp +++ b/cpu/native/include/c11_atomics_compat_cpu.hpp @@ -63,24 +63,24 @@ #define ATOMIC_UINT_FAST8_T_SIZE (1U) #define ATOMIC_UINT_FAST8_T_SAME_SIZED_TYPE uint8_t #endif -#ifdef __x86_64__ -#define ATOMIC_INT_FAST16_T_SIZE (8U) -#define ATOMIC_INT_FAST16_T_SAME_SIZED_TYPE uint64_t -#define ATOMIC_UINT_FAST16_T_SIZE (8U) -#define ATOMIC_UINT_FAST16_T_SAME_SIZED_TYPE uint64_t -#define ATOMIC_INT_FAST32_T_SIZE (8U) -#define ATOMIC_INT_FAST32_T_SAME_SIZED_TYPE uint64_t -#define ATOMIC_UINT_FAST32_T_SIZE (8U) -#define ATOMIC_UINT_FAST32_T_SAME_SIZED_TYPE uint64_t +#if defined(__x86_64__) && defined(__GLIBC__) +# define ATOMIC_INT_FAST16_T_SIZE (8U) +# define ATOMIC_INT_FAST16_T_SAME_SIZED_TYPE uint64_t +# define ATOMIC_UINT_FAST16_T_SIZE (8U) +# define ATOMIC_UINT_FAST16_T_SAME_SIZED_TYPE uint64_t +# define ATOMIC_INT_FAST32_T_SIZE (8U) +# define ATOMIC_INT_FAST32_T_SAME_SIZED_TYPE uint64_t +# define ATOMIC_UINT_FAST32_T_SIZE (8U) +# define ATOMIC_UINT_FAST32_T_SAME_SIZED_TYPE uint64_t #else -#define ATOMIC_INT_FAST16_T_SIZE (4U) -#define ATOMIC_INT_FAST16_T_SAME_SIZED_TYPE uint32_t -#define ATOMIC_UINT_FAST16_T_SIZE (4U) -#define ATOMIC_UINT_FAST16_T_SAME_SIZED_TYPE uint32_t -#define ATOMIC_INT_FAST32_T_SIZE (4U) -#define ATOMIC_INT_FAST32_T_SAME_SIZED_TYPE uint32_t -#define ATOMIC_UINT_FAST32_T_SIZE (4U) -#define ATOMIC_UINT_FAST32_T_SAME_SIZED_TYPE uint32_t +# define ATOMIC_INT_FAST16_T_SIZE (4U) +# define ATOMIC_INT_FAST16_T_SAME_SIZED_TYPE uint32_t +# define ATOMIC_UINT_FAST16_T_SIZE (4U) +# define ATOMIC_UINT_FAST16_T_SAME_SIZED_TYPE uint32_t +# define ATOMIC_INT_FAST32_T_SIZE (4U) +# define ATOMIC_INT_FAST32_T_SAME_SIZED_TYPE uint32_t +# define ATOMIC_UINT_FAST32_T_SIZE (4U) +# define ATOMIC_UINT_FAST32_T_SAME_SIZED_TYPE uint32_t #endif #define ATOMIC_INT_FAST64_T_SIZE (8U) #define ATOMIC_INT_FAST64_T_SAME_SIZED_TYPE uint64_t From 54702a53db4686e69d8d7756b9b2312f3618b18b Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 5 Jun 2024 21:59:02 +0200 Subject: [PATCH 5/5] examples/dtls-wolfssl: Sort Makefile.ci --- examples/dtls-wolfssl/Makefile.ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dtls-wolfssl/Makefile.ci b/examples/dtls-wolfssl/Makefile.ci index 7c669944d1..64f98b6349 100644 --- a/examples/dtls-wolfssl/Makefile.ci +++ b/examples/dtls-wolfssl/Makefile.ci @@ -14,6 +14,7 @@ BOARD_INSUFFICIENT_MEMORY := \ i-nucleo-lrwan1 \ im880b \ lobaro-lorabox \ + maple-mini \ microbit \ nrf51dongle \ nrf6310 \ @@ -35,7 +36,6 @@ BOARD_INSUFFICIENT_MEMORY := \ nucleo-l031k6 \ nucleo-l053r8 \ nucleo-l412kb \ - maple-mini \ olimexino-stm32 \ opencm904 \ samd10-xmini \