Added a function for generating 32-bit random numbers.
This commit is contained in:
parent
b332fcdfc8
commit
f651941402
2 changed files with 19 additions and 0 deletions
|
@ -63,4 +63,8 @@ void debug(char *msg, ...); /* Printf to debug output */
|
||||||
#define ASSERT(x) do { } while(0)
|
#define ASSERT(x) do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Pseudorandom numbers */
|
||||||
|
|
||||||
|
u32 random_u32(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,20 @@
|
||||||
|
|
||||||
#include "lib/unix.h"
|
#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
|
* Timers
|
||||||
*/
|
*/
|
||||||
|
@ -823,6 +837,7 @@ io_init(void)
|
||||||
init_list(&global_event_list);
|
init_list(&global_event_list);
|
||||||
krt_io_init();
|
krt_io_init();
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
srandom((int) now);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue