This is Unofficial EPICS BASE Doxygen Site
osdTime.cpp File Reference
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "osiSock.h"
#include "cantProceed.h"
#include "epicsTime.h"
#include "generalTimeSup.h"
+ Include dependency graph for osdTime.cpp:

Go to the source code of this file.

Macros

#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE
 
#define TIME_INIT
 

Functions

int osdTimeGetCurrent (epicsTimeStamp *pDest)
 
int epicsTime_gmtime (const time_t *pAnsiTime, struct tm *pTM)
 Break down a time_t into a struct tm in the UTC timezone. More...
 
int epicsTime_localtime (const time_t *clock, struct tm *result)
 Break down a time_t into a struct tm in the local timezone. More...
 
LIBCOM_API void convertDoubleToWakeTime (double timeout, struct timespec *wakeTime)
 

Macro Definition Documentation

#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE

Definition at line 16 of file osdTime.cpp.

#define TIME_INIT
Value:
#define generalTimeCurrentTpRegister
#define LAST_RESORT_PRIORITY
int osdTimeGetCurrent(epicsTimeStamp *pDest)
Definition: osdTime.cpp:28

Definition at line 30 of file osdTime.cpp.

Function Documentation

LIBCOM_API void convertDoubleToWakeTime ( double  timeout,
struct timespec wakeTime 
)

Definition at line 91 of file osdTime.cpp.

92 {
93  struct timespec now, wait;
94  int status;
95 
96  if (timeout < 0.0)
97  timeout = 0.0;
98  else if (timeout > 60 * 60 * 24 * 3652.5)
99  timeout = 60 * 60 * 24 * 3652.5; /* 10 years */
100 
101 #ifdef CLOCK_REALTIME
102  status = clock_gettime(CLOCK_REALTIME, &now);
103 #else
104  {
105  struct timeval tv;
106  struct timezone tz;
107  status = gettimeofday(&tv, &tz);
108  now.tv_sec = tv.tv_sec;
109  now.tv_nsec = tv.tv_usec * 1000;
110  }
111 #endif
112  if (status) {
113  perror("convertDoubleToWakeTime");
114  cantProceed("convertDoubleToWakeTime");
115  }
116 
117  wait.tv_sec = static_cast< time_t >(timeout);
118  wait.tv_nsec = static_cast< long >((timeout - (double)wait.tv_sec) * 1e9);
119 
120  wakeTime->tv_sec = now.tv_sec + wait.tv_sec;
121  wakeTime->tv_nsec = now.tv_nsec + wait.tv_nsec;
122  if (wakeTime->tv_nsec >= 1000000000L) {
123  wakeTime->tv_nsec -= 1000000000L;
124  ++wakeTime->tv_sec;
125  }
126 }
double timeout
Definition: pvutils.cpp:25
pvd::Status status
time_t tv_sec
Definition: osdTime.h:22
long tv_nsec
Definition: osdTime.h:23
BSD and SRV5 Unix timestamp.
Definition: epicsTime.h:52
LIBCOM_API void cantProceed(const char *msg,...)
Definition: cantProceed.c:54
Defined by POSIX Real Time.
Definition: osdTime.h:21
int epicsTime_gmtime ( const time_t *  pAnsiTime,
struct tm *  pTM 
)

Break down a time_t into a struct tm in the UTC timezone.

Definition at line 66 of file osdTime.cpp.

68 {
69  struct tm * pRet = gmtime_r ( pAnsiTime, pTM );
70  if ( pRet ) {
71  return epicsTimeOK;
72  }
73  else {
74  return errno;
75  }
76 }
#define epicsTimeOK
Success.
Definition: epicsTime.h:339
int epicsTime_localtime ( const time_t *  clock,
struct tm *  result 
)

Break down a time_t into a struct tm in the local timezone.

Definition at line 78 of file osdTime.cpp.

80 {
81  struct tm * pRet = localtime_r ( clock, result );
82  if ( pRet ) {
83  return epicsTimeOK;
84  }
85  else {
86  return errno;
87  }
88 }
pvac::PutEvent result
Definition: clientSync.cpp:117
#define epicsTimeOK
Success.
Definition: epicsTime.h:339
int osdTimeGetCurrent ( epicsTimeStamp pDest)

Definition at line 34 of file osdTime.cpp.

35  {
36  struct timeval tv;
37  struct timezone tz;
38 
39  if (gettimeofday (&tv, &tz))
40  return errno;
41 
42  *pDest = epicsTime(tv);
43  return epicsTimeOK;
44  }
#define epicsTimeOK
Success.
Definition: epicsTime.h:339
BSD and SRV5 Unix timestamp.
Definition: epicsTime.h:52