1*ce834c9cSThomas Weißschuh /* SPDX-License-Identifier: LGPL-2.1 OR MIT */ 2*ce834c9cSThomas Weißschuh /* 3*ce834c9cSThomas Weißschuh * Byte order conversion for NOLIBC 4*ce834c9cSThomas Weißschuh * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net> 5*ce834c9cSThomas Weißschuh */ 6*ce834c9cSThomas Weißschuh 7*ce834c9cSThomas Weißschuh /* make sure to include all global symbols */ 8*ce834c9cSThomas Weißschuh #include "nolibc.h" 9*ce834c9cSThomas Weißschuh 10*ce834c9cSThomas Weißschuh #ifndef _NOLIBC_ENDIAN_H 11*ce834c9cSThomas Weißschuh #define _NOLIBC_ENDIAN_H 12*ce834c9cSThomas Weißschuh 13*ce834c9cSThomas Weißschuh #include "stdint.h" 14*ce834c9cSThomas Weißschuh 15*ce834c9cSThomas Weißschuh #include <asm/byteorder.h> 16*ce834c9cSThomas Weißschuh 17*ce834c9cSThomas Weißschuh #define htobe16(_x) __cpu_to_be16(_x) 18*ce834c9cSThomas Weißschuh #define htole16(_x) __cpu_to_le16(_x) 19*ce834c9cSThomas Weißschuh #define be16toh(_x) __be16_to_cpu(_x) 20*ce834c9cSThomas Weißschuh #define le16toh(_x) __le16_to_cpu(_x) 21*ce834c9cSThomas Weißschuh 22*ce834c9cSThomas Weißschuh #define htobe32(_x) __cpu_to_be32(_x) 23*ce834c9cSThomas Weißschuh #define htole32(_x) __cpu_to_le32(_x) 24*ce834c9cSThomas Weißschuh #define be32toh(_x) __be32_to_cpu(_x) 25*ce834c9cSThomas Weißschuh #define le32toh(_x) __le32_to_cpu(_x) 26*ce834c9cSThomas Weißschuh 27*ce834c9cSThomas Weißschuh #define htobe64(_x) __cpu_to_be64(_x) 28*ce834c9cSThomas Weißschuh #define htole64(_x) __cpu_to_le64(_x) 29*ce834c9cSThomas Weißschuh #define be64toh(_x) __be64_to_cpu(_x) 30*ce834c9cSThomas Weißschuh #define le64toh(_x) __le64_to_cpu(_x) 31*ce834c9cSThomas Weißschuh 32*ce834c9cSThomas Weißschuh #endif /* _NOLIBC_ENDIAN_H */ 33