Rev 1619 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Project: OSLib |
2 | * Description: The OS Construction Kit |
||
3 | * Date: 1.6.2000 |
||
4 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
5 | * |
||
6 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
7 | * low-level infrastructure for developing OS kernels and Embedded |
||
8 | * Applications; it partially derives from the HARTIK project but it |
||
9 | * currently is independently developed. |
||
10 | * |
||
11 | * OSLib is distributed under GPL License, and some of its code has |
||
12 | * been derived from the Linux kernel source; also some important |
||
13 | * ideas come from studying the DJGPP go32 extender. |
||
14 | * |
||
15 | * We acknowledge the Linux Community, Free Software Foundation, |
||
16 | * D.J. Delorie and all the other developers who believe in the |
||
17 | * freedom of software and ideas. |
||
18 | * |
||
19 | * For legalese, check out the included GPL license. |
||
20 | */ |
||
21 | |||
1621 | fabio | 22 | #include <arch/i386/stdlib.h> |
23 | #include <arch/math.h> |
||
2 | pj | 24 | |
25 | FILE(random); |
||
26 | |||
27 | #define MODULUS 2147483647L |
||
28 | #define FACTOR 16807L |
||
29 | #define DIVISOR 127773L |
||
30 | #define REMAINDER 2836L |
||
31 | static long int last_val; |
||
32 | |||
33 | long int rand(void) |
||
34 | { |
||
35 | long int last_div = last_val / DIVISOR; |
||
36 | long int last_rem = last_val % DIVISOR; |
||
37 | last_val = (FACTOR * last_rem) - (REMAINDER * last_div); |
||
38 | if (last_val < 0) last_val += MODULUS; |
||
39 | return(last_val); |
||
40 | } |
||
41 | |||
42 | void srand(long int seed) |
||
43 | { |
||
44 | last_val = seed; |
||
45 | } |
||
46 |