Shared Persistent Heap Data Environment Manual  1.1.0
Macros | Functions
sphgtod.h File Reference

Functions to convert time stamp (sphtimer_t) values to struct timeval value format with gettimeofday() epoch. More...

#include <sys/time.h>
#include <sphtimer.h>

Go to the source code of this file.

Functions

__C__ int sphgtod (struct timeval *tv, struct timezone *tz)
 Return the timebase converted to gettimeofday struct timeval. More...
 
__C__ sphtimer_t sphget_gtod_conv_factor (void)
 Return the timebase-to-gettimeofday conversion factor. More...
 
__C__ int sphtb2gtod_withfactor (struct timeval *tv, sphtimer_t timestamp, sphtimer_t tb2gtod_factor)
 Return the timebase converted to gettimeofday struct timeval. More...
 

Detailed Description

Functions to convert time stamp (sphtimer_t) values to struct timeval value format with gettimeofday() epoch.

This API is intended to support post processing time stamps (including those generated by SPHLFLogger_t and SPHSinglePCQueue_t) into gettimeofday() epoch and related formatted time values.

It is not intended as an exact replacement for gettimeofday() because it may not include any NTP corrections for example, but it will close and will be monotonic.

Function Documentation

__C__ sphtimer_t sphget_gtod_conv_factor ( void  )

Return the timebase-to-gettimeofday conversion factor.

As the timebase (sphtimer_t) is a fast hardware timer or something similar to "uptime" we need to allow for logs that persist across reboot. By saving this conversion factor in the log we can use it during post processing of the log to get the corrected gettimeofday value for formatted time values.

This allow the logger to run as fast as possible by postponing the timebase to gettimeofday conversion until post processing.

Returns
The timebase to gettimeofday conversion factor.
__C__ int sphgtod ( struct timeval *  tv,
struct timezone *  tz 
)

Return the timebase converted to gettimeofday struct timeval.

Returns a fast emulation of the values returned by gettimeofday computed from a queried machine timebase register value.

The timezone is not currently honored in the conversion.

Parameters
tvaddress of the struct timeval buffer.
tzaddress of the stuct timezone or NULL.
Returns
The timebase converted to gettimeofday in struct timeval.
__C__ int sphtb2gtod_withfactor ( struct timeval *  tv,
sphtimer_t  timestamp,
sphtimer_t  tb2gtod_factor 
)

Return the timebase converted to gettimeofday struct timeval.

As the timebase (sphtimer_t) is a fast hardware timer or something similar to "uptime" we need to allow for logs that persist across reboot. By saving the conversion factor (via sphget_gtod_conv_factor()) in the log we can use it (via this API) during post processing of the log to get the corrected gettimeofday value for formatted time values.

Parameters
tvaddress of the struct timeval buffer.
timestampvalue via sphgettimer().
tb2gtod_factortimebase to gettimeofday conversion factor.
Returns
The timebase converted to gettimeofday in struct timeval.