9 #include "coap_config.h" 13 #ifdef HAVE_SYS_TIME_H 19 #ifdef HAVE_WINSOCK2_H 29 #if _POSIX_TIMERS && !defined(__APPLE__) 33 #define COAP_CLOCK CLOCK_REALTIME 36 #ifdef HAVE_WINSOCK2_H 38 gettimeofday(
struct timeval *tp, TIME_ZONE_INFORMATION *tzp) {
40 static const uint64_t s_tUnixEpoch = 116444736000000000Ui64;
44 uint64_t tUsSinceUnicEpoch;
46 GetSystemTimeAsFileTime( &file_time );
47 time.LowPart = file_time.dwLowDateTime;
48 time.HighPart = file_time.dwHighDateTime;
49 tUsSinceUnicEpoch = ( time.QuadPart - s_tUnixEpoch ) / 10;
51 tp->tv_sec = (long)(tUsSinceUnicEpoch / 1000000);
52 tp->tv_usec = (long)(tUsSinceUnicEpoch % 1000000);
61 clock_gettime(COAP_CLOCK, &tv);
64 gettimeofday(&tv, NULL);
67 coap_clock_offset = tv.tv_sec;
71 #define Q(frac,fval) ((coap_tick_t)(((1 << (frac)) * (fval)))) 77 #define SHR_FP(val,frac) (((val) + (1 << ((frac) - 1))) >> (frac)) 85 clock_gettime(COAP_CLOCK, &tv);
97 gettimeofday(&tv, NULL);
#define SHR_FP(val, frac)
void coap_clock_init(void)
Initializes the internal clock.
coap_time_t coap_ticks_to_rt(coap_tick_t t)
Helper function that converts coap ticks to wallclock time.
#define COAP_TICKS_PER_SECOND
Use ms resolution on POSIX systems.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
COAP_STATIC_INLINE void dummy(void)
time_t coap_time_t
CoAP time in seconds since epoch.
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
uint64_t coap_ticks_to_rt_us(coap_tick_t t)
Helper function that converts coap ticks to POSIX wallclock time in us.
#define COAP_STATIC_INLINE
coap_tick_t coap_ticks_from_rt_us(uint64_t t)
Helper function that converts POSIX wallclock time in us to coap ticks.
#define Q(frac, fval)
creates a Qx.frac from fval in coap_fixed_point_t