public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9100] libstdc++: Fix std::random_device for avr
@ 2023-02-02  9:34 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-02-02  9:34 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:cc0394346ac49659d446b2ef35c40ba1ef3cd117

commit r12-9100-gcc0394346ac49659d446b2ef35c40ba1ef3cd117
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 31 22:28:16 2023 +0000

    libstdc++: Fix std::random_device for avr
    
    This fixes a build failure that affects avr, but could affect other
    targets in theory. The _M_fini function should not try to use ::open or
    ::fopen if _GLIBCXX_USE_DEV_RANDOM is not defined, because no file can
    ever have been opened.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++11/random.cc (random_device::_M_fini): Do not try to
            close the file handle if the target doesn't support the
            /dev/random and /dev/urandom files.
    
    (cherry picked from commit 277dd6ea416718ba5493023b5a4660ecdbaf936c)

Diff:
---
 libstdc++-v3/src/c++11/random.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index 8b5175a4ebf..38e2153ec17 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -548,6 +548,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
       }
 #endif
 
+#ifdef _GLIBCXX_USE_DEV_RANDOM
 #ifdef USE_POSIX_FILE_IO
     ::close(_M_fd);
     _M_fd = -1;
@@ -555,6 +556,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
     std::fclose(static_cast<FILE*>(_M_file));
 #endif
     _M_file = nullptr;
+#endif
   }
 
   random_device::result_type

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

only message in thread, other threads:[~2023-02-02  9:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02  9:34 [gcc r12-9100] libstdc++: Fix std::random_device for avr 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).