title: Does gettimeofday() on macOS use a system call?
body: <p>I expect that <code>gettimeofday()</code> will call a system call to do the work of actually getting the time. However, running the following program</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(int argc, char const *argv[])
  {
      struct timeval tv;
  
      printf("Before gettimeofday() %ld!\n", tv.tv_sec);
  
      int rc = gettimeofday(&amp;tv, NULL);
  
      printf("After gettimeofday() %ld\n", tv.tv_sec);
  
      if (rc == -1) {
          printf("Error: gettimeofday() failed\n");
          exit(1);
      }
  
      printf("Exiting ! %ld\n", tv.tv_sec);
      return 0;
  }
  </code></pre>
  
  <p>under <code>dtruss -d</code> returns a long list of system calls, the last of which are:</p>
  
  <pre><code>RELATIVE SYSCALL(args)           = return
  
  ... lots of syscalls with earlier timestamps ...
  
      3866 fstat64(0x1, 0x7FFF56ABC8D8, 0x11)      = 0 0
      3868 ioctl(0x1, 0x4004667A, 0x7FFF56ABC91C)      = 0 0
      3882 write_nocancel(0x1, "Before gettimeofday() 0!\n\0", 0x19)       = 25 0
      3886 write_nocancel(0x1, "After gettimeofday() 1480913810\n\0", 0x20)        = 32 0
      3887 write_nocancel(0x1, "Exiting ! 1480913810\n\0", 0x15)       = 21 0
  </code></pre>
  
  <p>It looks like <code>gettimeofday()</code> isn't using a syscall, but this seems wrong-surely the kernel takes responsibility of the system clocks? Is <code>dtruss</code> missing something? Am I reading the output incorrectly?</p>