This is Unofficial EPICS BASE Doxygen Site
osdTime.h File Reference
#include <sys/time.h>
+ Include dependency graph for osdTime.h:

Go to the source code of this file.

Functions

LIBCOM_API void convertDoubleToWakeTime (double timeout, struct timespec *wakeTime)
 

Function Documentation

LIBCOM_API void convertDoubleToWakeTime ( double  timeout,
struct timespec wakeTime 
)

Definition at line 68 of file osdTime.cpp.

69 {
70  mach_timespec_t now;
71  struct timespec wait;
72 
73  if (timeout < 0.0)
74  timeout = 0.0;
75  else if (timeout > 60 * 60 * 24 * 3652.5)
76  timeout = 60 * 60 * 24 * 3652.5; /* 10 years */
77 
78  clock_get_time(host_clock, &now);
79 
80  wait.tv_sec = static_cast< time_t >(timeout);
81  wait.tv_nsec = static_cast< long >((timeout - (double)wait.tv_sec) * 1e9);
82 
83  wakeTime->tv_sec = now.tv_sec + wait.tv_sec;
84  wakeTime->tv_nsec = now.tv_nsec + wait.tv_nsec;
85  if (wakeTime->tv_nsec >= 1000000000L) {
86  wakeTime->tv_nsec -= 1000000000L;
87  ++wakeTime->tv_sec;
88  }
89 }
double timeout
Definition: pvutils.cpp:25
time_t tv_sec
Definition: osdTime.h:22
long tv_nsec
Definition: osdTime.h:23
Defined by POSIX Real Time.
Definition: osdTime.h:21