summaryrefslogtreecommitdiff
path: root/lib/libc/arpa/ntohs.c
blob: 6c7e55d6df539978bf3ea43e60fa2b40de0ae261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <arpa/inet.h> // for ntohs
#include <byteswap.h>  // for bswap16
#include <stdint.h>    // for uint16_t

uint16_t ntohs(uint16_t netshort)
{
	union {
		int i;
		char c;
	} u = { 1 };

	return u.c ? bswap16(netshort) : netshort;
}