src/lib/w32/random.c File Reference

#include "random.h"
#include "w32misc.h"

Include dependency graph for random.c:

Go to the source code of this file.

Defines

#define TYPE_0   0
#define BREAK_0   8
#define DEG_0   0
#define SEP_0   0
#define TYPE_1   1
#define BREAK_1   32
#define DEG_1   7
#define SEP_1   3
#define TYPE_2   2
#define BREAK_2   64
#define DEG_2   15
#define SEP_2   1
#define TYPE_3   3
#define BREAK_3   128
#define DEG_3   31
#define SEP_3   3
#define TYPE_4   4
#define BREAK_4   256
#define DEG_4   63
#define SEP_4   1
#define MAX_TYPES   5

Functions

void __srandom (unsigned int x)
char * __initstate (unsigned int seed, char *arg_state, size_t n)
char * __setstate (char *arg_state)
long int __random ()

Variables

static int32_t randtbl [31+1]
static struct random_data unsafe_state


Define Documentation

#define BREAK_0   8

Definition at line 113 of file random.c.

Referenced by __initstate_r().

#define BREAK_1   32

Definition at line 119 of file random.c.

Referenced by __initstate_r().

#define BREAK_2   64

Definition at line 125 of file random.c.

Referenced by __initstate_r().

#define BREAK_3   128

Definition at line 131 of file random.c.

Referenced by __initstate_r().

#define BREAK_4   256

Definition at line 137 of file random.c.

Referenced by __initstate_r().

#define DEG_0   0

Definition at line 114 of file random.c.

#define DEG_1   7

Definition at line 120 of file random.c.

#define DEG_2   15

Definition at line 126 of file random.c.

#define DEG_3   31

Definition at line 132 of file random.c.

#define DEG_4   63

Definition at line 138 of file random.c.

#define MAX_TYPES   5

Definition at line 145 of file random.c.

Referenced by __initstate_r(), __setstate_r(), and __srandom_r().

#define SEP_0   0

Definition at line 115 of file random.c.

#define SEP_1   3

Definition at line 121 of file random.c.

#define SEP_2   1

Definition at line 127 of file random.c.

#define SEP_3   3

Definition at line 133 of file random.c.

#define SEP_4   1

Definition at line 139 of file random.c.

#define TYPE_0   0

Definition at line 112 of file random.c.

Referenced by __initstate_r(), __random_r(), __setstate_r(), and __srandom_r().

#define TYPE_1   1

Definition at line 118 of file random.c.

Referenced by __initstate_r().

#define TYPE_2   2

Definition at line 124 of file random.c.

Referenced by __initstate_r().

#define TYPE_3   3

Definition at line 130 of file random.c.

Referenced by __initstate_r().

#define TYPE_4   4

Definition at line 136 of file random.c.

Referenced by __initstate_r(), and __setstate_r().


Function Documentation

char* __initstate ( unsigned int  seed,
char *  arg_state,
size_t  n 
)

Definition at line 241 of file random.c.

References __initstate_r(), __libc_lock_lock, __libc_lock_unlock, random_data::state, and unsafe_state.

00245 {
00246   int32_t *ostate;
00247 
00248   __libc_lock_lock (lock);
00249 
00250   ostate = &unsafe_state.state[-1];
00251 
00252   __initstate_r (seed, arg_state, n, &unsafe_state);
00253 
00254   __libc_lock_unlock (lock);
00255 
00256   return (char *) ostate;
00257 }

Here is the call graph for this function:

long int __random ( void   ) 

Definition at line 301 of file random.c.

References __libc_lock_lock, __libc_lock_unlock, __random_r(), and unsafe_state.

00302 {
00303   int32_t retval;
00304 
00305   __libc_lock_lock (lock);
00306 
00307   (void) __random_r (&unsafe_state, &retval);
00308 
00309   __libc_lock_unlock (lock);
00310 
00311   return retval;
00312 }

Here is the call graph for this function:

char* __setstate ( char *  arg_state  ) 

Definition at line 270 of file random.c.

References __libc_lock_lock, __libc_lock_unlock, __setstate_r(), NULL, random_data::state, and unsafe_state.

00272 {
00273   int32_t *ostate;
00274 
00275   __libc_lock_lock (lock);
00276 
00277   ostate = &unsafe_state.state[-1];
00278 
00279   if (__setstate_r (arg_state, &unsafe_state) < 0)
00280     ostate = NULL;
00281 
00282   __libc_lock_unlock (lock);
00283 
00284   return (char *) ostate;
00285 }

Here is the call graph for this function:

void __srandom ( unsigned int  x  ) 

Definition at line 218 of file random.c.

References __libc_lock_lock, __libc_lock_unlock, __srandom_r(), and unsafe_state.

00220 {
00221   __libc_lock_lock (lock);
00222   (void) __srandom_r (x, &unsafe_state);
00223   __libc_lock_unlock (lock);
00224 }

Here is the call graph for this function:


Variable Documentation

int32_t randtbl[31+1] [static]

Initial value:

  {
     3 ,

    -1726662223, 379960547, 1735697613, 1040273694, 1313901226,
    1627687941, -179304937, -2073333483, 1780058412, -1989503057,
    -615974602, 344556628, 939512070, -1249116260, 1507946756,
    -812545463, 154635395, 1388815473, -1926676823, 525320961,
    -1009028674, 968117788, -123449607, 1284210865, 435012392,
    -2017506339, -911064859, -370259173, 1132637927, 1398500161,
    -205601318,
  }

Definition at line 157 of file random.c.

struct random_data unsafe_state [static]

Initial value:

  {


 &randtbl[SEP_3 + 1],
 &randtbl[1],


 &randtbl[1],

 TYPE_3,
 DEG_3,
 SEP_3,

 &randtbl[sizeof (randtbl) / sizeof (randtbl[0])]
}

Definition at line 171 of file random.c.

Referenced by __initstate(), __random(), __setstate(), and __srandom().


Generated on Fri Mar 28 11:01:56 2008 for empserver by  doxygen 1.5.2