Skip to content

Commit

Permalink
Merge pull request #1112 from jphickey/partial-1108-add-typedef
Browse files Browse the repository at this point in the history
Partial #1108, add typedef for OSAL status codes
  • Loading branch information
astrogeco committed Nov 3, 2021
2 parents 42af0f7 + f097d7d commit 84d76c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/os/inc/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ extern "C"
*/
typedef uint32 osal_objtype_t;

/**
* The preferred type to represent OSAL status codes defined in osapi-error.h
*/
typedef int32 osal_status_t;

/**
* @brief General purpose OSAL callback function
*
Expand Down Expand Up @@ -155,5 +160,6 @@ extern "C"
#define OSAL_BLOCKCOUNT_C(X) ((osal_blockcount_t)(X))
#define OSAL_INDEX_C(X) ((osal_index_t)(X))
#define OSAL_OBJTYPE_C(X) ((osal_objtype_t)(X))
#define OSAL_STATUS_C(X) ((osal_status_t)(X))

#endif /* COMMON_TYPES_H */
16 changes: 16 additions & 0 deletions src/os/inc/osapi-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ typedef char os_err_name_t[OS_ERROR_NAME_LENGTH];
* @{
*/

/*-------------------------------------------------------------------------------------*/
/**
* @brief Convert a status code to a native "long" type
*
* For printing or logging purposes, this converts the given status code
* to a "long" (signed integer) value. It should be used in conjunction
* with the "%ld" conversion specifier in printf-style statements.
*
* @param[in] Status Execution status, see @ref OSReturnCodes
* @return Same status value converted to the "long" data type
*/
static inline long OS_StatusToInteger(osal_status_t Status)
{
return (long)Status;
}

/*-------------------------------------------------------------------------------------*/
/**
* @brief Convert an error number to a string
Expand Down

0 comments on commit 84d76c2

Please sign in to comment.