From 36d7f1518f347e2cdc21dcfd380e8316df139496 Mon Sep 17 00:00:00 2001 From: Johannes Pfau Date: Mon, 18 Feb 2019 23:29:39 +0000 Subject: [PATCH] libphobos: Detect if qsort_r is available Merges upstream druntime bbfb58e8. libphobos/ChangeLog: 2019-02-19 Johannes Pfau PR d/88127 * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_CLIB): Add new macro. * configure.ac: Use DRUNTIME_LIBRARIES_CLIB. * configure: Regenerate * Makefile.in: Regenerate * libdruntime/gcc/config.d.in: Add Have_Qsort_R. * libdruntime/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. From-SVN: r268999 --- libphobos/ChangeLog | 12 ++++++++++++ libphobos/Makefile.in | 1 + libphobos/configure | 26 ++++++++++++++++++++++++-- libphobos/configure.ac | 1 + libphobos/libdruntime/MERGE | 2 +- libphobos/libdruntime/Makefile.in | 1 + libphobos/libdruntime/gcc/config.d.in | 3 +++ libphobos/libdruntime/rt/qsort.d | 18 ++++++++++++++++++ libphobos/m4/druntime/libraries.m4 | 12 ++++++++++++ libphobos/src/Makefile.in | 1 + libphobos/testsuite/Makefile.in | 1 + 11 files changed, 75 insertions(+), 3 deletions(-) diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index c2bfe5034b3..5e24d948513 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,15 @@ +2019-02-19 Johannes Pfau + + PR d/88127 + * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_CLIB): Add new macro. + * configure.ac: Use DRUNTIME_LIBRARIES_CLIB. + * configure: Regenerate + * Makefile.in: Regenerate + * libdruntime/gcc/config.d.in: Add Have_Qsort_R. + * libdruntime/Makefile.in: Regenerate. + * src/Makefile.in: Regenerate. + * testsuite/Makefile.in: Regenerate. + 2019-02-18 Rainer Orth * testsuite/lib/libphobos-dg.exp: Tabify. diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in index 87eaf28aba7..e7c156aa5eb 100644 --- a/libphobos/Makefile.in +++ b/libphobos/Makefile.in @@ -213,6 +213,7 @@ DCFG_ARM_EABI_UNWINDER = @DCFG_ARM_EABI_UNWINDER@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ +DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/configure b/libphobos/configure index 4741c287a44..7bb034b841d 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -650,6 +650,7 @@ LIBATOMIC DCFG_HAVE_LIBATOMIC DCFG_HAVE_64BIT_ATOMICS DCFG_HAVE_ATOMIC_BUILTINS +DCFG_HAVE_QSORT_R DRUNTIME_OS_MINFO_BRACKETING_FALSE DRUNTIME_OS_MINFO_BRACKETING_TRUE DCFG_MINFO_BRACKETING @@ -11498,7 +11499,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11501 "configure" +#line 11502 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11604,7 +11605,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11607 "configure" +#line 11608 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14137,6 +14138,27 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + DCFG_HAVE_QSORT_R=false + ac_fn_c_check_func "$LINENO" "qsort_r" "ac_cv_func_qsort_r" +if test "x$ac_cv_func_qsort_r" = xyes; then : + DCFG_HAVE_QSORT_R=true +fi + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + gdc_save_DFLAGS=$GDCFLAGS diff --git a/libphobos/configure.ac b/libphobos/configure.ac index 3701a241b8e..b436dc034ae 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -126,6 +126,7 @@ DRUNTIME_OS_SOURCES DRUNTIME_OS_THREAD_MODEL DRUNTIME_OS_ARM_EABI_UNWINDER DRUNTIME_OS_MINFO_BRACKETING +DRUNTIME_LIBRARIES_CLIB WITH_LOCAL_DRUNTIME([ AC_LANG_PUSH([D]) diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 09ce8d03566..1a09ebf5410 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -fb4bda91b0b43b5a18e1c143943c101ad4e17667 +bbfb58e8a921cabdd0002a40bf63fe35ed7c77e8 The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 02331af95bd..8f4ff8b1831 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -1096,6 +1096,7 @@ DCFG_ARM_EABI_UNWINDER = @DCFG_ARM_EABI_UNWINDER@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ +DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/libdruntime/gcc/config.d.in b/libphobos/libdruntime/gcc/config.d.in index 1b5d5d9b692..4652bf09531 100644 --- a/libphobos/libdruntime/gcc/config.d.in +++ b/libphobos/libdruntime/gcc/config.d.in @@ -43,3 +43,6 @@ enum GNU_Have_64Bit_Atomics = @DCFG_HAVE_64BIT_ATOMICS@; // Do we have libatomic available enum GNU_Have_LibAtomic = @DCFG_HAVE_LIBATOMIC@; + +// Do we have qsort_r function +enum Have_Qsort_R = @DCFG_HAVE_QSORT_R@; diff --git a/libphobos/libdruntime/rt/qsort.d b/libphobos/libdruntime/rt/qsort.d index 6c3e71c35c7..af0c1eb704a 100644 --- a/libphobos/libdruntime/rt/qsort.d +++ b/libphobos/libdruntime/rt/qsort.d @@ -27,7 +27,25 @@ else version (TVOS) else version (WatchOS) version = Darwin; +// qsort_r was added in glibc in 2.8. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88127 version (CRuntime_Glibc) +{ + version (GNU) + { + import gcc.config : Have_Qsort_R; + enum Glibc_Qsort_R = Have_Qsort_R; + } + else + { + enum Glibc_Qsort_R = true; + } +} +else +{ + enum Glibc_Qsort_R = false; +} + +static if (Glibc_Qsort_R) { alias extern (C) int function(scope const void *, scope const void *, scope void *) Cmp; extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, Cmp cmp, scope void *arg); diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 index 17f93468b87..35a791d137a 100644 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -161,3 +161,15 @@ AC_DEFUN([DRUNTIME_LIBRARIES_BACKTRACE], AC_SUBST(BACKTRACE_SUPPORTS_THREADS) AC_LANG_POP([C]) ]) + +# DRUNTIME_LIBRARIES_CLIB +# ----------------------- +# Perform various feature checks on the C library. +AC_DEFUN([DRUNTIME_LIBRARIES_CLIB], +[ + AC_LANG_PUSH([C]) + DCFG_HAVE_QSORT_R=false + AC_CHECK_FUNC(qsort_r, [DCFG_HAVE_QSORT_R=true]) + AC_SUBST(DCFG_HAVE_QSORT_R) + AC_LANG_POP([C]) +]) diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index 3dffa6f6093..b6037ac0ff0 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -504,6 +504,7 @@ DCFG_ARM_EABI_UNWINDER = @DCFG_ARM_EABI_UNWINDER@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ +DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ diff --git a/libphobos/testsuite/Makefile.in b/libphobos/testsuite/Makefile.in index 205b6731d3d..78107d22680 100644 --- a/libphobos/testsuite/Makefile.in +++ b/libphobos/testsuite/Makefile.in @@ -159,6 +159,7 @@ DCFG_ARM_EABI_UNWINDER = @DCFG_ARM_EABI_UNWINDER@ DCFG_HAVE_64BIT_ATOMICS = @DCFG_HAVE_64BIT_ATOMICS@ DCFG_HAVE_ATOMIC_BUILTINS = @DCFG_HAVE_ATOMIC_BUILTINS@ DCFG_HAVE_LIBATOMIC = @DCFG_HAVE_LIBATOMIC@ +DCFG_HAVE_QSORT_R = @DCFG_HAVE_QSORT_R@ DCFG_MINFO_BRACKETING = @DCFG_MINFO_BRACKETING@ DCFG_THREAD_MODEL = @DCFG_THREAD_MODEL@ DEFS = @DEFS@ -- 2.30.2