Skip to content

Commit

Permalink
Merge pull request #596 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
Integration Candidate: 2020-09-09
  • Loading branch information
yammajamma authored Sep 15, 2020
2 parents c3b1398 + 4e8e345 commit 4f7e201
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 71 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: 5.1.0-rc1+dev27

- Introduces a new typedef, osal_id_t, in common_types.h, which should be used to represent an OSAL ID. All API structures/functions are updated to use this typedef in place of the uint32 type wherever it actually refers to an OSAL ID.
- Fail tests on startup or tear down failures. These are failures, just a different severity (likely mean the test didn't work as expected and needs to be fixed).
- Max timer create test was using OS_MAX_TIMERS (the limit for adding timers to a time base), but creating timers is limited by OS_MAX_TIMEBASES since the create adds a new time base.
- HOTFIX 20200902 - Fix documentation warnings in OSAL.
- HOTFIX 20200902 - Hide the call graph on utility functions.
- See <https://github.com/nasa/osal/pull/590>
### Development Build: 5.1.0-rc1+dev34

- Move this existing function into the public API, as it is performs more verification than the OS_ConvertToArrayIndex
function.
- The C library type is signed, and this makes the result check work as intended.
- See <https://github.com/nasa/osal/pull/596>

### Development Build: 5.1.0-rc1+dev16

Expand Down
39 changes: 39 additions & 0 deletions src/os/inc/osapi-os-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ uint32 OS_IdentifyObject (osal_id_t object_id);
* @note This does NOT verify the validity of the ID, that is left to the caller.
* This is only the conversion logic.
*
* This routine accepts any object type, and returns a value based on the
* maximum number of objects for that type. This is equivalent to invoking
* OS_ObjectIdToArrayIndex() with the idtype set to OS_OBJECT_TYPE_UNDEFINED.
*
* @sa OS_ObjectIdToArrayIndex
*
* @param[in] object_id The object ID to operate on
* @param[out] *ArrayIndex The Index to return
*
Expand All @@ -437,6 +443,39 @@ uint32 OS_IdentifyObject (osal_id_t object_id);
*/
int32 OS_ConvertToArrayIndex (osal_id_t object_id, uint32 *ArrayIndex);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Converts an abstract ID into a number suitable for use as an array index.
*
* This will return a unique zero-based integer number in the range of [0,MAX) for
* any valid object ID. This may be used by application code as an array index
* for indexing into local tables.
*
* This routine operates on a specific object type, and returns a value based on the
* maximum number of objects for that type.
*
* If the idtype is passed as #OS_OBJECT_TYPE_UNDEFINED, then object type verification
* is skipped and any object ID will be accepted and converted to an index. In this
* mode, the range of the output depends on the actual passed-in object type.
*
* If the idtype is passed as any other value, the passed-in ID value is first
* confirmed to be the correct type. This check will guarantee that the output
* is within an expected range; for instance, if the type is passed as
* #OS_OBJECT_TYPE_OS_TASK, then the output index is guaranteed to be between 0 and
* #OS_MAX_TASKS-1 after successful conversion.
*
* @param[in] idtype The object type to convert
* @param[in] object_id The object ID to operate on
* @param[out] *ArrayIndex The Index to return
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INCORRECT_OBJ_TYPE @copybrief OS_ERR_INCORRECT_OBJ_TYPE
* */
int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayIndex);



/*-------------------------------------------------------------------------------------*/
/**
* @brief call the supplied callback function for all valid object IDs
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 27
#define OS_BUILD_NUMBER 34
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
9 changes: 0 additions & 9 deletions src/os/shared/inc/os-shared-idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@ uint32 OS_GetBaseForObjectType(uint32 idtype);
------------------------------------------------------------------*/
int32 OS_ObjectIdFindByName (uint32 idtype, const char *name, osal_id_t *object_id);

