chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] Patch to use better PRNG on BSD's


From: Timo Myyrä
Subject: Re: [Chicken-hackers] Patch to use better PRNG on BSD's
Date: Wed, 11 Apr 2012 08:49:32 +0300

On Tue, Apr 10, 2012 at 11:18 PM, Peter Bex <address@hidden> wrote:
> On Tue, Apr 10, 2012 at 07:15:44PM +0300, Timo Myyrä wrote:
>> I noticed that chicken uses old rand / srand functions when better
>> alternatives are present.
>> Patch makes BSD's use arc4random instead of rand.
>
> NetBSD doesn't have arc4random_uniform either, so that'd need to be added
> to the test.

Ah, I checked the manual pages of NetBSD-current and it lists
arc4random_uniform.
Apparently its not in the current release versions, my bad.

> I think a cleaner and more robust way is to actually put a PRNG inside
> Chicken itself.  That way all platforms benefit from a good random
> generator instead of it being a hit-and-miss situation.  Chicken ought
> to provide as good an abstraction over nasty annoying OS details as it
> can.

Whats the problem of using hosts PRNG. I'd assume every host OS would
have decent PRNG.
Just provide wrapper for it and then fallback to rand / random if not
able to use any decent PRNG.
Then note the OS with poor PRNG's in documentation.

> Having said that, your patch is an unmistakable improvement over the
> current situation, especially on MacOS X, assuming they bothered to
> implement arc4random properly this time...
>
>> I'm not 100% sure this is correct so test, at least the Mac OS X part
>> as it doesn't have arc4random_uniform() function.
>> Builds and seems to work OK on OpenBSD when applied to 4.7.0 version.
>
> Your patch got mangled somewhere along the way.  I think it might be the
> mailinglist software at nongnu.org that did that.  Please put patches in
> your mail as a separate attachment instead of inlining them.

I'll try to remember to use git format-patch attachments in the future.

> Cheers,
> Peter
> --
> http://sjamaan.ath.cx
> --
> "The process of preparing programs for a digital computer
>  is especially attractive, not only because it can be economically
>  and scientifically rewarding, but also because it can be an aesthetic
>  experience much like composing poetry or music."
>                                                        -- Donald Knuth
>
> _______________________________________________
> Chicken-hackers mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Timo



reply via email to

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