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 <mach/mach.h>
#include <mach/clock.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
 

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 18 of file osdTime.cpp.

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
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 55 of file osdTime.cpp.

56 {
57  return gmtime_r(pAnsiTime, pTM) ?
58  epicsTimeOK : errno;
59 }
#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 61 of file osdTime.cpp.

62 {
63  return localtime_r(clock, result) ?
64  epicsTimeOK : errno;
65 }
pvac::PutEvent result
Definition: clientSync.cpp:117
#define epicsTimeOK
Success.
Definition: epicsTime.h:339
int osdTimeGetCurrent ( epicsTimeStamp pDest)

Definition at line 28 of file osdTime.cpp.

29 {
30  mach_timespec_t mts;
31  struct timespec ts;
32 
33  clock_get_time(host_clock, &mts);
34  ts.tv_sec = mts.tv_sec;
35  ts.tv_nsec = mts.tv_nsec;
36  *pDest = epicsTime(ts);
37  return epicsTimeOK;
38 }
#define epicsTimeOK
Success.
Definition: epicsTime.h:339
Defined by POSIX Real Time.
Definition: osdTime.h:21