public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3685] libstdc++: Simplify lifetime of eh_globals variable [PR107500]
@ 2022-11-04 14:05 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-11-04 14:05 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:418999fe382c608facf57f96b53a9cb12d2fdd20

commit r13-3685-g418999fe382c608facf57f96b53a9cb12d2fdd20
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Nov 3 11:48:57 2022 +0000

    libstdc++: Simplify lifetime of eh_globals variable [PR107500]
    
    Since this is a trivial type, we probably don't need to do anything to
    ensure it's still accessible after other static dtors.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/107500
            * libsupc++/eh_globals.cc (eh_globals): Remove immortalizing
            wrapper.
            (__cxxabiv1::__cxa_get_globals_fast): Adjust.
            (__cxxabiv1::__cxa_get_globals): Adjust.

Diff:
---
 libstdc++-v3/libsupc++/eh_globals.cc | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/libstdc++-v3/libsupc++/eh_globals.cc b/libstdc++-v3/libsupc++/eh_globals.cc
index 12abfc10521..74e8a454ecc 100644
--- a/libstdc++-v3/libsupc++/eh_globals.cc
+++ b/libstdc++-v3/libsupc++/eh_globals.cc
@@ -70,18 +70,8 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 
 namespace
 {
-  struct constant_init
-  {
-    union {
-      __cxa_eh_globals obj;
-    };
-    constexpr constant_init() : obj() { }
-
-    ~constant_init() { /* do nothing, union member is not destroyed */ }
-  };
-
   // Single-threaded fallback buffer.
-  __constinit constant_init eh_globals;
+  __constinit __cxa_eh_globals eh_globals;
 }
 
 #if __GTHREADS
@@ -142,7 +132,7 @@ __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
   if (init._S_init)
     g = static_cast<__cxa_eh_globals*>(__gthread_getspecific(init._M_key));
   else
-    g = &eh_globals.obj;
+    g = &eh_globals;
   return g;
 }
 
@@ -167,7 +157,7 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 	}
     }
   else
-    g = &eh_globals.obj;
+    g = &eh_globals;
   return g;
 }
 
@@ -175,11 +165,11 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 
 extern "C" __cxa_eh_globals*
 __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
-{ return &eh_globals.obj; }
+{ return &eh_globals; }
 
 extern "C" __cxa_eh_globals*
 __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
-{ return &eh_globals.obj; }
+{ return &eh_globals; }
 
 #endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-04 14:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 14:05 [gcc r13-3685] libstdc++: Simplify lifetime of eh_globals variable [PR107500] 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).