aboutsummaryrefslogtreecommitdiff
path: root/util/byteorder.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/byteorder.c')
-rw-r--r--util/byteorder.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/byteorder.c b/util/byteorder.c
index 18311972..0629b31e 100644
--- a/util/byteorder.c
+++ b/util/byteorder.c
@@ -36,6 +36,14 @@ uint32_t ntohl(uint32_t netlong) {
#endif
}
+uint16_t htons(uint16_t hostshort) {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ return __builtin_bswap16(hostshort);
+#else
+ return hostshort;
+#endif
+}
+
uint32_t htonl(uint32_t hostlong) {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return __builtin_bswap32(hostlong);