public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::random_device definition
@ 2022-04-28  4:55 François Dumont
  2022-04-28  9:35 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: François Dumont @ 2022-04-28  4:55 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

Hi

     Still time for this fix for gcc 12 ?

     If so I'll make sure to run tests quickly, especially the abi.exp 
one to confirm that the cleanup in gnu-versioned-namespace.ver do not 
need to be replaced by the same in __8 namespace.

libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::random_device definition

Definition shall be put in _GLIBCXX_BEGIN_VERSION_NAMESPACE/
_GLIBCXX_END_VERSION_NAMESPACE like the declaration.

libstdc++-v3/ChangeLog

     * src/c++11/cow-string-inst.cc: Put random_device member definitions
     in versioned namespace.
     * src/c++11/random.cc: Likewise.
     * config/abi/pre/gnu-versioned-namespace.ver: Remove std::random_device
     symbols.

François

[-- Attachment #2: random_device_versioned.patch --]
[-- Type: text/x-patch, Size: 1829 bytes --]

diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index e9520a6421e..b37199ece72 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -28,7 +28,6 @@ GLIBCXX_8.0 {
     {
       std::*;
       std::__8::*;
-      std::random_device::*
     };
 
     # operator new(size_t)
diff --git a/libstdc++-v3/src/c++11/cow-string-inst.cc b/libstdc++-v3/src/c++11/cow-string-inst.cc
index e5331bb029a..f038d0018f0 100644
--- a/libstdc++-v3/src/c++11/cow-string-inst.cc
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -38,6 +38,8 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   void
   random_device::_M_init(const std::string& token)
   { _M_init(token.c_str(), token.length()); }
@@ -45,5 +47,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
   void
   random_device::_M_init_pretr1(const std::string& token)
   { _M_init(token.c_str(), token.length()); }
+
+_GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #endif
diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index 8b5175a4ebf..9c806b92559 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -301,7 +301,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
       return any; // should be unreachable
     }
-  }
+  } // namespace
+
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   void
   random_device::_M_init(const std::string& token)
@@ -665,5 +667,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
     linear_congruential_engine<unsigned, 16807UL, 0UL, 2147483647UL>;
   template struct __detail::_Mod<unsigned, 2147483647UL, 16807UL, 0UL>;
 #endif
+_GLIBCXX_END_NAMESPACE_VERSION
 }
 #endif // _GLIBCXX_USE_C99_STDINT_TR1

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

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::random_device definition
  2022-04-28  4:55 [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::random_device definition François Dumont
@ 2022-04-28  9:35 ` Jonathan Wakely
  2022-04-28 19:57   ` François Dumont
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2022-04-28  9:35 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]

On Thu, 28 Apr 2022 at 05:56, François Dumont via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Hi
>
>      Still time for this fix for gcc 12 ?

What needs fixing?

std::random_device is already declared in the versioned namespace in
<bits/random.h>:

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
...
  /**
   * A standard interface to a platform-specific non-deterministic
   * random number generator (if any are available).
   */
  class random_device
  {

So that means the definitions of its member functions will be exported
as std::__8::random_device::* already, the macros are not needed in
the src/*/*.cc files.

So it seems to me that the only "problem" is a redundant line in
config/abi/pre/gnu-versioned-namespace.ver. That line has no effect,
and can be removed.

I've pushed the attached patch instead.

>
>      If so I'll make sure to run tests quickly, especially the abi.exp
> one to confirm that the cleanup in gnu-versioned-namespace.ver do not
> need to be replaced by the same in __8 namespace.
>
> libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::random_device definition
>
> Definition shall be put in _GLIBCXX_BEGIN_VERSION_NAMESPACE/
> _GLIBCXX_END_VERSION_NAMESPACE like the declaration.
>
> libstdc++-v3/ChangeLog
>
>      * src/c++11/cow-string-inst.cc: Put random_device member definitions
>      in versioned namespace.
>      * src/c++11/random.cc: Likewise.
>      * config/abi/pre/gnu-versioned-namespace.ver: Remove std::random_device
>      symbols.
>
> François

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 818 bytes --]

commit f39fcafbc0d2c49593dd8351b87cf43da9227953
Author: François Dumont <fdumont@gcc.gnu.org>
Date:   Thu Apr 28 10:01:14 2022

    libstdc++: Remove redundant line in versioned namespace linker script
    
    This doesn't match anything.
    
    libstdc++-v3/ChangeLog:
    
            * config/abi/pre/gnu-versioned-namespace.ver: Remove
            std::random_device::* pattern.

diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index e9520a6421e..b37199ece72 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -28,7 +28,6 @@ GLIBCXX_8.0 {
     {
       std::*;
       std::__8::*;
-      std::random_device::*
     };
 
     # operator new(size_t)

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

* Re: [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::random_device definition
  2022-04-28  9:35 ` Jonathan Wakely
@ 2022-04-28 19:57   ` François Dumont
  0 siblings, 0 replies; 3+ messages in thread
From: François Dumont @ 2022-04-28 19:57 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++

On 28/04/22 11:35, Jonathan Wakely wrote:
> On Thu, 28 Apr 2022 at 05:56, François Dumont via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
>> Hi
>>
>>       Still time for this fix for gcc 12 ?
> What needs fixing?
>
> std::random_device is already declared in the versioned namespace in
> <bits/random.h>:

Oh, I thought it was necessary because it is what is done in most if not 
all the other sources in src.

I might do a cleanup as part of the patch to adopt the cxx11 abi 
std::string in the _GLIBCXX_INLINE_VERSION mode.


>
> namespace std _GLIBCXX_VISIBILITY(default)
> {
> _GLIBCXX_BEGIN_NAMESPACE_VERSION
> ...
>    /**
>     * A standard interface to a platform-specific non-deterministic
>     * random number generator (if any are available).
>     */
>    class random_device
>    {
>
> So that means the definitions of its member functions will be exported
> as std::__8::random_device::* already, the macros are not needed in
> the src/*/*.cc files.
>
> So it seems to me that the only "problem" is a redundant line in
> config/abi/pre/gnu-versioned-namespace.ver. That line has no effect,
> and can be removed.
>
> I've pushed the attached patch instead.
>
>>       If so I'll make sure to run tests quickly, especially the abi.exp
>> one to confirm that the cleanup in gnu-versioned-namespace.ver do not
>> need to be replaced by the same in __8 namespace.
>>
>> libstdc++: [_GLIBCXX_INLINE_VERSION] Fix std::random_device definition
>>
>> Definition shall be put in _GLIBCXX_BEGIN_VERSION_NAMESPACE/
>> _GLIBCXX_END_VERSION_NAMESPACE like the declaration.
>>
>> libstdc++-v3/ChangeLog
>>
>>       * src/c++11/cow-string-inst.cc: Put random_device member definitions
>>       in versioned namespace.
>>       * src/c++11/random.cc: Likewise.
>>       * config/abi/pre/gnu-versioned-namespace.ver: Remove std::random_device
>>       symbols.
>>
>> François



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

end of thread, other threads:[~2022-04-28 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28  4:55 [PATCH][_GLIBCXX_INLINE_VERSION] Fix std::random_device definition François Dumont
2022-04-28  9:35 ` Jonathan Wakely
2022-04-28 19:57   ` François Dumont

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