Commit 959d14e1 by Chris Fairles Committed by Paolo Carlini

acinclude.m4 ([GLIBCXX_ENABLE_CLOCK_GETTIME], [...]): Remove.

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.

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>

From-SVN: r143397
parent 52535a64
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.
2009-01-13 Uros Bizjak <ubizjak@gmail.com> 2009-01-13 Uros Bizjak <ubizjak@gmail.com>
* testsuite/ext/pb_ds/regression/hash_data_map_rand.cc: * testsuite/ext/pb_ds/regression/hash_data_map_rand.cc:
......
...@@ -1074,26 +1074,28 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [ ...@@ -1074,26 +1074,28 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
dnl dnl
dnl Check for clock_gettime clocks, used in the implementation of 20.8.5 dnl Check for clock_gettime, nanosleep and sched_yield, used in the
dnl [time.clock] in the current C++0x working draft. dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
dnl dnl in the current C++0x working draft.
dnl --enable-clock-gettime dnl
dnl --enable-clock-gettime=yes dnl --enable-libstdcxx-time
dnl checks for the availability of monotonic and realtime clocks dnl --enable-libstdcxx-time=yes
dnl in libc and libposix4 and in case links the latter dnl checks for the availability of monotonic and realtime clocks,
dnl --enable-clock-gettime=rt 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 also searches (and, in case, 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, for example, in turn it
dnl triggers the linking of libpthread too, which activates locking, dnl triggers the linking of libpthread too, which activates locking,
dnl a large overhead for single-thread programs. dnl a large overhead for single-thread programs.
dnl --enable-clock-gettime=no dnl --enable-libstdcxx-time=no
dnl --disable-clock-gettime dnl --disable-libstdcxx-time
dnl disables the checks completely dnl disables the checks completely
dnl dnl
AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
AC_MSG_CHECKING([for clock_gettime clocks]) AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
GLIBCXX_ENABLE(clock-gettime,$1,[=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])
...@@ -1103,19 +1105,47 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [ ...@@ -1103,19 +1105,47 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
CXXFLAGS="$CXXFLAGS -fno-exceptions" CXXFLAGS="$CXXFLAGS -fno-exceptions"
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
ac_has_clock_monotonic=no; ac_has_clock_monotonic=no;
ac_has_clock_realtime=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(clock_gettime, [rt posix4])
AC_SEARCH_LIBS(nanosleep, [rt posix4])
else else
AC_SEARCH_LIBS(clock_gettime, [posix4]) AC_SEARCH_LIBS(clock_gettime, [posix4])
AC_SEARCH_LIBS(nanosleep, [posix4])
fi fi
case "$ac_cv_search_clock_gettime" in case "$ac_cv_search_clock_gettime" in
-l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime -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 esac
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no) 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], [ ...@@ -1146,8 +1176,20 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no]) ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
AC_MSG_RESULT($ac_has_clock_realtime) 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 fi
if test x"$ac_has_clock_monotonic" = x"yes"; then if test x"$ac_has_clock_monotonic" = x"yes"; then
...@@ -1160,6 +1202,11 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [ ...@@ -1160,6 +1202,11 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCK_GETTIME], [
[ Defined if clock_gettime has realtime clock support. ]) [ Defined if clock_gettime has realtime clock support. ])
fi 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) AC_SUBST(GLIBCXX_LIBS)
CXXFLAGS="$ac_save_CXXFLAGS" CXXFLAGS="$ac_save_CXXFLAGS"
...@@ -1201,39 +1248,6 @@ AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [ ...@@ -1201,39 +1248,6 @@ AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
]) ])
dnl 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 Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
dnl facilities in Chapter 8, "C compatibility". dnl facilities in Chapter 8, "C compatibility".
dnl dnl
......
...@@ -415,9 +415,6 @@ ...@@ -415,9 +415,6 @@
/* Define to 1 if you have the <tgmath.h> header file. */ /* Define to 1 if you have the <tgmath.h> header file. */
#undef HAVE_TGMATH_H #undef HAVE_TGMATH_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if the target supports thread-local storage. */ /* Define to 1 if the target supports thread-local storage. */
#undef HAVE_TLS #undef HAVE_TLS
...@@ -815,6 +812,9 @@ ...@@ -815,6 +812,9 @@
of TR1 (Chapter 5.1). */ of TR1 (Chapter 5.1). */
#undef _GLIBCXX_USE_RANDOM_TR1 #undef _GLIBCXX_USE_RANDOM_TR1
/* Defined if sched_yield is available. */
#undef _GLIBCXX_USE_SCHED_YIELD
/* Define if code specialized for wchar_t should be used. */ /* Define if code specialized for wchar_t should be used. */
#undef _GLIBCXX_USE_WCHAR_T #undef _GLIBCXX_USE_WCHAR_T
......
...@@ -901,21 +901,12 @@ GLIBCXX_3.4.11 { ...@@ -901,21 +901,12 @@ GLIBCXX_3.4.11 {
_ZNSt22condition_variable_anyD2Ev; _ZNSt22condition_variable_anyD2Ev;
# thread # thread
_ZNKSt6thread6get_idEv;
_ZNKSt6thread8joinableEv;
_ZNSt10shared_ptrISt18__thread_data_baseED1Ev; _ZNSt10shared_ptrISt18__thread_data_baseED1Ev;
_ZNSt11this_thread5yieldEv;
_ZNSt11this_thread6get_idEv;
_ZNSt12bad_weak_ptrD0Ev; _ZNSt12bad_weak_ptrD0Ev;
_ZNSt12bad_weak_ptrD1Ev; _ZNSt12bad_weak_ptrD1Ev;
_ZNSt6thread14__start_threadEv; _ZNSt6thread14__start_threadEv;
_ZNSt6thread4joinEv; _ZNSt6thread4joinEv;
_ZNSt6thread4swapEOS_;
_ZNSt6thread6detachEv; _ZNSt6thread6detachEv;
_ZNSt6threadC1Ev;
_ZNSt6threadC2Ev;
_ZNSt6threadD1Ev;
_ZNSt6threadD2Ev;
# system_error # system_error
_ZSt15system_category; _ZSt15system_category;
......
...@@ -145,16 +145,13 @@ GLIBCXX_CHECK_STDIO_MACROS ...@@ -145,16 +145,13 @@ GLIBCXX_CHECK_STDIO_MACROS
# For gettimeofday support. # For gettimeofday support.
GLIBCXX_CHECK_GETTIMEOFDAY GLIBCXX_CHECK_GETTIMEOFDAY
# For clock_gettime support. # For clock_gettime, nanosleep and sched_yield support.
# NB: The default is [no], because otherwise it requires linking. # NB: The default is [no], because otherwise it requires linking.
GLIBCXX_ENABLE_CLOCK_GETTIME([no]) GLIBCXX_ENABLE_LIBSTDCXX_TIME([no])
# For gthread support # For gthread support
GLIBCXX_CHECK_GTHREADS GLIBCXX_CHECK_GTHREADS
# For nanosleep support
GLIBCXX_CHECK_NANOSLEEP
AC_LC_MESSAGES AC_LC_MESSAGES
# Check for available headers. # Check for available headers.
......
...@@ -327,17 +327,19 @@ ...@@ -327,17 +327,19 @@
</para> </para>
</listitem></varlistentry> </listitem></varlistentry>
<varlistentry><term><code>--enable-clock-gettime=OPTION</code></term> <varlistentry><term><code>--enable-libstdcxx-time=OPTION</code></term>
<listitem><para>Enables link-type checks for the availability of the <listitem><para>Enables link-type checks for the availability of the
clock_gettime clocks, used in [time.clock] of the current C++0x draft. clock_gettime clocks, used in the implementation of [time.clock],
The choice OPTION=yes checks for the availability of the monotonic and and of the nanosleep and sched_yield functions, used in the
realtime clocks in libc and libposix4. In case of need the latter is implementation of [thread.thread.this] of the current C++0x draft.
also linked to libstdc++ as part of the build process. OPTION=rt The choice OPTION=yes checks for the availability of the facilities
also searches (and, in case, links) librt. Note that the latter in libc and libposix4. In case of need the latter is also linked
is not always desirable because, in glibc, for example, in turn it to libstdc++ as part of the build process. OPTION=rt also searches
triggers the linking of libpthread too, which activates locking, (and, in case, links) librt. Note that the latter is not always
a large overhead for single-thread programs. OPTION=no skips the desirable because, in glibc, for example, in turn it triggers the
tests completely. The default is OPTION=no. linking of libpthread too, which activates locking, a large overhead
for single-thread programs. OPTION=no skips the tests completely.
The default is OPTION=no.
</para> </para>
</listitem></varlistentry> </listitem></varlistentry>
......
// <thread> -*- C++ -*- // <thread> -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -96,7 +96,7 @@ namespace std ...@@ -96,7 +96,7 @@ namespace std
typedef __gthread_t native_handle_type; typedef __gthread_t native_handle_type;
// cons // cons
thread(); thread() = default;
template<typename _Callable> template<typename _Callable>
explicit thread(_Callable __f) explicit thread(_Callable __f)
...@@ -108,7 +108,8 @@ namespace std ...@@ -108,7 +108,8 @@ namespace std
: _M_thread_data(__make_thread_data(std::bind(__f, __args...))) : _M_thread_data(__make_thread_data(std::bind(__f, __args...)))
{ __start_thread(); } { __start_thread(); }
~thread(); ~thread()
{ detach(); }
thread(const thread&) = delete; thread(const thread&) = delete;
thread(thread&&); thread(thread&&);
...@@ -117,7 +118,8 @@ namespace std ...@@ -117,7 +118,8 @@ namespace std
// members // members
void void
swap(thread&& __t); swap(thread&& __t)
{ std::swap(_M_thread_data, __t._M_thread_data); }
bool bool
joinable() const; joinable() const;
...@@ -128,7 +130,7 @@ namespace std ...@@ -128,7 +130,7 @@ namespace std
void void
detach(); detach();
id thread::id
get_id() const; get_id() const;
native_handle_type native_handle_type
...@@ -181,18 +183,20 @@ namespace std ...@@ -181,18 +183,20 @@ namespace std
thread::id thread::id
get_id(); get_id();
void #ifdef _GLIBCXX_USE_SCHED_YIELD
yield(); inline void
yield()
{ __gthread_yield(); }
#endif
#ifdef _GLIBCXX_USE_NANOSLEEP
template<typename _Clock, typename _Duration> template<typename _Clock, typename _Duration>
void inline void
sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) sleep_until(const chrono::time_point<_Clock, _Duration>& __atime)
{ { sleep_for(__atime - _Clock::now()); }
sleep_for(__atime - _Clock::now());
}
template<typename _Rep, typename _Period> template<typename _Rep, typename _Period>
void inline void
sleep_for(const chrono::duration<_Rep, _Period>& __rtime) sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
{ {
chrono::seconds __s = chrono::seconds __s =
...@@ -207,10 +211,9 @@ namespace std ...@@ -207,10 +211,9 @@ namespace std
static_cast<long>(__ns.count()) static_cast<long>(__ns.count())
}; };
#ifdef _GLIBCXX_USE_NANOSLEEP
::nanosleep(&__ts, 0); ::nanosleep(&__ts, 0);
#endif
} }
#endif
} }
/// thread::id /// thread::id
...@@ -226,10 +229,8 @@ namespace std ...@@ -226,10 +229,8 @@ namespace std
friend bool friend bool
operator==(thread::id __x, thread::id __y) operator==(thread::id __x, thread::id __y)
{ { return static_cast<bool>(__gthread_equal(__x._M_thread_id,
return __y._M_thread_id)); }
static_cast<bool>(__gthread_equal(__x._M_thread_id, __y._M_thread_id));
}
friend bool friend bool
operator<(thread::id __x, thread::id __y) operator<(thread::id __x, thread::id __y)
...@@ -271,6 +272,26 @@ namespace std ...@@ -271,6 +272,26 @@ namespace std
else else
return __out << __id._M_thread_id; return __out << __id._M_thread_id;
} }
inline bool
thread::joinable() const
{ return get_id() != thread::id(); }
inline thread::id
thread::get_id() const
{
if(_M_thread_data)
return thread::id(_M_thread_data->_M_thread_handle);
else
return thread::id();
}
namespace this_thread
{
inline thread::id
get_id()
{ return thread::id(__gthread_self()); }
}
} }
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
......
// thread -*- C++ -*- // thread -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -58,27 +58,6 @@ namespace std ...@@ -58,27 +58,6 @@ namespace std
} }
} }
thread::thread()
{ }
thread::~thread()
{
detach();
}
thread::id
thread::get_id() const
{
if(_M_thread_data)
return thread::id(_M_thread_data->_M_thread_handle);
else
return thread::id();
}
bool
thread::joinable() const
{ return get_id() != id(); }
void void
thread::join() thread::join()
{ {
...@@ -108,12 +87,6 @@ namespace std ...@@ -108,12 +87,6 @@ namespace std
} }
} }
void
thread::swap(thread&& __t)
{
std::swap(_M_thread_data, __t._M_thread_data);
}
void void
thread::__start_thread() thread::__start_thread()
{ {
...@@ -123,17 +96,6 @@ namespace std ...@@ -123,17 +96,6 @@ namespace std
if(__e) if(__e)
__throw_system_error(__e); __throw_system_error(__e);
} }
namespace this_thread
{
thread::id
get_id()
{ return thread::id(__gthread_self()); }
void
yield()
{ __gthread_yield(); }
}
} }
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } // { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-require-gthreads "" } // { dg-require-gthreads "" }
// { dg-require-sched-yield "" }
// Copyright (C) 2008 Free Software Foundation, Inc. // Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
......
# Handlers for additional dg-xxx keywords in tests. # Handlers for additional dg-xxx keywords in tests.
# Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -125,6 +126,15 @@ proc dg-require-nanosleep { args } { ...@@ -125,6 +126,15 @@ proc dg-require-nanosleep { args } {
return return
} }
proc dg-require-sched-yield { args } {
if { ![ check_v3_target_sched_yield ] } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
return
}
return
}
proc dg-require-string-conversions { args } { proc dg-require-string-conversions { args } {
if { ![ check_v3_target_string_conversions ] } { if { ![ check_v3_target_string_conversions ] } {
upvar dg-do-what dg-do-what upvar dg-do-what dg-do-what
......
# libstdc++ "tool init file" for DejaGNU # libstdc++ "tool init file" for DejaGNU
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -1261,6 +1261,64 @@ proc check_v3_target_nanosleep { } { ...@@ -1261,6 +1261,64 @@ proc check_v3_target_nanosleep { } {
return $et_nanosleep return $et_nanosleep
} }
proc check_v3_target_sched_yield { } {
global cxxflags
global DEFAULT_CXXFLAGS
global et_sched_yield
global tool
if { ![info exists et_sched_yield_target_name] } {
set et_sched_yield_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_sched_yield_target_name } {
verbose "check_v3_target_sched_yield: `$et_sched_yield_target_name'" 2
set et_sched_yield_target_name $current_target
if [info exists et_sched_yield] {
verbose "check_v3_target_sched_yield: removing cached result" 2
unset et_sched_yield
}
}
if [info exists et_sched_yield] {
verbose "check_v3_target_sched_yield: using cached result" 2
} else {
set et_sched_yield 0
# Set up and compile a C++0x test program that depends
# on the sched_yield facility to be available.
set src sched_yield[pid].cc
set exe sched_yield[pid].exe
set f [open $src "w"]
puts $f "#include <bits/c++config.h>"
puts $f "int main()"
puts $f "#ifdef _GLIBCXX_USE_SCHED_YIELD"
puts $f "{ return 0; }"
puts $f "#endif"
close $f
set cxxflags_saved $cxxflags
set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror"
set lines [v3_target_compile $src $exe executable ""]
set cxxflags $cxxflags_saved
file delete $src
if [string match "" $lines] {
# No error message, compilation succeeded.
set et_sched_yield 1
} else {
verbose "check_v3_target_sched_yield: compilation failed" 2
}
}
verbose "check_v3_target_sched_yield: $et_sched_yield" 2
return $et_sched_yield
}
proc check_v3_target_string_conversions { } { proc check_v3_target_string_conversions { } {
global cxxflags global cxxflags
global DEFAULT_CXXFLAGS global DEFAULT_CXXFLAGS
......
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