From f651941402079052fbdabf64092e7dd4a6a8cafe Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 17 Aug 1999 20:47:40 +0000 Subject: Added a function for generating 32-bit random numbers. --- sysdep/unix/io.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sysdep') diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 5104664..fef1bd7 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -34,6 +34,20 @@ #include "lib/unix.h" +/* + * Random Numbers + */ + +u32 +random_u32(void) +{ + long int rand_low, rand_high; + + rand_low = random(); + rand_high = random(); + return (rand_low & 0xffff) | ((rand_high & 0xffff) << 16); +} + /* * Timers */ @@ -823,6 +837,7 @@ io_init(void) init_list(&global_event_list); krt_io_init(); now = time(NULL); + srandom((int) now); } void -- cgit v1.2.3