From: redi Date: Wed, 22 May 2013 08:12:45 +0000 (+0000) Subject: * acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add KIND=auto to X-Git-Tag: upstream/4.9.2~5957 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2da704e65c6e89d11160f314421acaa8db26a94d;p=platform%2Fupstream%2Flinaro-gcc.git * acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add KIND=auto to enable features if target OS is known to support them. * configure.ac (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Default to 'auto'. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199183 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d46fbcf..78e016d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2013-05-22 Jonathan Wakely + + * acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add KIND=auto to + enable features if target OS is known to support them. + * configure.ac (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Default to 'auto'. + * configure: Regenerate. + 2013-05-21 Jonathan Wakely PR libstdc++/57336 diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 619fff0..efeb6d4 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -871,7 +871,8 @@ dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) dnl -dnl See docs/html/17_intro/configury.html#enable for documentation. +dnl See manual/appendix_porting.html#appendix.porting.build_hacking for +dnl documentation. dnl m4_define([GLIBCXX_ENABLE],[dnl m4_define([_g_switch],[--enable-$1])dnl @@ -1161,8 +1162,9 @@ dnl nanosleep and sched_yield in libc and libposix4 and, if needed, dnl links in the latter. dnl --enable-libstdcxx-time=rt dnl also searches (and, if needed, links) librt. Note that this is -dnl not always desirable because, in glibc, for example, in turn it -dnl triggers the linking of libpthread too, which activates locking, +dnl not always desirable because, in glibc 2.16 and earlier, for +dnl example, in turn it triggers the linking of libpthread too, +dnl which activates locking, dnl a large overhead for single-thread programs. dnl --enable-libstdcxx-time=no dnl --disable-libstdcxx-time @@ -1175,8 +1177,7 @@ dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD. dnl AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ - AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield]) - GLIBCXX_ENABLE(libstdcxx-time,$1,[[[=KIND]]], + GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]], [use KIND for check type], [permit yes|no|rt]) @@ -1188,9 +1189,59 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ ac_has_clock_monotonic=no ac_has_clock_realtime=no - AC_MSG_RESULT($enable_libstdcxx_time) + ac_has_nanosleep=no + ac_has_sched_yield=no + + if test x"$enable_libstdcxx_time" = x"auto"; then + + case "${target_os}" in + cygwin*) + ac_has_nanosleep=yes + ;; + darwin*) + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) + AC_MSG_CHECKING([for at least GNU libc 2.17]) + AC_TRY_COMPILE( + [#include ], + [ + #if ! __GLIBC_PREREQ(2, 17) + #error + #endif + ], + [glibcxx_glibc217=yes], [glibcxx_glibc217=no]) + AC_MSG_RESULT($glibcxx_glibc217) + + if test x"$glibcxx_glibc217" = x"yes"; then + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + fi + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + freebsd*|netbsd*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + openbsd*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ;; + solaris*) + GLIBCXX_LIBS="$GLIBCXX_LIBS -lrt" + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + esac - if test x"$enable_libstdcxx_time" != x"no"; then + elif test x"$enable_libstdcxx_time" != x"no"; then if test x"$enable_libstdcxx_time" = x"rt"; then AC_SEARCH_LIBS(clock_gettime, [rt posix4]) @@ -1214,19 +1265,16 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ case "$ac_cv_search_sched_yield" in -lposix4*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" - AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, - [ Defined if sched_yield is available. ]) + ac_has_sched_yield=yes ;; -lrt*) if test x"$enable_libstdcxx_time" = x"rt"; then GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" - AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, - [ Defined if sched_yield is available. ]) + ac_has_sched_yield=yes fi ;; *) - AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, - [ Defined if sched_yield is available. ]) + ac_has_sched_yield=yes ;; esac @@ -1284,6 +1332,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ [ Defined if clock_gettime has realtime clock support. ]) fi + if test x"$ac_has_sched_yield" = x"yes"; then + AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, + [ Defined if sched_yield is available. ]) + fi + if test x"$ac_has_nanosleep" = x"yes"; then AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1, [ Defined if nanosleep is available. ]) diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 4437474..29344f0 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -1559,7 +1559,7 @@ Optional Features: enable extern template [default=yes] --enable-werror turns on -Werror [default=yes] --enable-libstdcxx-time[=KIND] - use KIND for check type [default=no] + use KIND for check type [default=auto] --enable-tls Use thread-local storage [default=yes] --disable-rpath do not hardcode runtime library paths --enable-linux-futex use the Linux futex system call [default=default] @@ -19343,11 +19343,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # For clock_gettime, nanosleep and sched_yield support. -# NB: The default is [no], because otherwise it requires linking. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime, nanosleep and sched_yield" >&5 -$as_echo_n "checking for clock_gettime, nanosleep and sched_yield... " >&6; } # Check whether --enable-libstdcxx-time was given. if test "${enable_libstdcxx_time+set}" = set; then : enableval=$enable_libstdcxx_time; @@ -19357,7 +19354,7 @@ if test "${enable_libstdcxx_time+set}" = set; then : esac else - enable_libstdcxx_time=no + enable_libstdcxx_time=auto fi @@ -19375,10 +19372,74 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_has_clock_monotonic=no ac_has_clock_realtime=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_libstdcxx_time" >&5 -$as_echo "$enable_libstdcxx_time" >&6; } + ac_has_nanosleep=no + ac_has_sched_yield=no + + if test x"$enable_libstdcxx_time" = x"auto"; then + + case "${target_os}" in + cygwin*) + ac_has_nanosleep=yes + ;; + darwin*) + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for at least GNU libc 2.17" >&5 +$as_echo_n "checking for at least GNU libc 2.17... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + #if ! __GLIBC_PREREQ(2, 17) + #error + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_glibc217=yes +else + glibcxx_glibc217=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_glibc217" >&5 +$as_echo "$glibcxx_glibc217" >&6; } + + if test x"$glibcxx_glibc217" = x"yes"; then + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + fi + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + freebsd*|netbsd*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + openbsd*) + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ;; + solaris*) + GLIBCXX_LIBS="$GLIBCXX_LIBS -lrt" + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; + esac - if test x"$enable_libstdcxx_time" != x"no"; then + elif test x"$enable_libstdcxx_time" != x"no"; then if test x"$enable_libstdcxx_time" = x"rt"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 @@ -19692,22 +19753,16 @@ fi case "$ac_cv_search_sched_yield" in -lposix4*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" - -$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h - + ac_has_sched_yield=yes ;; -lrt*) if test x"$enable_libstdcxx_time" = x"rt"; then GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" - -$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h - + ac_has_sched_yield=yes fi ;; *) - -$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h - + ac_has_sched_yield=yes ;; esac @@ -19840,6 +19895,12 @@ $as_echo "#define _GLIBCXX_USE_CLOCK_REALTIME 1" >>confdefs.h fi + if test x"$ac_has_sched_yield" = x"yes"; then + +$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h + + fi + if test x"$ac_has_nanosleep" = x"yes"; then $as_echo "#define _GLIBCXX_USE_NANOSLEEP 1" >>confdefs.h diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 73d430a..f6ba176 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -198,8 +198,7 @@ GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS GLIBCXX_CHECK_GETTIMEOFDAY # For clock_gettime, nanosleep and sched_yield support. -# NB: The default is [no], because otherwise it requires linking. -GLIBCXX_ENABLE_LIBSTDCXX_TIME([no]) +GLIBCXX_ENABLE_LIBSTDCXX_TIME AC_LC_MESSAGES