3 #include <ccan/typesafe_cb/typesafe_cb.h>
7 * asort - sort an array of elements
8 * @base: pointer to data to sort
9 * @num: number of elements
10 * @cmp: pointer to comparison function
11 * @ctx: a context pointer for the cmp function
13 * This function does a sort on the given array. The resulting array
14 * will be in ascending sorted order by the provided comparison function.
16 * The @cmp function should exactly match the type of the @base and
17 * @ctx arguments. Otherwise it can take three const void *.
19 #define asort(base, num, cmp, ctx) \
20 _asort((base), (num), sizeof(*(base)), \
21 cast_if_type(int (*)(const void *, const void *, const void *), \
23 int (*)(const __typeof__(*(base)) *, \
24 const __typeof__(*(base)) *, \
25 __typeof__(ctx))), (ctx))
27 void _asort(void *base, size_t nmemb, size_t size,
28 int(*compar)(const void *, const void *, const void *),
31 #endif /* CCAN_ASORT_H */