12 #define timercmp(a, b, CMP) \ 13 (((a)->tv_sec == (b)->tv_sec) ? \ 14 ((a)->tv_usec CMP (b)->tv_usec) : \ 15 ((a)->tv_sec CMP (b)->tv_sec)) 16 #define timeradd(a, b, result) \ 18 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 19 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 20 if ((result)->tv_usec >= 1000000) \ 23 (result)->tv_usec -= 1000000; \ 26 #define timersub(a, b, result) \ 28 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 29 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 30 if ((result)->tv_usec < 0) { \ 32 (result)->tv_usec += 1000000; \ 36 #define USECS_PER_SEC 1000000 37 #define USECS_PER_TICK (USECS_PER_SEC / CFG_TICKS_PER_SECOND) 52 tick_t tick = tick_get();
57 tp->tv_sec = tick / CFG_TICKS_PER_SECOND;
59 ticks_left = tick % CFG_TICKS_PER_SECOND;
79 struct timeval current_time;
83 return_value.sec = current_time.tv_sec;
84 return_value.usec = current_time.tv_usec;
90 struct timeval start_time;
91 struct timeval timeout;
92 struct timeval stop_time;
97 timeradd (&start_time, &timeout, &stop_time);
99 self->stop_time.sec = stop_time.tv_sec;
100 self->stop_time.usec = stop_time.tv_usec;
105 struct timeval current_time;
106 struct timeval stop_time;
107 int is_not_yet_expired;
110 stop_time.tv_sec =
self->stop_time.sec;
111 stop_time.tv_usec =
self->stop_time.usec;
112 is_not_yet_expired =
timercmp (¤t_time, &stop_time, <);
114 return is_not_yet_expired ==
false;
129 thandle = task_spawn (
"worker", func, 6,stacksize, param);
139 thandle = task_spawn (
"worker_rt", func, 15 ,stacksize, param);
boolean osal_timer_is_expired(osal_timert *self)
ec_timet osal_current_time(void)
void osal_free(void *ptr)
int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param)
#define timercmp(a, b, CMP)
#define timeradd(a, b, result)
int osal_usleep(uint32 usec)
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
void * osal_malloc(size_t size)
int gettimeofday(struct timeval *tp, void *tzp)
int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)