On Fri, 27 Feb 2015 02:56:59 +0000 (UTC) Warner Losh <i...@freebsd.org> wrote: ... > /* > + * We need some randomness. Implement the classic Linear Congruential > + * generator X_{n+1}=(aX_n+c) mod m. These values are optimized for > + * m = 2^32, a = 69069 and c = 5. This is signed so that we can get > + * both positive and negative values from it by shifting the value > + * right. > + */ > +static int sched_random() > +{ > + int rnd, *rndptr; > + rndptr = DPCPU_PTR(randomval); > + rnd = *rndptr * 69069 + 5; > + *rndptr = rnd; > + return(rnd); > +}
Didn't we recently have issues with signed integer overflow being undefined? Even though we worked around it with a compiler flag it would be better to not rely on undefined behaviour in the first place. Andrew _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"