mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
configure.ac: Check for qsort_r function before running the test program
When cross compiling, test programs cannot be run. In order to make it easier to cross compile for targets that do not have qsort_r(), check for the function before trying to run the test program. This avoid having to populate cache with glib_cv_have_qsort_r=no with e.g. mingw cross compiler. https://bugzilla.gnome.org/show_bug.cgi?id=651920
This commit is contained in:
parent
886a3499e1
commit
03441e406c
59
configure.ac
59
configure.ac
@ -579,40 +579,43 @@ AC_HEADER_STDC
|
|||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2)
|
AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2)
|
||||||
AC_CHECK_FUNCS(atexit on_exit timegm gmtime_r)
|
AC_CHECK_FUNCS(atexit on_exit timegm gmtime_r qsort_r)
|
||||||
|
|
||||||
# BSD has a qsort_r with wrong argument order
|
# BSD has a qsort_r with wrong argument order
|
||||||
AC_CACHE_CHECK([for qsort_r], glib_cv_have_qsort_r, [
|
if test x$ac_cv_func_qsort_r = xyes ; then
|
||||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
AC_CACHE_CHECK([if qsort_r uses glibc compatible argument order], glib_cv_have_qsort_r, [
|
||||||
#define _GNU_SOURCE
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||||
#include <stdlib.h>
|
#define _GNU_SOURCE
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmp (const void *a, const void *b, void *c)
|
cmp (const void *a, const void *b, void *c)
|
||||||
{
|
{
|
||||||
const int *ia = a;
|
const int *ia = a;
|
||||||
const int *ib = b;
|
const int *ib = b;
|
||||||
|
|
||||||
if (*ia < *ib)
|
if (*ia < *ib)
|
||||||
return -1;
|
return -1;
|
||||||
else if (*ia > *ib)
|
else if (*ia > *ib)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int arr[3] = { 1, 2, 0 };
|
int arr[3] = { 1, 2, 0 };
|
||||||
int d = 3;
|
int d = 3;
|
||||||
|
|
||||||
qsort_r (arr, 3, sizeof (int), cmp, &d);
|
qsort_r (arr, 3, sizeof (int), cmp, &d);
|
||||||
|
|
||||||
if (arr[0] == 0 && arr[1] == 1 && arr[2] == 2)
|
if (arr[0] == 0 && arr[1] == 1 && arr[2] == 2)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}]])],[glib_cv_have_qsort_r=yes],[glib_cv_have_qsort_r=no])])
|
}]])],[glib_cv_have_qsort_r=yes],[glib_cv_have_qsort_r=no])])
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$glib_cv_have_qsort_r = xyes ; then
|
if test x$glib_cv_have_qsort_r = xyes ; then
|
||||||
AC_DEFINE(HAVE_QSORT_R, 1, [Define to 1 if you have the 'qsort_r' function])
|
AC_DEFINE(HAVE_QSORT_R, 1, [Define to 1 if you have the 'qsort_r' function])
|
||||||
|
Loading…
Reference in New Issue
Block a user