diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2019-06-03 14:02:09 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2019-06-04 17:05:08 +0100 |
commit | 6b22174ff163b828a2069f22353018ca97fc0fb4 (patch) | |
tree | 25224c057c20981bff2e95d098b189673f3e6847 /libctf/configure | |
parent | 941accce38bc70a23c62e3c9439b67bf23298124 (diff) | |
download | gdb-6b22174ff163b828a2069f22353018ca97fc0fb4.zip gdb-6b22174ff163b828a2069f22353018ca97fc0fb4.tar.gz gdb-6b22174ff163b828a2069f22353018ca97fc0fb4.tar.bz2 |
libctf: look for BSD versus GNU qsort_r signatures
We cannot just look for any declaration of qsort_r, because some
operating systems have a qsort_r that has a different prototype
but which still has a pair of pointers in the right places (the last two
args are interchanged): so use AC_LINK_IFELSE to check for both
known variants of qsort_r(), and swap their args into a consistent order
in a suitable inline function. (The code for this is taken almost
unchanged from gnulib.)
(Now we are not using AC_LIBOBJ any more, we can use a better name for
the qsort_r replacement as well.)
libctf/
* qsort_r.c: Rename to...
* ctf-qsort_r.c: ... this.
(_quicksort): Define to ctf_qsort_r.
* ctf-decls.h (qsort_r): Remove.
(ctf_qsort_r): Add.
(struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
(ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
* Makefile.am (libctf_a_LIBADD): Remove.
(libctf_a_SOURCES): New, add ctf-qsort_r.c.
* ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
* ctf-create.c (ctf_update): Likewise.
* configure.ac: Check for BSD versus GNU qsort_r signature.
* Makefile.in: Regenerate.
* config.h.in: Likewise.
* configure: Likewise.
Diffstat (limited to 'libctf/configure')
-rwxr-xr-x | libctf/configure | 161 |
1 files changed, 104 insertions, 57 deletions
diff --git a/libctf/configure b/libctf/configure index 4fb44eb..d485b1a 100755 --- a/libctf/configure +++ b/libctf/configure @@ -620,10 +620,13 @@ ac_includes_default="\ #endif" ac_header_list= +ac_func_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +NEED_CTF_QSORT_R_FALSE +NEED_CTF_QSORT_R_TRUE zlibinc zlibdir ac_libctf_warn_cflags @@ -1809,52 +1812,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func - -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -2142,6 +2099,7 @@ fi as_fn_append ac_header_list " stdlib.h" as_fn_append ac_header_list " unistd.h" as_fn_append ac_header_list " sys/param.h" +as_fn_append ac_func_list " qsort_r" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -6401,23 +6359,108 @@ _ACEOF fi done -ac_fn_c_check_decl "$LINENO" "qsort_r" "ac_cv_have_decl_qsort_r" "$ac_includes_default" -if test "x$ac_cv_have_decl_qsort_r" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 + + + + + for ac_func in $ac_func_list +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + fi +done -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_QSORT_R $ac_have_decl + + + +if test $ac_cv_func_qsort_r = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for qsort_r signature" >&5 +$as_echo_n "checking for qsort_r signature... " >&6; } +if ${ac_cv_libctf_qsort_r_signature+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#undef qsort_r + #include <stdlib.h> + void qsort_r (void *, size_t, size_t, + int (*) (void const *, void const *, + void *), + void *); + void (*p) (void *, size_t, size_t, + int (*) (void const *, void const *, + void *), + void *) = qsort_r; + +int +main () +{ + + ; + return 0; +} _ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_libctf_qsort_r_signature=GNU +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#undef qsort_r + #include <stdlib.h> + void qsort_r (void *, size_t, size_t, void *, + int (*) (void *, + void const *, + void const *)); + void (*p) (void *, size_t, size_t, void *, + int (*) (void *, void const *, + void const *)) = qsort_r; -case " $LIBOBJS " in - *" qsort_r.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS qsort_r.$ac_objext" - ;; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_libctf_qsort_r_signature=BSD +else + ac_cv_libctf_qsort_r_signature=unknown +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libctf_qsort_r_signature" >&5 +$as_echo "$ac_cv_libctf_qsort_r_signature" >&6; } +fi + +case x$ac_cv_libctf_qsort_r_signature in + xGNU) +$as_echo "#define HAVE_QSORT_R_ARG_LAST 1" >>confdefs.h +;; + xBSD) +$as_echo "#define HAVE_QSORT_R_COMPAR_LAST 1" >>confdefs.h +;; + *) ac_cv_libctf_qsort_r_signature=unknown;; esac + if test "${ac_cv_libctf_qsort_r_signature}" = unknown; then + NEED_CTF_QSORT_R_TRUE= + NEED_CTF_QSORT_R_FALSE='#' +else + NEED_CTF_QSORT_R_TRUE='#' + NEED_CTF_QSORT_R_FALSE= +fi + ac_config_files="$ac_config_files Makefile" @@ -6561,6 +6604,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${NEED_CTF_QSORT_R_TRUE}" && test -z "${NEED_CTF_QSORT_R_FALSE}"; then + as_fn_error $? "conditional \"NEED_CTF_QSORT_R\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 |