12 #include "cl_t_config.h"
14 #if defined(HAVE_GETTIMEOFDAY)
16 #ifdef GETTIMEOFDAY_DOTS
17 extern "C" int gettimeofday (struct timeval * tp, ...);
19 extern "C" int gettimeofday (struct timeval * tp, GETTIMEOFDAY_TZP_T tzp);
21 #elif defined(HAVE_FTIME)
22 #include <sys/timeb.h>
24 extern "C" void ftime (struct timeb * tp);
26 extern "C" int ftime (struct timeb * tp);
31 #ifdef HAVE_PERROR_DECL
35 extern "C" int perror (const char *);
38 const cl_timespec cl_current_time ()
40 #if defined(HAVE_GETTIMEOFDAY)
41 var struct timeval tv;
42 if (gettimeofday(&tv,NULL) != 0) {
43 perror("gettimeofday");
44 tv.tv_sec = 0; tv.tv_usec = 0;
46 return cl_timespec(tv.tv_sec,
47 tv.tv_usec * (1000000000/1000000)
49 #elif defined(HAVE_FTIME)
50 var struct timeb timebuf;
52 return cl_timespec(timebuf.time,
53 (uintL)timebuf.millitm * (1000000000/1000)
56 return cl_timespec(time(NULL),0);