summaryrefslogtreecommitdiffstats
path: root/src/isaac_rand/isaac64.h
blob: e2ab55b3311cf3ee0d8ea22f1bcd52ae4fed758c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
------------------------------------------------------------------------------
isaac64.h: definitions for a random number generator
Bob Jenkins, 1996, Public Domain
------------------------------------------------------------------------------
*/
#ifndef ISAAC64
#define ISAAC64

#include "isaac_standard.h"

struct rand64ctx
{
 ub8 randrsl[RANDSIZ], randcnt;
 ub8 mm[RANDSIZ];
 ub8 aa, bb, cc;
};
typedef struct rand64ctx rand64ctx;

/*
------------------------------------------------------------------------------
 If (flag==TRUE), then use the contents of randrsl[0..255] as the seed.
------------------------------------------------------------------------------
*/
void rand64init(rand64ctx *r, word flag);

void isaac64(rand64ctx *ctx);


/*
------------------------------------------------------------------------------
 Call rand64() to retrieve a single 64-bit random value
------------------------------------------------------------------------------
*/
#define isaac64_rand() \
   (!(r)->randcnt-- ? \
     (isaac64(r), (r)->randcnt=RANDSIZ-1, (r)->randrsl[(r)->>randcnt]) : \
     (r)->randrsl[(r)->randcnt])

#endif  /* ISAAC64 */