> I'll look into hack tonight when I have more time.
Honestly, I would prefer to leave hack as it is right now since it will
take some work to repair it anyway. I would not want to add another
layer of (potential) complications.
> > > Index: lib/libc/stdlib/rand.c
> > > ===================================================================
> It's safe but takes a bit of thinking. I first had it as
> return (arc4random() & RAND_MAX);
> which to me is more obviously correct, but since it's safe as is. I have
> no strong opinion on this.
I have a mild preference for this version, and I think this version
would be preferable from the point of view of uniformity of usage,
especially after your patches have gone in.
> > > Index: usr.bin/awk/run.c
> > > ===================================================================
> >
> > Unsure about this one. I think deterministic sequences might be desired
> > in some circumstances (this one is deterministic when a seed was given).
>
> theo@ also pointed out that awk can be deterministic. Since RAND_MAX is
> 1 below a power of 2, & is safe. How about
>
> Index: run.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/awk/run.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 run.c
> --- run.c 5 Sep 2015 22:07:10 -0000 1.39
> +++ run.c 7 Dec 2015 19:28:31 -0000
> @@ -1581,7 +1581,7 @@ Cell *bltin(Node **a, int n) /* builtin
> u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */
> break;
> case FRAND:
> - u = (Awkfloat) (random() % RAND_MAX) / RAND_MAX;
> + u = (Awkfloat) (random() & RAND_MAX) / ((u_int)RAND_MAX + 1);
> break;
> case FSRAND:
> if (isrec(x)) { /* no argument provided */
>
ok from me on this one.