aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/acinclude.m4
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2013-05-22 08:12:45 +0000
committerJonathan Wakely <jwakely.gcc@gmail.com>2013-05-22 08:12:45 +0000
commit49998138a2c62949edf80d61f9447e0a67552e8e (patch)
tree17261709058f6d97674c28b4fd3d95dce06579e9 /libstdc++-v3/acinclude.m4
parent89e532e791e1df762a03fe1fc070aed1dfc3ce9f (diff)
* 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: https://gcc.gnu.org/svn/gcc/trunk@199183 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/acinclude.m4')
-rw-r--r--libstdc++-v3/acinclude.m479
1 files changed, 66 insertions, 13 deletions
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 619fff02bf7..efeb6d49206 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 <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
- 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. ])