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

uint32_t htonl(uint32_t hostlong)
{
	union {
		int i;
		char c;
	} u = { 1 };

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