public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <ryxi@stu.xidian.edu.cn>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: ryxi@stu.xidian.edu.cn, gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH] Implement non-trivial std::random_device::entropy (PR libstdc++/67578)
Date: Mon, 22 May 2017 13:50:00 -0000	[thread overview]
Message-ID: <1495460501.29130.6.camel@stu.xidian.edu.cn> (raw)
In-Reply-To: <20170522130058.GF4527@redhat.com>

On 2017-05-22 14:00 +0100, Jonathan Wakely wrote:
> On 18/05/17 19:27 +0800, Xi Ruoyao wrote:
> > This patch use ioctl to get entropy of std::random_device using
> > /dev/random and /dev/urandom.
> 
> This is a nice addition, thanks.
> 
> N.B. I couldn't apply your patch, several lines had U+00A0 (i.e.
> NO-BREAK SPACE) characters where normal spaces should be. I don't know
> if this is something your mail client did, but maybe attaching the
> patch as a multipart message rather than including it inline in the
> body will prevent it in future.

Oh no...  Seems my email client destroyed my patch. I'll attach the
patch next time.  Please wait for PATCH v2.

> > diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
> > index 3e6e70b..39ad330 100644
> > --- a/libstdc++-v3/config/abi/pre/gnu.ver
> > +++ b/libstdc++-v3/config/abi/pre/gnu.ver
> > @@ -1963,6 +1963,9 @@ GLIBCXX_3.4.23 {
> >      _ZNSt13__future_base13_State_baseV211_Make_ready6_M_setEv;
> >  #endif
> >  
> > +    # std::random_device::_M_getentropy() const
> > +    _ZNKSt13random_device13_M_getentropyEv;
> > +
> >  } GLIBCXX_3.4.22;
> 
> The 3.4.23 version is now "closed" because it was used for the GCC 7.1
> release, and so we can't add new symbols to it. That means we need to
> bump the library version and create a new GLIBCXX_3.4.24 version node.
> The required steps are documented in doc/xml/manual/build_hacking.xml
> (and done by the attached patch which I'm testing).

I'll do it.  Glad to add the first symbol in 3.4.24.

> > @@ -161,6 +169,34 @@ namespace std _GLIBCXX_VISIBILITY(default)
> >      return _M_mt();
> >    }
> >  
> > +  double
> > +  random_device::_M_getentropy() const noexcept
> > +  {
> > +#if defined _GLIBCXX_HAVE_SYS_IOCTL_H && \
> > +    defined _GLIBCXX_HAVE_LINUX_RANDOM_H
> 
> Is RNDGETENTCNT guaranteed to be defined by all versions of
> <linux/random.h>?
> 
> Would it be better to check for it explicitly? i.e.
> 
> #if defined _GLIBCXX_HAVE_SYS_IOCTL_H && defined RNDGETENTCNT

It has been there since the git repo of Linux kernel was created.
I have to check the ancient history of kernel code to know.

> 
> It would also be nice to have a test for this functionality, but since
> the available entropy might be zero sometimes we can't guarantee that
> a test for a non-zero value will always pass.

I've thought about it, but I couldn't find out how to do the test.
-- 
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2017-05-22 13:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 12:15 Xi Ruoyao
2017-05-22 13:21 ` Jonathan Wakely
2017-05-22 13:50   ` Xi Ruoyao [this message]
2017-05-22 14:10     ` Jonathan Wakely
2017-05-22 14:19       ` Xi Ruoyao
2017-05-23 12:11         ` Jonathan Wakely
2017-05-22 14:30       ` [PATCH v2] " Xi Ruoyao
2017-05-23 16:22         ` Jonathan Wakely
2017-05-24 19:28           ` Jonathan Wakely

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=1495460501.29130.6.camel@stu.xidian.edu.cn \
    --to=ryxi@stu.xidian.edu.cn \
    --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).