aboutsummaryrefslogtreecommitdiff
path: root/lib/libk/endian/little.c
blob: 56a20adeb197a51362ce35f4d298deb9f6831db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* spdx-license-identifier: ISC */

#include "endian.h"

#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error little.c included in build on big endian target
#endif

uint16_t
htole16(uint16_t host_16b)
{
  return host_16b;
}

uint32_t
htole32(uint32_t host_32b)
{
  return host_32b;
}

uint64_t
htole64(uint64_t host_64b)
{
  return host_64b;
}

uint16_t
htobe16(uint16_t host_16b)
{
  return __builtin_bswap16(host_16b);
}
uint32_t
htobe32(uint32_t host_32b)
{
  return __builtin_bswap32(host_32b);
}
uint64_t
htobe64(uint64_t host_64b)
{
  return __builtin_bswap64(host_64b);
}