From a134b05d2cbc0d05a5ad7d9ebbb4ba57d424752c Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 13:55:12 +0800
Subject: [PATCH] missing_type.h: add comparison_fn_t

Make it work with musl where comparison_fn_t and is not provided.

Upstream-Status: Inappropriate [musl specific]

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
[Rebased for v244]
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
[Rebased for v242]
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
[Rebased for v250, Drop __compare_fn_t]
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>

---
 src/basic/missing_type.h            | 4 ++++
 src/basic/sort-util.h               | 1 +
 src/libsystemd/sd-journal/catalog.c | 1 +
 3 files changed, 6 insertions(+)

diff --git a/src/basic/missing_type.h b/src/basic/missing_type.h
index f6233090a9..6c0456349d 100644
--- a/src/basic/missing_type.h
+++ b/src/basic/missing_type.h
@@ -10,3 +10,7 @@
 #if !HAVE_CHAR16_T
 #define char16_t uint16_t
 #endif
+
+#ifndef __GLIBC__
+typedef int (*comparison_fn_t)(const void *, const void *);
+#endif
diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h
index 02a6784d99..0b33c83d59 100644
--- a/src/basic/sort-util.h
+++ b/src/basic/sort-util.h
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
 #include "macro.h"
+#include "missing_type.h"
 
 /* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the
  * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that
diff --git a/src/libsystemd/sd-journal/catalog.c b/src/libsystemd/sd-journal/catalog.c
index 8fc87b131a..36a6efdbd8 100644
--- a/src/libsystemd/sd-journal/catalog.c
+++ b/src/libsystemd/sd-journal/catalog.c
@@ -28,6 +28,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "tmpfile-util.h"
+#include "missing_type.h"
 
 const char * const catalog_file_dirs[] = {
         "/usr/local/lib/systemd/catalog/",
