|
From: Paul F. <pa...@so...> - 2025-12-11 08:06:46
|
https://sourceware.org/cgit/valgrind/commit/?id=ef6b8d841b6fe79ba1d8475d2798e22540e8e7b9 commit ef6b8d841b6fe79ba1d8475d2798e22540e8e7b9 Author: Paul Floyd <pj...@wa...> Date: Thu Dec 11 09:03:08 2025 +0100 Darwin libcproc: fix for VG_(read_millisecond_timer) This function had some peculiar workaround for how the result was handled. That peculiarity seems to have gone away (some time before Darwin 17). Now use 'normal' handling for the result for Darwin 17+. This was causing some DRD timed mutex testcases to fail. Code copied from Louis Brunner. Diff: --- coregrind/m_libcproc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index 7c4d6acc9d..4c4b96eefb 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -1052,7 +1052,15 @@ UInt VG_(read_millisecond_timer) ( void ) struct vki_timeval tv_now = { 0, 0 }; res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)&tv_now, (UWord)NULL); vg_assert(! sr_isError(res)); +# if DARWIN_VERS >= DARWIN_10_13 + now = tv_now.tv_sec * 1000000ULL + tv_now.tv_usec; +# else + // 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. now = sr_Res(res) * 1000000ULL + sr_ResHI(res); +#endif } # else |