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

uint32_t ntohl(uint32_t netlong)
{
	union {
		int i;
		char c;
	} u = { 1 };

	return u.c ? bswap32(netlong) : netlong;
}