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 
30 #ifndef RANDOM_H
31 #define RANDOM_H
32 
33 #include <inttypes.h>
34 #include <stddef.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #ifndef RANDOM_SEED_DEFAULT
41 
45 #define RANDOM_SEED_DEFAULT (1)
46 #endif
47 
51 #ifndef PRNG_FLOAT
52 # define PRNG_FLOAT (0)
53 #endif
54 
64 void random_init(uint32_t s);
65 
75 void random_init_by_array(uint32_t init_key[], int key_length);
76 
81 uint32_t random_uint32(void);
82 
86 void random_bytes(uint8_t *buf, size_t size);
87 
98 uint32_t random_uint32_range(uint32_t a, uint32_t b);
99 
100 #if PRNG_FLOAT
101 /* These real versions are due to Isaku Wada, 2002/01/09 added */
102 
107 double random_real(void);
108 
113 double random_real_inclusive(void);
114 
119 double random_real_exclusive(void);
120 
125 double random_res53(void);
126 
127 #endif /* PRNG_FLOAT */
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* RANDOM_H */
134 
random_init_by_array
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...
random_init
void random_init(uint32_t s)
initializes PRNG with a seed
random_uint32_range
uint32_t random_uint32_range(uint32_t a, uint32_t b)
generates a random number r with a <= r < b.
random_uint32
uint32_t random_uint32(void)
generates a random number on [0,0xffffffff]-interval
random_bytes
void random_bytes(uint8_t *buf, size_t size)
writes random bytes in the [0,0xff]-interval to memory
inttypes.h
Adds include for missing inttype definitions.