[libc-commits] [libc] [libc] add `LLVM_LIBC_CAST` macro. (PR #127319)

via libc-commits libc-commits at lists.llvm.org
Mon Feb 17 16:48:21 PST 2025


================
@@ -20,27 +20,27 @@
 #define htobe16(x) __builtin_bswap16((x))
 #define htobe32(x) __builtin_bswap32((x))
 #define htobe64(x) __builtin_bswap64((x))
-#define htole16(x) ((uint16_t)(x))
-#define htole32(x) ((uint32_t)(x))
-#define htole64(x) ((uint64_t)(x))
+#define htole16(x) __LLVM_LIBC_CAST(reinterpret_cast, uint16_t, x)
----------------
c8ef wrote:

The bionic implementation omits it, while the glibc, musl, and freebsd implementations enforce it. Unsure which is more suitable.

https://github.com/llvm/llvm-project/pull/127319


More information about the libc-commits mailing list