]> git.draconx.ca Git - cdecl99.git/blobdiff - test/rng.c
Fix configuration on Solaris 8.
[cdecl99.git] / test / rng.c
index d86b623233ba88abfc069404ba149be5f1b5e62b..8ae2f1369cb812dff820e368ceab54d0e133ef17 100644 (file)
@@ -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 <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>
@@ -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;