29typedef unsigned char bool;
32# define inline __inline
42#define kmalloc(size, flags) malloc(size)
43#define kfree(ptr) free(ptr)
44#define vmalloc(size) malloc(size)
45#define vfree(ptr) free(ptr)
47#define memeq(a, b, size) (memcmp(a, b, size) == 0)
48#define memzero(buf, size) memset(buf, 0, size)
51# define min(x, y) ((x) < (y) ? (x) : (y))
53#define min_t(type, x, y) min(x, y)
65#ifndef __always_inline
67# define __always_inline \
68 inline __attribute__((__always_inline__))
70# define __always_inline inline
75#ifndef get_unaligned_le32
76static inline uint32_t get_unaligned_le32(
const uint8_t *buf)
78 return (uint32_t)buf[0]
79 | ((uint32_t)buf[1] << 8)
80 | ((uint32_t)buf[2] << 16)
81 | ((uint32_t)buf[3] << 24);
85#ifndef get_unaligned_be32
86static inline uint32_t get_unaligned_be32(
const uint8_t *buf)
88 return (uint32_t)(buf[0] << 24)
89 | ((uint32_t)buf[1] << 16)
90 | ((uint32_t)buf[2] << 8)
95#ifndef put_unaligned_le32
96static inline void put_unaligned_le32(uint32_t val, uint8_t *buf)
98 buf[0] = (uint8_t)val;
99 buf[1] = (uint8_t)(val >> 8);
100 buf[2] = (uint8_t)(val >> 16);
101 buf[3] = (uint8_t)(val >> 24);
105#ifndef put_unaligned_be32
106static inline void put_unaligned_be32(uint32_t val, uint8_t *buf)
108 buf[0] = (uint8_t)(val >> 24);
109 buf[1] = (uint8_t)(val >> 16);
110 buf[2] = (uint8_t)(val >> 8);
111 buf[3] = (uint8_t)val;
121# define get_le32 get_unaligned_le32