|
From: <sv...@va...> - 2009-07-22 02:52:46
|
Author: njn
Date: 2009-07-22 03:52:14 +0100 (Wed, 22 Jul 2009)
New Revision: 10516
Log:
Fix VG_(read_millisecond_timer) on Darwin. Fixes bug 200990.
Modified:
trunk/coregrind/m_libcproc.c
Modified: trunk/coregrind/m_libcproc.c
===================================================================
--- trunk/coregrind/m_libcproc.c 2009-07-21 17:47:30 UTC (rev 10515)
+++ trunk/coregrind/m_libcproc.c 2009-07-22 02:52:14 UTC (rev 10516)
@@ -630,11 +630,15 @@
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
|