out-of-line and arch-specific random_device

Marc Glisse marc.glisse@inria.fr
Tue Aug 28 12:42:00 GMT 2012


On Tue, 28 Aug 2012, Ulrich Drepper wrote:

> On Tue, Aug 28, 2012 at 3:47 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> I assume they are different enough that they can't all be abstracted
>> behind a nice common builtin (with default implementation in libgcc
>> and/or a macro advertising fast implementations of it) :-(
>
> What is different is the way to interact with the CPU facility to get
> the data.  That's exactly the part I abstracted out in its own
> function.  I named it __x86_rdrand() but that's more an historic
> accident.  I should have named it __get_random_word.  Then all that
> needs to be done for another architecture is to provide a definition
> of this function.  The rest can be shared.  But this function needs to
> be arch-specific since the details really differ sufficiently.

Thank you for your answers. My main concern was whether it was best to 
implement __get_random_word in libstdc++, or __builtin_random in gcc. 
But it looks like your solution of doing it in libstdc++ makes more sense 
(at least for now).

-- 
Marc Glisse



More information about the Gcc-patches mailing list