Files
pcas/src/libCom/osi/os/posix/osdTime.cpp
2000-01-28 02:24:14 +00:00

51 lines
1.0 KiB
C++

//
// should move the gettimeofday() proto
// into a different header
//
#include "osiSock.h"
#define epicsExportSharedSymbols
#include "osiTime.h"
//
// osiTime::osdGetCurrent ()
//
extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
{
# if defined(CLOCK_REALTIME)
struct timespec ts;
int status;
status = clock_gettime (CLOCK_REALTIME, &ts);
if (status) {
return tsStampERROR;
}
*pDest = osiTime (ts);
return tsStampERROR;
# else
int status;
struct timeval tv;
status = gettimeofday (&tv, NULL);
if (status) {
return tsStampERROR;
}
*pDest = osiTime (tv);
return tsStampERROR;
# endif
}
//
// tsStampGetEvent ()
//
extern "C" epicsShareFunc int epicsShareAPI tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
{
if (eventNumber==tsStampEventCurrentTime) {
return tsStampGetCurrent (pDest);
}
else {
return tsStampERROR;
}
}