[libc-commits] [libc] [libc] Add `IN6_IS_ADDR_{LINK, SITE}LOCAL` (PR #168207)
via libc-commits
libc-commits at lists.llvm.org
Tue Dec 9 12:02:35 PST 2025
================
@@ -33,4 +33,12 @@
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
+#define IN6_IS_ADDR_LINKLOCAL(a) \
+ ((__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[0]) == 0xfe && \
+ (__LLVM_LIBC_CAST(reinterpret_cast, uint8_t *, a)[1] & 0xc0) == 0x80)
----------------
lntue wrote:
This is testing `byte 0 == 0xfe` and `byte 1 & mask == 80`, so assuming the high parts of 32-bit address `a` are at byte 0 and 1, that's big endian. Are we assuming `a` will be big endian, or does it depend on the host?
https://github.com/llvm/llvm-project/pull/168207
More information about the libc-commits
mailing list