ERROR MANAGEMENT MACROS | |
Helper Macros to deal with the error management. Sample usage: alp_status_t foo() { ALP_ERROR_MANAGE // Enable error management ALP_FAIL(foo2()) // status_t foo2(); ALP_ON_ERROR // Manage error conditions / cleanup return ALP_ERROR; // Return actual error value } | |
| #define | ALP_ERROR _err_ |
| Contains the actual error value. | |
| #define | ALP_ERROR_MANAGE alp_status_t ALP_ERROR = ALP_STATUS_OK; |
| Needed at the beginning of the function for the following macros to work properly. | |
| #define | ALP_FAIL(statement) |
| Execute a statement and check success. Jump to ALP_ON_ERROR in case of failure. | |
| #define | ALP_FAIL_ERROR(statement, error) |
| Execute a statement and check success. Jump to ALP_ON_ERROR in case of failure. | |
| #define | ALP_FAIL_ERROR_LABEL(statement, error, label) |
| Execute a statement and check success. Jump to ALP_ON_ERROR in case of failure. | |
| #define | ALP_FAIL_LABEL(statement, label) |
| Execute a statement and check success. Jump to ALP_ON_ERROR in case of failure. | |
| #define | ALP_FAIL_MALLOC(var, size, error) |
| Allocate memory and check success. Jump to ALP_ON_ERROR in case of failure. | |
| #define | ALP_FAIL_NULL(var, statement, error) |
| Assigns the value of statement to the variable var. Jump to ALP_ON_ERROR if expression evaluates to NULL. | |
| #define | ALP_FAIL_NULL_LABEL(var, statement, error, label) |
| Assigns the value of statement to the variable var. Jump to ALP_ON_ERROR if expression evaluates to NULL. | |
| #define | ALP_ON_ERROR _on_error_ |
| Functions can jump to this label if they are performing their own error handling outside of the error macros. | |
| #define | ALP_ON_ERROR_LABEL ALP_ON_ERROR: |
| ALP_FAIL and ALP_FAIL_ERROR and ALP_FAIL_MALLOC macros will jump to this bloc in case of an error. | |
ERROR CONSTRUCTION MACROS | |
| Helper Macros to deal with error construction. | |
| #define | ALP_ERROR_DECLARE(class, error) ((alp_status_t)((alp_status_t)(class) | (alp_status_t)(error) << 16)) |
| Define an error. | |
| #define | ALP_ERROR_SET_INFO(error, info) (alp_status_t)(((alp_status_t)(error))| ((((alp_status_t)(info)) >> 16) & 0x0000FFFF)) |
| Set the error info part. | |
|
|
Contains the actual error value.
|
|
|
Define an error.
|
|
|
Needed at the beginning of the function for the following macros to work properly.
|
|
|
Set the error info part.
|
|
|
Value: {ALP_ERROR = statement; \
if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
goto ALP_ON_ERROR;}
|
|
|
Value: {ALP_ERROR = statement;\
if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
{\
ALP_ERROR = error;\
goto ALP_ON_ERROR;\
}}
|
|
|
Value: {ALP_ERROR = statement;\
if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
{\
ALP_ERROR = error;\
goto label;\
}}
|
|
|
Value: {ALP_ERROR = statement;\
if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
goto label;}
|
|
|
Value: {(var) = malloc((size));\
if((var) == NULL)\
{\
ALP_ERROR = error;\
goto ALP_ON_ERROR;\
}}
|
|
|
Value: {(var) = statement; \
if((var) == NULL) \
{\
ALP_ERROR = error; \
goto ALP_ON_ERROR; \
}}
|
|
|
Value: {(var) = statement; \
if((var) == NULL) \
{\
ALP_ERROR = error; \
goto label; \
}}
|
|
|
Functions can jump to this label if they are performing their own error handling outside of the error macros.
|
|
|
ALP_FAIL and ALP_FAIL_ERROR and ALP_FAIL_MALLOC macros will jump to this bloc in case of an error.
|
Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.