string-buffer tests: Avoid test failure on native Windows.
[gnulib.git] / m4 / qsort_r.m4
blob67cd556cd163af54526cf4cf72d9e735d3b404d3
1 # qsort_r.m4
2 # serial 1
3 dnl Copyright 2014-2024 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 Reentrant sort function.
10 dnl Written by Paul Eggert.
12 AC_DEFUN([gl_FUNC_QSORT_R],
14   dnl Persuade glibc to declare qsort_r.
15   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
19   AC_CHECK_FUNCS_ONCE([qsort_r])
20   if test $ac_cv_func_qsort_r = yes; then
21     AC_CACHE_CHECK([for qsort_r signature], [gl_cv_qsort_r_signature],
22       [AC_LINK_IFELSE(
23          [AC_LANG_PROGRAM([[#include <stdlib.h>
24                             void qsort_r (void *, size_t, size_t,
25                                           int (*) (void const *, void const *,
26                                                    void *),
27                                           void *);
28                             void (*p) (void *, size_t, size_t,
29                                        int (*) (void const *, void const *,
30                                                 void *),
31                                        void *) = qsort_r;
32                           ]])],
33          [gl_cv_qsort_r_signature=GNU],
34          [AC_LINK_IFELSE(
35             [AC_LANG_PROGRAM([[#include <stdlib.h>
36                                void qsort_r (void *, size_t, size_t, void *,
37                                              int (*) (void *,
38                                                       void const *,
39                                                       void const *));
40                                void (*p) (void *, size_t, size_t, void *,
41                                           int (*) (void *, void const *,
42                                                    void const *)) = qsort_r;
43                              ]])],
44             [gl_cv_qsort_r_signature=BSD],
45             [gl_cv_qsort_r_signature=unknown])])])
46     case $gl_cv_qsort_r_signature in
47       GNU)     ;;
48       BSD)     REPLACE_QSORT_R=1 ;;
49       unknown) HAVE_QSORT_R=0 REPLACE_QSORT_R=1 ;;
50     esac
51   else
52     HAVE_QSORT_R=0
53   fi