bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'random'


From: Bruno Haible
Subject: Re: new module 'random'
Date: Sat, 14 Jan 2012 18:24:58 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Jose E. Marchesi wrote:
> Note that my reason for preferring random to random_r in code which must
> not be reentrant is the not documented requirement of memsetting the
> random_data passed to initstate_r to zeroes.  Even if that trick works
> with the current versions of glibc (and the random_r module from gnulib)
> AFAIK nothing guarantees that it will work in the future.

Good point. I have registered a glibc manual bug about it:
http://sourceware.org/bugzilla/show_bug.cgi?id=13595

My understanding is that

  - The memset() is necessary, and is part of BSD culture.

  - The initstate_r() call is only necessary if you want truly different
    numbers at each program run. [1] says:
        "If initstate() has not been called, then random() shall behave
         as though initstate() had been called with seed=1 and size=128."

Bruno

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/initstate.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]