Merge branch 'master' of gitlab.ops-class.org:staff/os161
This commit is contained in:
commit
5a48788226
@ -40,6 +40,8 @@ static int buf_num = 0;
|
|||||||
|
|
||||||
#ifndef _KERNEL
|
#ifndef _KERNEL
|
||||||
static int did_random = 0;
|
static int did_random = 0;
|
||||||
|
#define NSEC_PER_MSEC 1000000ULL
|
||||||
|
#define MSEC_PER_SEC 1000ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void * _alloc(size_t size)
|
static void * _alloc(size_t size)
|
||||||
@ -143,9 +145,14 @@ static void make_salt(char *salt_str)
|
|||||||
#ifndef _KERNEL
|
#ifndef _KERNEL
|
||||||
if (!did_random) {
|
if (!did_random) {
|
||||||
did_random = 1;
|
did_random = 1;
|
||||||
time_t t;
|
time_t sec;
|
||||||
time(&t);
|
unsigned long ns;
|
||||||
srandom(t);
|
unsigned long long ms;
|
||||||
|
|
||||||
|
__time(&sec, &ns);
|
||||||
|
ms = (unsigned long long)sec * MSEC_PER_SEC;
|
||||||
|
ms += (ns / NSEC_PER_MSEC);
|
||||||
|
srandom((unsigned long)ms);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user