Skip to content

Commit 27c2469

Browse files
authored
Merge pull request #607 from nasa/integration-candidate
Integration Candidate: 2020-09-23
2 parents f12d42b + c3c8d40 commit 27c2469

23 files changed

+138
-221
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF
1010

1111
## Version History
1212

13+
### Development Build: 5.1.0-rc1+dev44
14+
- Removes OS_Tick2Micros and internalize OS_Milli2Ticks.
15+
- Adds ut_assert address equal macro.
16+
- See <https://github.com/nasa/osal/pull/607>
17+
1318
### Development Build: 5.1.0-rc1+dev38
1419
- Sets Revision to 99 for development builds
1520
- See <https://github.com/nasa/osal/pull/600>

src/os/inc/osapi-os-core.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,38 +1222,10 @@ int32 OS_MutSemGetIdByName (osal_id_t *sem_id, const char *sem_name);
12221222
int32 OS_MutSemGetInfo (osal_id_t sem_id, OS_mut_sem_prop_t *mut_prop);
12231223
/**@}*/
12241224

1225-
/** @defgroup OSAPITime OSAL Time/Tick APIs
1225+
/** @defgroup OSAPITime OSAL Time APIs
12261226
* @{
12271227
*/
12281228

1229-
/*-------------------------------------------------------------------------------------*/
1230-
/**
1231-
* @brief Convert time units from milliseconds to system ticks
1232-
*
1233-
* This function accepts a time interval in milliseconds and
1234-
* returns the tick equivalent. If the result is not an exact
1235-
* number of system ticks, the result will be rounded up to
1236-
* the nearest tick.
1237-
*
1238-
* @param[in] milli_seconds the number of milliseconds
1239-
*
1240-
* @return The number of ticks
1241-
*/
1242-
int32 OS_Milli2Ticks (uint32 milli_seconds);
1243-
1244-
/*-------------------------------------------------------------------------------------*/
1245-
/**
1246-
* @brief Get the system tick size, in microseconds
1247-
*
1248-
* This function returns the duration of a system tick in micro seconds
1249-
*
1250-
* @note care is taken to ensure this does not return "0" since it is often used
1251-
* as the divisor in mathematical operations
1252-
*
1253-
* @return Duration of a system tick in microseconds
1254-
*/
1255-
int32 OS_Tick2Micros (void);
1256-
12571229
/*-------------------------------------------------------------------------------------*/
12581230
/**
12591231
* @brief Get the local time

src/os/inc/osapi-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/*
3131
* Development Build Macro Definitions
3232
*/
33-
#define OS_BUILD_NUMBER 38
33+
#define OS_BUILD_NUMBER 44
3434
#define OS_BUILD_BASELINE "v5.1.0-rc1"
3535

3636
/*

src/os/posix/src/os-impl-timebase.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ int32 OS_Posix_TimeBaseAPI_Impl_Init(void)
275275

276276
/*
277277
* Pre-calculate the clock tick to microsecond conversion factor.
278-
* This is used by OS_Tick2Micros(), OS_Milli2Ticks(), etc.
279278
*/
280279
OS_SharedGlobalVars.TicksPerSecond = sysconf(_SC_CLK_TCK);
281280
if (OS_SharedGlobalVars.TicksPerSecond <= 0)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,12 @@ int32 OS_BinSemTake_Impl (uint32 sem_id)
244244
int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
245245
{
246246
rtems_status_code status;
247-
uint32 TimeInTicks;
247+
int TimeInTicks;
248248

249-
TimeInTicks = OS_Milli2Ticks(msecs);
249+
if (OS_Milli2Ticks(msecs, &TimInTicks) != OS_SUCCESS)
250+
{
251+
return OS_ERROR;
252+
}
250253

251254
status = rtems_semaphore_obtain(OS_impl_bin_sem_table[sem_id].id, RTEMS_WAIT, TimeInTicks) ;
252255

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ int32 OS_Rtems_TimeBaseAPI_Impl_Init ( void )
231231

232232

233233
/*
234-
* Finally compute the Microseconds per tick that is used for OS_Tick2Micros() call
234+
* Finally compute the Microseconds per tick
235235
* This must further round again to the nearest microsecond, so it is undesirable to use
236236
* this for time computations if the result is not exact.
237237
*/

src/os/shared/inc/os-shared-timebase.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ int32 OS_TimeBaseGetInfo_Impl (uint32 timer_id, OS_timebase_prop_t *timer_
134134
------------------------------------------------------------------*/
135135
void OS_TimeBase_CallbackThread (osal_id_t timebase_id);
136136

137+
/*----------------------------------------------------------------
138+
Function: OS_Milli2Ticks
139+
140+
Purpose: Convert milliseconds to ticks
141+
------------------------------------------------------------------*/
142+
int32 OS_Milli2Ticks(uint32 milli_seconds, int *ticks);
137143

138144
#endif /* INCLUDE_OS_SHARED_TIMEBASE_H_ */
139145

src/os/shared/src/osapi-timebase.c

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -545,49 +545,32 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id)
545545
}
546546
} /* end OS_TimeBase_CallbackThread */
547547

