Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Partial #1108, add typedef for OSAL status codes #1112

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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