warnings: fix compilation with old autoconf
[gnulib/ericb.git] / m4 / qsort_r.m4
blob4e642621d76c130bd58a7ba60da88b6f2e136c58
1 dnl Reentrant sort function.
3 dnl Copyright 2014-2017 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl Written by Paul Eggert.
10 AC_DEFUN([gl_FUNC_QSORT_R],
12   dnl Persuade glibc to declare qsort_r.
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17   AC_CHECK_FUNCS_ONCE([qsort_r])
18   if test $ac_cv_func_qsort_r = yes; then
19     AC_CACHE_CHECK([for qsort_r signature], [gl_cv_qsort_r_signature],
20       [AC_LINK_IFELSE(
21          [AC_LANG_PROGRAM([[#include <stdlib.h>
22                             void qsort_r (void *, size_t, size_t,
23                                           int (*) (void const *, void const *,
24                                                    void *),
25                                           void *);
26                             void (*p) (void *, size_t, size_t,
27                                        int (*) (void const *, void const *,
28                                                 void *),
29                                        void *) = qsort_r;
30                           ]])],
31          [gl_cv_qsort_r_signature=GNU],
32          [AC_LINK_IFELSE(
33             [AC_LANG_PROGRAM([[#include <stdlib.h>
34                                void qsort_r (void *, size_t, size_t, void *,
35                                              int (*) (void *,
36                                                       void const *,
37                                                       void const *));
38                                void (*p) (void *, size_t, size_t, void *,
39                                           int (*) (void *, void const *,
40                                                    void const *)) = qsort_r;
41                              ]])],
42             [gl_cv_qsort_r_signature=BSD],
43             [gl_cv_qsort_r_signature=unknown])])])
44     case $gl_cv_qsort_r_signature in
45       GNU)     ;;
46       BSD)     REPLACE_QSORT_R=1 ;;
47       unknown) HAVE_QSORT_R=0 REPLACE_QSORT_R=1 ;;
48     esac
49   else
50     HAVE_QSORT_R=0
51   fi