]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix VG_(read_millisecond_timer) on Darwin. Fixes bug 200990.
authorNicholas Nethercote <njn@valgrind.org>
Wed, 22 Jul 2009 02:52:14 +0000 (02:52 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Wed, 22 Jul 2009 02:52:14 +0000 (02:52 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10516

coregrind/m_libcproc.c

index 8269369a29fece0d32e791369c332a0a8c1aeed0..a01b2554f812578884d8f3f3edc5bb3648bdc6bc 100644 (file)
@@ -630,11 +630,15 @@ UInt VG_(read_millisecond_timer) ( void )
    now += (ULong)(nsec / 1000);
 
 #  elif defined(VGO_darwin)
+   // Weird: it seems that gettimeofday() doesn't fill in the timeval, but
+   // rather returns the tv_sec as the low 32 bits of the result and the
+   // tv_usec as the high 32 bits of the result.  (But the timeval cannot be
+   // NULL!)  See bug 200990.
    { SysRes res;
      struct vki_timeval tv_now = { 0, 0 };
      res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)&tv_now, (UWord)NULL);
      vg_assert(! sr_isError(res));
-     now = tv_now.tv_sec * 1000000ULL + tv_now.tv_usec;
+     now = sr_Res(res) * 1000000ULL + sr_ResHI(res);
    }
 
 #  else