diff --git a/packages/ti/osal/src/nonos/SemaphoreP_nonos.c b/packages/ti/osal/src/nonos/SemaphoreP_nonos.c
index c8f55cd342e3d2dcb0dc20b077f8018684e5bb7c..455878b86dd9dba7fb34d39231e65fc731a941f0 100644 (file)
{
uint32_t i;
Sem_Struct *semPool_ptr = semPool;
- for(i=0;i<maxSemaphores;i++)
+ for(i = 0U; i < maxSemaphores; i++)
{
- semPool_ptr->used = (bool)false;
+ semPool_ptr->used = BFALSE;
semPool_ptr->sem = i;
semPool_ptr->count = 0;
semPool_ptr->mode = SemaphoreP_Mode_COUNTING;
/* Check if user has specified any memory block to be used, which gets
* the precedence over the internal static memory block
*/
- if (gOsal_HwAttrs.extSemaphorePBlock.base != (uintptr_t)0U)
+ if ((uintptr_t)0U != gOsal_HwAttrs.extSemaphorePBlock.base)
{
/* pick up the external memory block configured */
semPool = (Sem_Struct *) gOsal_HwAttrs.extSemaphorePBlock.base;
maxSemaphores = OSAL_NONOS_CONFIGNUM_SEMAPHORE;
}
/* First time, semaphores are not initialized */
- if(gOsalSemAllocCnt==0U)
+ if(0U == gOsalSemAllocCnt)
{
semaphoreInit(semPool,maxSemaphores);
}
- for (i = 0; i < maxSemaphores; i++)
+ for (i = 0U; i < maxSemaphores; i++)
{
- if (semPool[i].used == (bool)false)
+ if (BFALSE == semPool[i].used)
{
- semPool[i].used = (bool)true;
+ semPool[i].used = BTRUE;
/* Update statistics */
gOsalSemAllocCnt++;
semPool[i].sem = i;
semPool[i].count = count;
- if (params != NULL_PTR)
+ if (NULL_PTR != params)
{
semPool[i].mode = params->mode;
}
*/
SemaphoreP_Status SemaphoreP_delete(SemaphoreP_Handle handle)
{
- OSAL_Assert((handle == NULL_PTR));
SemaphoreP_Status ret = SemaphoreP_OK;
uintptr_t key;
Sem_Struct *semS = (Sem_Struct *)handle;
- if((semS != NULL_PTR) && (semS->used))
+ if((NULL_PTR != semS) && (semS->used))
{
key = HwiP_disable();
- semS->used = (bool)false;
+ semS->used = BFALSE;
/* Found the bsp osal semaphore object to delete */
- if (gOsalSemAllocCnt > 0U)
+ if (0U < gOsalSemAllocCnt)
{
gOsalSemAllocCnt--;
}
*/
void SemaphoreP_Params_init(SemaphoreP_Params *params)
{
- OSAL_Assert((params == NULL_PTR));
- if(params!=NULL_PTR) {
+ if(NULL_PTR != params) {
params->mode = SemaphoreP_Mode_COUNTING;
params->name = (char *) NULL_PTR;
}
*/
SemaphoreP_Status SemaphoreP_pend(SemaphoreP_Handle handle, uint32_t timeout)
{
- OSAL_Assert((handle == NULL_PTR));
-
uintptr_t key;
Sem_Struct *semS = (Sem_Struct *)handle;
uint32_t semTimeout = timeout;
SemaphoreP_Status ret_val = SemaphoreP_OK;
- bool iterate = (bool)true;
+ bool iterate = BTRUE;
- if(semS!=NULL) {
- while ( (ret_val == SemaphoreP_OK) && (iterate== (bool)true))
+ if(NULL != semS) {
+ while ( (SemaphoreP_OK == ret_val) && (BTRUE == iterate))
{
key = HwiP_disable();
- if (semS->count > 0U)
+ if (0U < (semS->count))
{
- if (semS->mode == SemaphoreP_Mode_BINARY)
+ if (SemaphoreP_Mode_BINARY == semS->mode)
{
- semS->count = 0;
+ semS->count = 0U;
}
else
{
semS->count--;
}
HwiP_restore(key);
- iterate=(bool)false;
+ iterate = BFALSE;
}
else
{
HwiP_restore(key);
- if (semTimeout == SemaphoreP_NO_WAIT)
+ if (SemaphoreP_NO_WAIT == semTimeout)
{
ret_val = (SemaphoreP_TIMEOUT);
- iterate=(bool)false;
+ iterate = BFALSE;
}
- else if (semTimeout == SemaphoreP_WAIT_FOREVER)
+ else if (SemaphoreP_WAIT_FOREVER == semTimeout)
{
/* Wait forever */
}
*/
SemaphoreP_Status SemaphoreP_post(SemaphoreP_Handle handle)
{
- OSAL_Assert((handle == NULL_PTR));
SemaphoreP_Status ret = SemaphoreP_OK;
uintptr_t key;
Sem_Struct *semS = (Sem_Struct *)handle;
- if(semS != NULL_PTR)
+ if(NULL_PTR != semS)
{
key = HwiP_disable();
- if (semS->mode == SemaphoreP_Mode_BINARY)
+ if (SemaphoreP_Mode_BINARY == semS->mode)
{
- semS->count = 1;
+ semS->count = 1U;
}
else
{
int32_t SemaphoreP_getCount(SemaphoreP_Handle handle)
{
- int32_t ret=0;
- OSAL_Assert((handle == NULL_PTR));
+ int32_t ret = 0;
Sem_Struct *semS = (Sem_Struct *)handle;
- if(semS !=NULL_PTR) {
+ if(NULL_PTR != semS) {
ret = (int32_t)semS->count;
} else {
ret = 0;