mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 09:33:50 +01:00
Merge pull request #21443 from maribu/tree-wide/gcc-15-1-fixes
tree-wide: fix compilation with GCC 15.1 and picolibc 1.8.10
This commit is contained in:
commit
385f06e784
@ -33,11 +33,25 @@ extern "C" {
|
||||
* cannot return.
|
||||
*/
|
||||
#ifndef NORETURN
|
||||
#ifdef __GNUC__
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
#define NORETURN
|
||||
# ifdef __GNUC__
|
||||
# define NORETURN __attribute__((noreturn))
|
||||
# else
|
||||
# define NORETURN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def NONSTRING
|
||||
* @brief The `NONSTRING` keyword tells the compiler to assume that a char array
|
||||
* is not used as c string. (Specifically: It does not need a terminating
|
||||
* zero byte.)
|
||||
*/
|
||||
#ifndef NONSTRING
|
||||
# if (__GNUC__ >= 15)
|
||||
# define NONSTRING __attribute__((nonstring))
|
||||
# else
|
||||
# define NONSTRING
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -48,11 +62,11 @@ extern "C" {
|
||||
* optimization just as an arithmetic operator would be.
|
||||
*/
|
||||
#ifndef PURE
|
||||
#ifdef __GNUC__
|
||||
#define PURE __attribute__((pure))
|
||||
#else
|
||||
#define PURE
|
||||
#endif
|
||||
# ifdef __GNUC__
|
||||
# define PURE __attribute__((pure))
|
||||
# else
|
||||
# define PURE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -61,11 +75,11 @@ extern "C" {
|
||||
* static functions, function arguments, local variables
|
||||
*/
|
||||
#ifndef MAYBE_UNUSED
|
||||
#ifdef __GNUC__
|
||||
#define MAYBE_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define MAYBE_UNUSED
|
||||
#endif
|
||||
# ifdef __GNUC__
|
||||
# define MAYBE_UNUSED __attribute__((unused))
|
||||
# else
|
||||
# define MAYBE_UNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -77,9 +91,9 @@ extern "C" {
|
||||
* by llvm.
|
||||
*/
|
||||
#if defined(__llvm__) || defined(__clang__)
|
||||
#define NO_SANITIZE_ARRAY __attribute__((no_sanitize("address")))
|
||||
# define NO_SANITIZE_ARRAY __attribute__((no_sanitize("address")))
|
||||
#else
|
||||
#define NO_SANITIZE_ARRAY
|
||||
# define NO_SANITIZE_ARRAY
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -90,9 +104,9 @@ extern "C" {
|
||||
* an assembler instruction causes a longjmp, or a write causes a reboot.
|
||||
*/
|
||||
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5) || defined(__clang__)
|
||||
#define UNREACHABLE() __builtin_unreachable()
|
||||
# define UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
#define UNREACHABLE() do { /* nothing */ } while (1)
|
||||
# define UNREACHABLE() do { /* nothing */ } while (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -138,12 +152,12 @@ extern "C" {
|
||||
* This allows providing two different implementations in C, with one being
|
||||
* more efficient if constant folding is used.
|
||||
*/
|
||||
#define IS_CT_CONSTANT(expr) <IMPLEMENTATION>
|
||||
# define IS_CT_CONSTANT(expr) <IMPLEMENTATION>
|
||||
#elif defined(__GNUC__)
|
||||
/* both clang and gcc (which both define __GNUC__) support this */
|
||||
#define IS_CT_CONSTANT(expr) __builtin_constant_p(expr)
|
||||
# define IS_CT_CONSTANT(expr) __builtin_constant_p(expr)
|
||||
#else
|
||||
#define IS_CT_CONSTANT(expr) 0
|
||||
# define IS_CT_CONSTANT(expr) 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -175,9 +189,9 @@ extern "C" {
|
||||
* @param[in] cond Condition that is guaranteed to be true
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define assume(cond) ((cond) ? (void)0 : UNREACHABLE())
|
||||
# define assume(cond) ((cond) ? (void)0 : UNREACHABLE())
|
||||
#else
|
||||
#define assume(cond) assert(cond)
|
||||
# define assume(cond) assert(cond)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@ -23,6 +23,7 @@ export NATIVEINCLUDES # The native include paths, set by the various nati
|
||||
|
||||
export GCC_C_INCLUDES # system include dirs implicitly used by GCC's c compiler, only defined with TOOLCHAIN=llvm
|
||||
export GCC_CXX_INCLUDES # system include dirs implicitly used by GCC's c++ compiler, only defined with TOOLCHAIN=llvm
|
||||
export GCC_VERSION # version of GCC if GCC is used, empty otherwise
|
||||
|
||||
export USEMODULE # Sys Module dependencies of the application. Set in the application's Makefile.
|
||||
export BIN_USEMODULE # Modules specific to bindist (see bindist.ink.mk). Set in the application's Makefile.
|
||||
|
||||
10
pkg/pkg.mk
10
pkg/pkg.mk
@ -197,6 +197,16 @@ distclean:: clean
|
||||
endif
|
||||
|
||||
# Disabling some diagnostics: These issues needs to be fixed upstream
|
||||
CFLAGS += -Wno-maybe-uninitialized
|
||||
ifeq (llvm,$(TOOLCHAIN))
|
||||
CFLAGS += -Wno-documentation
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/makefiles/utils/strings.mk
|
||||
# Disabling -Wunterminated-string-initialization on toolchains that support this
|
||||
# warning
|
||||
ifeq (1,$(call version_is_greater_or_equal,$(GCC_VERSION),15))
|
||||
CFLAGS += -Wno-unterminated-string-initialization
|
||||
# this flag should not be passed to g++, only gcc:
|
||||
CXXUWFLAGS += -Wno-unterminated-string-initialization
|
||||
endif
|
||||
|
||||
@ -27,12 +27,14 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "container.h"
|
||||
#include "fmt.h"
|
||||
#include "modules.h"
|
||||
|
||||
extern ssize_t stdio_write(const void* buffer, size_t len);
|
||||
|
||||
NONSTRING
|
||||
static const char _hex_chars[16] = "0123456789ABCDEF";
|
||||
|
||||
static const uint32_t _tenmap[] = {
|
||||
|
||||
@ -24,9 +24,11 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "fmt.h"
|
||||
#include "fmt_table.h"
|
||||
|
||||
NONSTRING
|
||||
static const char fmt_table_spaces[16] = " ";
|
||||
|
||||
/**
|
||||
|
||||
@ -238,7 +238,9 @@ static int picolibc_get(FILE *file)
|
||||
FILE picolibc_stdio =
|
||||
FDEV_SETUP_STREAM(picolibc_put, picolibc_get, picolibc_flush, _FDEV_SETUP_RW);
|
||||
|
||||
#ifdef PICOLIBC_STDIO_GLOBALS
|
||||
/* Since picolibc 1.8.10, PICOLIBC_STDIO_GLOBALS is prefixed with two leading
|
||||
* underscores. We just test for both to remain backwards compatible */
|
||||
#if defined(PICOLIBC_STDIO_GLOBALS) || defined(__PICOLIBC_STDIO_GLOBALS)
|
||||
#ifdef __strong_reference
|
||||
/* This saves two const pointers.
|
||||
* See https://github.com/RIOT-OS/RIOT/pull/17001#issuecomment-945936918
|
||||
|
||||
@ -22,15 +22,20 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "base64.h"
|
||||
#include "compiler_hints.h"
|
||||
#include "fmt.h"
|
||||
#include "macros/utils.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
static char buf[128];
|
||||
|
||||
/* no need for the zero-termination here, base64_encode() gets the size of the
|
||||
* string as explicit argument */
|
||||
NONSTRING
|
||||
static const char input[96] = "This is an extremely, enormously, greatly, "
|
||||
"immensely, tremendously, remarkably lengthy "
|
||||
"sentence!";
|
||||
NONSTRING
|
||||
static const char base64[128] =
|
||||
"VGhpcyBpcyBhbiBleHRyZW1lbHksIGVub3Jtb3VzbHksIGdyZWF0bHksIGltbWVuc2VseSwgdHJl"
|
||||
"bWVuZG91c2x5LCByZW1hcmthYmx5IGxlbmd0aHkgc2VudGVuY2Uh";
|
||||
|
||||
@ -7,5 +7,6 @@ USEMODULE += $(DRIVER)
|
||||
USEMODULE += ztimer_usec
|
||||
USEMODULE += ztimer_msec
|
||||
USEMODULE += fmt
|
||||
USEMODULE += fmt_table
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
||||
@ -13,40 +13,19 @@
|
||||
* @file
|
||||
* @brief HM330X driver test application
|
||||
*
|
||||
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
* @author Francisco Molina <francois-xavier.molinas@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "fmt_table.h"
|
||||
#include "time_units.h"
|
||||
#include "ztimer.h"
|
||||
#include "timex.h"
|
||||
|
||||
#include "hm330x.h"
|
||||
#include "hm330x_params.h"
|
||||
|
||||
static const char spaces[16] = " ";
|
||||
|
||||
static void print_col_u32_dec(uint32_t number, size_t width)
|
||||
{
|
||||
char sbuf[10]; /* "4294967295" */
|
||||
size_t slen;
|
||||
|
||||
slen = fmt_u32_dec(sbuf, number);
|
||||
if (width > slen) {
|
||||
width -= slen;
|
||||
while (width > sizeof(spaces)) {
|
||||
print(spaces, sizeof(spaces));
|
||||
}
|
||||
print(spaces, width);
|
||||
}
|
||||
print(sbuf, slen);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hm330x_t dev;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "embUnit.h"
|
||||
#include "compiler_hints.h"
|
||||
#include "psa/crypto.h"
|
||||
|
||||
void addFailurePSA(const char *func, psa_status_t errcode, long line, const char *file)
|
||||
@ -73,7 +74,9 @@ static void test_hash_interleaved(void)
|
||||
{
|
||||
const psa_algorithm_t alg = PSA_ALG_SHA_256;
|
||||
|
||||
NONSTRING
|
||||
const uint8_t in1[1] = "a";
|
||||
NONSTRING
|
||||
const uint8_t in2[1] = "b";
|
||||
|
||||
const uint8_t exp1[] = {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "psa/crypto.h"
|
||||
|
||||
/*
|
||||
@ -42,6 +43,7 @@ static const uint8_t public_key[] = {0x04, 0x60, 0xFE, 0xD4, 0xBA, 0x25, 0x5A, 0
|
||||
|
||||
/* certain PSA backends require the data to be in RAM rather than ROM
|
||||
* so these values cannot be `const` */
|
||||
NONSTRING
|
||||
static uint8_t message[6] = "sample";
|
||||
static uint8_t signature[] = {0xEF, 0xD4, 0x8B, 0x2A, 0xAC, 0xB6, 0xA8, 0xFD, 0x11, 0x40,
|
||||
0xDD, 0x9C, 0xD4, 0x5E, 0x81, 0xD6, 0x9D, 0x2C, 0x87, 0x7B, 0x56, 0xAA, 0xF9, 0x91, 0xC3, 0x4D,
|
||||
|
||||
@ -29,17 +29,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "shell.h"
|
||||
#include "tm.h"
|
||||
|
||||
NONSTRING
|
||||
static const char MON_NAMES[12][3] = {
|
||||
"JAN", "FEB", "MAR", "APR",
|
||||
"MAY", "JUN", "JUL", "AUG",
|
||||
"SEP", "OCT", "NOV", "DEC",
|
||||
};
|
||||
NONSTRING
|
||||
static const char DAY_NAMES[7][3] = {
|
||||
"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
|
||||
};
|
||||
NONSTRING
|
||||
static const char BOOL_NAMES[2][3] = { "NO", "YES" };
|
||||
|
||||
bool proper_atoi(const char *a, int *i)
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "embUnit/embUnit.h"
|
||||
|
||||
#include "compiler_hints.h"
|
||||
#include "fmt.h"
|
||||
#include "tests-fmt.h"
|
||||
|
||||
@ -244,6 +245,7 @@ static void test_fmt_hex_bytes(void)
|
||||
|
||||
static void test_fmt_u16_hex(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[8] = "zzzzzzzz";
|
||||
|
||||
/* Check return count with null buffer input */
|
||||
@ -260,6 +262,7 @@ static void test_fmt_u16_hex(void)
|
||||
|
||||
static void test_fmt_u32_hex(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[12] = "zzzzzzzzzzzz";
|
||||
|
||||
/* Check return count with null buffer input */
|
||||
@ -276,6 +279,7 @@ static void test_fmt_u32_hex(void)
|
||||
|
||||
static void test_fmt_u64_hex(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[20] = "zzzzzzzzzzzzzzzzzzzz";
|
||||
|
||||
/* Check return count with null buffer input */
|
||||
@ -292,6 +296,7 @@ static void test_fmt_u64_hex(void)
|
||||
|
||||
static void test_fmt_u16_dec(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[8] = "zzzzzzzz";
|
||||
uint8_t chars = 0;
|
||||
|
||||
@ -310,6 +315,7 @@ static void test_fmt_u16_dec(void)
|
||||
|
||||
static void test_fmt_u32_dec(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[16] = "zzzzzzzzzzzzzzzz";
|
||||
uint8_t chars = 0;
|
||||
|
||||
@ -329,6 +335,7 @@ static void test_fmt_u32_dec(void)
|
||||
|
||||
static void test_fmt_u64_dec(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
|
||||
uint8_t chars = 0;
|
||||
|
||||
@ -345,6 +352,7 @@ static void test_fmt_u64_dec(void)
|
||||
|
||||
static void test_fmt_u64_dec_zero(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
|
||||
uint8_t chars = 0;
|
||||
|
||||
@ -355,6 +363,7 @@ static void test_fmt_u64_dec_zero(void)
|
||||
|
||||
static void test_fmt_u64_dec_u64max(void)
|
||||
{
|
||||
NONSTRING
|
||||
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
|
||||
uint8_t chars = 0;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user