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 }
sysfrequency
static int64_t sysfrequency
Definition: intime/osal.c:10
osal_mtx_create
osal_mutex_t * osal_mtx_create(void)
Definition: intime/osal.c:84
uint32
uint32_t uint32
Definition: osal.h:30
osal_usleep
int osal_usleep(uint32 usec)
Definition: intime/osal.c:60
osal.h
uint32_t
unsigned int uint32_t
Definition: stdint.h:80
osal_timer
Definition: osal.h:42
osal_gettimeofday
int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: intime/osal.c:15
osal_current_time
ec_timet osal_current_time(void)
Definition: intime/osal.c:20
int64_t
signed __int64 int64_t
Definition: stdint.h:89
osal_mtx_lock_timeout
int osal_mtx_lock_timeout(osal_mutex_t *mtx, uint32_t time_ms)
Definition: intime/osal.c:78
FALSE
#define FALSE
Definition: osal.h:22
osal_timer_start
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
Definition: intime/osal.c:31
osal_mtx_unlock
void osal_mtx_unlock(osal_mutex_t *mtx)
Definition: intime/osal.c:73
timeradd
#define timeradd(a, b, result)
Definition: rtk/osal.c:16
USECS_PER_SEC
#define USECS_PER_SEC
Definition: intime/osal.c:13
ec_timet
Definition: osal.h:36
timercmp
#define timercmp(a, b, CMP)
Definition: rtk/osal.c:12
qpc2usec
static double qpc2usec
Definition: intime/osal.c:11
gettimeofday
int gettimeofday(struct timeval *tp, void *tzp)
Definition: rtk/osal.c:50
osal_mtx_lock
void osal_mtx_lock(osal_mutex_t *mtx)
Definition: intime/osal.c:68
osal_timer_is_expired
boolean osal_timer_is_expired(osal_timert *self)
Definition: intime/osal.c:46


soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49