mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-09 01:01:11 +08:00
use CLOCK_BOOTTIME when available.
Signed-off-by: Tobias Assarsson <tobias.assarsson@gmail.com>
This commit is contained in:
parent
a6347cd7d2
commit
2e2a420099
@ -61,8 +61,11 @@ int mosquitto_lib_init(void)
|
||||
srand((unsigned int)GetTickCount64());
|
||||
#elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
#ifdef CLOCK_BOOTTIME
|
||||
clock_gettime(CLOCK_BOOTTIME, &tp);
|
||||
#else
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
#endif
|
||||
srand((unsigned int)tp.tv_nsec);
|
||||
#elif defined(__APPLE__)
|
||||
uint64_t ticks;
|
||||
|
@ -43,7 +43,11 @@ time_t mosquitto_time(void)
|
||||
#elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK)
|
||||
struct timespec tp;
|
||||
|
||||
#ifdef CLOCK_BOOTTIME
|
||||
clock_gettime(CLOCK_BOOTTIME, &tp);
|
||||
#else
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
#endif
|
||||
return tp.tv_sec;
|
||||
#elif defined(__APPLE__)
|
||||
static mach_timebase_info_data_t tb;
|
||||
|
Loading…
x
Reference in New Issue
Block a user