Skip to content

Commit dc9305b

Browse files
committed
random: don't special case clock usage on macOS
clock_gettime(), CLOCK_MONOTONIC and CLOCK_REALTIME are all available for use on macOS (now that we require macOS >=10.12). Use them rather than the deprecated mach_timespec_t time API. master: 2019-12-23T20:49:43Z Feeding 216 bytes of dynamic environment data into RNG 2019-12-23T20:50:43Z Feeding 216 bytes of dynamic environment data into RNG this commit: 2019-12-23T20:32:41Z Feeding 232 bytes of dynamic environment data into RNG 2019-12-23T20:33:42Z Feeding 232 bytes of dynamic environment data into RNG
1 parent 8a56f79 commit dc9305b

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/randomenv.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ void RandAddDynamicEnv(CSHA512& hasher)
237237
GetSystemTimeAsFileTime(&ftime);
238238
hasher << ftime;
239239
#else
240-
# ifndef __MACH__
241-
// On non-MacOS systems, use various clock_gettime() calls.
242240
struct timespec ts = {};
243241
# ifdef CLOCK_MONOTONIC
244242
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -252,18 +250,6 @@ void RandAddDynamicEnv(CSHA512& hasher)
252250
clock_gettime(CLOCK_BOOTTIME, &ts);
253251
hasher << ts;
254252
# endif
255-
# else
256-
// On MacOS use mach_absolute_time (number of CPU ticks since boot) as a replacement for CLOCK_MONOTONIC,
257-
// and clock_get_time for CALENDAR_CLOCK as a replacement for CLOCK_REALTIME.
258-
hasher << mach_absolute_time();
259-
// From https://gist.github.com/jbenet/1087739
260-
clock_serv_t cclock;
261-
mach_timespec_t mts = {};
262-
if (host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock) == KERN_SUCCESS && clock_get_time(cclock, &mts) == KERN_SUCCESS) {
263-
hasher << mts;
264-
mach_port_deallocate(mach_task_self(), cclock);
265-
}
266-
# endif
267253
// gettimeofday is available on all UNIX systems, but only has microsecond precision.
268254
struct timeval tv = {};
269255
gettimeofday(&tv, nullptr);

0 commit comments

Comments
 (0)