_export void
p4_gettimeofday (p4ucell* sec, p4ucell* usec)
{
# ifdef PFE_HAVE_VXWORKS_H
# define PFE_HAVE_CLOCK_GETTIME
# endif
# if defined PFE_HAVE_CLOCK_GETTIME
struct timespec tv;
clock_gettime (CLOCK_REALTIME, &tv);
if (usec) *usec = tv.tv_nsec/1000;
*sec = tv.tv_sec;
# elif defined PFE_HAVE_WINBASE_H
SYSTEMTIME stime;
GetSystemTime (&stime);
if (usec) *usec = stime.wMilliseconds*1000;
*sec = time(0);
# elif defined PFE_HAVE_UNISTD_H || defined PFE_HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday (&tv, 0);
if (usec) *usec = tv.tv_usec;
*sec = tv.tv_sec;
# else
if (usec) *usec = 0;
*sec = time(0);
# endif
}; |