summaryrefslogtreecommitdiff
path: root/userland/libc/arpa/inet/htons.c
blob: 798a64a4b3cf432683428a35b35403c9755f411c (plain)
1
2
3
4
5
6
7
8
9
10
#include <arpa/inet.h>
#include <endian.h>
#include <stdint.h>

uint16_t htons(uint16_t hostlong) {
#if BYTE_ORDER == LITTLE_ENDIAN
  hostlong = ((hostlong & 0xFF00) >> 8) | ((hostlong & 0x00FF) << 8);
#endif
  return hostlong;
}