mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-11-08 13:42:31 +05:30
random_seed.c: do not define struct timespec ts
twice
This commit is contained in:
parent
4a0a2d0f96
commit
4cdc125fef
@ -4,8 +4,11 @@
|
||||
uint32_t mt_generate_random_seed(void) {
|
||||
uint32_t seed = (uint32_t) time(NULL);
|
||||
|
||||
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
|
||||
#if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)) || defined(SYS_LINUX)
|
||||
struct timespec ts;
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
seed ^= (uint32_t) ts.tv_nsec;
|
||||
#endif
|
||||
@ -27,7 +30,6 @@ uint32_t mt_generate_random_seed(void) {
|
||||
sysctlbyname("kern.boottime", &uptime_usec, &len, NULL, 0);
|
||||
seed ^= (uint32_t) ((uptime_usec / 1000) & 0xFFFFFFFF);
|
||||
#elif defined(SYS_LINUX)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_BOOTTIME, &ts);
|
||||
seed ^= (uint32_t) ((ts.tv_sec * 1000 + ts.tv_nsec / 1000000) & 0xFFFFFFFF);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user