include/alp/error_macros.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (c) 1999-2008 ACCESS CO., LTD. All rights reserved.
00003  * Copyright (c) 2006 PalmSource, Inc (an ACCESS company). All rights reserved.
00004  *****************************************************************************/
00013 #ifndef ALP_ERROR_MACROS_H
00014 #define ALP_ERROR_MACROS_H
00015 
00022 #include <alp/types.h>
00023 #include <alp/sysclass.h>
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif /* __cplusplus */
00028 
00035 #define ALP_ERROR_DECLARE(class, error) \
00036         ((alp_status_t)((alp_status_t)(class) | (alp_status_t)(error) << 16))
00037 
00042 #define ALP_ERROR_SET_INFO(error, info) \
00043         (alp_status_t)(((alp_status_t)(error))| ((((alp_status_t)(info)) >> 16) & 0x0000FFFF))
00044 
00045 /* @} */
00046 
00065 #define ALP_ERROR                                                                               _err_
00066 
00068 #define ALP_ERROR_MANAGE                                                                alp_status_t ALP_ERROR = ALP_STATUS_OK;
00069 
00073 #define ALP_ON_ERROR                                                                _on_error_
00074 
00077 #define ALP_ON_ERROR_LABEL                                                              ALP_ON_ERROR:
00078 
00079 
00080 
00087 #define ALP_FAIL_MALLOC(var, size, error)                               {(var) = malloc((size));\
00088                                                                                                                 if((var) == NULL)\
00089                                                                                                                 {\
00090                                                                                                                         ALP_ERROR = error;\
00091                                                                                                                         goto ALP_ON_ERROR;\
00092                                                                                                                 }}
00093 
00099 #define ALP_FAIL(statement)                                                     {ALP_ERROR = statement; \
00100                                                                                                                 if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
00101                                                                                                                         goto ALP_ON_ERROR;}
00102 
00111 #define ALP_FAIL_NULL(var, statement, error)                    {(var) = statement; \
00112                                                                 if((var) == NULL) \
00113                                                                                                                 {\
00114                                                                                                                         ALP_ERROR = error; \
00115                                                                                                                         goto ALP_ON_ERROR; \
00116                                                                                                                 }}
00117 
00123 #define ALP_FAIL_ERROR(statement, error)                                {ALP_ERROR = statement;\
00124                                                                                                                 if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
00125                                                                                                                 {\
00126                                                                                                                         ALP_ERROR = error;\
00127                                                                                                                         goto ALP_ON_ERROR;\
00128                                                                                                                 }}
00129 
00135 #define ALP_FAIL_LABEL(statement, label)                                {ALP_ERROR = statement;\
00136                                                                                                                 if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
00137                                                                                                                         goto label;}
00138 
00145 #define ALP_FAIL_ERROR_LABEL(statement, error, label)   {ALP_ERROR = statement;\
00146                                                                                                                 if(ALP_STATUS_VALUE(ALP_ERROR) != ALP_STATUS_OK)\
00147                                                                                                                 {\
00148                                                                                                                         ALP_ERROR = error;\
00149                                                                                                                         goto label;\
00150                                                                                                                 }}
00151 
00152 
00162 #define ALP_FAIL_NULL_LABEL(var,statement,error,label) {(var) = statement; \
00163                                                                 if((var) == NULL) \
00164                                                                                                                 {\
00165                                                                                                                         ALP_ERROR = error; \
00166                                                                                                                         goto label; \
00167                                                                                                                 }}
00168 
00169 /* @} */
00170 
00171 #ifdef __cplusplus
00172 }
00173 #endif /* __cplusplus */
00174 
00175 
00176 #endif /* ALP_ERROR_MACROS_H */

Generated on Wed Jul 30 07:06:39 2008 by Doxygen 1.4.6 for ALP SDK + Hiker Documentation

Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.