public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.
@ 2022-12-04 11:08 Iain Sandoe
  2022-12-04 12:36 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2022-12-04 11:08 UTC (permalink / raw)
  To: libstdc++, gcc-patches

While looking at Darwin's os_defines, I wondered whether
_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC was really still necessary. On checking
the OS, it seems that it was a transient problem that only appears in Darwin11.
Earlier versions do not have the initializer, and the operation is fixed in
Darwin12+.  So, I figure we still need the workaround for Darwin8-11 but not
later versions (patch implements this).

Testing on both earlier and later systems does not (as one might expect) reveal
any differences (we still have some lock-related tests that 'twinkle' so that
there can be something still hidden by that).

Anyway. the question is. "is there any reason not to use the system version of
this where it works, or should I just leave the status quo?"  If the former,
then "ok for master?".

thanks
Iain

-- >8 --

The problem described in pr 51906 was fixed in the next OS release.  Limit the
workaround to systems that need it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

libstdc++-v3/ChangeLog:

	* config/os/bsd/darwin/os_defines.h
	(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC): Limit use of this macro
	to OS versions that need it.
---
 libstdc++-v3/config/os/bsd/darwin/os_defines.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index 38fdfb5f6f0..5b611d32e0d 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -39,8 +39,12 @@
 // implementation is not itself a weak definition).
 #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((__weak__))
 
-// Static initializer macro is buggy in darwin, see libstdc++/51906
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+     && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080)
+// Static initializer macro is absent for Darwin < 11 and buggy in Darwin 11,
+// see libstdc++/51906.  Fixed in Darwin 12 (OS X 10.8).
 #define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+#endif
 
 // Configure checks for nanosleep fail on Darwin, but nanosleep and
 // sched_yield are always available, so use them.
-- 
2.37.1 (Apple Git-137.1)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it.
  2022-12-04 11:08 [PATCH] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it Iain Sandoe
@ 2022-12-04 12:36 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2022-12-04 12:36 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: libstdc++, gcc-patches, Iain Sandoe

[-- Attachment #1: Type: text/plain, Size: 2491 bytes --]

On Sun, 4 Dec 2022, 11:08 Iain Sandoe via Libstdc++, <libstdc++@gcc.gnu.org>
wrote:

> While looking at Darwin's os_defines, I wondered whether
> _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC was really still necessary. On
> checking
> the OS, it seems that it was a transient problem that only appears in
> Darwin11.
> Earlier versions do not have the initializer, and the operation is fixed in
> Darwin12+.  So, I figure we still need the workaround for Darwin8-11 but
> not
> later versions (patch implements this).
>
> Testing on both earlier and later systems does not (as one might expect)
> reveal
> any differences (we still have some lock-related tests that 'twinkle' so
> that
> there can be something still hidden by that).
>
> Anyway. the question is. "is there any reason not to use the system
> version of
> this where it works, or should I just leave the status quo?"  If the
> former,
> then "ok for master?".
>


Using the initializer seems preferable when it works, so ok for master,
thanks.




> thanks
> Iain
>
> -- >8 --
>
> The problem described in pr 51906 was fixed in the next OS release.  Limit
> the
> workaround to systems that need it.
>
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
>
> libstdc++-v3/ChangeLog:
>
>         * config/os/bsd/darwin/os_defines.h
>         (_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC): Limit use of this macro
>         to OS versions that need it.
> ---
>  libstdc++-v3/config/os/bsd/darwin/os_defines.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
> b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
> index 38fdfb5f6f0..5b611d32e0d 100644
> --- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
> +++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
> @@ -39,8 +39,12 @@
>  // implementation is not itself a weak definition).
>  #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((__weak__))
>
> -// Static initializer macro is buggy in darwin, see libstdc++/51906
> +#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
> +     && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080)
> +// Static initializer macro is absent for Darwin < 11 and buggy in Darwin
> 11,
> +// see libstdc++/51906.  Fixed in Darwin 12 (OS X 10.8).
>  #define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
> +#endif
>
>  // Configure checks for nanosleep fail on Darwin, but nanosleep and
>  // sched_yield are always available, so use them.
> --
> 2.37.1 (Apple Git-137.1)
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-04 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-04 11:08 [PATCH] libstdc++, Darwin: Limit recursive mutex init to OS versions needing it Iain Sandoe
2022-12-04 12:36 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).