intime/osal.c
Go to the documentation of this file.
1 /*
2  * Licensed under the GNU General Public License version 2 with exceptions. See
3  * LICENSE file in the project root for full license information
4  */
5 
6 #include <rt.h>
7 #include <sys/time.h>
8 #include <osal.h>
9 
11 static double qpc2usec;
12 
13 #define USECS_PER_SEC 1000000
14 
15 int osal_gettimeofday (struct timeval *tv, struct timezone *tz)
16 {
17  return gettimeofday (tv, tz);
18 }
19 
21 {
22  struct timeval current_time;
23  ec_timet return_value;
24 
25  osal_gettimeofday (&current_time, 0);
26  return_value.sec = current_time.tv_sec;
27  return_value.usec = current_time.tv_usec;
28  return return_value;
29 }
30 
31 void osal_timer_start (osal_timert * self, uint32 timeout_usec)
32 {
33  struct timeval start_time;
34  struct timeval timeout;
35  struct timeval stop_time;
36 
37  osal_gettimeofday (&start_time, 0);
38  timeout.tv_sec = timeout_usec / USECS_PER_SEC;
39  timeout.tv_usec = timeout_usec % USECS_PER_SEC;
40  timeradd (&start_time, &timeout, &stop_time);
41 
42  self->stop_time.sec = stop_time.tv_sec;
43  self->stop_time.usec = stop_time.tv_usec;
44 }
45 
47 {
48  struct timeval current_time;
49  struct timeval stop_time;
50  int is_not_yet_expired;
51 
52  osal_gettimeofday (&current_time, 0);
53  stop_time.tv_sec = self->stop_time.sec;
54  stop_time.tv_usec = self->stop_time.usec;
55  is_not_yet_expired = timercmp (&current_time, &stop_time, <);
56 
57  return is_not_yet_expired == FALSE;
58 }
59 
61 {
62  RtSleepEx (usec / 1000);
63  return 1;
64 }
65 
66 /* Mutex is not needed when running single threaded */
67 
68 void osal_mtx_lock(osal_mutex_t * mtx)
69 {
70  /* RtWaitForSingleObject((HANDLE)mtx, INFINITE); */
71 }
72 
73 void osal_mtx_unlock(osal_mutex_t * mtx)
74 {
75  /* RtReleaseMutex((HANDLE)mtx); */
76 }
77 
78 int osal_mtx_lock_timeout(osal_mutex_t * mtx, uint32_t time_ms)
79 {
80  /* return RtWaitForSingleObject((HANDLE)mtx, time_ms); */
81  return 0;
82 }
83 
84 osal_mutex_t * osal_mtx_create(void)
85 {
86  /* return (void*)RtCreateMutex(NULL, FALSE, NULL); */
87  return (void *)0;
88 }
ec_timet osal_current_time(void)
Definition: intime/osal.c:20
int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: intime/osal.c:15
int osal_mtx_lock_timeout(osal_mutex_t *mtx, uint32_t time_ms)
Definition: intime/osal.c:78
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
Definition: intime/osal.c:31
void osal_mtx_unlock(osal_mutex_t *mtx)
Definition: intime/osal.c:73
static double qpc2usec
Definition: intime/osal.c:11
#define USECS_PER_SEC
Definition: intime/osal.c:13
void osal_mtx_lock(osal_mutex_t *mtx)
Definition: intime/osal.c:68
Definition: osal.h:36
unsigned int uint32_t
Definition: stdint.h:80
#define FALSE
Definition: osal.h:22
boolean osal_timer_is_expired(osal_timert *self)
Definition: intime/osal.c:46
#define timercmp(a, b, CMP)
Definition: rtk/osal.c:12
static int64_t sysfrequency
Definition: intime/osal.c:10
#define timeradd(a, b, result)
Definition: rtk/osal.c:16
osal_mutex_t * osal_mtx_create(void)
Definition: intime/osal.c:84
signed __int64 int64_t
Definition: stdint.h:89
uint32_t uint32
Definition: osal.h:30
int osal_usleep(uint32 usec)
Definition: intime/osal.c:60
int gettimeofday(struct timeval *tp, void *tzp)
Definition: rtk/osal.c:50


soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Sat Jun 27 2020 03:48:21