From 4a251d0a9c6a6a5981b6bc6500994fa9b8f1c43c Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 6 May 2021 17:28:12 +0200 Subject: vppinfra: fix tests Type: fix Change-Id: If59a66aae658dd35dbcb4987ab00c306b3c6e2e2 Signed-off-by: Damjan Marion --- src/vppinfra/bihash_template.c | 4 ++++ src/vppinfra/elf.c | 18 +++++++++--------- src/vppinfra/elog.c | 12 ++++++------ src/vppinfra/hash.c | 10 +++++----- src/vppinfra/heap.c | 8 ++++---- src/vppinfra/macros.c | 4 ++-- src/vppinfra/maplog.c | 18 +++++++++--------- src/vppinfra/mem_dlmalloc.c | 4 ++-- src/vppinfra/pmalloc.c | 4 ++-- src/vppinfra/random.c | 4 ++-- src/vppinfra/random_isaac.c | 16 ++++++++-------- src/vppinfra/serialize.c | 36 ++++++++++++++++++------------------ src/vppinfra/test_hash.c | 8 -------- src/vppinfra/test_macros.c | 4 ++-- src/vppinfra/test_vec.c | 4 ---- src/vppinfra/unix-misc.c | 2 +- src/vppinfra/valloc.c | 9 ++++----- 17 files changed, 78 insertions(+), 87 deletions(-) diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index 0c6aa2a3e5e..ddaccbdb126 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -23,6 +23,10 @@ #define BIIHASH_MIN_ALLOC_LOG2_PAGES 10 #endif +#ifndef BIHASH_USE_HEAP +#define BIHASH_USE_HEAP 1 +#endif + static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes) { uword rv; diff --git a/src/vppinfra/elf.c b/src/vppinfra/elf.c index c492b3b0795..11fac45b27e 100644 --- a/src/vppinfra/elf.c +++ b/src/vppinfra/elf.c @@ -65,9 +65,9 @@ elf_get_section_by_start_address_no_check (elf_main_t * em, return p ? vec_elt_at_index (em->sections, p[0]) : 0; } -clib_error_t * -elf_get_section_by_start_address (elf_main_t * em, uword start_address, - elf_section_t ** result) +__clib_export clib_error_t * +elf_get_section_by_start_address (elf_main_t *em, uword start_address, + elf_section_t **result) { elf_section_t *s = elf_get_section_by_start_address_no_check (em, start_address); @@ -541,8 +541,8 @@ elf_segment_va_compare (void *a1, void *a2) (i64) s2->header.virtual_address); } -u8 * -format_elf_main (u8 * s, va_list * args) +__clib_export u8 * +format_elf_main (u8 *s, va_list *args) { elf_main_t *em = va_arg (*args, elf_main_t *); u32 verbose = va_arg (*args, u32); @@ -895,8 +895,8 @@ elf_parse_symbols (elf_main_t * em) } } -void -elf_set_dynamic_entries (elf_main_t * em) +__clib_export void +elf_set_dynamic_entries (elf_main_t *em) { uword i; @@ -1750,8 +1750,8 @@ layout_sections (elf_main_t * em) } } -clib_error_t * -elf_write_file (elf_main_t * em, char *file_name) +__clib_export clib_error_t * +elf_write_file (elf_main_t *em, char *file_name) { int fd; FILE *f; diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c index 423d8d5ba15..8ae752eb6af 100644 --- a/src/vppinfra/elog.c +++ b/src/vppinfra/elog.c @@ -395,8 +395,8 @@ format_elog_event (u8 * s, va_list * va) return s; } -u8 * -format_elog_track_name (u8 * s, va_list * va) +__clib_export u8 * +format_elog_track_name (u8 *s, va_list *va) { elog_main_t *em = va_arg (*va, elog_main_t *); elog_event_t *e = va_arg (*va, elog_event_t *); @@ -695,8 +695,8 @@ elog_cmp (void *a1, void *a2) /* * merge two event logs. Complicated and cranky. */ -void -elog_merge (elog_main_t * dst, u8 * dst_tag, elog_main_t * src, u8 * src_tag, +__clib_export void +elog_merge (elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak) { elog_event_t *e; @@ -1143,8 +1143,8 @@ serialize_elog_main (serialize_main_t * m, va_list * va) vec_foreach (e, em->events) serialize (m, serialize_elog_event, em, e); } -void -unserialize_elog_main (serialize_main_t * m, va_list * va) +__clib_export void +unserialize_elog_main (serialize_main_t *m, va_list *va) { elog_main_t *em = va_arg (*va, elog_main_t *); uword i; diff --git a/src/vppinfra/hash.c b/src/vppinfra/hash.c index da37b6e88a7..fc6c4518048 100644 --- a/src/vppinfra/hash.c +++ b/src/vppinfra/hash.c @@ -653,8 +653,8 @@ _hash_get_pair (void *v, uword key) return lookup (v, key, GET, 0, 0); } -hash_pair_t * -hash_next (void *v, hash_next_t * hn) +__clib_export hash_pair_t * +hash_next (void *v, hash_next_t *hn) { hash_t *h = hash_header (v); hash_pair_t *p; @@ -1015,8 +1015,8 @@ hash_bytes (void *v) return bytes; } -u8 * -format_hash (u8 * s, va_list * va) +__clib_export u8 * +format_hash (u8 *s, va_list *va) { void *v = va_arg (*va, void *); int verbose = va_arg (*va, int); @@ -1110,7 +1110,7 @@ unformat_hash_string (unformat_input_t * input, va_list * va) return unformat_hash_string_internal (input, va, /* is_vec */ 0); } -clib_error_t * +__clib_export clib_error_t * hash_validate (void *v) { hash_t *h = hash_header (v); diff --git a/src/vppinfra/heap.c b/src/vppinfra/heap.c index b81e1e1339e..bc22da1d8f6 100644 --- a/src/vppinfra/heap.c +++ b/src/vppinfra/heap.c @@ -597,7 +597,7 @@ combine_free_blocks (void *v, heap_elt_t * e0, heap_elt_t * e1) set_free_elt (v, elt_at (h, g.index), g.bin_index); } -uword +__clib_export uword heap_len (void *v, word handle) { heap_header_t *h = heap_header (v); @@ -694,8 +694,8 @@ debug_elt (u8 * s, void *v, word i, word n) return s; } -u8 * -format_heap (u8 * s, va_list * va) +__clib_export u8 * +format_heap (u8 *s, va_list *va) { void *v = va_arg (*va, void *); uword verbose = va_arg (*va, uword); @@ -722,7 +722,7 @@ format_heap (u8 * s, va_list * va) return s; } -void +__clib_export void heap_validate (void *v) { heap_header_t *h = heap_header (v); diff --git a/src/vppinfra/macros.c b/src/vppinfra/macros.c index f34b7afc173..b8a8e1744aa 100644 --- a/src/vppinfra/macros.c +++ b/src/vppinfra/macros.c @@ -197,8 +197,8 @@ clib_macro_eval (clib_macro_main_t * mm, i8 * s, i32 complain, u16 level, * eval: takes a string, returns a vector. * looks up $foobar in the variable table. */ -i8 * -clib_macro_eval_dollar (clib_macro_main_t * mm, i8 * s, i32 complain) +__clib_export i8 * +clib_macro_eval_dollar (clib_macro_main_t *mm, i8 *s, i32 complain) { i8 *s2; i8 *rv; diff --git a/src/vppinfra/maplog.c b/src/vppinfra/maplog.c index 68913365130..4e59631bdbe 100644 --- a/src/vppinfra/maplog.c +++ b/src/vppinfra/maplog.c @@ -24,8 +24,8 @@ * @param[in/out] a init args structure * @return 0 => success, <0 => failure */ -int -clib_maplog_init (clib_maplog_init_args_t * a) +__clib_export int +clib_maplog_init (clib_maplog_init_args_t *a) { int i, fd, limit; int rv = 0; @@ -171,8 +171,8 @@ fail: /* slow path: unmap a full log segment, and replace it */ -u8 * -_clib_maplog_get_entry_slowpath (clib_maplog_main_t * mm, u64 my_record_index) +__clib_export u8 * +_clib_maplog_get_entry_slowpath (clib_maplog_main_t *mm, u64 my_record_index) { int fd; u8 *rv; @@ -295,8 +295,8 @@ out: * * @param[in/out] mm mapped log object */ -void -clib_maplog_close (clib_maplog_main_t * mm) +__clib_export void +clib_maplog_close (clib_maplog_main_t *mm) { int i, limit; u64 file_size_in_bytes; @@ -331,8 +331,8 @@ clib_maplog_close (clib_maplog_main_t * mm) * @param [in] h clib_maplog_header_t pointer * @param [in] verbose self-explanatory */ -u8 * -format_maplog_header (u8 * s, va_list * args) +__clib_export u8 * +format_maplog_header (u8 *s, va_list *args) { clib_maplog_header_t *h = va_arg (*args, clib_maplog_header_t *); int verbose = va_arg (*args, int); @@ -380,7 +380,7 @@ brief: * @param [in] file_basename Same basename supplied to clib_maplog_init * @param [in] fp_arg Callback function pointer */ -int +__clib_export int clib_maplog_process (char *file_basename, void *fp_arg) { clib_maplog_header_t _h, *h = &_h; diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index f8d4ca19fd8..e2a0f71e084 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -297,8 +297,8 @@ clib_mem_destroy (void) clib_mem_vm_unmap (base); } -u8 * -format_clib_mem_usage (u8 * s, va_list * va) +__clib_export u8 * +format_clib_mem_usage (u8 *s, va_list *va) { int verbose = va_arg (*va, int); return format (s, "$$$$ heap at %llx verbose %d", clib_mem_get_heap (), diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c index e5fdc2654d5..a0b1d1f1104 100644 --- a/src/vppinfra/pmalloc.c +++ b/src/vppinfra/pmalloc.c @@ -483,8 +483,8 @@ clib_pmalloc_alloc_aligned (clib_pmalloc_main_t * pm, uword size, uword align) CLIB_PMALLOC_NUMA_LOCAL); } -void * -clib_pmalloc_alloc_from_arena (clib_pmalloc_main_t * pm, void *arena_va, +__clib_export void * +clib_pmalloc_alloc_from_arena (clib_pmalloc_main_t *pm, void *arena_va, uword size, uword align) { clib_pmalloc_arena_t *a = clib_pmalloc_get_arena (pm, arena_va); diff --git a/src/vppinfra/random.c b/src/vppinfra/random.c index f16f3960eca..56362a839b6 100644 --- a/src/vppinfra/random.c +++ b/src/vppinfra/random.c @@ -61,8 +61,8 @@ u32 standalone_random_default_seed = 1; * @return d - Pearson's X2 test statistic */ -f64 -clib_chisquare (u64 * values) +__clib_export f64 +clib_chisquare (u64 *values) { u32 i, len; f64 d, delta_d, actual_frequency, expected_frequency; diff --git a/src/vppinfra/random_isaac.c b/src/vppinfra/random_isaac.c index 6f00fc32424..ad7a272b7c1 100644 --- a/src/vppinfra/random_isaac.c +++ b/src/vppinfra/random_isaac.c @@ -68,8 +68,8 @@ *(r++) = b = ind32(mm,y>>ISAAC_LOG2_SIZE) + x; \ } -void -isaac (isaac_t * ctx, uword * results) +__clib_export void +isaac (isaac_t *ctx, uword *results) { u32 a, b, c, x, y, *m, *mm, *m2, *r, *mend; @@ -179,8 +179,8 @@ do { \ h^=a>>9; c+=h; a+=b; \ } -void -isaac_init (isaac_t * ctx, uword * seeds) +__clib_export void +isaac_init (isaac_t *ctx, uword *seeds) { word i; u32 a, b, c, d, e, f, g, h, *m, *r; @@ -251,8 +251,8 @@ isaac_init (isaac_t * ctx, uword * seeds) *(r++) = b = ind64(mm,y>>ISAAC_LOG2_SIZE) + x; \ } -void -isaac (isaac_t * ctx, uword * results) +__clib_export void +isaac (isaac_t *ctx, uword *results) { u64 a, b, c, x, y, *m, *mm, *m2, *r, *mend; @@ -364,8 +364,8 @@ do { \ h-=d; e^=g<<14; g+=h; \ } -void -isaac_init (isaac_t * ctx, uword * seeds) +__clib_export void +isaac_init (isaac_t *ctx, uword *seeds) { word i; u64 a, b, c, d, e, f, g, h, *m, *r; diff --git a/src/vppinfra/serialize.c b/src/vppinfra/serialize.c index 89a0e36dcf1..64509254b5d 100644 --- a/src/vppinfra/serialize.c +++ b/src/vppinfra/serialize.c @@ -930,9 +930,9 @@ serialize_close_vector (serialize_main_t * m) return result; } -void -serialize_multiple_1 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +serialize_multiple_1 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { u8 *d = data; u8 *p; @@ -962,9 +962,9 @@ serialize_multiple_1 (serialize_main_t * m, } } -void -serialize_multiple_2 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +serialize_multiple_2 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { void *d = data; u16 *p; @@ -999,9 +999,9 @@ serialize_multiple_2 (serialize_main_t * m, } } -void -serialize_multiple_4 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +serialize_multiple_4 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { void *d = data; u32 *p; @@ -1036,9 +1036,9 @@ serialize_multiple_4 (serialize_main_t * m, } } -void -unserialize_multiple_1 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +unserialize_multiple_1 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { u8 *d = data; u8 *p; @@ -1068,9 +1068,9 @@ unserialize_multiple_1 (serialize_main_t * m, } } -void -unserialize_multiple_2 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +unserialize_multiple_2 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { void *d = data; u16 *p; @@ -1105,9 +1105,9 @@ unserialize_multiple_2 (serialize_main_t * m, } } -void -unserialize_multiple_4 (serialize_main_t * m, - void *data, uword data_stride, uword n_data) +__clib_export void +unserialize_multiple_4 (serialize_main_t *m, void *data, uword data_stride, + uword n_data) { void *d = data; u32 *p; diff --git a/src/vppinfra/test_hash.c b/src/vppinfra/test_hash.c index 7f047d9ec78..95ced448c13 100644 --- a/src/vppinfra/test_hash.c +++ b/src/vppinfra/test_hash.c @@ -184,8 +184,6 @@ test_word_key (hash_test_t * ht) /* *INDENT-ON* */ } - clib_mem_validate (); - if ((error = hash_validate (h))) goto done; @@ -222,8 +220,6 @@ test_word_key (hash_test_t * ht) || (i + 1) % ht->n_iterations_per_validate) continue; - clib_mem_validate (); - if ((error = hash_validate (h))) goto done; @@ -317,8 +313,6 @@ test_string_key (hash_test_t * ht) || (i + 1) % ht->n_iterations_per_validate) continue; - clib_mem_validate (); - if ((error = hash_validate (h))) goto done; @@ -355,8 +349,6 @@ test_string_key (hash_test_t * ht) || (i + 1) % ht->n_iterations_per_validate) continue; - clib_mem_validate (); - if ((error = hash_validate (h))) goto done; diff --git a/src/vppinfra/test_macros.c b/src/vppinfra/test_macros.c index ad3ea37a903..9c88507d806 100644 --- a/src/vppinfra/test_macros.c +++ b/src/vppinfra/test_macros.c @@ -18,8 +18,8 @@ clib_macro_main_t clib_macro_main; -int -test_macros_main (unformat_input_t * input) +__clib_export int +test_macros_main (unformat_input_t *input) { clib_macro_main_t *mm = &clib_macro_main; diff --git a/src/vppinfra/test_vec.c b/src/vppinfra/test_vec.c index bc878eef518..c6f97fb984d 100644 --- a/src/vppinfra/test_vec.c +++ b/src/vppinfra/test_vec.c @@ -1149,10 +1149,6 @@ test_vec_main (unformat_input_t * input) dump_call_stats (g_call_stats); prob_free (); - if (verbose) - { - memory_snap (); - } return 0; usage: diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c index 7c276b0ceeb..5559a2392fe 100644 --- a/src/vppinfra/unix-misc.c +++ b/src/vppinfra/unix-misc.c @@ -171,7 +171,7 @@ unix_proc_file_contents (char *file, u8 ** result) void os_panic (void) __attribute__ ((weak)); -void +__clib_export void os_panic (void) { abort (); diff --git a/src/vppinfra/valloc.c b/src/vppinfra/valloc.c index 5e17a594428..2f9e8d218a0 100644 --- a/src/vppinfra/valloc.c +++ b/src/vppinfra/valloc.c @@ -29,9 +29,8 @@ chunks, the chunk fusion algorithm won't merge them. */ -void -clib_valloc_add_chunk (clib_valloc_main_t * vam, - clib_valloc_chunk_t * template) +__clib_export void +clib_valloc_add_chunk (clib_valloc_main_t *vam, clib_valloc_chunk_t *template) { clib_valloc_chunk_t *ch, *new_ch; u32 index; @@ -309,8 +308,8 @@ clib_valloc_free (clib_valloc_main_t * vam, uword baseva) @param verbose - int - verbosity level @return u8 vector */ -u8 * -format_valloc (u8 * s, va_list * va) +__clib_export u8 * +format_valloc (u8 *s, va_list *va) { clib_valloc_main_t *vam = va_arg (*va, clib_valloc_main_t *); int verbose = va_arg (*va, int); -- cgit 1.2.3-korg