[libc-commits] [PATCH] D144506: [libc] Implement ntohl and ntohs
Raman Tenneti via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Feb 22 10:14:42 PST 2023
rtenneti updated this revision to Diff 499574.
rtenneti added a comment.
Fixed comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144506/new/
https://reviews.llvm.org/D144506
Files:
libc/src/network/ntohl.cpp
libc/src/network/ntohs.cpp
Index: libc/src/network/ntohs.cpp
===================================================================
--- libc/src/network/ntohs.cpp
+++ libc/src/network/ntohs.cpp
@@ -13,7 +13,10 @@
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(uint16_t, ntohs, (uint16_t netshort)) {
- return Endian::IS_LITTLE ? __builtin_bswap16(netshort) : netshort;
+ if constexpr (Endian::IS_LITTLE)
+ return __builtin_bswap16(netshort);
+ else
+ return netshort;
}
} // namespace __llvm_libc
Index: libc/src/network/ntohl.cpp
===================================================================
--- libc/src/network/ntohl.cpp
+++ libc/src/network/ntohl.cpp
@@ -13,7 +13,10 @@
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(uint32_t, ntohl, (uint32_t netlong)) {
- return Endian::IS_LITTLE ? __builtin_bswap32(netlong) : netlong;
+ if constexpr (Endian::IS_LITTLE)
+ return __builtin_bswap32(netlong);
+ else
+ return netlong;
}
} // namespace __llvm_libc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144506.499574.patch
Type: text/x-patch
Size: 955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230222/1570908a/attachment.bin>
More information about the libc-commits
mailing list