38 #ifndef included_test_vec_h 39 #define included_test_vec_h 54 u32 val = va_arg (*va,
u32);
57 for (i =
BITS (val) - 1; i >= 0; i--)
68 #define VERBOSE1(fmt, args...) \ 71 fformat (stdout, fmt, ## args); \ 74 #define VERBOSE2(fmt, args...) \ 77 fformat (stdout, fmt, ## args); \ 80 #define VERBOSE3(fmt, args...) \ 83 fformat (stdout, fmt, ## args); \ 86 #define clib_mem_free_safe(p) \ 103 const u32 mask = 0x12345678;
104 u32 seed,
a, b, result;
111 seed = 16807 * b - 2836 *
a;
114 seed += ((
u32) 1 << 31) - 1;
118 *seed_return = seed ^ mask;
131 return ((
my_random_u32 (seed) % (hi - lo + ((hi != ~0) ? (1) : (0)))) + lo);
134 #define fill_with_random_data(ptr, bytes, seed) \ 136 u8 * _v(p) = (u8 *) (ptr); \ 137 uword _v(b) = (bytes); \ 140 for (_v(i) = 0; _v(i) < _v(b); _v(i)++) \ 141 _v(p)[_v(i)] = (u8) bounded_random_u32 (&(seed), 0, 255); \ 145 #define compute_mem_hash(hash, ptr, bytes) \ 147 u8 * _v(p) = (u8 *) (ptr); \ 148 uword _v(b) = (uword) (bytes); \ 150 uword _v(h) = (u8) (hash); \ 152 if (_v(p) && _v(b) > 0) \ 154 for (_v(i) = 0; _v(i) < _v(b); _v(i)++) \ 155 _v(h) ^= _v(p)[_v(i)]; \ 161 #define log2_align_down(value, align) \ 163 uword _v = (uword) (value); \ 164 uword _a = (uword) (align); \ 165 uword _m = (1 << _a) - 1; \ 170 #define log2_align_up(value, align) \ 172 uword _v = (uword) (value); \ 173 uword _a = (uword) (align); \ 174 uword _m = (1 << _a) - 1; \ 176 _v = (_v + _m) & ~_m; \ 179 #define log2_align_ptr_down(ptr, align) \ 180 uword_to_pointer (log2_align_down (pointer_to_uword (ptr), align), void *) 182 #define log2_align_ptr_up(ptr, align) \ 183 uword_to_pointer (log2_align_up (pointer_to_uword (ptr), align), void *) 185 #define MAX_LOG2_ALIGN 6 186 #define MAX_UNALIGN_OFFSET ((1 << MAX_LOG2_ALIGN) - 1) 227 #define memory_snap() \ 229 clib_mem_usage_t _usage = { 0 }; \ 230 clib_mem_usage (&_usage); \ 231 fformat (stdout, "%U\n", format_clib_mem_usage, _usage, 0); \ static u32 my_random_u32(u32 *seed_return)
static u8 * format_u32_binary(u8 *s, va_list *va)
sll srl srl sll sra u16x4 i
static u32 bounded_random_u32(u32 *seed, uword lo, uword hi)
static void * clib_mem_alloc(uword size)
#define MAX_UNALIGN_OFFSET
template key/value backing page structure
static void * alloc_unaligned(uword size, uword offset, void **ptr_to_free)
#define log2_align_ptr_up(ptr, align)
static void * alloc_aligned(uword size, uword log2_align, void **ptr_to_free)