summaryrefslogtreecommitdiffstats
path: root/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'vppinfra')
-rw-r--r--vppinfra/vppinfra/elog.c12
-rw-r--r--vppinfra/vppinfra/test_timing_wheel.c22
2 files changed, 26 insertions, 8 deletions
diff --git a/vppinfra/vppinfra/elog.c b/vppinfra/vppinfra/elog.c
index b0570afc002..3c327481141 100644
--- a/vppinfra/vppinfra/elog.c
+++ b/vppinfra/vppinfra/elog.c
@@ -562,6 +562,14 @@ static void maybe_fix_string_table_offset (elog_event_t * e,
}
}
+static int elog_cmp (void * a1, void * a2)
+{
+ elog_event_t * e1 = a1;
+ elog_event_t * e2 = a2;
+
+ return e1->time - e2->time;
+}
+
void elog_merge (elog_main_t * dst, u8 * dst_tag,
elog_main_t * src, u8 * src_tag)
{
@@ -668,7 +676,7 @@ void elog_merge (elog_main_t * dst, u8 * dst_tag,
}
/* Sort events by increasing time. */
- vec_sort (dst->events, e1, e2, e1->time < e2->time ? -1 : (e1->time > e2->time ? +1 : 0));
+ vec_sort_with_function (dst->events, elog_cmp);
/* Recreate the event ring or the results won't serialize */
{
@@ -960,7 +968,7 @@ serialize_elog_main (serialize_main_t * m, va_list * va)
serialize_integer (m, vec_len (em->events), sizeof (u32));
/* SMP logs can easily have local time paradoxes... */
- vec_sort (em->events, e0, e1, e0->time - e1->time);
+ vec_sort_with_function (em->events, elog_cmp);
vec_foreach (e, em->events)
serialize (m, serialize_elog_event, em, e);
diff --git a/vppinfra/vppinfra/test_timing_wheel.c b/vppinfra/vppinfra/test_timing_wheel.c
index fa3113205c5..81483027905 100644
--- a/vppinfra/vppinfra/test_timing_wheel.c
+++ b/vppinfra/vppinfra/test_timing_wheel.c
@@ -54,6 +54,12 @@ typedef struct {
f64 time_next_status_update;
} test_timing_wheel_main_t;
+typedef struct {
+ f64 dt;
+ f64 fraction;
+ u64 count;
+} test_timing_wheel_tmp_t;
+
static void set_event (test_timing_wheel_main_t * tm, uword i)
{
timing_wheel_t * w = &tm->timing_wheel;
@@ -70,6 +76,14 @@ static void set_event (test_timing_wheel_main_t * tm, uword i)
tm->events[i] = cpu_time;
}
+static int test_timing_wheel_tmp_cmp (void * a1, void * a2)
+{
+ test_timing_wheel_tmp_t * f1 = a1;
+ test_timing_wheel_tmp_t * f2 = a2;
+
+ return f1->dt < f2->dt ? -1 : (f1->dt > f2->dt ? +1 : 0);
+}
+
clib_error_t *
test_timing_wheel_main (unformat_input_t * input)
{
@@ -294,11 +308,7 @@ test_timing_wheel_main (unformat_input_t * input)
min_error, max_error);
{
- struct tmp {
- f64 dt;
- f64 fraction;
- u64 count;
- } * fs, * f;
+ test_timing_wheel_tmp_t * fs, * f;
f64 total_fraction;
fs = 0;
@@ -313,7 +323,7 @@ test_timing_wheel_main (unformat_input_t * input)
f->count = error_hist[i];
}
- vec_sort (fs, f1, f2, f1->dt < f2->dt ? -1 : (f1->dt > f2->dt ? +1 : 0));
+ vec_sort_with_function (fs, test_timing_wheel_tmp_cmp);
total_fraction = 0;
vec_foreach (f, fs)