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

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

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