MoarVM/MoarVM — pull request #119 by carbin (2014-07-26 16:03:58+00:00)
Title: use arc4random on platforms that support it

This fixes MVM_bigint_rand not being random on the various BSDs due to broken rand() implementations on those platforms

I have built and tested moar/rakudo on OpenBSD and FreeBSD with this patch applied, and have tested and confirmed that arc4random() is available out-of-the-box on NetBSD and DragonFlyBSD.

Before:

> say nqp::rand_I(2, Int) xx 40
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

> say (1..2).pick() xx 40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
a
> say (1..20).pick() xx 32 # no evens
17 15 13 15 1 11 5 15 13 11 1 3 5 19 5 15 5 3 1 19 17 19 17 7 1 11 9 3 9 19 13 7

After:

> say nqp::rand_I(2, Int) xx 40
1 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1

> say (1..2).pick() xx 40
1 1 1 2 2 1 1 1 2 1 1 2 1 2 1 2 2 1 1 2 1 1 2 2 2 2 2 2 2 2 2 1 2 1 2 2 1 1 1 2

> say (1..20).pick() xx 32
3 11 4 6 10 13 12 7 6 15 20 16 11 13 10 5 16 3 9 17 2 3 17 19 3 14 1 3 9 4 3 20