This is Unofficial EPICS BASE Doxygen Site
osdMonotonic.c File Reference
#include <vxWorks.h>
#include <stdio.h>
#include <sysLib.h>
#include <taskLib.h>
#include "epicsTypes.h"
#include "epicsTime.h"
#include "cantProceed.h"
#include <arch/ppc/vxPpcLib.h>
#include "epicsFindSymbol.h"
+ Include dependency graph for osdMonotonic.c:

Go to the source code of this file.

Classes

union  timebase
 

Macros

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>
 
#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE
 
#define NS_PER_SEC   1000000000
 
#define TIMEBASEGET(TB)   vxTimeBaseGet(&TB.u32[0], &TB.u32[1])
 

Functions

void osdMonotonicInit (void)
 
epicsUInt64 epicsMonotonicResolution (void)
 Monotonic time resolution, may not be accurate. Returns the minimum non-zero time difference between two calls to epicsMonotonicGet() in units of nanoseconds. More...
 
epicsUInt64 epicsMonotonicGet (void)
 Fetch monotonic counter, returns the number of nanoseconds since some unspecified time. More...
 

Macro Definition Documentation

#define _VSB_CONFIG_FILE   <../lib/h/config/vsbConfig.h>

Definition at line 8 of file osdMonotonic.c.

#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE

Definition at line 15 of file osdMonotonic.c.

#define NS_PER_SEC   1000000000

Definition at line 21 of file osdMonotonic.c.

#define TIMEBASEGET (   TB)    vxTimeBaseGet(&TB.u32[0], &TB.u32[1])

Definition at line 41 of file osdMonotonic.c.

Function Documentation

epicsUInt64 epicsMonotonicGet ( void  )

Fetch monotonic counter, returns the number of nanoseconds since some unspecified time.

Definition at line 107 of file osdMonotonic.c.

108 {
109  union timebase tbNow;
110 
111  if (!ticksPerSec) {
112  cantProceed("Monotonic time source not available.\n");
113  }
114 
115  TIMEBASEGET(tbNow);
116  /* Using a long double for the calculation below to preserve
117  * as many bits in the mantissa as possible.
118  */
119  return ((long double) tbNow.u64) * NS_PER_SEC / ticksPerSec;
120 }
#define NS_PER_SEC
Definition: osdMonotonic.c:21
LIBCOM_API void cantProceed(const char *msg,...)
Definition: cantProceed.c:54
#define TIMEBASEGET(TB)
Definition: osdMonotonic.c:41
epicsUInt64 epicsMonotonicResolution ( void  )

Monotonic time resolution, may not be accurate. Returns the minimum non-zero time difference between two calls to epicsMonotonicGet() in units of nanoseconds.

Definition at line 99 of file osdMonotonic.c.

100 {
101  if (!ticksPerSec)
102  return 0;
103 
104  return NS_PER_SEC / ticksPerSec;
105 }
#define NS_PER_SEC
Definition: osdMonotonic.c:21
void osdMonotonicInit ( void  )

Definition at line 44 of file osdMonotonic.c.

45 {
46  typedef epicsUInt32 (*sysTimeBaseFreq_t)(void);
47  sysTimeBaseFreq_t sysTimeBaseFreq =
48  (sysTimeBaseFreq_t) epicsFindSymbol("_sysTimeBaseFreq");
49 
50  if (sysTimeBaseFreq) {
51  ticksPerSec = sysTimeBaseFreq();
52 
53  if (ticksPerSec)
54  return;
55 
56  /* This should never happen */
57  printf("Warning: sysTimeBaseFreq() present but returned zero.\n");
58  }
59 
60  /* Fall back to measuring */
61  measureTickRate();
62 }
#define printf
Definition: epicsStdio.h:41
unsigned int epicsUInt32
Definition: epicsTypes.h:43
LIBCOM_API void *epicsStdCall epicsFindSymbol(const char *name)
Definition: osdFindSymbol.c:23