clock_gettime on MacOS

I often run into the issue of the lack of clock_gettime(CLOCK_MONOTONIC,...) on MacOS prior to OS X 10.12 Sierra when porting software to the Mac. (And the version in Sierra is not so hot; it's limited to microsecond resolution rather than nanosecond resolution, so I read on the net.) I usually depend on a DuckDuckGo search to find the canonical answer, but today I noticed that the top hits are mostly wrong and don't even include a link to the canonical solution.

So, I'm including a link to the solution here, so I can find it the next time I need it. The answer is in Apple Technical Q&A QA1398.

© Steve Byan 2011-2019