Debian Codegraph @

lib/table_rn.c

raw symbols SCIP
1 /* The Ace of Penguins - table-rn.c
2 Copyright (C) 1998 DJ Delorie
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 /* Not all platforms do these right, so supply our own */
19
20 #include <time.h>
21
22 static unsigned long long next = 0;
23 static int initialized = 0;
24
25 int
26 rand(void)
27 {
28 if (! initialized)
29 {
30 time((time_t *)&next);
31 initialized = 1;
32 }
33 next = next * 0x5deece66dLL + 11;
34 return (int)((next >> 16) & 0x7fffffff);
35 }
36
37 void
38 srand(unsigned seed)
39 {
40 next = seed;
41 }