The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/module/zfs/vdev_draid_rand.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Xorshift Pseudo Random Number Generator based on work by David Blackman
    3  * and Sebastiano Vigna (vigna@acm.org).
    4  *
    5  *   "Further scramblings of Marsaglia's xorshift generators"
    6  *   http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
    7  *   http://prng.di.unimi.it/xoroshiro128plusplus.c
    8  *
    9  * To the extent possible under law, the author has dedicated all copyright
   10  * and related and neighboring rights to this software to the public domain
   11  * worldwide. This software is distributed without any warranty.
   12  *
   13  * See <http://creativecommons.org/publicdomain/zero/1.0/>.
   14  *
   15  * This is xoroshiro128++ 1.0, one of our all-purpose, rock-solid,
   16  * small-state generators. It is extremely (sub-ns) fast and it passes all
   17  * tests we are aware of, but its state space is large enough only for
   18  * mild parallelism.
   19  */
   20 
   21 #include <sys/vdev_draid.h>
   22 
   23 static inline uint64_t rotl(const uint64_t x, int k)
   24 {
   25         return (x << k) | (x >> (64 - k));
   26 }
   27 
   28 uint64_t
   29 vdev_draid_rand(uint64_t *s)
   30 {
   31         const uint64_t s0 = s[0];
   32         uint64_t s1 = s[1];
   33         const uint64_t result = rotl(s0 + s1, 17) + s0;
   34 
   35         s1 ^= s0;
   36         s[0] = rotl(s0, 49) ^ s1 ^ (s1 << 21); // a, b
   37         s[1] = rotl(s1, 28); // c
   38 
   39         return (result);
   40 }

Cache object: 4d60562289003e8d7fbb2ed7d2fd9df8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.