summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/acinclude.m4
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-15 14:01:04 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-01-15 14:01:04 +0000
commit99e43922811ec0cde4827bb388ff341034a1685e (patch)
treea3d0a02869ac2d4272d8edb67dd33bc6a37b3633 /libstdc++-v3/acinclude.m4
parent8408ca006c318141a4bde09a937d8ce7180d8bad (diff)
downloadppe42-gcc-99e43922811ec0cde4827bb388ff341034a1685e.tar.gz
ppe42-gcc-99e43922811ec0cde4827bb388ff341034a1685e.zip
2009-01-15 Chris Fairles <cfairles@gcc.gnu.org>
Paolo Carlini <paolo.carlini@oracle.com> * acinclude.m4 ([GLIBCXX_ENABLE_CLOCK_GETTIME], [GLIBCXX_CHECK_NANOSLEEP]): Remove. ([GLIBCXX_ENABLE_LIBSTDCXX_TIME]): Add. * configure.ac: Adjust. * doc/xml/manual/configure.xml: Update. * testsuite/lib/libstdc++.exp (check_v3_target_sched_yield): Add. * testsuite/lib/dg-options.exp (dg-require-sched-yield): Add. * testsuite/30_threads/thread/this_thread/2.cc: Use the latter. * configure: Regenerate. * config.h.in: Likewise. * src/thread.cc (thread::thread(), thread::~thread, thread::get_id, thread::joinable, thread::swap, this_thread::get_id, this_thread::yield): Define inline... * include/std/thread: ... here. * config/abi/pre/gnu.ver: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143397 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/acinclude.m4')
-rw-r--r--libstdc++-v3/acinclude.m4114
1 files changed, 64 insertions, 50 deletions
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 71cc7e9bc80..4dd2b2b109b 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1074,26 +1074,28 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
dnl
-dnl Check for clock_gettime clocks, used in the implementation of 20.8.5
-dnl [time.clock] in the current C++0x working draft.
-dnl
-dnl --enable-clock-gettime
-dnl --enable-clock-gettime=yes
-dnl checks for the availability of monotonic and realtime clocks
-dnl in libc and libposix4 and in case links the latter
-dnl --enable-clock-gettime=rt
+dnl Check for clock_gettime, nanosleep and sched_yield, used in the
+dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
+dnl in the current C++0x working draft.
+dnl
+dnl --enable-libstdcxx-time
+dnl --enable-libstdcxx-time=yes
+dnl checks for the availability of monotonic and realtime clocks,
+dnl nanosleep and sched_yield in libc and libposix4 and, in case, links
+dnl the latter
+dnl --enable-libstdcxx-time=rt
dnl also searches (and, in case, 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 a large overhead for single-thread programs.
-dnl --enable-clock-gettime=no
-dnl --disable-clock-gettime
+dnl --enable-libstdcxx-time=no
+dnl --disable-libstdcxx-time
dnl disables the checks completely
dnl
-AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
+AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
- AC_MSG_CHECKING([for clock_gettime clocks])
- GLIBCXX_ENABLE(clock-gettime,$1,[=KIND],
+ AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
+ GLIBCXX_ENABLE(libstdcxx-time,$1,[=KIND],
[use KIND for check type],
[permit yes|no|rt])
@@ -1103,19 +1105,47 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
CXXFLAGS="$CXXFLAGS -fno-exceptions"
ac_save_LIBS="$LIBS"
- ac_has_clock_monotonic=no;
+ ac_has_clock_monotonic=no;
ac_has_clock_realtime=no;
- if test x"$enable_clock_gettime" != x"no"; then
+ if test x"$enable_libstdcxx_time" != x"no"; then
- if test x"$enable_clock_gettime" = x"rt"; then
+ if test x"$enable_libstdcxx_time" = x"rt"; then
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
+ AC_SEARCH_LIBS(nanosleep, [rt posix4])
else
AC_SEARCH_LIBS(clock_gettime, [posix4])
+ AC_SEARCH_LIBS(nanosleep, [posix4])
fi
case "$ac_cv_search_clock_gettime" in
-l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
+ ;;
+ esac
+ case "$ac_cv_search_nanosleep" in
+ -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
+ ;;
+ esac
+
+ AC_SEARCH_LIBS(sched_yield, [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. ])
+ ;;
+ -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. ])
+ fi
+ ;;
+ *)
+ AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
+ [ Defined if sched_yield is available. ])
+ ;;
esac
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
@@ -1146,8 +1176,20 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
AC_MSG_RESULT($ac_has_clock_realtime)
- fi
+ AC_MSG_CHECKING([for nanosleep])
+ AC_TRY_LINK(
+ [#include <unistd.h>
+ #include <time.h>
+ ],
+ [#if _POSIX_TIMERS > 0
+ timespec tp;
+ #endif
+ nanosleep(&tp, 0);
+ ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
+
+ AC_MSG_RESULT($ac_has_nanosleep)
+ fi
fi
if test x"$ac_has_clock_monotonic" = x"yes"; then
@@ -1160,6 +1202,11 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
[ Defined if clock_gettime has realtime clock support. ])
fi
+ if test x"$ac_has_nanosleep" = x"yes"; then
+ AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
+ [ Defined if nanosleep is available. ])
+ fi
+
AC_SUBST(GLIBCXX_LIBS)
CXXFLAGS="$ac_save_CXXFLAGS"
@@ -1201,39 +1248,6 @@ AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
])
dnl
-dnl Check for nanosleep, used in the implementation of 30.2.2
-dnl [thread.thread.this] in the current C++0x working draft.
-dnl
-AC_DEFUN([GLIBCXX_CHECK_NANOSLEEP], [
-
- AC_MSG_CHECKING([for nanosleep])
-
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -fno-exceptions"
-
- ac_has_nanosleep=no;
- AC_CHECK_HEADERS(time.h, ac_has_time_h=yes, ac_has_time_h=no)
- if test x"$ac_has_time_h" = x"yes"; then
- AC_MSG_CHECKING([for nanosleep])
- AC_TRY_COMPILE([#include <time.h>],
- [timespec ts; nanosleep(&ts, 0);],
- [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
-
- AC_MSG_RESULT($ac_has_nanosleep)
- fi
-
- if test x"$ac_has_nanosleep" = x"yes"; then
- AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
- [ Defined if nanosleep is available. ])
- fi
-
- CXXFLAGS="$ac_save_CXXFLAGS"
- AC_LANG_RESTORE
-])
-
-dnl
dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
dnl facilities in Chapter 8, "C compatibility".
dnl
OpenPOWER on IntegriCloud