]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sort-util: use comparison_fn_t instead of __compar_fn_t
authorLennart Poettering <lennart@poettering.net>
Mon, 11 Oct 2021 11:21:36 +0000 (13:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Oct 2021 12:09:18 +0000 (14:09 +0200)
Let's avoid using the internal type of glibc, and rather use the one
they officially export.

https://www.gnu.org/software/libc/manual/html_node/Comparison-Functions.html

src/basic/sort-util.h

index 49586a4a24073f5599aa0ba28dd67d8b6b8a1518..daa0305a60b5b77616243d01b5ff827d8adfa396 100644 (file)
@@ -20,7 +20,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
  * that only if nmemb > 0.
  */
 static inline void* bsearch_safe(const void *key, const void *base,
-                                 size_t nmemb, size_t size, __compar_fn_t compar) {
+                                 size_t nmemb, size_t size, comparison_fn_t compar) {
         if (nmemb <= 0)
                 return NULL;
 
@@ -32,14 +32,14 @@ static inline void* bsearch_safe(const void *key, const void *base,
         ({                                                              \
                 const typeof(b[0]) *_k = k;                             \
                 int (*_func_)(const typeof(b[0])*, const typeof(b[0])*) = func; \
-                bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (__compar_fn_t) _func_); \
+                bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \
         })
 
 /**
  * Normal qsort requires base to be nonnull. Here were require
  * that only if nmemb > 0.
  */
-static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn_t compar) {
+static inline void _qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
         if (nmemb <= 1)
                 return;
 
@@ -52,7 +52,7 @@ static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_f
 #define typesafe_qsort(p, n, func)                                      \
         ({                                                              \
                 int (*_func_)(const typeof(p[0])*, const typeof(p[0])*) = func; \
-                _qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \
+                _qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \
         })
 
 static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) {