diff options
Diffstat (limited to 'src/arpa/inet/htons.c')
-rw-r--r-- | src/arpa/inet/htons.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/arpa/inet/htons.c b/src/arpa/inet/htons.c index 78592e9..1aeb39c 100644 --- a/src/arpa/inet/htons.c +++ b/src/arpa/inet/htons.c @@ -16,6 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <arpa/inet.h> +#include <bits/intconf.h> + /** @@ -31,9 +33,10 @@ */ uint16_t _htons(uint16_t value) { - char rc[2]; - rc[0] = (value >> 8) & 255; - rc[1] = (value >> 0) & 255; - return *(uint16_t*)rc; +#if __INT16_BYTEORDER == 0x0102 + return value; +#else + return (value >> 8) | (value << 8); +#endif } |