diff --git a/src/random_seed.c b/src/random_seed.c index be9db0d..1255938 100644 --- a/src/random_seed.c +++ b/src/random_seed.c @@ -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