3 #include <osmocom/core/endian.h>
8 static inline uint32_t osmo_swab32(uint32_t in)
12 out = (in & 0xff) << 24;
13 out |= (in & 0xff00) << 8;
14 out |= (in & 0xff0000) >> 8;
15 out |= (in & 0xff000000) >> 24;
23 static inline uint16_t osmo_swab16(uint16_t in)
27 out = (in & 0xff) << 8;
28 out |= (in & 0xff00) >> 8;
33 #ifdef OSMO_IS_LITTLE_ENDIAN
34 #define osmo_ntohl(x) osmo_swab32(x)
35 #define osmo_ntohs(x) osmo_swab16(x)
36 #define osmo_htonl(x) osmo_swab32(x)
37 #define osmo_htons(x) osmo_swab16(x)
39 #define osmo_ntohl(x) (x)
40 #define osmo_ntohs(x) (x)
41 #define osmo_htonl(x) (x)
42 #define osmo_htons(x) (x)