public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-11-09  1:58 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-11-09  1:58 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:9ffc2e1c2d4e214eafdb9e3a04a63485c13f01c9

commit 9ffc2e1c2d4e214eafdb9e3a04a63485c13f01c9
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Nov 8 20:31:23 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on
    platforms that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
            detection of __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..cabd7c0a4a0 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,24 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__
+  if (__cxa_thread_atexit_impl)
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-12-06 22:47 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-12-06 22:47 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:e295a6e2562df5fa76d334466cf4dd5dae4a0134

commit e295a6e2562df5fa76d334466cf4dd5dae4a0134
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Dec 5 22:27:53 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on select
    platforms (GNU variants, for starters) that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            PR libstdc++/112858
            * config/os/gnu-linux/os_defines.h
            (_GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL): Define.
            * libsupc++/atexit_thread.cc [__GXX_WEAK__ &&
            _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL]
            (__cxa_thread_atexit): Add dynamic detection of
            __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/config/os/gnu-linux/os_defines.h |  5 +++++
 libstdc++-v3/libsupc++/atexit_thread.cc       | 23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index 87317031fcd..a2e4baec069 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -60,6 +60,11 @@
 # define _GLIBCXX_HAVE_FLOAT128_MATH 1
 #endif
 
+// Enable __cxa_thread_atexit to rely on a (presumably libc-provided)
+// __cxa_thread_atexit_impl, if it happens to be defined, even if
+// configure couldn't find it during the build.
+#define _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL 1
+
 #ifdef __linux__
 // The following libpthread properties only apply to Linux, not GNU/Hurd.
 
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..28423344a0f 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,32 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, [[maybe_unused]] void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+  if (__cxa_thread_atexit_impl)
+    // Rely on a (presumably libc-provided) __cxa_thread_atexit_impl,
+    // if it happens to be defined, even if configure couldn't find it
+    // during the build.  _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+    // may be defined e.g. in os_defines.h on platforms where some
+    // versions of libc have a __cxa_thread_atexit_impl definition,
+    // but whose earlier versions didn't.  This enables programs build
+    // by toolchains compatible with earlier libc versions to still
+    // benefit from a libc-provided __cxa_thread_atexit_impl.
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-12-06 20:01 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-12-06 20:01 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:a517eeccad4117732cf112a61792e5110d07bbf8

commit a517eeccad4117732cf112a61792e5110d07bbf8
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Dec 5 22:27:53 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on select
    platforms (GNU variants, for starters) that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * config/os/gnu-linux/os_defines.h
            (_GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL): Define.
            * libsupc++/atexit_thread.cc [__GXX_WEAK__ &&
            _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL]
            (__cxa_thread_atexit): Add dynamic detection of
            __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/config/os/gnu-linux/os_defines.h |  5 +++++
 libstdc++-v3/libsupc++/atexit_thread.cc       | 23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index 87317031fcd..a2e4baec069 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -60,6 +60,11 @@
 # define _GLIBCXX_HAVE_FLOAT128_MATH 1
 #endif
 
+// Enable __cxa_thread_atexit to rely on a (presumably libc-provided)
+// __cxa_thread_atexit_impl, if it happens to be defined, even if
+// configure couldn't find it during the build.
+#define _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL 1
+
 #ifdef __linux__
 // The following libpthread properties only apply to Linux, not GNU/Hurd.
 
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..28423344a0f 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,32 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, [[maybe_unused]] void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+  if (__cxa_thread_atexit_impl)
+    // Rely on a (presumably libc-provided) __cxa_thread_atexit_impl,
+    // if it happens to be defined, even if configure couldn't find it
+    // during the build.  _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+    // may be defined e.g. in os_defines.h on platforms where some
+    // versions of libc have a __cxa_thread_atexit_impl definition,
+    // but whose earlier versions didn't.  This enables programs build
+    // by toolchains compatible with earlier libc versions to still
+    // benefit from a libc-provided __cxa_thread_atexit_impl.
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-12-06  2:31 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-12-06  2:31 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:08223399f04117db7051eed33fd595d153f5920a

commit 08223399f04117db7051eed33fd595d153f5920a
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Dec 5 22:27:53 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on
    platforms that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
            detection of __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/config/os/gnu-linux/os_defines.h |  5 +++++
 libstdc++-v3/libsupc++/atexit_thread.cc       | 23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index 87317031fcd..a2e4baec069 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -60,6 +60,11 @@
 # define _GLIBCXX_HAVE_FLOAT128_MATH 1
 #endif
 
+// Enable __cxa_thread_atexit to rely on a (presumably libc-provided)
+// __cxa_thread_atexit_impl, if it happens to be defined, even if
+// configure couldn't find it during the build.
+#define _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL 1
+
 #ifdef __linux__
 // The following libpthread properties only apply to Linux, not GNU/Hurd.
 
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..aa4ed5312bf 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,32 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__ && _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+  if (__cxa_thread_atexit_impl)
+    // Rely on a (presumably libc-provided) __cxa_thread_atexit_impl,
+    // if it happens to be defined, even if configure couldn't find it
+    // during the build.  _GLIBCXX_MAY_HAVE___CXA_THREAD_ATEXIT_IMPL
+    // may be defined e.g. in os_defines.h on platforms where some
+    // versions of libc have a __cxa_thread_atexit_impl definition,
+    // but whose earlier versions didn't.  This enables programs build
+    // by toolchains compatible with earlier libc versions to still
+    // benefit from a libc-provided __cxa_thread_atexit_impl.
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-12-01 23:42 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-12-01 23:42 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:b3395198ea59085b6f7c514cd02ff37252a169ed

