Changeset 4dd8529 in mainline for uspace/lib/socket/include/net_err.h
- Timestamp:
- 2010-04-06T11:39:41Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 24ab58b3
- Parents:
- 11e543c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/socket/include/net_err.h
r11e543c r4dd8529 28 28 29 29 /** @addtogroup net 30 * 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 34 * Common error processing codes and routines. 35 35 */ 36 36 … … 41 41 42 42 #ifdef CONFIG_DEBUG 43 #include <stdio.h> 44 #include <strerror.h> 45 #endif 43 46 44 #include <stdio.h> 47 /** An actual stored error code. 48 * 49 */ 50 #define ERROR_CODE error_check_return_value 51 52 /** An error processing routines declaration. 53 * 54 * This has to be declared in the block where the error processing 55 * is desired. 56 * 57 */ 58 #define ERROR_DECLARE int ERROR_CODE 59 60 /** Store the value as an error code and checks if an error occurred. 61 * 62 * @param[in] value The value to be checked. May be a function call. 63 * @return False if the value indicates success (EOK). 64 * @return True otherwise. 65 * 66 */ 67 #ifdef CONFIG_DEBUG 68 69 #define ERROR_OCCURRED(value) \ 70 (((ERROR_CODE = (value)) != EOK) \ 71 && ({ \ 72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \ 73 __FILE__, __LINE__, str_error(ERROR_CODE)); \ 74 1; \ 75 })) 76 77 #else 78 79 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK) 45 80 46 81 #endif 47 82 48 /** An actual stored error code. 49 */ 50 #define ERROR_CODE error_check_return_value 51 52 /** An error processing routines declaration. 53 * This has to be declared in the block where the error processing is desired. 54 */ 55 #define ERROR_DECLARE int ERROR_CODE 56 57 /** Stores the value as an error code and checks if an error occurred. 58 * @param[in] value The value to be checked. May be a function call. 59 * @returns FALSE if the value indicates success (EOK). 60 * @returns TRUE otherwise. 61 */ 62 #ifdef CONFIG_DEBUG 63 64 #define ERROR_OCCURRED(value) \ 65 (((ERROR_CODE = (value)) != EOK) \ 66 && ({printf("error at %s:%d %d\n", __FILE__, __LINE__, ERROR_CODE); 1;})) 67 68 #else 69 70 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK) 71 72 #endif 73 74 /** Checks if an error occurred and immediately exits the actual function returning the error code. 75 * @param[in] value The value to be checked. May be a function call. 83 /** Error propagation 84 * 85 * Check if an error occurred and immediately exit the actual 86 * function returning the error code. 87 * 88 * @param[in] value The value to be checked. May be a function call. 89 * 76 90 */ 77 91 78 #define ERROR_PROPAGATE(value) if(ERROR_OCCURRED(value)) return ERROR_CODE 92 #define ERROR_PROPAGATE(value) \ 93 if (ERROR_OCCURRED(value)) \ 94 return ERROR_CODE 79 95 80 96 #endif
Note:
See TracChangeset
for help on using the changeset viewer.