summaryrefslogtreecommitdiff
path: root/src/basic/util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-13 12:14:47 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-13 12:16:43 +0100
commit760877e90cfdf1efd12e12ad29ce47d0ed1503dc (patch)
tree1cfb3ff933c36333079168b4aeb3275416ee1e3d /src/basic/util.h
parent0a9707187b7d7b02751b068336fa27757797d44c (diff)
downloadsystemd-760877e90cfdf1efd12e12ad29ce47d0ed1503dc.tar.gz
util: split out sorting related calls to new sort-util.[ch]
Diffstat (limited to 'src/basic/util.h')
-rw-r--r--src/basic/util.h64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/basic/util.h b/src/basic/util.h
index 3c29586749..02fc31e69e 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -63,70 +63,6 @@ int prot_from_flags(int flags) _const_;
bool in_initrd(void);
void in_initrd_force(bool value);
-void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
- __compar_d_fn_t compar, void *arg);
-
-#define typesafe_bsearch_r(k, b, n, func, userdata) \
- ({ \
- const typeof(b[0]) *_k = k; \
- int (*_func_)(const typeof(b[0])*, const typeof(b[0])*, typeof(userdata)) = func; \
- xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (__compar_d_fn_t) _func_, userdata); \
- })
-
-/**
- * Normal bsearch requires base to be nonnull. Here were require
- * 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) {
- if (nmemb <= 0)
- return NULL;
-
- assert(base);
- return bsearch(key, base, nmemb, size, compar);
-}
-
-#define typesafe_bsearch(k, b, n, func) \
- ({ \
- 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_); \
- })
-
-/**
- * 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) {
- if (nmemb <= 1)
- return;
-
- assert(base);
- qsort(base, nmemb, size, compar);
-}
-
-/* A wrapper around the above, but that adds typesafety: the element size is automatically derived from the type and so
- * is the prototype for the comparison function */
-#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_); \
- })
-
-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) {
- if (nmemb <= 1)
- return;
-
- assert(base);
- qsort_r(base, nmemb, size, compar, userdata);
-}
-
-#define typesafe_qsort_r(p, n, func, userdata) \
- ({ \
- int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \
- qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \
- })
-
int on_ac_power(void);
static inline void _reset_errno_(int *saved_errno) {