39 #define OROBLD_OS_LXRT_INTERNAL 42 #ifdef OROBLD_OS_AGNOSTIC 49 timevl.tv_sec = nano2count(hrt) / 1000000000LL;
50 timevl.tv_nsec = nano2count(hrt) % 1000000000LL;
55 #ifdef OROSEM_OS_LXRT_CHECK 56 #define CHK_LXRT_CALL() do { if(rt_buddy() == 0) { \ 57 printf("LXRT NOT INITIALISED IN THIS THREAD pid=%d,\n\ 58 BUT TRIES TO INVOKE LXRT FUNCTION >>%s<< ANYWAY\n", getpid(), __FUNCTION__ );\ 59 assert( rt_buddy() != 0 ); }\ 61 #define CHK_LXRT_PTR(ptr) do { if(ptr == 0) { \ 62 printf("TRIED TO PASS NULL POINTER TO LXRT IN THREAD pid=%d,\n\ 63 IN TRYING TO INVOKE LXRT FUNCTION >>%s<<\n", getpid(), __FUNCTION__ );\ 64 assert( ptr != 0 ); }\ 67 #define CHK_LXRT_CALL() 68 #define CHK_LXRT_PTR( a ) 94 m->sem = rt_sem_init( rt_get_name(0) , value);
95 return m->sem == 0 ? -1 : 0;
101 return rt_sem_delete(m->sem);
107 return rt_sem_signal(m->sem);
113 return rt_sem_wait(m->sem);
119 return rt_sem_wait_if(m->sem);
125 return rt_sem_count(m->sem);
132 ret = rt_sem_wait_timed(m->sem, nano2count(delay) );
133 #if defined(CONFIG_RTAI_VERSION_MINOR) && defined(CONFIG_RTAI_VERSION_MAJOR) 134 # if CONFIG_RTAI_VERSION_MAJOR == 3 && CONFIG_RTAI_VERSION_MINOR > 3 135 return (ret == RTE_TIMOUT) ? -1 : 0;
137 return (ret == SEM_TIMOUT) ? -1 : 0;
140 return (ret == SEM_TIMOUT) ? -1 : 0;
148 ret = rt_sem_wait_until(m->sem, nano2count(when) ) ;
149 #if defined(CONFIG_RTAI_VERSION_MINOR) && defined(CONFIG_RTAI_VERSION_MAJOR) 150 # if CONFIG_RTAI_VERSION_MAJOR == 3 && CONFIG_RTAI_VERSION_MINOR > 3 151 return (ret == RTE_TIMOUT) ? -1 : 0;
153 return (ret == SEM_TIMOUT) ? -1 : 0;
156 return (ret == SEM_TIMOUT) ? -1 : 0;
163 m->sem = rt_typed_sem_init( rt_get_name(0),1, BIN_SEM | PRIO_Q);
164 return m->sem == 0 ? -1 : 0;
171 return rt_sem_delete(m->sem);
178 m->sem = rt_typed_sem_init( rt_get_name(0), 1, RES_SEM);
179 return m->sem == 0 ? -1 : 0;
186 return rt_sem_delete(m->sem);
192 return rt_sem_wait(m->sem);
198 return rt_sem_wait_if(m->sem) > 0 ? 0 : -EAGAIN;
204 return rt_sem_wait_until(m->sem, nano2count(abs_time)) < SEM_TIMOUT ? 0 : -EAGAIN;
210 return rt_sem_wait_until(m->sem, nano2count(abs_time)) < SEM_TIMOUT ? 0 : -EAGAIN;
216 return rt_sem_signal(m->sem);
223 return rt_sem_wait(m->sem);
230 return rt_sem_wait_if(m->sem) > 0 ? 0 : -EAGAIN;
237 return rt_sem_signal(m->sem);
243 cond->cond = rt_cond_init(0);
244 return cond->cond == 0 ? -1 : 0;
250 return rt_cond_delete(cond->cond);
256 int ret = rt_cond_wait(cond->cond, mutex->sem );
265 int ret = rt_cond_wait_until(cond->cond, mutex->sem, nano2count(abs_time) );
268 if ( ret == SEM_TIMOUT )
276 return rt_cond_broadcast(cond->cond);
282 char printkbuf [2000];
284 va_start (list, fmt);
285 vsprintf(printkbuf, fmt, list);
288 return rtai_print_to_screen(printkbuf);
292 #endif // OROBLD_OS_AGNOSTIC
int rtos_mutex_rec_lock(rt_rec_mutex_t *m)
static int rtos_mutex_destroy(rt_mutex_t *m)
int rtos_cond_destroy(rt_cond_t *cond)
NANO_TIME rtos_get_time_ns(void)
static int rtos_mutex_unlock(rt_mutex_t *m)
int rtos_mutex_rec_init(rt_rec_mutex_t *m)
int rtos_sem_trywait(rt_sem_t *m)
int rtos_mutex_rec_trylock(rt_rec_mutex_t *m)
int rtos_sem_signal(rt_sem_t *m)
static int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time)
static int rtos_sem_wait_until(rt_sem_t *m, NANO_TIME when)
int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex)
cyg_tick_count_t TICK_TIME
int rtos_mutex_rec_unlock(rt_rec_mutex_t *m)
int rtos_sem_destroy(rt_sem_t *m)
int rtos_mutex_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
static TIME_SPEC ticks2timespec(TICK_TIME hrt)
int rtos_mutex_rec_lock_until(rt_rec_mutex_t *m, NANO_TIME abs_time)
TICK_TIME rtos_get_time_ticks(void)
TICK_TIME ticksPerSec(void)
int rtos_mutex_trylock(rt_mutex_t *m)
NANO_TIME ticks2nano(TICK_TIME count)
int rtos_sem_init(rt_sem_t *m, int value)
TICK_TIME nano2ticks(NANO_TIME nano)
int rtos_sem_value(rt_sem_t *m)
static int rtos_sem_wait_timed(rt_sem_t *m, NANO_TIME delay)
struct timespec TIME_SPEC
static int rtos_mutex_init(rt_mutex_t *m)
int rtos_cond_init(rt_cond_t *cond)
int rtos_sem_wait(rt_sem_t *m)
static int rtos_mutex_lock(rt_mutex_t *m)
int rtos_cond_broadcast(rt_cond_t *cond)
int rtos_mutex_rec_destroy(rt_rec_mutex_t *m)