40 #define COAP_TICKS_PER_SECOND 1000
42 typedef uint32_t coap_tick_t;
53 #define coap_clock_init coap_clock_init_impl
55 #define coap_ticks coap_ticks_impl
61 typedef clock_time_t coap_tick_t;
68 typedef int coap_tick_diff_t;
70 #define COAP_TICKS_PER_SECOND CLOCK_SECOND
73 extern clock_time_t clock_offset;
76 contiki_clock_init_impl(
void) {
78 clock_offset = clock_time();
81 #define coap_clock_init contiki_clock_init_impl
84 contiki_ticks_impl(coap_tick_t *t) {
88 #define coap_ticks contiki_ticks_impl
92 typedef unsigned int coap_tick_t;
99 typedef int coap_tick_diff_t;
101 #define COAP_TICKS_PER_SECOND 1024
104 extern time_t clock_offset;
107 #ifndef coap_clock_init
111 clock_offset = time(NULL);
116 # warning "cannot initialize clock"
121 #define coap_clock_init coap_clock_init_impl
127 #ifdef HAVE_SYS_TIME_H
129 gettimeofday(&tv, NULL);
130 *t = (tv.tv_sec - clock_offset) * COAP_TICKS_PER_SECOND
131 + (tv.tv_usec * COAP_TICKS_PER_SECOND / 1000000);
133 #error "clock not implemented"
136 #define coap_ticks coap_ticks_impl
145 return ((coap_tick_diff_t)(a - b)) < 0;
static void coap_clock_init_impl(void)
static void coap_ticks_impl(coap_tick_t *t)
static int coap_time_le(coap_tick_t a, coap_tick_t b)
Returns 1 if and only if a is less than or equal b where less is defined on a signed data type...
static int coap_time_lt(coap_tick_t a, coap_tick_t b)
Returns 1 if and only if a is less than b where less is defined on a signed data type.