The friendly Operating System for the Internet of Things
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 
26 #ifndef RANDOM_H
27 #define RANDOM_H
28 
29 #include <inttypes.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 #ifndef PRNG_FLOAT
39 # define PRNG_FLOAT (0)
40 #endif
41 
51 void random_init(uint32_t s);
52 
62 void random_init_by_array(uint32_t init_key[], int key_length);
63 
68 uint32_t random_uint32(void);
69 
80 static inline uint32_t random_uint32_range(uint32_t a, uint32_t b)
81 {
82  return (random_uint32() % (b - a)) + a;
83 }
84 
85 #if PRNG_FLOAT
86 /* These real versions are due to Isaku Wada, 2002/01/09 added */
87 
92 double random_real(void);
93 
98 double random_real_inclusive(void);
99 
104 double random_real_exclusive(void);
105 
110 double random_res53(void);
111 
112 #endif /* PRNG_FLOAT */
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* RANDOM_H */
119 
static uint32_t random_uint32_range(uint32_t a, uint32_t b)
generates a random number r with a <= r < b.
Definition: random.h:80
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...
Adds include for missing inttype definitions.
void random_init(uint32_t s)
initializes PRNG with a seed
uint32_t random_uint32(void)
generates a random number on [0,0xffffffff]-interval