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
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
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])
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])
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
[ 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. ])
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]
# 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;
esac
else
- enable_libstdcxx_time=no
+ enable_libstdcxx_time=auto
fi
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 <features.h>
+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
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
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