LCOV - code coverage report
Current view: top level - src - random.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 4 4 100.0 %
Date: 2015-10-12 22:39:14 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2014 The Bitcoin Core developers
       3             : // Distributed under the MIT software license, see the accompanying
       4             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5             : 
       6             : #ifndef BITCOIN_RANDOM_H
       7             : #define BITCOIN_RANDOM_H
       8             : 
       9             : #include "uint256.h"
      10             : 
      11             : #include <stdint.h>
      12             : 
      13             : /**
      14             :  * Seed OpenSSL PRNG with additional entropy data
      15             :  */
      16             : void RandAddSeed();
      17             : void RandAddSeedPerfmon();
      18             : 
      19             : /**
      20             :  * Functions to gather random data via the OpenSSL PRNG
      21             :  */
      22             : void GetRandBytes(unsigned char* buf, int num);
      23             : uint64_t GetRand(uint64_t nMax);
      24             : int GetRandInt(int nMax);
      25             : uint256 GetRandHash();
      26             : 
      27             : /**
      28             :  * Seed insecure_rand using the random pool.
      29             :  * @param Deterministic Use a deterministic seed
      30             :  */
      31             : void seed_insecure_rand(bool fDeterministic = false);
      32             : 
      33             : /**
      34             :  * MWC RNG of George Marsaglia
      35             :  * This is intended to be fast. It has a period of 2^59.3, though the
      36             :  * least significant 16 bits only have a period of about 2^30.1.
      37             :  *
      38             :  * @return random value
      39             :  */
      40             : extern uint32_t insecure_rand_Rz;
      41             : extern uint32_t insecure_rand_Rw;
      42     8345531 : static inline uint32_t insecure_rand(void)
      43             : {
      44     8345531 :     insecure_rand_Rz = 36969 * (insecure_rand_Rz & 65535) + (insecure_rand_Rz >> 16);
      45     8345531 :     insecure_rand_Rw = 18000 * (insecure_rand_Rw & 65535) + (insecure_rand_Rw >> 16);
      46     8345531 :     return (insecure_rand_Rw << 16) + insecure_rand_Rz;
      47             : }
      48             : 
      49             : #endif // BITCOIN_RANDOM_H

Generated by: LCOV version 1.11