X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fnetwork%2Fhtonl.c;h=6622d16cc5351749d1b76c5f24aa71009b018ff0;hp=b21dace04600aea25b95bcc9435a28f9ef6bfec2;hb=c89862660bd3845ace7977480db3a43dc80475f4;hpb=c546be175c169399420fff4706cd1d4fcefd7d31 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; }