548-
/****************************************************************************************
549-
Other Time-Related API Implementation
550-
***************************************************************************************/
551-
552-
/*
553-
* This is the OSAL-defined interface to the OS Timer tick -
554-
* Not sure what it is really useful for since none of the user API timer calls deal with
555-
* OS ticks directly.
556-
*/
557-
558-
559-
/*----------------------------------------------------------------
560-
*
561-
* Function: OS_Tick2Micros
562-
*
563-
* Purpose: Implemented per public OSAL API
564-
* See description in API and header file for detail
565-
*
566-
*-----------------------------------------------------------------*/
567-
int32 OS_Tick2Micros (void)
568-
{
569-
return (OS_SharedGlobalVars.MicroSecPerTick);
570-
} /* end OS_Tick2Micros */
571-
572-
573548
/*----------------------------------------------------------------
574549
*
575550
* Function: OS_Milli2Ticks
576551
*
577-
* Purpose: Implemented per public OSAL API
578-
* See description in API and header file for detail
552+
* Purpose: Internal helper to convert milliseconds to ticks
553+
*
554+
* Returns: OS_SUCCESS on success, OS_ERROR on failure (rollover)
579555
*
580556
*-----------------------------------------------------------------*/
581-
int32 OS_Milli2Ticks(uint32 milli_seconds)
557+
int32 OS_Milli2Ticks(uint32 milli_seconds, int *ticks)
582558
{
583-
unsigned long num_of_ticks;
584-
585-
num_of_ticks = (unsigned long)milli_seconds;
586-
num_of_ticks *= OS_SharedGlobalVars.TicksPerSecond;
587-
num_of_ticks = (num_of_ticks + 999) / 1000;
588-
589-
return((uint32)num_of_ticks);
590-
} /* end OS_Milli2Ticks */
559+
uint64 num_of_ticks;
560+
int32 return_code = OS_SUCCESS;
591561

562+
num_of_ticks = (((uint64)milli_seconds * OS_SharedGlobalVars.TicksPerSecond) + 999) / 1000;
592563

564+
/* Check against maximum int32 (limit from some OS's) */
565+
if (num_of_ticks <= INT_MAX)
566+
{
567+
*ticks = (int)num_of_ticks;
568+
}
569+
else
570+
{
571+
return_code = OS_ERROR;
572+
*ticks = 0;
573+
}
593574

575+
return return_code;
576+
} /* end OS_Milli2Ticks */

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "os-impl-binsem.h"
3434
#include "os-shared-binsem.h"
35+
#include "os-shared-timebase.h"
3536

3637
/****************************************************************************************
3738
DEFINES
@@ -175,7 +176,17 @@ int32 OS_BinSemTake_Impl (uint32 sem_id)
175176
*-----------------------------------------------------------------*/
176177
int32 OS_BinSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
177178
{
178-
return OS_VxWorks_GenericSemTake(OS_impl_bin_sem_table[sem_id].vxid, OS_Milli2Ticks(msecs));
179+
int ticks;
180+
int32 status;
181+
182+
status = OS_Milli2Ticks(msecs, &ticks);
183+
184+
if (status == OS_SUCCESS)
185+
{
186+
status = OS_VxWorks_GenericSemTake(OS_impl_bin_sem_table[sem_id].vxid, ticks);
187+
}
188+
189+
return status;
179190
} /* end OS_BinSemTimedWait_Impl */
180191

181192

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "os-vxworks.h"
3232
#include "os-impl-countsem.h"
3333
#include "os-shared-countsem.h"
34+
#include "os-shared-timebase.h"
3435

3536
/****************************************************************************************
3637
DEFINES
@@ -153,8 +154,17 @@ int32 OS_CountSemTake_Impl (uint32 sem_id)
153154
*-----------------------------------------------------------------*/
154155
int32 OS_CountSemTimedWait_Impl (uint32 sem_id, uint32 msecs)
155156
{
156-
return OS_VxWorks_GenericSemTake(OS_impl_count_sem_table[sem_id].vxid,
157-
OS_Milli2Ticks(msecs));
157+
int ticks;
158+
int32 status;
159+
160+
status = OS_Milli2Ticks(msecs, &ticks);
161+
162+
if (status == OS_SUCCESS)
163+
{
164+
status = OS_VxWorks_GenericSemTake(OS_impl_count_sem_table[sem_id].vxid, ticks);
165+
}
166+
167+
return status;
158168
} /* end OS_CountSemTimedWait_Impl */
159169

160170

0 commit comments

Comments
 (0)