From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 38B023858438; Mon, 18 Mar 2024 14:03:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38B023858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710770606; bh=12OQuT53JB2eYQaqPWTV4SP0Bt/6Af1vgEOPHi2Y8Tk=; h=From:To:Subject:Date:From; b=UzESsuQuftgXJVqcYuerLZRq6Qkp0UpzGN/CHD8F+NQ7MmH754VQqa+mZSygt3VKX m4Jl9BURjKccGsJgou5Z/pdMppmzUA7U8oNnBCI84DVbDeZ7tWOR0eQEZQedIZGTeu xeDmnwup8lDAWa+UtKzJDTDs+0jFwlE/HQFSg57k= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-10222] libstdc++: Simplify lifetime of eh_globals variable [PR107500] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: fbdeeb1604d52a8ece8631f70ecd64d925d31741 X-Git-Newrev: d9076dafa12c93e96b349035fb59050151403866 Message-Id: <20240318140326.38B023858438@sourceware.org> Date: Mon, 18 Mar 2024 14:03:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d9076dafa12c93e96b349035fb59050151403866 commit r12-10222-gd9076dafa12c93e96b349035fb59050151403866 Author: Jonathan Wakely 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. (cherry picked from commit 418999fe382c608facf57f96b53a9cb12d2fdd20) Diff: --- libstdc++-v3/libsupc++/eh_globals.cc | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/libstdc++-v3/libsupc++/eh_globals.cc b/libstdc++-v3/libsupc++/eh_globals.cc index 0aadb692a96..74e8a454ecc 100644 --- a/libstdc++-v3/libsupc++/eh_globals.cc +++ b/libstdc++-v3/libsupc++/eh_globals.cc @@ -70,19 +70,8 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW namespace { - struct constant_init - { - union { - unsigned char unused; - __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 @@ -143,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; } @@ -168,7 +157,7 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW } } else - g = &eh_globals.obj; + g = &eh_globals; return g; } @@ -176,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