24 #define _CMP_TIME_UTIL 59 const char n_supp_msg[] =
"fast (memory mapped) time stamps";
62 err_msg_fnc, n_supp_msg );
66 err_msg_fnc, n_supp_msg );
142 double *p_delta_ts,
double *p_delta_cyc )
150 #if defined( MBG_TGT_WIN32 ) 153 delta_cyc = (double) dt_t / (__int64)
cyc_freq;
160 *p_delta_ts = delta_ts;
163 *p_delta_cyc = delta_cyc;
165 return delta_ts - delta_cyc;
194 n += snprintf( &s[n], max_len - n,
" (0x%08lX.%08lX)",
232 ( pt->utc_offs < 0 ) ?
'-' :
'+',
int mbg_snprintf(char *s, size_t max_len, const char *fmt,...)
A portable, safer implementation of snprintf().
bool mbg_cond_err_msg(int rc, const char *what)
Check if a value is an error code and print an associated error message.
PCPS_SECONDS sec
seconds since 1970, usually UTC scale
#define _int_from_size_t(_n)
_MBG_API_ATTR int _MBG_API mbg_get_hr_time_cycles(MBG_DEV_HANDLE dh, PCPS_HR_TIME_CYCLES *p)
Read the current high resolution time plus the associated PC cycles from a device.
#define mbg_rc_is_success(_rc)
High resolution time stamp plus associated system cycles count.
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_cycles(MBG_DEV_HANDLE dh, PCPS_TIME_STAMP_CYCLES *p)
Read a high resolution PCPS_TIME_STAMP_CYCLES structure via memory mapped access. ...
int get_htc_timestamps(MBG_DEV_HANDLE dh1, PCPS_HR_TIME_CYCLES *p_htc1, MBG_DEV_HANDLE dh2, PCPS_HR_TIME_CYCLES *p_htc2, int read_fast)
Read timestamps and cycles from both devices.
int32_t utc_offs
UTC offs [sec] (loc_time = tstamp + utc_offs)
PCPS_TIME_STATUS_X status
status bits, see PCPS_TIME_STATUS_FLAGS
PCPS_FRAC_32 frac
binary fractions of second, see PCPS_FRAC_32
MBG_PC_CYCLES_FREQUENCY cyc_freq
Must be set up tby the application.
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
returned time is always UTC instead of some local time
int mbg_snprint_hr_tstamp_ext(char *s, int max_len, const PCPS_TIME_STAMP *p, int print_raw)
Print UTC date and time from a PCPS_TIME_STAMP structure to a string.
MBG_CHK_SUPP_FNC mbg_chk_dev_has_fast_hr_timestamp
Check if a device supports the mbg_get_fast_hr_timestamp... calls.
uint64_t MBG_PC_CYCLES_FREQUENCY
double get_htc_delta(const PCPS_HR_TIME_CYCLES *p_htc, const PCPS_HR_TIME_CYCLES *p_htc_ref, double *p_delta_ts, double *p_delta_cyc)
Compute the delta cycles and time difference.
High resolution time including status and local time offset.
High resolution time plus associated system cycles count.
A high resolution time stamp.
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
int chk_feat_supp(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, MBG_CHK_SUPP_FNC *chk_supp_fnc, MBG_ERR_MSG_FNC *err_msg_fnc, const char *not_supp_msg)
int MBG_ERR_MSG_FNC(const PCPS_DEV *p_dev, const char *s)
int mbg_snprint_hr_time_loc(char *s, size_t max_len, const PCPS_HR_TIME *p)
Print local date and time from a PCPS_TIME_STAMP structure to a string.
static __mbg_inline void setup_hr_time_cycles_from_timestamp_cycles(PCPS_HR_TIME_CYCLES *p_ht_c, const PCPS_TIME_STAMP_CYCLES *p_ts_c)
static __mbg_inline double dfrac_sec_from_bin(uint32_t b)
Convert a binary fraction to "double" fractions.
int chk_fast_tstamp_supp(MBG_DEV_HANDLE dh1, const PCPS_DEV *p_dev_1, MBG_DEV_HANDLE dh2, const PCPS_DEV *p_dev_2, MBG_ERR_MSG_FNC err_msg_fnc)
Check if both devices support fast HR timestamps.
int mbg_str_pcps_hr_time_offs(char *s, int max_len, const PCPS_HR_TIME *pt, const char *info)
Print the UTC offset from a PCPS_HR_TIME structure to a string buffer.