XROAD
xroad_tsc.h File Reference
#include <common/xroad_common_types.h>
#include <time.h>
#include <x86intrin.h>
Include dependency graph for xroad_tsc.h:

Go to the source code of this file.

Classes

struct  xroad_priv_tsc_conv_t
 Internal structure with TSC <-> wallclock conversion constants. More...
 

Enumerations

enum  { xroad_priv_tsc_conv_shift = 31 , xroad_priv_tsc_sec_in_ns = 1000000000ul }
 

Functions

void xroad_tsc_initialize (void)
 Make sure the TSC sub-library is initialized.
 
xroad_priv_tsc_conv_t xroad_tsc_spec_from_khz (uint64_t khz)
 Returns TSC/ns conversion spec from TSC frequency.
 
xroad_tsc_t xroad_tsc_time_pair_now (clockid_t clockid, uint64_t *ns)
 Obtain a relatively accurate time-pair, TSC and wallclock in nanoseconds since epoche. More...
 

Variables

xroad_priv_tsc_conv_t g_xroad_priv_cc
 Global instance of the xroad_priv_tsc_conv_t. Initialized at startup.
 

Detailed Description

Author
Vladimir Solontsov

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
xroad_priv_tsc_conv_shift 

Number of bit to shift-right in TSC<->nsec conversion.

Function Documentation

◆ xroad_tsc_time_pair_now()

xroad_tsc_t xroad_tsc_time_pair_now ( clockid_t  clockid,
uint64_t *  ns 
)

Obtain a relatively accurate time-pair, TSC and wallclock in nanoseconds since epoche.

NB The returned timepair might be a bit behind against current time as it tends to get an accurate match between wallclock and TSC.

Parameters
[out]-time in nanoseconds
Returns
time in TSC