Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree wide: compilation fixes for native64 on musl systems #20730

Merged
merged 5 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/include/native_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
#ifdef CPU_NATIVE
#include <stdio.h>

#if __GLIBC__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker for this PR but why is there no #elseif __musl__ ...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In musl those are already provided (causing the conflict).

/*
* Required to use some C++11 headers with g++ on the native board.
*/
Expand All @@ -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.
Expand Down
34 changes: 17 additions & 17 deletions cpu/native/include/c11_atomics_compat_cpu.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check warning on line 1 in cpu/native/include/c11_atomics_compat_cpu.hpp

View workflow job for this annotation

GitHub Actions / static-tests

no copyright notice found
* This file was generated using
* ./dist/tools/generate_c11_atomics_cpp_compat_header/generate_c11_atomics_cpp_compat_header.sh
* for 32 and 64 bit and merged manually.
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions drivers/at25xxx/at25xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha! 😸

#define ADDR_LEN (AT25XXX_PARAM_ADDR_LEN)
#define ADDR_MSK ((1UL << ADDR_LEN) - 1)

Expand Down Expand Up @@ -83,14 +83,14 @@
return tries == 0 ? -ETIMEDOUT : 0;
}

static int _at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len)

Check warning on line 86 in drivers/at25xxx/at25xxx.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
{
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);
Expand All @@ -115,7 +115,7 @@
return len;
}

int at25xxx_write_page(const at25xxx_t *dev, uint32_t page, uint32_t offset, const void *data, size_t len)

Check warning on line 118 in drivers/at25xxx/at25xxx.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
{
int res;

Expand All @@ -136,8 +136,8 @@
}

/* 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;
Expand Down Expand Up @@ -214,8 +214,8 @@
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;
Expand Down
2 changes: 1 addition & 1 deletion examples/dtls-wolfssl/Makefile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ BOARD_INSUFFICIENT_MEMORY := \
i-nucleo-lrwan1 \
im880b \
lobaro-lorabox \
maple-mini \
microbit \
nrf51dongle \
nrf6310 \
Expand All @@ -35,7 +36,6 @@ BOARD_INSUFFICIENT_MEMORY := \
nucleo-l031k6 \
nucleo-l053r8 \
nucleo-l412kb \
maple-mini \
olimexino-stm32 \
opencm904 \
samd10-xmini \
Expand Down
21 changes: 16 additions & 5 deletions sys/posix/include/sys/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@
* @file
* @brief Select types
* @see [The Open Group Base Specification Issue 7, 2018 edition,
* <sys/select.h>](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/sys_select.h)

Check warning on line 26 in sys/posix/include/sys/select.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/

#ifndef SYS_SELECT_H
#define SYS_SELECT_H

#ifdef CPU_NATIVE
/* On native, system headers may depend on system's <sys/select.h>. Hence,
* include the real sys/select.h here. */
__extension__
#include_next <sys/select.h>
#endif

#include <string.h>
/* prevent cyclic dependency with newlib/picolibc's `sys/types.h` */
#if (defined(MODULE_NEWLIB) || defined(MODULE_PICOLIBC)) && !defined(CPU_ESP8266)
Expand All @@ -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
* @{
Expand All @@ -59,11 +73,6 @@
#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)
/**
Expand Down Expand Up @@ -164,6 +173,8 @@
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds,
struct timeval *timeout);

#endif /* CPU_NATIVE */

#ifdef __cplusplus
}
#endif
Expand Down
Loading