]> git.ozlabs.org Git - ccan/blobdiff - ccan/asort/asort.c
asort: Use qsort_r if the system provides it.
[ccan] / ccan / asort / asort.c
index ce12fe660eb9146299fcf0c53937d381bdac055f..f5ed8f863f6f400cdcbb72217146a9387c52a6eb 100644 (file)
@@ -1,10 +1,12 @@
 #include <ccan/asort/asort.h>
 #include <stdlib.h>
 
+#if !HAVE_QSORT_R_PRIVATE_LAST
+
 #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)
+           int(*compar)(const void *, const void *, void *ctx),
+           void *ctx)
 {
        /* This gives bogus "warning: no previous prototype for ‘cmp’"
         * with gcc 4 with -Wmissing-prototypes.  Hence the auto crap. */
@@ -107,8 +109,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;
 
@@ -269,3 +271,5 @@ _asort (void *const pbase, size_t total_elems, size_t size,
   }
 }
 #endif /* !HAVE_NESTED_FUNCTIONS */
+
+#endif /* !HAVE_QSORT_R_PRIVATE_LAST */