67 #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_DOS ) 68 #if !defined( MBG_TGT_MINGW ) 69 typedef int clockid_t;
70 #define clockid_t clockid_t 72 #define CLOCK_REALTIME ( (clockid_t) 0 ) 78 #if defined( MBG_TGT_WIN32 ) 80 #define __const__ const 88 typedef VOID (WINAPI *GSTAFT_FNC)(LPFILETIME lpSystemTimeAsFileTime);
90 _ext GSTAFT_FNC gstaft_fnc
92 = GetSystemTimeAsFileTime
100 #if !defined( MBG_TGT_MISSING_64_BIT_TYPES ) 120 struct tm *p_tm_tmp = gmtime( p_time );
122 if ( p_tm_tmp == NULL )
133 #if !defined( MBG_TGT_MISSING_64_BIT_TYPES ) 149 #if 0 // TODO Currently not supported 150 if ( tmp >= NSEC_PER_SEC )
151 mbglog( LOG_WARNING,
"Range overflow in ntp_frac_to_nsec: 0x%X -> %Lu",
168 #if 0 // TODO Currently not supported 169 if ( tmp >= NTP_FRAC_PER_SEC )
170 mbglog( LOG_WARNING,
"Range overflow in nsec_to_ntp_frac: %lu -> 0x%LX",
174 return (uint32_t) tmp;
198 #endif // !defined( MBG_TGT_MISSING_64_BIT_TYPES ) 205 return p->tv_sec != 0 || p->tv_nsec != 0;
216 const struct timespec *ts_ref )
218 return ( (
double) ts->tv_sec - (
double) ts_ref->tv_sec )
219 + ( (double) ts->tv_nsec - (
double) ts_ref->tv_nsec ) /
NSEC_PER_SEC;
225 #if !defined( MBG_TGT_MISSING_64_BIT_TYPES ) 229 const struct timespec *ts_ref )
231 int64_t tmp = ts->tv_sec - ts_ref->tv_sec;
232 tmp = ( tmp *
NSEC_PER_SEC ) + ( ts->tv_nsec - ts_ref->tv_nsec );
238 #endif // !defined( MBG_TGT_MISSING_64_BIT_TYPES ) 247 int snprint_gmtime_error(
char *s,
size_t max_len,
int mbg_errno, time_t t,
const char *calling_fnc ) ;
263 int snprint_utc_offs(
char *s,
size_t max_len,
const char *info,
long utc_offs ) ;
uint32_t fractions
binary fractional part of a second, 0xFFFFFFFF -> 0.9999999... s (resolution 2^-32s =~ 233 ps) ...
int snprint_time_t_to_iso(time_t tstamp, int offs_hours, char *buf, size_t len)
int snprint_time_t_to_iso_ns(time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
Structure that represents a timestamp in NTP Timestamp Format.
int snprint_ntp_tstamp_to_iso_ns(const NTP_TSTAMP *ts, char *buf, size_t len)
int snprint_ntp_tstamp_to_iso_us(const NTP_TSTAMP *ts, char *buf, size_t len)
void check_precise_time_api(void)
static __mbg_inline double ntp_tstamp_to_double(const NTP_TSTAMP *t)
static __mbg_inline void ntp_tstamp_to_timespec(struct timespec *t_ts, const NTP_TSTAMP *t_ntp)
static __mbg_inline uint32_t nsec_to_ntp_frac(ulong nsec)
static __mbg_inline time_t cvt_to_time_t(mbg_time_t t)
static __mbg_inline ulong ntp_frac_to_nsec(uint32_t frac)
int snprint_ntp_tstamp_to_iso_ms(const NTP_TSTAMP *ts, char *buf, size_t len)
static __mbg_inline double delta_timespec_d_s(const struct timespec *ts, const struct timespec *ts_ref)
static __mbg_inline int timespec_is_set(const struct timespec *p)
int mbg_clock_gettime(clockid_t clock_id, struct timespec *tp)
static __mbg_inline void timespec_to_ntp_tstamp(NTP_TSTAMP *t_ntp, const struct timespec *t_ts)
int snprint_time_t_to_iso_ms(time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
uint32_t seconds
seconds since NTP epoch, see NTP_SEC_BIAS
static __mbg_inline int mbg_gmtime(struct tm *p_tm, const time_t *p_time)
int snprint_gmtime_error(char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc)
int snprint_time_t_to_iso_us(time_t tstamp, int offs_hours, time_t frac, char *buf, size_t len)
unsigned __int64 uint64_t
static __mbg_inline int64_t delta_timespec_ll_ns(const struct timespec *ts, const struct timespec *ts_ref)
int snprint_utc_offs(char *s, size_t max_len, const char *info, long utc_offs)
Print a UTC offset into a string.
int mbg_get_last_error(const char *info)
Get and translate last error after non-socket function call.
int mbg_clock_settime(clockid_t clock_id, const struct timespec *tp)
#define NTP_SEC_BIAS
NTP epoch bias from ordinary time_t epoch.