This is Unofficial EPICS BASE Doxygen Site
osdMonotonic.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2015 Michael Davidsaver
3 * EPICS BASE is distributed subject to a Software License Agreement found
4 * in file LICENSE that is included with this distribution.
5 \*************************************************************************/
6 
7 #include <mach/mach.h>
8 #include <mach/mach_time.h>
9 
10 #define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE
11 #include "dbDefs.h"
12 #include "errlog.h"
13 #include "epicsTime.h"
14 #include "generalTimeSup.h"
15 
16 /* see https://developer.apple.com/library/content/qa/qa1398/_index.html */
17 static mach_timebase_info_data_t tbinfo;
18 
19 void osdMonotonicInit(void)
20 {
21  (void)mach_timebase_info(&tbinfo);
22 }
23 
25 {
26  return 1e-9 * tbinfo.numer / tbinfo.denom;
27 }
28 
30 {
31  uint64_t val = mach_absolute_time();
32  return val * tbinfo.numer / tbinfo.denom;
33 }
void osdMonotonicInit(void)
Definition: osdMonotonic.c:19
epicsUInt64 epicsMonotonicGet(void)
Fetch monotonic counter, returns the number of nanoseconds since some unspecified time...
Definition: osdMonotonic.c:29
Miscellaneous macro definitions.
unsigned long long epicsUInt64
Definition: epicsTypes.h:45
epicsUInt64 epicsMonotonicResolution(void)
Monotonic time resolution, may not be accurate. Returns the minimum non-zero time difference between ...
Definition: osdMonotonic.c:24
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...