7 #include "cln/timing.h"
12 #include "cl_t_config.h"
15 #if defined(HAVE_GETTIMEOFDAY)
17 #ifdef GETTIMEOFDAY_DOTS
18 extern "C" int gettimeofday (struct timeval * tp, ...);
20 extern "C" int gettimeofday (struct timeval * tp, GETTIMEOFDAY_TZP_T tzp);
22 #elif defined(HAVE_FTIME)
23 #include <sys/timeb.h>
25 extern "C" void ftime (struct timeb * tp);
27 extern "C" int ftime (struct timeb * tp);
32 #ifdef HAVE_PERROR_DECL
36 extern "C" int perror (const char *);
41 const cl_timespec cl_current_time ()
43 #if defined(HAVE_GETTIMEOFDAY)
44 var struct timeval tv;
45 if (gettimeofday(&tv,NULL) != 0) {
46 perror("gettimeofday");
47 tv.tv_sec = 0; tv.tv_usec = 0;
49 return cl_timespec(tv.tv_sec,
50 tv.tv_usec * (1000000000/1000000)
52 #elif defined(HAVE_FTIME)
53 var struct timeb timebuf;
55 return cl_timespec(timebuf.time,
56 (uintL)timebuf.millitm * (1000000000/1000)
59 return cl_timespec(time(NULL),0);