diff --git a/src/init.c b/src/init.c index df6d1eea..7348851e 100644 --- a/src/init.c +++ b/src/init.c @@ -115,8 +115,10 @@ mi_stats_t _mi_stats_main = { MI_STATS_NULL }; Initialization of random numbers ----------------------------------------------------------- */ -#ifdef _WIN32 +#if defined(_WIN32) #include +#elif defined(__APPLE__) +#include #else #include #endif @@ -145,10 +147,12 @@ uintptr_t _mi_random_init(uintptr_t seed /* can be zero */) { uintptr_t x = (uintptr_t)((void*)&_mi_random_init); x ^= seed; // xor with high res time -#ifdef _WIN32 +#if defined(_WIN32) LARGE_INTEGER pcount; QueryPerformanceCounter(&pcount); x ^= (uintptr_t)(pcount.QuadPart); +#elif defined(__APPLE__) + x ^= (uintptr_t)mach_absolute_time(); #else struct timespec time; clock_gettime(CLOCK_MONOTONIC, &time); @@ -156,7 +160,7 @@ uintptr_t _mi_random_init(uintptr_t seed /* can be zero */) { x ^= (uintptr_t)time.tv_nsec; #endif // and do a few randomization steps - uintptr_t max = ((x ^ (x >> 7)) & 0x0F) + 1; + uintptr_t max = ((x ^ (x >> 17)) & 0x0F) + 1; for (uintptr_t i = 0; i < max; i++) { x = _mi_random_shuffle(x); }