diff --git a/src/os/inc/common_types.h b/src/os/inc/common_types.h index 411407452..277c85ec9 100644 --- a/src/os/inc/common_types.h +++ b/src/os/inc/common_types.h @@ -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 * @@ -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 */ diff --git a/src/os/inc/osapi-error.h b/src/os/inc/osapi-error.h index f71e97eb7..53db5c3c5 100644 --- a/src/os/inc/osapi-error.h +++ b/src/os/inc/osapi-error.h @@ -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