diff --git a/boards/cc2650stk/doc.txt b/boards/cc2650stk/doc.txt index 1f3f50d4b638..eb74a39560dc 100644 --- a/boards/cc2650stk/doc.txt +++ b/boards/cc2650stk/doc.txt @@ -127,7 +127,9 @@ advertising channels, as well as the corresponding variables in the RIOT command. ``` -typedef struct __attribute__ ((aligned(4))) { +#include + +typedef struct alignas(4) { radio_op_command_t ropCmd; uint8_t channel; struct { diff --git a/core/lib/include/xfa.h b/core/lib/include/xfa.h index e18196ff788b..06cc1693a3db 100644 --- a/core/lib/include/xfa.h +++ b/core/lib/include/xfa.h @@ -26,6 +26,8 @@ #define XFA_H #include +#include + #include "compiler_hints.h" /* @@ -45,7 +47,7 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") */ #define _XFA(type, name, prio) \ NO_SANITIZE_ARRAY \ - __attribute__((used, section(".xfa." #name "." #prio))) _Alignas(type) type + __attribute__((used, section(".xfa." #name "." #prio))) alignas(type) type /** * @brief helper macro for other XFA_* macros @@ -54,7 +56,7 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") */ #define _XFA_CONST(type, name, prio) \ NO_SANITIZE_ARRAY \ - __attribute__((used, section(".roxfa." #name "." #prio))) _Alignas(type) type + __attribute__((used, section(".roxfa." #name "." #prio))) alignas(type) type /** * @brief Define a read-only cross-file array diff --git a/cpu/arm7_common/arm_cpu.c b/cpu/arm7_common/arm_cpu.c index 16343499560c..f1b91b0a3a52 100644 --- a/cpu/arm7_common/arm_cpu.c +++ b/cpu/arm7_common/arm_cpu.c @@ -16,8 +16,10 @@ * @} */ +#include #include #include + #include "arm_cpu.h" #include "irq.h" #include "sched.h" @@ -26,12 +28,12 @@ #define STACK_MARKER (0x77777777) #define REGISTER_CNT (12) -__attribute__((used, section(".usr_stack"), aligned(4))) uint8_t usr_stack[USR_STACKSIZE]; -__attribute__((used, section(".und_stack"), aligned(4))) uint8_t und_stack[UND_STACKSIZE]; -__attribute__((used, section(".fiq_stack"), aligned(4))) uint8_t fiq_stack[FIQ_STACKSIZE]; -__attribute__((used, section(".irq_stack"), aligned(4))) uint8_t irq_stack[ISR_STACKSIZE]; -__attribute__((used, section(".abt_stack"), aligned(4))) uint8_t abt_stack[ABT_STACKSIZE]; -__attribute__((used, section(".svc_stack"), aligned(4))) uint8_t svc_stack[ISR_STACKSIZE]; +__attribute__((used, section(".usr_stack"))) alignas(4) uint8_t usr_stack[USR_STACKSIZE]; +__attribute__((used, section(".und_stack"))) alignas(4) uint8_t und_stack[UND_STACKSIZE]; +__attribute__((used, section(".fiq_stack"))) alignas(4) uint8_t fiq_stack[FIQ_STACKSIZE]; +__attribute__((used, section(".irq_stack"))) alignas(4) uint8_t irq_stack[ISR_STACKSIZE]; +__attribute__((used, section(".abt_stack"))) alignas(4) uint8_t abt_stack[ABT_STACKSIZE]; +__attribute__((used, section(".svc_stack"))) alignas(4) uint8_t svc_stack[ISR_STACKSIZE]; #if (ISR_STACKSIZE % 4) #error "ISR_STACKSIZE must be a multiple of 4" diff --git a/cpu/esp32/include/periph_cpu.h b/cpu/esp32/include/periph_cpu.h index 6bd48fd821b7..d27d3191dc6a 100644 --- a/cpu/esp32/include/periph_cpu.h +++ b/cpu/esp32/include/periph_cpu.h @@ -19,6 +19,7 @@ #ifndef PERIPH_CPU_H #define PERIPH_CPU_H +#include #include #include #include "sdkconfig.h" @@ -726,7 +727,7 @@ typedef struct { /** * @brief SDIO/SDMMC buffer instantiation requirement for SDHC */ -#define SDMMC_CPU_DMA_REQUIREMENTS __attribute__((aligned(SDMMC_CPU_DMA_ALIGNMENT))) +#define SDMMC_CPU_DMA_REQUIREMENTS alignas(SDMMC_CPU_DMA_ALIGNMENT) /** * @brief SDIO/SDMMC buffer alignment for SDHC because of DMA/FIFO buffer restrictions diff --git a/cpu/native/periph/flashpage.c b/cpu/native/periph/flashpage.c index 8da0c26a8ea7..19e6561a62dd 100644 --- a/cpu/native/periph/flashpage.c +++ b/cpu/native/periph/flashpage.c @@ -19,6 +19,7 @@ */ #include +#include #include #include "cpu.h" @@ -27,7 +28,7 @@ #define ENABLE_DEBUG 0 #include "debug.h" -__attribute__((aligned(FLASHPAGE_SIZE * FLASHPAGE_NUMOF))) +alignas(FLASHPAGE_SIZE * FLASHPAGE_NUMOF) char _native_flash[FLASHPAGE_SIZE * FLASHPAGE_NUMOF]; void flashpage_erase(unsigned page) diff --git a/cpu/nrf5x_common/include/periph_cpu_common.h b/cpu/nrf5x_common/include/periph_cpu_common.h index b37a4a8b1da2..b0f6d9d7163d 100644 --- a/cpu/nrf5x_common/include/periph_cpu_common.h +++ b/cpu/nrf5x_common/include/periph_cpu_common.h @@ -417,7 +417,7 @@ typedef struct { /** * @brief USBDEV buffer instantiation requirement */ -#define USBDEV_CPU_DMA_REQUIREMENTS __attribute__((aligned(USBDEV_CPU_DMA_ALIGNMENT))) +#define USBDEV_CPU_DMA_REQUIREMENTS alignas(USBDEV_CPU_DMA_ALIGNMENT) #if !defined(CPU_FAM_NRF51) && !defined(DOXYGEN) /** diff --git a/cpu/riscv_common/irq_arch.c b/cpu/riscv_common/irq_arch.c index f37b58e55050..dd73f3f38907 100644 --- a/cpu/riscv_common/irq_arch.c +++ b/cpu/riscv_common/irq_arch.c @@ -18,8 +18,9 @@ * @} */ -#include #include +#include +#include #include "macros/xtstr.h" #include "cpu.h" @@ -160,7 +161,7 @@ static void handle_trap(uword_t mcause) /* Marking this as interrupt to ensure an mret at the end, provided by the * compiler. Aligned to 64-byte boundary as per RISC-V spec and required by some * of the supported platforms (gd32)*/ -__attribute((aligned(64))) +alignas(64) static void __attribute__((interrupt)) trap_entry(void) { __asm__ volatile ( diff --git a/cpu/sam0_common/include/periph_cpu_common.h b/cpu/sam0_common/include/periph_cpu_common.h index dd8be928de9a..1093bb6cc58e 100644 --- a/cpu/sam0_common/include/periph_cpu_common.h +++ b/cpu/sam0_common/include/periph_cpu_common.h @@ -21,6 +21,8 @@ #ifndef PERIPH_CPU_COMMON_H #define PERIPH_CPU_COMMON_H +#include + #include "cpu.h" #include "exti_config.h" #include "timer_config.h" @@ -992,7 +994,7 @@ typedef struct { /** * @brief USBDEV buffer instantiation requirement */ -#define USBDEV_CPU_DMA_REQUIREMENTS __attribute__((aligned(USBDEV_CPU_DMA_ALIGNMENT))) +#define USBDEV_CPU_DMA_REQUIREMENTS alignas(USBDEV_CPU_DMA_ALIGNMENT) /** * @brief USB peripheral parameters @@ -1015,7 +1017,7 @@ typedef struct { /** * @brief SDIO/SDMMC buffer instantiation requirement for SDHC */ -#define SDMMC_CPU_DMA_REQUIREMENTS __attribute__((aligned(SDMMC_CPU_DMA_ALIGNMENT))) +#define SDMMC_CPU_DMA_REQUIREMENTS alignas(SDMMC_CPU_DMA_ALIGNMENT) /** * @brief SDHC peripheral configuration diff --git a/cpu/sam0_common/periph/eth.c b/cpu/sam0_common/periph/eth.c index f2f54982f5cb..313509ef77eb 100644 --- a/cpu/sam0_common/periph/eth.c +++ b/cpu/sam0_common/periph/eth.c @@ -78,8 +78,8 @@ struct eth_buf_desc { /* GMAC buffer descriptors */ #define GMAC_DESC_ALIGNMENT 8 #define GMAC_BUF_ALIGNMENT 32 -static struct eth_buf_desc rx_desc[ETH_RX_BUFFER_COUNT] __attribute__((aligned(GMAC_DESC_ALIGNMENT))); -static struct eth_buf_desc tx_desc[ETH_TX_BUFFER_COUNT] __attribute__((aligned(GMAC_DESC_ALIGNMENT))); +static alignas(GMAC_DESC_ALIGNMENT) struct eth_buf_desc rx_desc[ETH_RX_BUFFER_COUNT]; +static alignas(GMAC_DESC_ALIGNMENT) struct eth_buf_desc tx_desc[ETH_TX_BUFFER_COUNT]; static struct eth_buf_desc *rx_curr; static struct eth_buf_desc *tx_curr; @@ -89,8 +89,8 @@ static struct eth_buf_desc *tx_curr; static uint8_t tx_idx; static uint8_t rx_idx; -static uint8_t rx_buf[ETH_RX_BUFFER_COUNT][ETH_RX_BUFFER_SIZE] __attribute__((aligned(GMAC_BUF_ALIGNMENT))); -static uint8_t tx_buf[ETH_TX_BUFFER_COUNT][ETH_TX_BUFFER_SIZE] __attribute__((aligned(GMAC_BUF_ALIGNMENT))); +static alignas(GMAC_BUF_ALIGNMENT) uint8_t rx_buf[ETH_RX_BUFFER_COUNT][ETH_RX_BUFFER_SIZE]; +static alignas(GMAC_BUF_ALIGNMENT) uint8_t tx_buf[ETH_TX_BUFFER_COUNT][ETH_TX_BUFFER_SIZE]; extern sam0_eth_netdev_t _sam0_eth_dev; static bool _is_sleeping; diff --git a/cpu/stm32/include/periph/cpu_sdmmc.h b/cpu/stm32/include/periph/cpu_sdmmc.h index 4048c55655b6..1f8fcb67bc38 100644 --- a/cpu/stm32/include/periph/cpu_sdmmc.h +++ b/cpu/stm32/include/periph/cpu_sdmmc.h @@ -19,6 +19,7 @@ #ifndef PERIPH_CPU_SDMMC_H #define PERIPH_CPU_SDMMC_H +#include #include #include "periph/cpu_dma.h" @@ -45,7 +46,7 @@ extern "C" { /** * @brief SDIO/SDMMC buffer instantiation requirement for STM32 */ -#define SDMMC_CPU_DMA_REQUIREMENTS __attribute__((aligned(SDMMC_CPU_DMA_ALIGNMENT))) +#define SDMMC_CPU_DMA_REQUIREMENTS alignas(SDMMC_CPU_DMA_ALIGNMENT) /** * @brief SDIO/SDMMC pin structure for STM32 diff --git a/cpu/stm32/include/periph/cpu_usbdev.h b/cpu/stm32/include/periph/cpu_usbdev.h index bd978c9422f5..e6d34320b256 100644 --- a/cpu/stm32/include/periph/cpu_usbdev.h +++ b/cpu/stm32/include/periph/cpu_usbdev.h @@ -21,6 +21,7 @@ #ifndef PERIPH_CPU_USBDEV_H #define PERIPH_CPU_USBDEV_H +#include #include #include "periph/cpu_gpio.h" @@ -37,7 +38,7 @@ extern "C" { /** * @brief USBDEV buffer instantiation requirement */ -#define USBDEV_CPU_DMA_REQUIREMENTS __attribute__((aligned(USBDEV_CPU_DMA_ALIGNMENT))) +#define USBDEV_CPU_DMA_REQUIREMENTS alignas(USBDEV_CPU_DMA_ALIGNMENT) /** * @brief stm32 USB device FS configuration diff --git a/drivers/include/periph/flashpage.h b/drivers/include/periph/flashpage.h index a2c8908d087f..af95b3daf242 100644 --- a/drivers/include/periph/flashpage.h +++ b/drivers/include/periph/flashpage.h @@ -48,6 +48,7 @@ #ifndef PERIPH_FLASHPAGE_H #define PERIPH_FLASHPAGE_H +#include #include #include @@ -171,7 +172,7 @@ enum { * @param[in] size size of the array in unit of @ref FLASHPAGE_SIZE */ #define FLASH_WRITABLE_INIT(name, size) \ - __attribute__((aligned(FLASHPAGE_SIZE))) \ + alignas(FLASHPAGE_SIZE) \ __attribute__((section(".flash_writable." #name))) \ static const uint8_t name [size * FLASHPAGE_SIZE] #endif diff --git a/drivers/mtd_flashpage/mtd_flashpage.c b/drivers/mtd_flashpage/mtd_flashpage.c index 426927c3f3d3..1356c1bd0efd 100644 --- a/drivers/mtd_flashpage/mtd_flashpage.c +++ b/drivers/mtd_flashpage/mtd_flashpage.c @@ -21,9 +21,10 @@ * @} */ -#include -#include #include +#include +#include +#include #include "architecture.h" #include "cpu.h" @@ -114,8 +115,7 @@ static int _write_page(mtd_dev_t *dev, const void *buf, uint32_t page, uint32_t if ((addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT) || (size < FLASHPAGE_WRITE_BLOCK_SIZE) || ((uintptr_t)buf % FLASHPAGE_WRITE_BLOCK_ALIGNMENT)) { - uint8_t tmp[FLASHPAGE_WRITE_BLOCK_SIZE] - __attribute__ ((aligned (FLASHPAGE_WRITE_BLOCK_ALIGNMENT))); + uint8_t alignas(FLASHPAGE_WRITE_BLOCK_ALIGNMENT) tmp[FLASHPAGE_WRITE_BLOCK_SIZE]; offset = addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT; size = MIN(size, FLASHPAGE_WRITE_BLOCK_SIZE - offset); diff --git a/examples/lua_REPL/main.c b/examples/lua_REPL/main.c index 361d726300cc..8145b7eb8024 100644 --- a/examples/lua_REPL/main.c +++ b/examples/lua_REPL/main.c @@ -18,6 +18,7 @@ * @} */ +#include #include #include @@ -31,7 +32,7 @@ */ #define MAIN_LUA_MEM_SIZE (40000) -static char lua_memory[MAIN_LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__))); +static alignas(__BIGGEST_ALIGNMENT__) char lua_memory[MAIN_LUA_MEM_SIZE]; #define BARE_MINIMUM_MODS (LUAR_LOAD_BASE | LUAR_LOAD_IO | LUAR_LOAD_CORO | LUAR_LOAD_PACKAGE) diff --git a/examples/lua_basic/main.c b/examples/lua_basic/main.c index ba1ba378259d..1e8dca678fb2 100644 --- a/examples/lua_basic/main.c +++ b/examples/lua_basic/main.c @@ -18,6 +18,7 @@ * @} */ +#include #include #include @@ -32,7 +33,7 @@ #else #define LUA_MEM_SIZE (11000) #endif -static char lua_mem[LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__))); +static alignas(__BIGGEST_ALIGNMENT__) char lua_mem[LUA_MEM_SIZE]; int lua_run_script(const uint8_t *buffer, size_t buffer_len) { diff --git a/sys/include/architecture.h b/sys/include/architecture.h index 37c36a7a32d6..34081e1bbba3 100644 --- a/sys/include/architecture.h +++ b/sys/include/architecture.h @@ -24,9 +24,10 @@ #ifndef ARCHITECTURE_H #define ARCHITECTURE_H -#include #include #include +#include +#include #include "architecture_arch.h" /* IWYU pragma: export */ @@ -203,7 +204,7 @@ typedef uintptr_t uinttxtptr_t; * char WORD_ALIGNED thread_stack[THREAD_STACKSIZE_DEFAULT]; * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#define WORD_ALIGNED __attribute__((aligned(ARCHITECTURE_WORD_BYTES))) +#define WORD_ALIGNED alignas(ARCHITECTURE_WORD_BYTES) /** * @brief Check if @p addr is alignment to @p alignment diff --git a/sys/include/can/can.h b/sys/include/can/can.h index b0974aa743fb..a071399bf412 100644 --- a/sys/include/can/can.h +++ b/sys/include/can/can.h @@ -26,12 +26,13 @@ #ifndef CAN_CAN_H #define CAN_CAN_H +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include - #if defined(__linux__) #include @@ -92,7 +93,7 @@ struct can_frame { uint8_t __res0; /**< reserved / padding */ uint8_t __res1; /**< reserved / padding */ /** Frame data */ - uint8_t data[CAN_MAX_DLEN] __attribute__((aligned(8))); + uint8_t alignas(8) data[CAN_MAX_DLEN]; }; /** diff --git a/sys/include/event.h b/sys/include/event.h index 19daf5c2091b..6015a5d3da9e 100644 --- a/sys/include/event.h +++ b/sys/include/event.h @@ -153,7 +153,8 @@ struct event { /** * @brief event queue structure */ -typedef struct PTRTAG { +typedef struct { + PTRTAG clist_node_t event_list; /**< list of queued events */ thread_t *waiter; /**< thread owning event queue */ } event_queue_t; diff --git a/sys/include/pm_layered.h b/sys/include/pm_layered.h index f0c2236654cd..397e5221b05c 100644 --- a/sys/include/pm_layered.h +++ b/sys/include/pm_layered.h @@ -55,8 +55,9 @@ extern "C" { * @brief Power Management mode blocker typedef */ typedef struct { + WORD_ALIGNED uint8_t blockers[PM_NUM_MODES]; /**< number of blockers for the mode */ -} WORD_ALIGNED pm_blocker_t; +} pm_blocker_t; /** * @brief Block a power mode diff --git a/sys/include/ptrtag.h b/sys/include/ptrtag.h index 187477b2f91d..c93f0f77ba60 100644 --- a/sys/include/ptrtag.h +++ b/sys/include/ptrtag.h @@ -63,6 +63,7 @@ #include #include +#include #include #ifdef __cplusplus @@ -74,7 +75,7 @@ extern "C" { * * @details This will ensure a minimum alignment of 4 bytes */ -#define PTRTAG __attribute__((aligned(4))) +#define PTRTAG alignas(4) /** * @brief Create a tagged pointer diff --git a/sys/include/riotboot/flashwrite.h b/sys/include/riotboot/flashwrite.h index c76a7b2dc3cb..43cc424ba3c6 100644 --- a/sys/include/riotboot/flashwrite.h +++ b/sys/include/riotboot/flashwrite.h @@ -59,6 +59,8 @@ #ifndef RIOTBOOT_FLASHWRITE_H #define RIOTBOOT_FLASHWRITE_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -94,7 +96,7 @@ extern "C" { * @brief Extra attributes required for the firmware intermediate buffer */ #define RIOTBOOT_FLASHPAGE_BUFFER_ATTRS \ - __attribute__((aligned(FLASHPAGE_WRITE_BLOCK_ALIGNMENT))) + alignas(FLASHPAGE_WRITE_BLOCK_ALIGNMENT) /** * @brief firmware update state structure diff --git a/sys/riotboot/serial.c b/sys/riotboot/serial.c index ae6f57808861..f744cc2848f3 100644 --- a/sys/riotboot/serial.c +++ b/sys/riotboot/serial.c @@ -19,6 +19,7 @@ */ #include +#include #include #include "stdio_uart.h" @@ -109,8 +110,7 @@ static bool _bootdelay(unsigned tries, volatile bool *boot_default) return *boot_default; } -__attribute__ ((aligned(4))) -static struct { +static alignas(4) struct { uint8_t pos; /* current pos in rx buffer */ uint8_t remaining; /* remaining bytes to read */ union { diff --git a/tests/drivers/mtd_flashpage/main.c b/tests/drivers/mtd_flashpage/main.c index 96957ca67bb9..56d05419babd 100644 --- a/tests/drivers/mtd_flashpage/main.c +++ b/tests/drivers/mtd_flashpage/main.c @@ -11,6 +11,7 @@ * * @file */ +#include #include #include #include @@ -118,8 +119,7 @@ static void test_mtd_write_erase(void) static void test_mtd_write_read(void) { - const char buf[] __attribute__ ((aligned (FLASHPAGE_WRITE_BLOCK_ALIGNMENT))) - = "ABCDEFGHIJKLMNO"; + const alignas(FLASHPAGE_WRITE_BLOCK_ALIGNMENT) char buf[] = "ABCDEFGHIJKLMNO"; uint8_t buf_empty[3]; memset(buf_empty, FLASHPAGE_ERASE_STATE, sizeof(buf_empty)); diff --git a/tests/periph/flashpage/main.c b/tests/periph/flashpage/main.c index 738bd1653213..45bb3a694df0 100644 --- a/tests/periph/flashpage/main.c +++ b/tests/periph/flashpage/main.c @@ -18,12 +18,12 @@ * @} */ -#include +#include #include +#include #include -#include #include -#include +#include #include "architecture.h" #include "od.h" @@ -43,7 +43,7 @@ #endif /* When writing raw bytes on flash, data must be correctly aligned. */ -#define ALIGNMENT_ATTR __attribute__((aligned(FLASHPAGE_WRITE_BLOCK_ALIGNMENT))) +#define ALIGNMENT_ATTR alignas(FLASHPAGE_WRITE_BLOCK_ALIGNMENT) /* We must not write chunks smaller than FLASHPAGE_WRITE_BLOCK_SIZE */ #if FLASHPAGE_WRITE_BLOCK_SIZE > 64 @@ -55,7 +55,7 @@ /* * @brief Allocate an aligned buffer for raw writings */ -static uint8_t raw_buf[RAW_BUF_SIZE] ALIGNMENT_ATTR; +static ALIGNMENT_ATTR uint8_t raw_buf[RAW_BUF_SIZE]; #ifdef MODULE_PERIPH_FLASHPAGE_PAGEWISE /** @@ -66,7 +66,7 @@ static uint8_t raw_buf[RAW_BUF_SIZE] ALIGNMENT_ATTR; * 32 bit alignment implicitly and there are cases (stm32l4) that * requires 64 bit alignment. */ -static uint8_t page_mem[FLASHPAGE_SIZE] ALIGNMENT_ATTR; +static ALIGNMENT_ATTR uint8_t page_mem[FLASHPAGE_SIZE]; #ifdef MODULE_PERIPH_FLASHPAGE_IN_ADDRESS_SPACE /** diff --git a/tests/pkg/lua_loader/main.c b/tests/pkg/lua_loader/main.c index 889546bcc44f..2fa96dc8b289 100644 --- a/tests/pkg/lua_loader/main.c +++ b/tests/pkg/lua_loader/main.c @@ -25,6 +25,7 @@ */ #include +#include #include #include "lua_run.h" @@ -74,7 +75,7 @@ const size_t lua_riot_builtin_c_table_len = #else #define LUA_MEM_SIZE (11000) #endif -static char lua_mem[LUA_MEM_SIZE] __attribute__ ((aligned(__BIGGEST_ALIGNMENT__))); +static alignas(__BIGGEST_ALIGNMENT__) char lua_mem[LUA_MEM_SIZE]; #define LINEBUF_SZ (32) static char linebuf[LINEBUF_SZ]; diff --git a/tests/sys/ptrtag/main.c b/tests/sys/ptrtag/main.c index ab157b7b6e85..38dfabf03e29 100644 --- a/tests/sys/ptrtag/main.c +++ b/tests/sys/ptrtag/main.c @@ -25,7 +25,8 @@ #include "ptrtag.h" #include "test_utils/expect.h" -typedef struct PTRTAG { +typedef struct { + PTRTAG uint8_t a; } custom_type_t;