This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: random, srandom, and initstate


Hi Joel,

sorry for the late response.


On May 19 13:40, Joel Sherrill wrote:
> Hi,
> 
> I have been looking around for an implementation
> to port to newlib.  This is a link to the
> FreeBSD version.
> 
> http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/stdlib/random.c?rev=1.25.12.1;content-type=text%2Fplain
> 
> It is OK license-wise.  But I was curious if
> 
> (1) It's use of /dev/random and gettimeofday
>     as possible seed sources can be accomodated
>     in newlib.  Probably need to be disabled
>     via some conditional compilation.

I don't think you need to conditionalize them at all.  gettimeofday is
expected to exist (but see below) and the existence of "/dev/random" is
tested by the open call anyway.  If it doesn't exist, the srandomdev
function will use gettimeofday.

> (2) Should I go ahead and modify them to be
>     the _r versions and have the non-_r version
>     call those with static variables?

Yes.  Along the same lines the srandomdev function should use the
gettimeofday_r call.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]