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

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

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