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

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

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