random.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 
27 #ifndef RANDOM_H
28 #define RANDOM_H
29 
30 #include <inttypes.h>
31 #include <stddef.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef RANDOM_SEED_DEFAULT
38 
42 #define RANDOM_SEED_DEFAULT (1)
43 #endif
44 
48 #ifndef PRNG_FLOAT
49 # define PRNG_FLOAT (0)
50 #endif
51 
61 void random_init(uint32_t s);
62 
72 void random_init_by_array(uint32_t init_key[], int key_length);
73 
78 uint32_t random_uint32(void);
79 
83 void random_bytes(uint8_t *buf, size_t size);
84 
95 uint32_t random_uint32_range(uint32_t a, uint32_t b);
96 
97 #if PRNG_FLOAT
98 /* These real versions are due to Isaku Wada, 2002/01/09 added */
99 
104 double random_real(void);
105 
110 double random_real_inclusive(void);
111 
116 double random_real_exclusive(void);
117 
122 double random_res53(void);
123 
124 #endif /* PRNG_FLOAT */
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* RANDOM_H */
131 
void random_init_by_array(uint32_t init_key[], int key_length)
initialize by an array with array-length init_key is the array for initializing keys key_length is it...
void random_init(uint32_t s)
initializes PRNG with a seed
uint32_t random_uint32(void)
generates a random number on [0,0xffffffff]-interval
void random_bytes(uint8_t *buf, size_t size)
writes random bytes in the [0,0xff]-interval to memory
uint32_t random_uint32_range(uint32_t a, uint32_t b)
generates a random number r with a <= r < b.