commit b3395198ea59085b6f7c514cd02ff37252a169ed
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Nov 14 22:16:31 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on
    platforms that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
            detection of __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..cabd7c0a4a0 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,24 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__
+  if (__cxa_thread_atexit_impl)
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-11-15  2:26 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-11-15  2:26 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:59e9da3e33dc56c8aade694b4d24842bd5b09ca9

commit 59e9da3e33dc56c8aade694b4d24842bd5b09ca9
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Nov 14 22:16:31 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on
    platforms that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
            detection of __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..cabd7c0a4a0 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,24 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__
+  if (__cxa_thread_atexit_impl)
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-11-08 23:48 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-11-08 23:48 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:e07716aa13d7c3e81cb0ff5c5031ddcf8278b63a

commit e07716aa13d7c3e81cb0ff5c5031ddcf8278b63a
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Nov 8 20:34:20 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime

Diff:
---
 libstdc++-v3/include/bits/stl_bvector.h | 50 ++++-----------------------------
 1 file changed, 6 insertions(+), 44 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 81b31684645..97a45582e69 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -56,6 +56,10 @@
 #ifndef _STL_BVECTOR_H
 #define _STL_BVECTOR_H 1
 
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
 #if __cplusplus >= 201103L
 #include <initializer_list>
 #include <bits/functional_hash.h>
@@ -177,53 +181,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
     _Bit_type * _M_p;
     unsigned int _M_offset;
 
-#if __OPTIMIZE__ && !__GLIBCXX_DISABLE_ASSUMPTIONS
-// If the assumption (EXPR) fails, invoke undefined behavior, so that
-// the test and the failure block gets optimized out, but the compiler
-// still recalls that (expr) can be taken for granted.  Use this only
-// for expressions that are simple and explicit enough that the
-// compiler can optimize based on them.  When not optimizing, the
-// expression is still compiled, but it's never executed.
-#if 0 /* ??? */ && __cpp_lib_is_constant_evaluated
-#define __GLIBCXX_BUILTIN_ASSUME(expr)		\
-    do						\
-      if (std::is_constant_evaluated ())	\
-	static_assert(expr);			\
-      else if (!(expr))				\
-	{					\
-	  void **__assert_failed = 0;		\
-	  *__assert_failed = 0;			\
-	  __builtin_unreachable ();		\
-	}					\
-    while (0)
-#else
-#define __GLIBCXX_BUILTIN_ASSUME(expr)		\
-    do						\
-      if (!(expr))				\
-	{					\
-	  void **__assert_failed = 0;		\
-	  *__assert_failed = 0;			\
-	  __builtin_unreachable ();		\
-	}					\
-    while (0)
-#endif
-#else
-#define __GLIBCXX_BUILTIN_ASSUME(expr)		\
-    (void)(false && (expr))
-#endif
-
-    _GLIBCXX20_CONSTEXPR
-    bool
-    _M_normalized_p() const
-    {
-      return (_M_offset < unsigned(_S_word_bit));
-    }
-
-    _GLIBCXX20_CONSTEXPR
+    _GLIBCXX20_CONSTEXPR _GLIBCXX_ALWAYS_INLINE
     void
     _M_assume_normalized() const
     {
-      __GLIBCXX_BUILTIN_ASSUME (_M_normalized_p ());
+      __attribute__ ((__assume__ (_M_offset < unsigned(_S_word_bit))));
     }
 
     _GLIBCXX20_CONSTEXPR

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

* [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime
@ 2023-11-08 23:48 Alexandre Oliva
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Oliva @ 2023-11-08 23:48 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:444accc1f77eb1656c6e4fb92d17819d0b1d4f6a

commit 444accc1f77eb1656c6e4fb92d17819d0b1d4f6a
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Nov 8 20:31:23 2023 -0300

    libsupc++: try cxa_thread_atexit_impl at runtime
    
    g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
    a platform that lacks __cxa_thread_atexit_impl, even if the program is
    built and run using that toolchain on a (later) platform that offers
    __cxa_thread_atexit_impl.
    
    This patch adds runtime testing for __cxa_thread_atexit_impl on
    platforms that support weak symbols.
    
    
    for  libstdc++-v3/ChangeLog
    
            * libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
            detection of __cxa_thread_atexit_impl.

Diff:
---
 libstdc++-v3/libsupc++/atexit_thread.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
index 9346d50f5da..cabd7c0a4a0 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -138,11 +138,24 @@ namespace {
   }
 }
 
+#if __GXX_WEAK__
+extern "C"
+int __attribute__ ((__weak__))
+__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *),
+			  void *arg, void *d);
+#endif
+
+// ??? We can't make it an ifunc, can we?
 extern "C" int
 __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *),
-				 void *obj, void */*dso_handle*/)
+				 void *obj, void *dso_handle)
   _GLIBCXX_NOTHROW
 {
+#if __GXX_WEAK__
+  if (__cxa_thread_atexit_impl)
+    return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
+#endif
+
   // Do this initialization once.
   if (__gthread_active_p ())
     {

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

end of thread, other threads:[~2023-12-06 22:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09  1:58 [gcc(refs/users/aoliva/heads/testme)] libsupc++: try cxa_thread_atexit_impl at runtime Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2023-12-06 22:47 Alexandre Oliva
2023-12-06 20:01 Alexandre Oliva
2023-12-06  2:31 Alexandre Oliva
2023-12-01 23:42 Alexandre Oliva
2023-11-15  2:26 Alexandre Oliva
2023-11-08 23:48 Alexandre Oliva
2023-11-08 23:48 Alexandre Oliva

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).