From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 2107B385840C; Mon, 18 Mar 2024 14:07:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2107B385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710770836; bh=/OXfRnA8A1/Q5olfPHt3UzSkT/TsLc74YhpwDxAfapE=; h=From:To:Subject:Date:From; b=vhkUwVWCffxpgkjLrJBa/GUN9j4TnJ5GjGGm9biGmYL1k0J8MoNRJcoHZG91YgIDV Jye5GfKU2wJbvhr9C6O3QykEKPRXme3M4gd4jrYvjTedBILsRhPHp49aDrwsPmBXaj +mRtsyNjWIUtf91jsCiajSAs4AVw8UH1GhIaoCG0= 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-10265] libstdc++: Add macros for the inline namespace std::_V2 X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: d9f006da30def40747792d3ea37add1d80e02444 X-Git-Newrev: f8ab9b7c08161739242b2760f881a3918373cd46 Message-Id: <20240318140716.2107B385840C@sourceware.org> Date: Mon, 18 Mar 2024 14:07:13 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f8ab9b7c08161739242b2760f881a3918373cd46 commit r12-10265-gf8ab9b7c08161739242b2760f881a3918373cd46 Author: Jonathan Wakely Date: Wed May 11 16:35:45 2022 +0100 libstdc++: Add macros for the inline namespace std::_V2 Use macros to open and close the inline namespace _V2 that is used for ABI versioning of individual components such as chrono::system_clock. This allows the namespace to be hidden in the docs generated by Doxygen, so that we document std::foo instead of std::_V2::foo. This also makes it easy to remove that namespace entirely for the gnu-versioned-namespace build, where everything is already versioned as std::__8 and there are no backwards compatibility guarantees. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (PREDEFINED): Expand new macros to nothing. * include/bits/c++config (_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE) (_GLIBCXX_END_INLINE_ABI_NAMESPACE): Define new macros. * include/bits/algorithmfwd.h (_V2::__rotate): Use new macros for the namespace. * include/bits/chrono.h (chrono::_V2::system_clock): Likewise. * include/bits/stl_algo.h (_V2::__rotate): Likewise. * include/std/condition_variable (_V2::condition_variable_any): Likewise. * include/std/system_error (_V2::error_category): Likewise. (cherry picked from commit e4905f11852d722cd711b53a5626245528ace1d2) Diff: --- libstdc++-v3/doc/doxygen/user.cfg.in | 2 ++ libstdc++-v3/include/bits/algorithmfwd.h | 15 ++++++++------- libstdc++-v3/include/bits/c++config | 11 +++++++++-- libstdc++-v3/include/bits/chrono.h | 4 ++-- libstdc++-v3/include/bits/stl_algo.h | 5 ++--- libstdc++-v3/include/std/condition_variable | 4 ++-- libstdc++-v3/include/std/system_error | 5 +++-- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index b095addd10c..ba85d4bb2a8 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2348,6 +2348,8 @@ PREDEFINED = __cplusplus=202002L \ "_GLIBCXX_END_NAMESPACE_CONTAINER= " \ "_GLIBCXX_END_NAMESPACE_CXX11= " \ "_GLIBCXX_END_NAMESPACE_LDBL= " \ + "-D_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)= " \ + "-D_GLIBCXX_END_INLINE_ABI_NAMESPACE(X)= " \ "_GLIBCXX_TEMPLATE_ARGS=... " \ "_GLIBCXX_DEPRECATED= " \ "_GLIBCXX_DEPRECATED_SUGGEST(E)= " \ diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 5b85b0bc60d..4cfc53f4968 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -601,13 +601,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _OIter reverse_copy(_BIter, _BIter, _OIter); - inline namespace _V2 - { - template - _GLIBCXX20_CONSTEXPR - _FIter - rotate(_FIter, _FIter, _FIter); - } +_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) + + template + _GLIBCXX20_CONSTEXPR + _FIter + rotate(_FIter, _FIter, _FIter); + +_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) template _GLIBCXX20_CONSTEXPR diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 2798b9786dc..150b0bc5834 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -345,13 +345,16 @@ namespace __gnu_cxx # define _GLIBCXX_DEFAULT_ABI_TAG #endif -// Defined if inline namespaces are used for versioning. +// Non-zero if inline namespaces are used for versioning the entire library. #define _GLIBCXX_INLINE_VERSION -// Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION +// Inline namespace for symbol versioning of (nearly) everything in std. # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { # define _GLIBCXX_END_NAMESPACE_VERSION } +// Unused when everything in std is versioned anyway. +# define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) +# define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) namespace std { @@ -376,8 +379,12 @@ _GLIBCXX_END_NAMESPACE_VERSION } #else +// Unused. # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION +// Used to version individual components, e.g. std::_V2::error_category. +# define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) inline namespace X { +# define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X) } // inline namespace X #endif // Inline namespaces for special modes: debug, parallel. diff --git a/libstdc++-v3/include/bits/chrono.h b/libstdc++-v3/include/bits/chrono.h index d09f8563a59..43d91b8713b 100644 --- a/libstdc++-v3/include/bits/chrono.h +++ b/libstdc++-v3/include/bits/chrono.h @@ -1193,7 +1193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // compatibility definitions for previous versions. At some // point, when these clocks settle down, the inlined namespaces // can be removed. XXX GLIBCXX_ABI Deprecated - inline namespace _V2 { +_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) /** * @brief System clock. @@ -1265,7 +1265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ using high_resolution_clock = system_clock; - } // end inline namespace _V2 +_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) #if __cplusplus >= 202002L /// @addtogroup chrono diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 41a8cf2f3e1..61f572d8d5f 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1190,8 +1190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __m; } - inline namespace _V2 - { +_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) /// This is a helper function for the rotate algorithm. template @@ -1398,7 +1397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::__iterator_category(__first)); } - } // namespace _V2 +_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) /** * @brief Copy a sequence, rotating its elements. diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index 2a23e65bbd3..06c4ff9ebdd 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -234,7 +234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void (*_M_cb)(void*); }; - inline namespace _V2 { +_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) /// condition_variable_any // Like above, but mutex is not required to have try_lock. @@ -439,7 +439,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif }; - } // end inline namespace +_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) /// @} group condition_variables _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 28f01da3fc2..da6c308e748 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -77,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // C++17 /// @} - inline namespace _V2 { +_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) /** @addtogroup diagnostics * @{ @@ -188,7 +188,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION system_category() noexcept; /// @} - } // end inline namespace + +_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) /** @addtogroup diagnostics * @{