diff options
Diffstat (limited to '05/musl-0.6.0/src/prng/rand.c')
-rw-r--r-- | 05/musl-0.6.0/src/prng/rand.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/05/musl-0.6.0/src/prng/rand.c b/05/musl-0.6.0/src/prng/rand.c new file mode 100644 index 0000000..e3ce634 --- /dev/null +++ b/05/musl-0.6.0/src/prng/rand.c @@ -0,0 +1,13 @@ +#include <stdlib.h> + +static unsigned seed; + +void srand(unsigned s) +{ + seed = s-1; +} + +int rand(void) +{ + return (seed = (seed+1) * 1103515245 + 12345 - 1)+1 & 0x7fffffff; +} |