/* struct timeval syscalltime[VG_N_THREADS]; */
#if CLG_MICROSYSTIME
-#include <sys/time.h>
-#include <sys/syscall.h>
-extern Int VG_(do_syscall) ( UInt, ... );
-
ULong syscalltime[VG_N_THREADS];
#else
UInt syscalltime[VG_N_THREADS];
if (CLG_(clo).collect_systime) {
#if CLG_MICROSYSTIME
struct vki_timeval tv_now;
- VG_(do_syscall)(__NR_gettimeofday, (UInt)&tv_now, (UInt)NULL);
+ VG_(gettimeofday)(&tv_now, NULL);
syscalltime[tid] = tv_now.tv_sec * 1000000ULL + tv_now.tv_usec;
#else
syscalltime[tid] = VG_(read_millisecond_timer)();
struct vki_timeval tv_now;
ULong diff;
- VG_(do_syscall)(__NR_gettimeofday, (UInt)&tv_now, (UInt)NULL);
+ VG_(gettimeofday)(&tv_now, NULL);
diff = (tv_now.tv_sec * 1000000ULL + tv_now.tv_usec) - syscalltime[tid];
#else
UInt diff = VG_(read_millisecond_timer)() - syscalltime[tid];
/* offset o is for "SysCount", o+1 for "SysTime" */
o = fullOffset(EG_SYS);
CLG_ASSERT(o>=0);
- CLG_DEBUG(0," Time (Off %d) for Syscall %d: %ull\n", o, syscallno, diff);
+ CLG_DEBUG(0," Time (Off %d) for Syscall %u: %llu\n", o, syscallno,
+ (ULong)diff);
CLG_(current_state).cost[o] ++;
CLG_(current_state).cost[o+1] += diff;
return (now - base) / 1000;
}
+Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz)
+{
+ SysRes res;
+ res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)tv, (UWord)tz);
+
+ if (! sr_isError(res)) return 0;
+
+ /* Make sure, argument values are determinstic upon failure */
+ if (tv) *tv = (struct vki_timeval){ .tv_sec = 0, .tv_usec = 0 };
+ if (tz) *tz = (struct vki_timezone){ .tz_minuteswest = 0, .tz_dsttime = 0 };
+
+ return -1;
+}
+
/* ---------------------------------------------------------------------
atfork()
// (roughly; it gets initialised partway through Valgrind's initialisation
// steps).
extern UInt VG_(read_millisecond_timer) ( void );
+extern Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz);
/* ---------------------------------------------------------------------
atfork