Macros | Functions
random.h File Reference

A PRNG library. More...

#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.


#define random_int()   ((int) random_int64())
 Get a random int. More...
#define random_uint()   ((unsigned) random_int64())
 Get a random unsigned int. More...
#define random_int32()   ((int32_t) random_int64())
 Get a random int32_t. More...


void random_init (void)
 Initialize the random number generator. More...
int64_t random_int64 (void)
 Get a random int64_t. More...
void random_array (void *m, size_t l)
 Insert random data into an array. More...
void random_hex (char *s, size_t l)
 Insert a random string in hexadecimal. More...

Detailed Description

A PRNG library.

Macro Definition Documentation

#define random_int ( )    ((int) random_int64())

Get a random int.

a random int.
#define random_uint ( )    ((unsigned) random_int64())

Get a random unsigned int.

a random unsigned int.
#define random_int32 ( )    ((int32_t) random_int64())

Get a random int32_t.

a random int32_t.

Function Documentation

void random_init ( void  )

Initialize the random number generator.

Uses system PRNG devices to seed the library PRNG.

int64_t random_int64 ( void  )

Get a random int64_t.

a random int64_t.
void random_array ( void *  m,
size_t  l 

Insert random data into an array.

mthe memory to fill.
lthe length of the m.
void random_hex ( char *  s,
size_t  l 

Insert a random string in hexadecimal.

sthe location in the string.
lthe number of characters to insert. Includes NUL byte!