+static int
+log_type_compare(const void *a, const void *b)
+{
+ const struct rte_log_dynamic_type *type_a = a;
+ const struct rte_log_dynamic_type *type_b = b;
+
+ if (type_a->name == NULL && type_b->name == NULL)
+ return 0;
+ if (type_a->name == NULL)
+ return -1;
+ if (type_b->name == NULL)
+ return 1;
+ return strcmp(type_a->name, type_b->name);
+}
+
+/* Dump name of each logtype, one per line. */
+void
+rte_log_list_types(FILE *out, const char *prefix)
+{
+ struct rte_log_dynamic_type *sorted_types;
+ const size_t type_size = sizeof(rte_logs.dynamic_types[0]);
+ const size_t type_count = rte_logs.dynamic_types_len;
+ const size_t total_size = type_size * type_count;
+ size_t type;
+
+ sorted_types = malloc(total_size);
+ if (sorted_types == NULL) {
+ /* no sorting - unlikely */
+ sorted_types = rte_logs.dynamic_types;
+ } else {
+ memcpy(sorted_types, rte_logs.dynamic_types, total_size);
+ qsort(sorted_types, type_count, type_size, log_type_compare);
+ }
+
+ for (type = 0; type < type_count; ++type) {
+ if (sorted_types[type].name == NULL)
+ continue;
+ fprintf(out, "%s%s\n", prefix, sorted_types[type].name);
+ }
+
+ if (sorted_types != rte_logs.dynamic_types)
+ free(sorted_types);
+}
+