1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20985 from benpicco/picolibc-endian.h

sys/endian: fix build with picolibc
This commit is contained in:
Marian Buschsieweke 2024-11-13 17:29:37 +00:00 committed by GitHub
commit fe621438dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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