66 #include "../oro_limits.h" 67 #include "../../rtt-config.h" 85 RTT_API
unsigned int sleep(
unsigned int seconds);
88 RTT_API
int usleep(
unsigned int us);
99 #define ORO_WAIT_ABS 0 101 #define ORO_WAIT_REL 1 108 NANO_TIME periodMark;
117 #define ORO_SCHED_RT 0 118 #define ORO_SCHED_OTHER 1 120 //conflicts with another struct under MSVC 133 timevl.tv_sec = (long)(hrt / 1000000000LL);
134 timevl.tv_nsec = (long)(hrt % 1000000000LL);
142 QueryPerformanceFrequency(&freq);
143 QueryPerformanceCounter(&ticks);
145 return(
NANO_TIME)(((double)ticks.QuadPart * 1000000000LL) / (double)freq.QuadPart);
161 if (nano > 3000000L) Sleep((DWORD)(nano/1000000L) - 1);
195 *m = CreateSemaphore(NULL, value, 100000, NULL);
196 return (*m != NULL) ? 0 : -1;
207 return (ReleaseSemaphore(*m, 1, NULL) == 0) ? -1 : 0;
212 return (WaitForSingleObject(*m, INFINITE) == WAIT_FAILED) ? -1 : 0;
217 return (WaitForSingleObject(*m, 0) == WAIT_TIMEOUT) ? -1 : 0;
222 return (WaitForSingleObject(*m, (DWORD)(delay/1000000)) == WAIT_TIMEOUT) ? -1 : 0;
236 switch (WaitForSingleObject(*m, 0))
239 if (!ReleaseSemaphore(*m, 1, &previous))
return -1;
241 case WAIT_TIMEOUT:
return 0;
254 InitializeCriticalSection(m);
260 DeleteCriticalSection(m);
276 EnterCriticalSection(m);
282 LeaveCriticalSection(m);
288 if(TryEnterCriticalSection(m) != 0)
return 0;
331 enum { SIGNAL = 0, BROADCAST = 1, MAX_EVENTS = 2 };
333 HANDLE events_[MAX_EVENTS];
382 LeaveCriticalSection (external_mutex);
387 int result = WaitForMultipleObjects (2, cond->
events_, FALSE, ms);
402 EnterCriticalSection (external_mutex);
441 #define rtos_printf printf 443 int setenv(
const char *name,
const char *value,
int overwrite);
static void rtos_disable_rt_warning()
static int rtos_mutex_rec_unlock(rt_rec_mutex_t *m)
static int rtos_sem_wait_until(rt_sem_t *m, NANO_TIME abs_time)
static int rtos_mutex_destroy(rt_mutex_t *m)
int setenv(const char *name, const char *value, int overwrite)
static int rtos_mutex_rec_lock(rt_rec_mutex_t *m)
static int rtos_sem_destroy(rt_sem_t *m)
const double InfiniteSeconds
static int rtos_mutex_rec_trylock(rt_rec_mutex_t *m)
static int rtos_cond_timedwait_internal(rt_cond_t *cond, rt_mutex_t *external_mutex, DWORD ms)
static int rtos_sem_trywait(rt_sem_t *m)
static int rtos_mutex_lock(rt_mutex_t *m)
unsigned int waiters_count_
static int rtos_mutex_init(rt_mutex_t *m)
static int rtos_cond_init(rt_cond_t *cond)
struct cond_struct rt_cond_t
CRITICAL_SECTION rt_rec_mutex_t
const NANO_TIME InfiniteNSecs
int win32_nanosleep(long long nano)
NANO_TIME rtos_get_time_ns(void)
static int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex)
TIME_SPEC ticks2timespec(TICK_TIME hrt)
static int rtos_mutex_rec_init(rt_rec_mutex_t *m)
static int rtos_sem_wait(rt_sem_t *m)
cyg_tick_count_t TICK_TIME
static int rtos_mutex_trylock(rt_mutex_t *m)
CRITICAL_SECTION rt_mutex_t
static int rtos_mutex_unlock(rt_mutex_t *m)
HANDLE events_[MAX_EVENTS]
static int rtos_sem_init(rt_sem_t *m, int value)
long long nano2ticks(long long nano)
static int rtos_cond_signal(rt_cond_t *cond)
static int rtos_mutex_rec_destroy(rt_rec_mutex_t *m)
static int rtos_sem_signal(rt_sem_t *m)
TICK_TIME rtos_get_time_ticks()
static int rtos_cond_broadcast(rt_cond_t *cond)
RTT_API unsigned int sleep(unsigned int seconds)
long long ticks2nano(long long count)
RTT_API int usleep(unsigned int us)
static int rtos_mutex_rec_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
const TICK_TIME InfiniteTicks
static int rtos_cond_destroy(rt_cond_t *cond)
static int rtos_sem_wait_timed(rt_sem_t *m, NANO_TIME delay)
CRITICAL_SECTION waiters_count_lock_
static int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time)
int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
static int rtos_mutex_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
struct timespec TIME_SPEC
static int rtos_sem_value(rt_sem_t *m)
static void rtos_enable_rt_warning()