[libc-commits] [PATCH] D144506: [libc] Implement ntohl and ntohs
Raman Tenneti via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Feb 21 17:06:36 PST 2023
rtenneti added inline comments.
================
Comment at: libc/src/network/ntohl.cpp:16
+LLVM_LIBC_FUNCTION(uint32_t, ntohl, (uint32_t netlong)) {
+ return Endian::to_big_endian(netlong);
+}
----------------
sivachandra wrote:
> Should this always convert to big-endian, or should it convert to the host's endianness?
I thought of implementing it as the following:
LLVM_LIBC_FUNCTION(uint32_t, ntohl, (uint32_t netlong)) {
return Endian::IS_LITTLE ? __builtin_bswap32(netlong) : netlong;
}
The above seem to be same as Endian::to_big_endian. I am wondering if it is better to implement the above (to be clearer). What do you think? Thanks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144506/new/
https://reviews.llvm.org/D144506
More information about the libc-commits
mailing list