summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/htons.c
blob: 765d3bbc5bd2d67ffbb580ec7653889417b4933f (plain)
1
2
3
4
5
6
7
8
9
10
11
#include <endian.h>

unsigned short int htons(unsigned short int hostshort) {
#if __BYTE_ORDER==__LITTLE_ENDIAN
  return ((hostshort>>8)&0xff) | (hostshort<<8);
#else
  return hostshort;
#endif
}

unsigned short int ntohs(unsigned short int hostshort) __attribute__((weak,alias("htons")));