Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Mach kernel provides access to system clocks, out of which at least one (<code>SYSTEM_CLOCK</code>) is <a href="https://opensource.apple.com/source/xnu/xnu-2422.1.72/osfmk/mach/clock_types.h">advertised by the documentation</a> as being monotonically incrementing.</p> <pre><code>#include &lt;mach/clock.h&gt; #include &lt;mach/mach.h&gt; clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &amp;cclock); clock_get_time(cclock, &amp;mts); mach_port_deallocate(mach_task_self(), cclock); </code></pre> <p><code>mach_timespec_t</code> has nanosecond precision. I'm not sure about the accuracy, though.</p> <p>Mac OS X supports three clocks:</p> <ul> <li><code>SYSTEM_CLOCK</code> returns the time since boot time;</li> <li><code>CALENDAR_CLOCK</code> returns the UTC time since 1970-01-01;</li> <li><code>REALTIME_CLOCK</code> is deprecated and is the same as <code>SYSTEM_CLOCK</code> in its current implementation.</li> </ul> <p>The <a href="https://opensource.apple.com/source/xnu/xnu-2422.1.72/osfmk/man/clock_get_time.html">documentation for <code>clock_get_time</code></a> says the clocks are monotonically incrementing unless someone calls <code>clock_set_time</code>. Calls to <code>clock_set_time</code> are <a href="https://opensource.apple.com/source/xnu/xnu-2422.1.72/osfmk/man/clock_set_time.html">discouraged</a> as it could break the monotonic property of the clocks, and in fact, <a href="https://opensource.apple.com/source/xnu/xnu-2422.1.72/osfmk/kern/clock_oldops.c">the current implementation returns <code>KERN_FAILURE</code></a> without doing anything.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload