X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/c7660385e5c91c48db526fabd9c7761c882b96aa..ae5cf9ed24d380cdc8c33239d92bb330438aefaa:/test/rng.c diff --git a/test/rng.c b/test/rng.c index d86b623..8ae2f13 100644 --- a/test/rng.c +++ b/test/rng.c @@ -1,23 +1,23 @@ /* - * Simple random number generator for testing. - * Copyright © 2022 Nick Bowler + * Simple random number generator for testing. + * Copyright © 2022 Nick Bowler * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * - * This implementation is adapted from xoshiro256+ and splitmix64 - * by David Blackman and Sebastiano Vigna, originally distributed - * under the Creative Commons Zero public domain dedication. + * The RNG implementation is adapted from xoshiro256+ and splitmix64 + * by David Blackman and Sebastiano Vigna, originally distributed under + * the Creative Commons Zero public domain dedication. */ #include @@ -46,16 +46,16 @@ static unsigned long long rot_left64(unsigned long long val, int n) static unsigned long long xoshiro256p(unsigned long long *s) { - unsigned long long ret = s[0]; - unsigned long long t; + unsigned long long tmp, ret; - t = B64(s[1] << 17); + ret = B64(s[0] + s[3]); + tmp = B64(s[1] << 17); s[2] ^= s[0]; s[3] ^= s[1]; s[1] ^= s[2]; s[0] ^= s[3]; - s[2] ^= t; + s[2] ^= tmp; s[3] = rot_left64(s[3], 45); return ret;