Skip to content

Commit

Permalink
Merge pull request #616 from jphickey/fix-615-rtems-build
Browse files Browse the repository at this point in the history
Fix #615, RTEMS build issues
  • Loading branch information
astrogeco authored Oct 5, 2020
2 parents d753a45 + cd1e468 commit 9f0975c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/os/rtems/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "os-impl-binsem.h"
#include "os-shared-binsem.h"
#include "os-shared-idmap.h"
#include "os-shared-timebase.h"


/****************************************************************************************
Expand Down Expand Up @@ -246,7 +247,7 @@ int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
rtems_status_code status;
int TimeInTicks;

if (OS_Milli2Ticks(msecs, &TimInTicks) != OS_SUCCESS)
if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS)
{
return OS_ERROR;
}
Expand Down
8 changes: 6 additions & 2 deletions src/os/rtems/src/os-impl-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "os-shared-countsem.h"
#include "os-shared-idmap.h"
#include "os-shared-timebase.h"

/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -207,9 +208,12 @@ int32 OS_CountSemTake_Impl (uint32 sem_id)
int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
{
rtems_status_code status;
uint32 TimeInTicks;
int TimeInTicks;

TimeInTicks = OS_Milli2Ticks(msecs);
if (OS_Milli2Ticks(msecs, &TimeInTicks) != OS_SUCCESS)
{
return OS_ERROR;
}

status = rtems_semaphore_obtain(OS_impl_count_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks);
if (status == RTEMS_TIMEOUT)
Expand Down
11 changes: 10 additions & 1 deletion src/os/rtems/src/os-impl-queues.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#include "os-shared-queue.h"
#include "os-shared-idmap.h"
#include "os-shared-timebase.h"


/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -162,6 +164,7 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c
int32 return_code;
rtems_status_code status;
rtems_interval ticks;
int tick_count;
rtems_option option_set;
size_t rtems_size;
rtems_id rtems_queue_id;
Expand All @@ -182,8 +185,14 @@ int32 OS_QueueGet_Impl (uint32 queue_id, void *data, uint32 size, uint32 *size_c
else
{
option_set = RTEMS_WAIT;

/* msecs rounded to the closest system tick count */
ticks = OS_Milli2Ticks(timeout);
if (OS_Milli2Ticks(timeout, &tick_count) != OS_SUCCESS)
{
return OS_ERROR;
}

ticks = (rtems_interval)tick_count;
}

/*
Expand Down
22 changes: 18 additions & 4 deletions src/os/rtems/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "os-shared-task.h"
#include "os-shared-idmap.h"
#include "os-shared-timebase.h"

/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -199,15 +200,28 @@ void OS_TaskExit_Impl()
*-----------------------------------------------------------------*/
int32 OS_TaskDelay_Impl (uint32 milli_second)
{
rtems_interval ticks;
int tick_count;
int32 return_code;

ticks = OS_Milli2Ticks(milli_second);
return_code = OS_Milli2Ticks(milli_second, &tick_count);

if (return_code != OS_SUCCESS)
{
/*
* always want to do some form of delay, because if
* this function becomes a no-op then this might create a
* tight loop that doesn't ever yield the CPU - effectively
* locking the system in an RTOS environment.
*/
tick_count = 10;
}

rtems_task_wake_after(ticks);
/*
** Always successful ( from RTEMS docs )
*/
return (OS_SUCCESS);
rtems_task_wake_after((rtems_interval)tick_count);

return (return_code);

} /* end OS_TaskDelay_Impl */

Expand Down

0 comments on commit 9f0975c

Please sign in to comment.