1#include <endian.h>
2
3#if __BYTE_ORDER == __BIG_ENDIAN
4# define cpu_to_le16(w16) le16_to_cpu(w16)
5# define le16_to_cpu(w16) ((u_int16_t)((u_int16_t)(w16) >> 8) | \
6                           (u_int16_t)((u_int16_t)(w16) << 8))
7# define cpu_to_le32(w32) le32_to_cpu(w32)
8# define le32_to_cpu(w32) ((u_int32_t)( (u_int32_t)(w32) >>24) | \
9                           (u_int32_t)(((u_int32_t)(w32) >> 8) & 0xFF00) | \
10                           (u_int32_t)(((u_int32_t)(w32) << 8) & 0xFF0000) | \
11			   (u_int32_t)( (u_int32_t)(w32) <<24))
12#elif __BYTE_ORDER == __LITTLE_ENDIAN
13# define cpu_to_le16(w16) ((u_int16_t)(w16))
14# define le16_to_cpu(w16) ((u_int16_t)(w16))
15# define cpu_to_le32(w32) ((u_int32_t)(w32))
16# define le32_to_cpu(w32) ((u_int32_t)(w32))
17#else
18# error unknown endianess?
19#endif
20
21