diff options
-rw-r--r-- | lib/birdlib.h | 4 | ||||
-rw-r--r-- | sysdep/unix/io.c | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h index b57478d..93ac38e 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -63,4 +63,8 @@ void debug(char *msg, ...); /* Printf to debug output */ #define ASSERT(x) do { } while(0) #endif +/* Pseudorandom numbers */ + +u32 random_u32(void); + #endif 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 @@ -35,6 +35,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 |