1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-12-28 16:10:58 +05:30

random_seed.c: do not define struct timespec ts twice

This commit is contained in:
Intel A80486DX2-66 2024-07-07 01:19:18 +03:00
parent 4a0a2d0f96
commit 4cdc125fef
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -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