From: "François Dumont" <frs.dumont@gmail.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix gnu-versioned-namespace build
Date: Wed, 11 Dec 2019 20:23:00 -0000 [thread overview]
Message-ID: <25bc8816-e4b3-b953-0e93-5949ffbe0494@gmail.com> (raw)
In-Reply-To: <20191211111639.GV11522@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3056 bytes --]
On 12/11/19 12:16 PM, Jonathan Wakely wrote:
> On 11/12/19 08:29 +0100, François Dumont wrote:
>> I plan to commit this tomorrow.
>>
>> Note that rather than just adding the missing
>> _GLIBCXX_[BEGIN,END]_VERSION_NAMESPACE I also move anonymous
>> namespace usage outside std namespace. Let me know if it was
>> intentional.
>
> It was intentional, why move it?
I just don't get the intention so I proposed to move it. But there are
indeed other usages of this pattern in other src files.
Note that in src/c++11/debug.cc I am using anonymous namespace at global
scope, is that wrong ?
>
> Adding the BEGIN/END_VERSION macros is unnecessary. Those namespaces
> are inline, so std::random_device already refers to
> std::__8::random_device when the original declaration was in the
> versioned namespace.
Ok. I must confess I wasn't clear about this but looking at other src
files, at least in src/c++11, was showing that it is done almost always
this way, I guess we could cleanup those files.
>
> The only fix needed here seems to be qualifying std::isdigit (and
> strictly-speaking we should also include <cctype> to declare that).
>
Like in attached patch ?
I am including it unconditionnaly with other C wrapping headers like
<cstdio>, is that fine ?
At least it builds fine.
>
>> Â Â Â * src/c++11/random.cc: Add _GLIBCXX_BEGIN_NAMESPACE_VERSION and
>> Â Â Â _GLIBCXX_END_NAMESPACE_VERSION. Move anonymous namespace outside std
>> Â Â Â namespace.
>>
>> Tested under Linux x86_64 normal/debug/versioned namespace modes.
>>
>> There are still tests failing in versioned namespace, more patches to
>> come.
>>
>> François
>>
>
>> diff --git a/libstdc++-v3/src/c++11/random.cc
>> b/libstdc++-v3/src/c++11/random.cc
>> index 10fbe1dc4c4..d4ebc9556ab 100644
>> --- a/libstdc++-v3/src/c++11/random.cc
>> +++ b/libstdc++-v3/src/c++11/random.cc
>> @@ -73,8 +73,6 @@
>> # define USE_MT19937 1
>> #endif
>>
>> -namespace std _GLIBCXX_VISIBILITY(default)
>> -{
>> namespace
>> {
>> #if USE_RDRAND
>> @@ -124,6 +122,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
>> #endif
>> }
>>
>> +namespace std _GLIBCXX_VISIBILITY(default)
>> +{
>> +_GLIBCXX_BEGIN_NAMESPACE_VERSION
>> +
>> Â void
>> Â random_device::_M_init(const std::string& token)
>> Â {
>> @@ -286,7 +288,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
>> Â Â Â _M_mt.seed(seed);
>> #else
>> Â Â Â // Convert old default token "mt19937" or numeric seed tokens to
>> "default".
>> -Â Â Â if (token == "mt19937" || isdigit((unsigned char)token[0]))
>> +Â Â Â if (token == "mt19937" || std::isdigit((unsigned char)token[0]))
>> Â Â Â Â Â _M_init("default");
>> Â Â Â else
>> Â Â Â Â Â _M_init(token);
>> @@ -407,5 +409,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
>> Â Â Â 0x9d2c5680UL, 15,
>> Â Â Â 0xefc60000UL, 18, 1812433253UL>;
>> #endif // USE_MT19937
>> -}
>> +
>> +_GLIBCXX_END_NAMESPACE_VERSION
>> +} // namespace std
>> #endif // _GLIBCXX_USE_C99_STDINT_TR1
>
> .
[-- Attachment #2: versioned_namespace_build.patch --]
[-- Type: text/x-patch, Size: 1164 bytes --]
diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index 10fbe1dc4c4..d4ebc9556ab 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -73,8 +73,6 @@
# define USE_MT19937 1
#endif
-namespace std _GLIBCXX_VISIBILITY(default)
-{
namespace
{
#if USE_RDRAND
@@ -124,6 +122,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
#endif
}
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
void
random_device::_M_init(const std::string& token)
{
@@ -286,7 +288,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
_M_mt.seed(seed);
#else
// Convert old default token "mt19937" or numeric seed tokens to "default".
- if (token == "mt19937" || isdigit((unsigned char)token[0]))
+ if (token == "mt19937" || std::isdigit((unsigned char)token[0]))
_M_init("default");
else
_M_init(token);
@@ -407,5 +409,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
0x9d2c5680UL, 15,
0xefc60000UL, 18, 1812433253UL>;
#endif // USE_MT19937
-}
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
#endif // _GLIBCXX_USE_C99_STDINT_TR1
next prev parent reply other threads:[~2019-12-11 20:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 7:29 François Dumont
2019-12-11 11:16 ` Jonathan Wakely
2019-12-11 11:22 ` Jonathan Wakely
2019-12-11 20:26 ` [PATCH] Fix gnu-versioned-namespace tr1 declaration François Dumont
2019-12-11 21:04 ` Jonathan Wakely
2019-12-11 20:23 ` François Dumont [this message]
2019-12-11 20:44 ` [PATCH] Fix gnu-versioned-namespace build Jonathan Wakely
2019-12-11 21:28 ` François Dumont
2019-12-11 21:33 ` Jonathan Wakely
2019-12-11 16:48 ` Jonathan Wakely
2020-10-30 12:59 François Dumont
2020-10-30 13:23 ` Jonathan Wakely
2020-10-30 13:37 ` Jonathan Wakely
2020-10-30 14:11 ` Jonathan Wakely
2020-10-30 17:51 ` François Dumont
2020-10-30 18:48 ` Jonathan Wakely
2020-10-31 17:16 ` François Dumont
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25bc8816-e4b3-b953-0e93-5949ffbe0494@gmail.com \
--to=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).