[PATCH] revised fix for nanosleep check in GLIBCXX_ENABLE_LIBSTDCXX_TIME for darwin

Jonathan Wakely jwakely.gcc@gmail.com
Wed Oct 10 23:09:00 GMT 2012


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.
-------------- next part --------------
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.

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



More information about the Libstdc++ mailing list