From f097d7d30465f5bf1dd6b658260646ef29a117ca Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 20 Jul 2021 15:55:10 -0400 Subject: [PATCH] Partial #1108, add typedef for OSAL status codes Minimal change to add a typedef for OS_Status_t, a macro for constants/literals, and an inline function to convert to "long" for printing/logging. --- src/os/inc/common_types.h | 6 ++++++ src/os/inc/osapi-error.h | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) 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