15 #ifdef HAVE_SYS_TIME_H
21 #ifdef HAVE_WINSOCK2_H
28 #if _POSIX_TIMERS && !defined(__APPLE__)
32 #define COAP_CLOCK CLOCK_REALTIME
35 #ifdef HAVE_WINSOCK2_H
37 gettimeofday(
struct timeval *tp, TIME_ZONE_INFORMATION *tzp) {
39 static const uint64_t s_tUnixEpoch = 116444736000000000Ui64;
43 uint64_t tUsSinceUnicEpoch;
45 GetSystemTimeAsFileTime( &file_time );
46 time.LowPart = file_time.dwLowDateTime;
47 time.HighPart = file_time.dwHighDateTime;
48 tUsSinceUnicEpoch = ( time.QuadPart - s_tUnixEpoch ) / 10;
50 tp->tv_sec = (long)(tUsSinceUnicEpoch / 1000000);
51 tp->tv_usec = (long)(tUsSinceUnicEpoch % 1000000);
60 clock_gettime(COAP_CLOCK, &tv);
63 gettimeofday(&tv, NULL);
66 coap_clock_offset = tv.tv_sec;
70 #define Q(frac,fval) ((1 << (frac)) * (fval))
76 #define SHR_FP(val,frac) (((coap_tick_t)((val) + (1 << ((frac) - 1)))) >> (frac))
84 clock_gettime(COAP_CLOCK, &tv);
96 gettimeofday(&tv, NULL);
Pulls together all the internal only header files.
COAP_STATIC_INLINE void dummy(void)
coap_tick_t coap_ticks_from_rt_us(uint64_t t)
Helper function that converts POSIX wallclock time in us to coap ticks.
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
time_t coap_time_t
CoAP time in seconds since epoch.
void coap_clock_init(void)
Initializes the internal clock.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
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_ticks_to_rt_us(coap_tick_t t)
Helper function that converts coap ticks to POSIX wallclock time in us.
#define COAP_STATIC_INLINE
#define SHR_FP(val, frac)
#define Q(frac, fval)
creates a Qx.frac from fval in coap_fixed_point_t