Config check for qsort_s/qsort_r
This commit is contained in:
parent
0b78c9ded0
commit
582bf3feb1
4 changed files with 24 additions and 1 deletions
9
configure
vendored
9
configure
vendored
|
|
@ -7006,6 +7006,15 @@ then :
|
|||
fi
|
||||
|
||||
|
||||
# Check to use freebsd:s qsort_s instead of linux qsort_r
|
||||
ac_fn_c_check_func "$LINENO" "qsort_s" "ac_cv_func_qsort_s"
|
||||
if test "x$ac_cv_func_qsort_s" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_QSORT_S 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
test "x$prefix" = xNONE && prefix=$ac_default_prefix
|
||||
|
|
|
|||
|
|
@ -458,6 +458,9 @@ fi
|
|||
# Dummy to disable native language support (nls) to remove warnings in buildroot
|
||||
AC_ARG_ENABLE(nls)
|
||||
|
||||
# Check to use freebsd:s qsort_s instead of linux qsort_r
|
||||
AC_CHECK_FUNCS(qsort_s)
|
||||
|
||||
AH_BOTTOM([#include <clixon_custom.h>])
|
||||
|
||||
test "x$prefix" = xNONE && prefix=$ac_default_prefix
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@
|
|||
/* Define to 1 if you have the <nghttp2/nghttp2.h> header file. */
|
||||
#undef HAVE_NGHTTP2_NGHTTP2_H
|
||||
|
||||
/* Define to 1 if you have the `qsort_s' function. */
|
||||
#undef HAVE_QSORT_S
|
||||
|
||||
/* Define to 1 if you have the `setns' function. */
|
||||
#undef HAVE_SETNS
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#define __USE_GNU /* for qsort_r */
|
||||
#define __USE_GNU /* for qsort_r or qsort_s */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -434,7 +434,11 @@ xml_sort_by(cxobj *x,
|
|||
char *indexvar)
|
||||
{
|
||||
xml_enumerate_children(x); /* This is to make sorting "stable", ie not change existing order */
|
||||
#ifdef HAVE_QSORT_S
|
||||
qsort_s(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp_qsort, indexvar);
|
||||
#else
|
||||
qsort_r(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp_qsort, indexvar);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +463,11 @@ xml_sort(cxobj *x)
|
|||
return 1;
|
||||
#endif
|
||||
xml_enumerate_children(x); /* This is to make sorting "stable", ie not change existing order */
|
||||
#ifdef HAVE_QSORT_S
|
||||
qsort_s(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp_qsort, NULL);
|
||||
#else
|
||||
qsort_r(xml_childvec_get(x), xml_child_nr(x), sizeof(cxobj *), xml_cmp_qsort, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue