Subject: bug#57346: undeclared identifier 'CLOCK_MONOTONIC'

From: Gregory Heytings <[email-masked]>
Date: Tue, 23 Aug 2022 11:29:06 +0000

>> Right, the internet says OS X doesn't have clock_gettime.
>>
>> Does gnulib provide it?
>
> Not AFAICT.
>

It should be easy to emulate it with what Mac OS X/macOS provides, 
however:

int
clock_gettime (clockid_t ignored /* assuming CLOCK_MONOTONIC */,
                struct timespec *tp)
{
   clock_serv_t cs;
   mach_timespec_t mts;
   kern_return_t ret;
   host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &cs);
   ret = clock_get_time (cs, &mts);
   mach_port_deallocate(mach_task_self (), cs);
   if (ret) return ret;
   tp->tv_sec = mts.tv_sec;
   tp->tv_nsec = mts.tv_nsec;
}