diff mbox

revised fix for nanosleep check in GLIBCXX_ENABLE_LIBSTDCXX_TIME for darwin

Message ID CAH6eHdSqnvavSavXzQZi7ix4+of4ZDzQW2L9pqkGZQ5fZH_W4w@mail.gmail.com
State New
Headers show

Commit Message

Jonathan Wakely Oct. 10, 2012, 11:09 p.m. UTC
On 9 October 2012 18:49, Benjamin De Kosnik wrote:
>
>> I don't like the sched_yield macro being set there because it's
>> detected correctly by configure anyway, but I'm not going to labour
>> that point any more.
>
> Indeed. Then somebody will waste hours in the future wondering why
> configure says no but their TU says yes.
>
> At least a comment in the configure bits admitting defeat, people.

Committed to trunk like so.
commit 1616a77cdcdf619b1621265f33165cf6c74a3eed
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date:   Thu Oct 11 00:06:14 2012 +0100

    2012-10-10  Jack Howarth  <howarth@bromo.med.uc.edu>
    	    Jonathan Wakely  <jwakely.gcc@gmail.com>
    
    	* config/os/bsd/darwin/os_defines.h: Define _GLIBCXX_USE_NANOSLEEP
    	and _GLIBCXX_USE_SCHED_YIELD.
    	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Add comment.

Comments

Jonathan Wakely Oct. 10, 2012, 11:18 p.m. UTC | #1
On 11 October 2012 00:09, Jonathan Wakely wrote:
> On 9 October 2012 18:49, Benjamin De Kosnik wrote:
>>
>>> I don't like the sched_yield macro being set there because it's
>>> detected correctly by configure anyway, but I'm not going to labour
>>> that point any more.
>>
>> Indeed. Then somebody will waste hours in the future wondering why
>> configure says no but their TU says yes.
>>
>> At least a comment in the configure bits admitting defeat, people.
>
> Committed to trunk like so.

Oops, that changelog entry missed out the PR number, so it hasn't
updated Bugzilla, sorry.

Jack, please test and check and unpatched GCC trunk now supports
this_thread::yield() and this_thread::sleep_for().

Thanks for persevering to get it working.
diff mbox

Patch

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 960bae3..c4cde86 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1158,6 +1158,11 @@  dnl --enable-libstdcxx-time=no
 dnl --disable-libstdcxx-time
 dnl        disables the checks completely
 dnl
+dnl N.B. Darwin provides nanosleep but doesn't support the whole POSIX
+dnl Timers option, so doesn't define _POSIX_TIMERS. Because the test
+dnl below fails Darwin unconditionally defines _GLIBCXX_USE_NANOSLEEP in
+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])
diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index 421478d..be4aa14 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -42,4 +42,9 @@ 
 // Static initializer macro is buggy in darwin, see libstdc++/51906
 #define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
 
+// Configure checks for nanosleep fail on Darwin, but nanosleep and
+// sched_yield are always available, so use them.
+#define _GLIBCXX_USE_NANOSLEEP 1
+#define _GLIBCXX_USE_SCHED_YIELD 1
+
 #endif