-#define asearch(key, base, num, cmp) \
- ((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \
- cast_if_type((cmp), \
- int (*)(const __typeof__(*(key)) *, \
- const __typeof__(*(base)) *), \
- int (*)(const void *, const void *)))))
+#define asearch(key, base, num, cmp, ctx) \
+ ((__typeof__(*(base))*)(_asearch((key), (base), (num), sizeof(*(base)), \
+ typesafe_cb_cast(asearch_cmp, \
+ int (*)(const __typeof__(*(key)) *, \
+ const __typeof__(*(base)) *, \
+ __typeof__(*(ctx)) *), \
+ (cmp)), (ctx))))
+