/*----------------------------------------------------------------
Function: OS_ObjectIdToArrayIndex
Purpose: Convert a 32-bit OSAL ID into a zero-based array index
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t id, uint32 *ArrayIndex);

/*----------------------------------------------------------------
Function: OS_ObjectIdGetBySearch
Expand Down
103 changes: 51 additions & 52 deletions src/os/shared/src/osapi-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,58 +663,6 @@ void OS_Unlock_Global(uint32 idtype)
}
}


/*----------------------------------------------------------------
*
* Function: OS_ObjectIdToArrayIndex
*
* Purpose: Local helper routine, not part of OSAL API.
* Convert an object ID (which must be of the given type) to a number suitable
* for use as an array index. The array index will be in the range of:
* 0 <= ArrayIndex < OS_MAX_<OBJTYPE>
*
* If the passed-in ID type is OS_OBJECT_TYPE_UNDEFINED, then any type
* is allowed.
*
* returns: If the passed-in ID is not of the proper type, OS_ERROR is returned
* Otherwise OS_SUCCESS is returned.
*
*-----------------------------------------------------------------*/
int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t id, uint32 *ArrayIndex)
{
uint32 max_id;
uint32 obj_index;
uint32 actual_type;
int32 return_code;

obj_index = OS_ObjectIdToSerialNumber_Impl(id);
actual_type = OS_ObjectIdToType_Impl(id);

/*
* If requested by the caller, enforce that the ID is of the correct type.
* If the caller passed OS_OBJECT_TYPE_UNDEFINED, then anything is allowed.
*/
if (idtype != OS_OBJECT_TYPE_UNDEFINED && actual_type != idtype)
{
return_code = OS_ERR_INVALID_ID;
}
else
{
max_id = OS_GetMaxForObjectType(actual_type);
if (max_id == 0)
{
return_code = OS_ERR_INVALID_ID;
}
else
{
return_code = OS_SUCCESS;
*ArrayIndex = obj_index % max_id;
}
}

return return_code;
} /* end OS_ObjectIdToArrayIndex */

/*----------------------------------------------------------------
*
* Function: OS_ObjectIdFinalizeNew
Expand Down Expand Up @@ -1249,3 +1197,54 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size)
} /* end OS_GetResourceName */


/*----------------------------------------------------------------
*
* Function: OS_ObjectIdToArrayIndex
*
* Purpose: Convert an object ID (which must be of the given type) to a number suitable
* for use as an array index. The array index will be in the range of:
* 0 <= ArrayIndex < OS_MAX_<OBJTYPE>
*
* If the passed-in ID type is OS_OBJECT_TYPE_UNDEFINED, then any type
* is allowed.
*
* returns: If the passed-in ID is not of the proper type, OS_ERROR is returned
* Otherwise OS_SUCCESS is returned.
*
*-----------------------------------------------------------------*/
int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayIndex)
{
uint32 max_id;
uint32 obj_index;
uint32 actual_type;
int32 return_code;

obj_index = OS_ObjectIdToSerialNumber_Impl(object_id);
actual_type = OS_ObjectIdToType_Impl(object_id);

/*
* If requested by the caller, enforce that the ID is of the correct type.
* If the caller passed OS_OBJECT_TYPE_UNDEFINED, then anything is allowed.
*/
if (idtype != OS_OBJECT_TYPE_UNDEFINED && actual_type != idtype)
{
return_code = OS_ERR_INVALID_ID;
}
else
{
max_id = OS_GetMaxForObjectType(actual_type);
if (max_id == 0)
{
return_code = OS_ERR_INVALID_ID;
}
else
{
return_code = OS_SUCCESS;
*ArrayIndex = obj_index % max_id;
}
}

return return_code;
} /* end OS_ObjectIdToArrayIndex */


2 changes: 1 addition & 1 deletion src/unit-test-coverage/ut-stubs/inc/OCS_sys_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/* types normally defined in sys/types.h */
/* ----------------------------------------- */
typedef ptrdiff_t OCS_ssize_t;
typedef size_t OCS_off_t;
typedef long OCS_off_t;
typedef unsigned int OCS_mode_t;
typedef long OCS_time_t;
typedef int OCS_pid_t;
Expand Down

0 comments on commit 4f7e201

Please sign in to comment.