]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added a function for generating 32-bit random numbers.
authorMartin Mares <mj@ucw.cz>
Tue, 17 Aug 1999 20:47:40 +0000 (20:47 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 17 Aug 1999 20:47:40 +0000 (20:47 +0000)
lib/birdlib.h
sysdep/unix/io.c

index b57478df22532d9ccffd5f3802f3aeae9257431d..93ac38ef34bbadf3b88cf582b43c5eecd72173ee 100644 (file)
@@ -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
index 51046645ba6f0e8f52017cf3b5bfb109256ad51b..fef1bd7635f408414e57819c6f6e5b57c55bcd1a 100644 (file)
 
 #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