Merge 1a51cd1ac5 into merged_master (Bitcoin PR #17800)

This commit is contained in:
Andrew Poelstra 2020-11-26 01:07:47 +00:00
commit 862b02f20b

View file

@ -237,8 +237,6 @@ void RandAddDynamicEnv(CSHA512& hasher)
GetSystemTimeAsFileTime(&ftime);
hasher << ftime;
#else
# ifndef __MACH__
// On non-MacOS systems, use various clock_gettime() calls.
struct timespec ts = {};
# ifdef CLOCK_MONOTONIC
clock_gettime(CLOCK_MONOTONIC, &ts);
@ -252,18 +250,6 @@ void RandAddDynamicEnv(CSHA512& hasher)
clock_gettime(CLOCK_BOOTTIME, &ts);
hasher << ts;
# endif
# else
// On MacOS use mach_absolute_time (number of CPU ticks since boot) as a replacement for CLOCK_MONOTONIC,
// and clock_get_time for CALENDAR_CLOCK as a replacement for CLOCK_REALTIME.
hasher << mach_absolute_time();
// From https://gist.github.com/jbenet/1087739
clock_serv_t cclock;
mach_timespec_t mts = {};
if (host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock) == KERN_SUCCESS && clock_get_time(cclock, &mts) == KERN_SUCCESS) {
hasher << mts;
mach_port_deallocate(mach_task_self(), cclock);
}
# endif
// gettimeofday is available on all UNIX systems, but only has microsecond precision.
struct timeval tv = {};
gettimeofday(&tv, nullptr);