38 #ifndef included_test_vec_h 39 #define included_test_vec_h 53 u32 val = va_arg (*va,
u32);
56 for (i =
BITS (val) - 1; i >= 0; i--)
67 #define VERBOSE1(fmt, args...) \ 70 fformat (stdout, fmt, ## args); \ 73 #define VERBOSE2(fmt, args...) \ 76 fformat (stdout, fmt, ## args); \ 79 #define VERBOSE3(fmt, args...) \ 82 fformat (stdout, fmt, ## args); \ 85 #define clib_mem_free_safe(p) \ 101 const u32 mask = 0x12345678;
102 u32 seed,
a, b, result;
109 seed = 16807 * b - 2836 *
a;
112 seed += ((
u32) 1 << 31) - 1;
116 *seed_return = seed ^ mask;
128 return ((
my_random_u32 (seed) % (hi - lo + ((hi != ~0) ? (1) : (0)))) + lo);
131 #define fill_with_random_data(ptr, bytes, seed) \ 133 u8 * _v(p) = (u8 *) (ptr); \ 134 uword _v(b) = (bytes); \ 137 for (_v(i) = 0; _v(i) < _v(b); _v(i)++) \ 138 _v(p)[_v(i)] = (u8) bounded_random_u32 (&(seed), 0, 255); \ 142 #define compute_mem_hash(hash, ptr, bytes) \ 144 u8 * _v(p) = (u8 *) (ptr); \ 145 uword _v(b) = (uword) (bytes); \ 147 uword _v(h) = (u8) (hash); \ 149 if (_v(p) && _v(b) > 0) \ 151 for (_v(i) = 0; _v(i) < _v(b); _v(i)++) \ 152 _v(h) ^= _v(p)[_v(i)]; \ 158 #define log2_align_down(value, align) \ 160 uword _v = (uword) (value); \ 161 uword _a = (uword) (align); \ 162 uword _m = (1 << _a) - 1; \ 167 #define log2_align_up(value, align) \ 169 uword _v = (uword) (value); \ 170 uword _a = (uword) (align); \ 171 uword _m = (1 << _a) - 1; \ 173 _v = (_v + _m) & ~_m; \ 176 #define log2_align_ptr_down(ptr, align) \ 177 uword_to_pointer (log2_align_down (pointer_to_uword (ptr), align), void *) 179 #define log2_align_ptr_up(ptr, align) \ 180 uword_to_pointer (log2_align_up (pointer_to_uword (ptr), align), void *) 182 #define MAX_LOG2_ALIGN 6 183 #define MAX_UNALIGN_OFFSET ((1 << MAX_LOG2_ALIGN) - 1) 221 #define memory_snap() \ 223 clib_mem_usage_t _usage = { 0 }; \ 224 clib_mem_usage (&_usage); \ 225 fformat (stdout, "%U\n", format_clib_mem_usage, _usage, 0); \ static u32 my_random_u32(u32 *seed_return)
sll srl srl sll sra u16x4 i
static u32 bounded_random_u32(u32 *seed, uword lo, uword hi)
always_inline u8 * format_u32_binary(u8 *s, va_list *va)
always_inline void * alloc_aligned(uword size, uword log2_align, void **ptr_to_free)
always_inline void * alloc_unaligned(uword size, uword offset, void **ptr_to_free)
always_inline void * clib_mem_alloc(uword size)
#define MAX_UNALIGN_OFFSET
#define log2_align_ptr_up(ptr, align)