diff --git a/makefiles/arch/mips.inc.mk b/makefiles/arch/mips.inc.mk index 93f3258a5e..bca4fe7b82 100644 --- a/makefiles/arch/mips.inc.mk +++ b/makefiles/arch/mips.inc.mk @@ -23,13 +23,9 @@ ifeq ($(ROMABLE),1) MIPS_HAL_LDFLAGS += -T bootcode.ld endif -# define build specific options -# Remove -std=gnu99 once the MIPS toolchain headers are updated to include upstream -# newlib commit 81c17949f0419d1c4fee421c60987ea1149522ae -# https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=81c17949f0419d1c4fee421c60987ea1149522ae # Otherwise we get an error about a missing declaration of strnlen in some parts. ifeq (, $(filter -std=%, $(CFLAGS))) - CFLAGS += -std=gnu99 + CFLAGS += -std=gnu11 endif CFLAGS_CPU = -EL -mabi=$(ABI) CFLAGS_LINK = -ffunction-sections -fno-builtin -fshort-enums -fdata-sections diff --git a/pkg/ccn-lite/patches/0001-cmake-Use-std-c11-instead-of-std-c99.patch b/pkg/ccn-lite/patches/0001-cmake-Use-std-c11-instead-of-std-c99.patch new file mode 100644 index 0000000000..b98bb81dfb --- /dev/null +++ b/pkg/ccn-lite/patches/0001-cmake-Use-std-c11-instead-of-std-c99.patch @@ -0,0 +1,28 @@ +From 540627a749f627df4a23fe3fc03757f37616c2eb Mon Sep 17 00:00:00 2001 +From: Marian Buschsieweke +Date: Thu, 11 Nov 2021 09:51:13 +0100 +Subject: [PATCH] cmake: Use -std=c11 instead of -std=c99 + +--- + src/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a56946be..a30f77fc 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -89,9 +89,9 @@ if(CCNL_RIOT) + endif() + + if (NOT CCNL_RIOT) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall -Werror -std=c99 -g -pedantic") #TODO: add -fsanitize=address ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall -Werror -std=c11 -g -pedantic") #TODO: add -fsanitize=address + else() +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall -Werror -std=c99 -g") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall -Werror -std=c11 -g") + endif() + + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g") +-- +2.33.1 + diff --git a/sys/posix/include/sys/socket.h b/sys/posix/include/sys/socket.h index 3514b160a7..ea223edf78 100644 --- a/sys/posix/include/sys/socket.h +++ b/sys/posix/include/sys/socket.h @@ -38,10 +38,12 @@ #define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) #endif +#include #include #include #include +#include "architecture.h" #include "net/af.h" #include "sys/bytes.h" @@ -120,18 +122,24 @@ typedef unsigned short sa_family_t; /**< address family type */ /** * @brief Used to define the socket address. + * + * @details This structure is is forced to be aligned as `uint32_t`, as e.g. + * the IPv4 address is stored as `uint32_t` */ struct sockaddr { - sa_family_t sa_family; /**< Address family */ + alignas(uint32_t) sa_family_t sa_family;/**< Address family */ char sa_data[SOCKADDR_MAX_DATA_LEN]; /**< Socket address (variable length data) */ }; /** * @brief Implementation based socket address table. * @extends struct sockaddr + * + * @details This structure is is forced to be aligned as `uint32_t`, as e.g. + * the IPv4 address is stored as `uint32_t` */ struct sockaddr_storage { - sa_family_t ss_family; /**< Address family */ + alignas(uint32_t) sa_family_t ss_family;/**< Address family */ uint8_t ss_data[SOCKADDR_MAX_DATA_LEN]; /**< Socket address */ };