Skip to content

Commit 9f0975c

Browse files
authored
Merge pull request #616 from jphickey/fix-615-rtems-build
Fix #615, RTEMS build issues
2 parents d753a45 + cd1e468 commit 9f0975c

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

src/os/rtems/src/os-impl-binsem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "os-impl-binsem.h"
4040
#include "os-shared-binsem.h"
4141
#include "os-shared-idmap.h"
42+
#include "os-shared-timebase.h"
4243

4344

4445
/****************************************************************************************
@@ -246,7 +247,7 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
246247
rtems_status_code status;
247248
int TimeInTicks;
248249

249-
if (OS_Milli2Ticks(msecs, &TimInTicks) != OS_SUCCESS)
250+
if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS)
250251
{
251252
return OS_ERROR;
252253
}

src/os/rtems/src/os-impl-countsem.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "os-shared-countsem.h"
4242
#include "os-shared-idmap.h"
43+
#include "os-shared-timebase.h"
4344

4445
/****************************************************************************************
4546
DEFINES
@@ -207,9 +208,12 @@ int32 OS_CountSemTake_Impl (uint32 sem_id)
207208
int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
208209
{
209210
rtems_status_code status;
210-
uint32 TimeInTicks;
211+
int TimeInTicks;
211212

212-
TimeInTicks = OS_Milli2Ticks(msecs);
213+
if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS)
214+
{
215+
return OS_ERROR;
216+
}
213217

214218
status = rtems_semaphore_obtain(OS_impl_count_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks);
215219
if (status == RTEMS_TIMEOUT)

src/os/rtems/src/os-impl-queues.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
#include "os-shared-queue.h"
4242
#include "os-shared-idmap.h"
43+
#include "os-shared-timebase.h"
44+
4345

4446
/****************************************************************************************
4547
DEFINES
@@ -162,6 +164,7 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c
162164
int32 return_code;
163165
rtems_status_code status;
164166
rtems_interval ticks;
167+
int tick_count;
165168
rtems_option option_set;
166169
size_t rtems_size;
167170
rtems_id rtems_queue_id;
@@ -182,8 +185,14 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c
182185
else
183186
{
184187
option_set = RTEMS_WAIT;
188+
185189
/* msecs rounded to the closest system tick count */
186-
ticks = OS_Milli2Ticks(timeout);
190+
if (OS_Milli2Ticks(timeout, &tick_count) != OS_SUCCESS)
191+
{
192+
return OS_ERROR;
193+
}
194+
195+
ticks = (rtems_interval)tick_count;
187196
}
188197

189198
/*

src/os/rtems/src/os-impl-tasks.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "os-shared-task.h"
4242
#include "os-shared-idmap.h"
43+
#include "os-shared-timebase.h"
4344

4445
/****************************************************************************************
4546
DEFINES
@@ -199,15 +200,28 @@ void OS_TaskExit_Impl()
199200
*-----------------------------------------------------------------*/
200201
int32 OS_TaskDelay_Impl (uint32 milli_second)
201202
{
202-
rtems_interval ticks;
203+
int tick_count;
204+
int32 return_code;
203205

204-
ticks = OS_Milli2Ticks(milli_second);
206+
return_code = OS_Milli2Ticks(milli_second, &tick_count);
207+
208+
if (return_code != OS_SUCCESS)
209+
{
210+
/*
211+
* always want to do some form of delay, because if
212+
* this function becomes a no-op then this might create a
213+
* tight loop that doesn't ever yield the CPU - effectively
214+
* locking the system in an RTOS environment.
215+
*/
216+
tick_count = 10;
217+
}
205218

206-
rtems_task_wake_after(ticks);
207219
/*
208220
** Always successful ( from RTEMS docs )
209221
*/
210-
return (OS_SUCCESS);
222+
rtems_task_wake_after((rtems_interval)tick_count);
223+
224+
return (return_code);
211225

212226
} /* end OS_TaskDelay_Impl */
213227

0 commit comments

Comments
 (0)