]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/lib/src/rand.c
f434d85c164414977e4f713a8164fa9145987644
[l4.git] / l4 / pkg / l4util / lib / src / rand.c
1 /*
2  * (c) 2008-2009 Frank Mehnert <fm3@os.inf.tu-dresden.de>,
3  *               Michael Hohmuth <hohmuth@os.inf.tu-dresden.de>,
4  *               Lars Reuther <reuther@os.inf.tu-dresden.de>
5  *     economic rights: Technische Universität Dresden (Germany)
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU Lesser General Public License 2.1.
8  * Please see the COPYING-LGPL-2.1 file for details.
9  */
10 /*
11  */
12
13 /*****************************************************************************
14  * random.c                                                                  *
15  * pseudo-random number generator                                            *
16  *****************************************************************************/
17
18 #include <l4/util/rand.h>
19
20 static unsigned int l4_rand_next = 1;
21
22 l4_uint32_t
23 l4util_rand(void)
24 {
25   l4_rand_next = l4_rand_next * 1103515245 + 12345;
26   return ((l4_rand_next >>16) & L4_RAND_MAX);
27 }
28
29 void
30 l4util_srand (l4_uint32_t seed)
31 {
32   l4_rand_next = seed;
33 }
34