X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fasort%2Fasort.c;h=e7eaf2c2999b68a3f0f6ea9d3b300f59df38ffc7;hp=ce12fe660eb9146299fcf0c53937d381bdac055f;hb=18fe5ef012a96014b9e61e48616e682b4a5708a2;hpb=870fa5e89f066d3c98f8f35e2fba2e310cfefaf8;ds=sidebyside diff --git a/ccan/asort/asort.c b/ccan/asort/asort.c index ce12fe66..e7eaf2c2 100644 --- a/ccan/asort/asort.c +++ b/ccan/asort/asort.c @@ -1,21 +1,8 @@ #include #include -#if HAVE_NESTED_FUNCTIONS -void _asort(void *base, size_t nmemb, size_t size, - int(*compar)(const void *, const void *, const void *ctx), - const void *ctx) -{ - /* This gives bogus "warning: no previous prototype for ‘cmp’" - * with gcc 4 with -Wmissing-prototypes. Hence the auto crap. */ - auto int cmp(const void *a, const void *b); - int cmp(const void *a, const void *b) - { - return compar(a, b, ctx); - } - qsort(base, nmemb, size, cmp); -} -#else +#if !HAVE_QSORT_R_PRIVATE_LAST + /* Steal glibc's code. */ /* Copyright (C) 1991,1992,1996,1997,1999,2004 Free Software Foundation, Inc. @@ -107,8 +94,8 @@ typedef struct void _asort (void *const pbase, size_t total_elems, size_t size, - int(*cmp)(const void *, const void *, const void *arg), - const void *arg) + int(*cmp)(const void *, const void *, void *arg), + void *arg) { register char *base_ptr = (char *) pbase; @@ -268,4 +255,5 @@ _asort (void *const pbase, size_t total_elems, size_t size, } } } -#endif /* !HAVE_NESTED_FUNCTIONS */ + +#endif /* !HAVE_QSORT_R_PRIVATE_LAST */