From 3e8c7d0861b410ad917fee82f3c2fb58b2b1af28 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 13 Nov 2024 16:01:34 +0100 Subject: [PATCH] sys/endian: fix build with picolibc --- sys/include/endian.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sys/include/endian.h b/sys/include/endian.h index 4d0b4bb50b..9f253955d8 100644 --- a/sys/include/endian.h +++ b/sys/include/endian.h @@ -94,31 +94,79 @@ uint64_t le64toh(uint64_t little_endian_64bits);/**< little endian to host, 64 b #endif #if BYTE_ORDER == LITTLE_ENDIAN +# ifndef htobe16 # define htobe16(_x) __builtin_bswap16(_x) +# endif +# ifndef htole16 # define htole16(_x) ((uint16_t)(_x)) +# endif +# ifndef be16toh # define be16toh(_x) __builtin_bswap16(_x) +# endif +# ifndef le16toh # define le16toh(_x) ((uint16_t)(_x)) +# endif +# ifndef htobe32 # define htobe32(_x) __builtin_bswap32(_x) +# endif +# ifndef htole32 # define htole32(_x) ((uint32_t)(_x)) +# endif +# ifndef be32toh # define be32toh(_x) __builtin_bswap32(_x) +# endif +# ifndef le32toh # define le32toh(_x) ((uint32_t)(_x)) +# endif +# ifndef htobe64 # define htobe64(_x) __builtin_bswap64(_x) +# endif +# ifndef htole64 # define htole64(_x) ((uint64_t)(_x)) +# endif +# ifndef be64toh # define be64toh(_x) __builtin_bswap64(_x) +# endif +# ifndef le64toh # define le64toh(_x) ((uint64_t)(_x)) +# endif #elif BYTE_ORDER == BIG_ENDIAN +# ifndef htole16 # define htole16(_x) __builtin_bswap16(_x) +# endif +# ifndef htobe16 # define htobe16(_x) ((uint16_t)(_x)) +# endif +# ifndef le16toh # define le16toh(_x) __builtin_bswap16(_x) +# endif +# ifndef be16toh # define be16toh(_x) ((uint16_t)(_x)) +# endif +# ifndef htole32 # define htole32(_x) __builtin_bswap32(_x) +# endif +# ifndef htobe32 # define htobe32(_x) ((uint32_t)(_x)) +# endif +# ifndef le32toh # define le32toh(_x) __builtin_bswap32(_x) +# endif +# ifndef be32toh # define be32toh(_x) ((uint32_t)(_x)) +# endif +# ifndef htole64 # define htole64(_x) __builtin_bswap64(_x) +# endif +# ifndef htobe64 # define htobe64(_x) ((uint64_t)(_x)) +# endif +# ifndef le64toh # define le64toh(_x) __builtin_bswap64(_x) +# endif +# ifndef be64toh # define be64toh(_x) ((uint64_t)(_x)) +# endif #else # error "Byte order not supported" #endif