/*
- * 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 <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- * 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 <config.h>
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;