Commit 88b1a025 by Jonathan Wakely Committed by Jonathan Wakely

acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add KIND=auto to enable features…

acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add KIND=auto to enable features if target OS is known to support them.

	* 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.

From-SVN: r199183
parent 50efa772
2013-05-22 Jonathan Wakely <jwakely.gcc@gmail.com>
* 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 <jwakely.gcc@gmail.com> 2013-05-21 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/57336 PR libstdc++/57336
......
...@@ -871,7 +871,8 @@ dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) ...@@ -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, permit a|b|c)
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
dnl 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 dnl
m4_define([GLIBCXX_ENABLE],[dnl m4_define([GLIBCXX_ENABLE],[dnl
m4_define([_g_switch],[--enable-$1])dnl m4_define([_g_switch],[--enable-$1])dnl
...@@ -1161,8 +1162,9 @@ dnl nanosleep and sched_yield in libc and libposix4 and, if needed, ...@@ -1161,8 +1162,9 @@ dnl nanosleep and sched_yield in libc and libposix4 and, if needed,
dnl links in the latter. dnl links in the latter.
dnl --enable-libstdcxx-time=rt dnl --enable-libstdcxx-time=rt
dnl also searches (and, if needed, links) librt. Note that this is 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 not always desirable because, in glibc 2.16 and earlier, for
dnl triggers the linking of libpthread too, which activates locking, dnl example, in turn it triggers the linking of libpthread too,
dnl which activates locking,
dnl a large overhead for single-thread programs. dnl a large overhead for single-thread programs.
dnl --enable-libstdcxx-time=no dnl --enable-libstdcxx-time=no
dnl --disable-libstdcxx-time dnl --disable-libstdcxx-time
...@@ -1175,8 +1177,7 @@ dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD. ...@@ -1175,8 +1177,7 @@ dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD.
dnl dnl
AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield]) GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]],
GLIBCXX_ENABLE(libstdcxx-time,$1,[[[=KIND]]],
[use KIND for check type], [use KIND for check type],
[permit yes|no|rt]) [permit yes|no|rt])
...@@ -1188,9 +1189,59 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ ...@@ -1188,9 +1189,59 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
ac_has_clock_monotonic=no ac_has_clock_monotonic=no
ac_has_clock_realtime=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"no"; then 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 <features.h>],
[
#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
elif test x"$enable_libstdcxx_time" != x"no"; then
if test x"$enable_libstdcxx_time" = x"rt"; then if test x"$enable_libstdcxx_time" = x"rt"; then
AC_SEARCH_LIBS(clock_gettime, [rt posix4]) AC_SEARCH_LIBS(clock_gettime, [rt posix4])
...@@ -1214,19 +1265,16 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ ...@@ -1214,19 +1265,16 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
case "$ac_cv_search_sched_yield" in case "$ac_cv_search_sched_yield" in
-lposix4*) -lposix4*)
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, ac_has_sched_yield=yes
[ Defined if sched_yield is available. ])
;; ;;
-lrt*) -lrt*)
if test x"$enable_libstdcxx_time" = x"rt"; then if test x"$enable_libstdcxx_time" = x"rt"; then
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, ac_has_sched_yield=yes
[ Defined if sched_yield is available. ])
fi fi
;; ;;
*) *)
AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, ac_has_sched_yield=yes
[ Defined if sched_yield is available. ])
;; ;;
esac esac
...@@ -1284,6 +1332,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ ...@@ -1284,6 +1332,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
[ Defined if clock_gettime has realtime clock support. ]) [ Defined if clock_gettime has realtime clock support. ])
fi 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 if test x"$ac_has_nanosleep" = x"yes"; then
AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1, AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
[ Defined if nanosleep is available. ]) [ Defined if nanosleep is available. ])
......
...@@ -1559,7 +1559,7 @@ Optional Features: ...@@ -1559,7 +1559,7 @@ Optional Features:
enable extern template [default=yes] enable extern template [default=yes]
--enable-werror turns on -Werror [default=yes] --enable-werror turns on -Werror [default=yes]
--enable-libstdcxx-time[=KIND] --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] --enable-tls Use thread-local storage [default=yes]
--disable-rpath do not hardcode runtime library paths --disable-rpath do not hardcode runtime library paths
--enable-linux-futex use the Linux futex system call [default=default] --enable-linux-futex use the Linux futex system call [default=default]
...@@ -19343,11 +19343,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ...@@ -19343,11 +19343,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# For clock_gettime, nanosleep and sched_yield support. # 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. # Check whether --enable-libstdcxx-time was given.
if test "${enable_libstdcxx_time+set}" = set; then : if test "${enable_libstdcxx_time+set}" = set; then :
enableval=$enable_libstdcxx_time; enableval=$enable_libstdcxx_time;
...@@ -19357,7 +19354,7 @@ if test "${enable_libstdcxx_time+set}" = set; then : ...@@ -19357,7 +19354,7 @@ if test "${enable_libstdcxx_time+set}" = set; then :
esac esac
else else
enable_libstdcxx_time=no enable_libstdcxx_time=auto
fi fi
...@@ -19375,10 +19372,74 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ...@@ -19375,10 +19372,74 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ac_has_clock_monotonic=no ac_has_clock_monotonic=no
ac_has_clock_realtime=no ac_has_clock_realtime=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_libstdcxx_time" >&5 ac_has_nanosleep=no
$as_echo "$enable_libstdcxx_time" >&6; } 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 <features.h>
int
main ()
{
if test x"$enable_libstdcxx_time" != x"no"; then #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
elif test x"$enable_libstdcxx_time" != x"no"; then
if test x"$enable_libstdcxx_time" = x"rt"; then if test x"$enable_libstdcxx_time" = x"rt"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
...@@ -19692,22 +19753,16 @@ fi ...@@ -19692,22 +19753,16 @@ fi
case "$ac_cv_search_sched_yield" in case "$ac_cv_search_sched_yield" in
-lposix4*) -lposix4*)
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
ac_has_sched_yield=yes
$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h
;; ;;
-lrt*) -lrt*)
if test x"$enable_libstdcxx_time" = x"rt"; then if test x"$enable_libstdcxx_time" = x"rt"; then
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
ac_has_sched_yield=yes
$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h
fi fi
;; ;;
*) *)
ac_has_sched_yield=yes
$as_echo "#define _GLIBCXX_USE_SCHED_YIELD 1" >>confdefs.h
;; ;;
esac esac
...@@ -19840,6 +19895,12 @@ $as_echo "#define _GLIBCXX_USE_CLOCK_REALTIME 1" >>confdefs.h ...@@ -19840,6 +19895,12 @@ $as_echo "#define _GLIBCXX_USE_CLOCK_REALTIME 1" >>confdefs.h
fi 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 if test x"$ac_has_nanosleep" = x"yes"; then
$as_echo "#define _GLIBCXX_USE_NANOSLEEP 1" >>confdefs.h $as_echo "#define _GLIBCXX_USE_NANOSLEEP 1" >>confdefs.h
...@@ -198,8 +198,7 @@ GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS ...@@ -198,8 +198,7 @@ GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS
GLIBCXX_CHECK_GETTIMEOFDAY GLIBCXX_CHECK_GETTIMEOFDAY
# For clock_gettime, nanosleep and sched_yield support. # For clock_gettime, nanosleep and sched_yield support.
# NB: The default is [no], because otherwise it requires linking. GLIBCXX_ENABLE_LIBSTDCXX_TIME
GLIBCXX_ENABLE_LIBSTDCXX_TIME([no])
AC_LC_MESSAGES AC_LC_MESSAGES
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment