57 #define _XOPEN_SOURCE 600 // use all Posix features. 61 #include <semaphore.h> 68 #include "../oro_limits.h" 85 #define ORO_WAIT_ABS 0 87 #define ORO_WAIT_REL 1 105 #define ORO_SCHED_RT SCHED_FIFO 106 #define ORO_SCHED_OTHER SCHED_OTHER 109 // high-resolution time to timespec 114 timevl.tv_sec = hrt / 1000000000LL;
115 timevl.tv_nsec = hrt % 1000000000LL;
146 return nanosleep( rqtp, rmtp );
170 return sem_init(m, 0, value);
175 return sem_destroy(m);
190 return sem_trywait(m);
196 if ( sem_getvalue(m, &val) == 0)
208 return pthread_mutex_init(m, 0 );
213 return pthread_mutex_destroy(m);
218 pthread_mutexattr_t
attr;
219 int ret = pthread_mutexattr_init(&attr);
220 if (ret != 0)
return ret;
223 ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
224 if (ret != 0)
return ret;
226 ret = pthread_mutex_init(m, &attr);
228 pthread_mutexattr_destroy(&attr);
234 return pthread_mutex_destroy(m);
239 return pthread_mutex_lock(m);
244 return pthread_mutex_lock(m);
254 return pthread_mutex_timedlock(m, &arg_time);
264 return pthread_mutex_timedlock(m, &arg_time);
273 if (relative_time < 0)
return ETIMEDOUT;
283 if (relative_time < 0)
return ETIMEDOUT;
289 return pthread_mutex_trylock(m);
294 return pthread_mutex_trylock(m);
299 return pthread_mutex_unlock(m);
304 return pthread_mutex_unlock(m);
319 pthread_condattr_t
attr;
320 int ret = pthread_condattr_init(&attr);
321 if (ret != 0)
return ret;
324 ret = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
326 pthread_condattr_destroy(&attr);
330 ret = pthread_cond_init(cond, &attr);
331 pthread_condattr_destroy(&attr);
338 return pthread_cond_destroy(cond);
343 return pthread_cond_wait(cond, mutex);
349 return pthread_cond_timedwait(cond, mutex, &arg_time);
354 return pthread_cond_broadcast(cond);
357 #define rtos_printf printf
static int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time)
static int rtos_sem_wait(rt_sem_t *m)
static int rtos_sem_destroy(rt_sem_t *m)
static int rtos_mutex_rec_unlock(rt_rec_mutex_t *m)
static int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex)
static int rtos_cond_destroy(rt_cond_t *cond)
static void rtos_enable_rt_warning(void)
static long long nano2ticks(long long nano)
static int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
static int rtos_mutex_unlock(rt_mutex_t *m)
static const double InfiniteSeconds
static int rtos_mutex_rec_lock(rt_rec_mutex_t *m)
static NANO_TIME rtos_get_time_ns(void)
static int rtos_mutex_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
static long long ticks2nano(long long count)
cyg_tick_count_t TICK_TIME
static int rtos_mutex_rec_trylock_for(rt_rec_mutex_t *m, NANO_TIME relative_time)
static int rtos_cond_init(rt_cond_t *cond)
static int rtos_mutex_destroy(rt_mutex_t *m)
static int rtos_mutex_trylock_for(rt_mutex_t *m, NANO_TIME relative_time)
static NANO_TIME rtos_get_realtime_ns(void)
static int rtos_mutex_rec_lock_until(rt_rec_mutex_t *m, NANO_TIME abs_time)
static const NANO_TIME InfiniteNSecs
static TIME_SPEC ticks2timespec(TICK_TIME hrt)
static void rtos_disable_rt_warning(void)
static int rtos_mutex_rec_destroy(rt_rec_mutex_t *m)
static int rtos_cond_broadcast(rt_cond_t *cond)
static const TICK_TIME InfiniteTicks
static int clock_gettime(int clk_id, struct timespec *tp)
static int rtos_sem_value(rt_sem_t *m)
pthread_mutex_t rt_rec_mutex_t
static int rtos_sem_init(rt_sem_t *m, int value)
static int rtos_mutex_init(rt_mutex_t *m)
static int rtos_mutex_trylock(rt_mutex_t *m)
static NANO_TIME rtos_get_time_ticks(void)
struct timespec TIME_SPEC
static int rtos_mutex_lock(rt_mutex_t *m)
static int rtos_mutex_rec_init(rt_rec_mutex_t *m)
static int rtos_mutex_rec_trylock(rt_rec_mutex_t *m)
static int rtos_sem_signal(rt_sem_t *m)
pthread_mutex_t rt_mutex_t
static int rtos_sem_trywait(rt_sem_t *m)