X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fnetwork%2Fhtonl.c;h=6622d16cc5351749d1b76c5f24aa71009b018ff0;hb=e172c7b4df9a33e3f090e347eebd5426b94e6fee;hp=b21dace04600aea25b95bcc9435a28f9ef6bfec2;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/network/htonl.c b/src/network/htonl.c index b21dace0..6622d16c 100644 --- a/src/network/htonl.c +++ b/src/network/htonl.c @@ -1,10 +1,8 @@ #include +#include uint32_t htonl(uint32_t n) { - union { - uint8_t b[4]; - uint32_t i; - } u = { { n>>24, n>>16, n>>8, n } }; - return u.i; + union { int i; char c; } u = { 1 }; + return u.c ? bswap_32(n) : n; }