30 #if __BYTE_ORDER == __LITTLE_ENDIAN
31 #define le16_to_cpu(val) (val)
32 #define le32_to_cpu(val) (val)
33 #define le64_to_cpu(val) (val)
34 #define cpu_to_le16(val) (val)
35 #define cpu_to_le32(val) (val)
36 #define cpu_to_le64(val) (val)
37 #define be16_to_cpu(val) bswap_16(val)
38 #define be32_to_cpu(val) bswap_32(val)
39 #define be64_to_cpu(val) bswap_64(val)
40 #define cpu_to_be16(val) bswap_16(val)
41 #define cpu_to_be32(val) bswap_32(val)
42 #define cpu_to_be64(val) bswap_64(val)
43 #elif __BYTE_ORDER == __BIG_ENDIAN
44 #define le16_to_cpu(val) bswap_16(val)
45 #define le32_to_cpu(val) bswap_32(val)
46 #define le64_to_cpu(val) bswap_64(val)
47 #define cpu_to_le16(val) bswap_16(val)
48 #define cpu_to_le32(val) bswap_32(val)
49 #define cpu_to_le64(val) bswap_64(val)
50 #define be16_to_cpu(val) (val)
51 #define be32_to_cpu(val) (val)
52 #define be64_to_cpu(val) (val)
53 #define cpu_to_be16(val) (val)
54 #define cpu_to_be32(val) (val)
55 #define cpu_to_be64(val) (val)
57 #error "Unknown byte order"
60 #define get_unaligned(ptr) \
62 struct __attribute__((packed)) { \
63 __typeof__(*(ptr)) __v; \
64 } *__p = (__typeof__(__p)) (ptr); \
68 #define put_unaligned(val, ptr) \
70 struct __attribute__((packed)) { \
71 __typeof__(*(ptr)) __v; \
72 } *__p = (__typeof__(__p)) (ptr); \
76 #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
77 #define UINT_TO_PTR(u) ((void *) ((uintptr_t) (u)))
79 #define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
80 #define INT_TO_PTR(u) ((void *) ((intptr_t) (u)))
82 #define new0(t, n) ((t*) calloc((n), sizeof(t)))
83 #define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
84 #define malloc0(n) (calloc((n), 1))
89 const char *format, ...)
92 void util_hexdump(const
char dir, const
unsigned char *buf,
size_t len,
95 unsigned char util_get_dt(const
char *parent, const
char *name);
130 static inline void put_le16(uint16_t val,
void *dst)
135 static inline void put_be16(uint16_t val,
const void *ptr)
140 static inline void put_le32(uint32_t val,
void *dst)
145 static inline void put_be32(uint32_t val,
void *dst)
150 static inline void put_le64(uint64_t val,
void *dst)
155 static inline void put_be64(uint64_t val,
void *dst)
#define get_unaligned(ptr)
void(* util_debug_func_t)(const char *str, void *user_data)
void util_clear_uid(unsigned int *bitmap, uint8_t id)
static uint32_t get_be32(const void *ptr)
void util_debug(util_debug_func_t function, void *user_data, const char *format,...) __attribute__((format(printf
static uint64_t get_le64(const void *ptr)
static void put_be32(uint32_t val, void *dst)
static void put_be16(uint16_t val, const void *ptr)
uint8_t util_get_uid(unsigned int *bitmap, uint8_t max)
static void put_le16(uint16_t val, void *dst)
static void put_be64(uint64_t val, void *dst)
static uint32_t get_le32(const void *ptr)
unsigned char util_get_dt(const char *parent, const char *name)
static void put_le32(uint32_t val, void *dst)
static uint16_t get_be16(const void *ptr)
static void put_le64(uint64_t val, void *dst)
void void util_hexdump(const char dir, const unsigned char *buf, size_t len, util_debug_func_t function, void *user_data)
#define put_unaligned(val, ptr)
static uint16_t get_le16(const void *ptr)
static uint64_t get_be64(const void *ptr)