Changeset ec1bdc8 in mainline for uspace/lib/c
- Timestamp:
- 2010-09-26T18:57:30Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fe57ea7
- Parents:
- 2a786f9 (diff), 70ce016 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/c
- Files:
-
- 8 added
- 3 edited
- 1 moved
-
Makefile (modified) (1 diff)
-
generic/adt/char_map.c (added)
-
generic/adt/dynamic_fifo.c (added)
-
generic/adt/measured_strings.c (added)
-
include/adt/char_map.h (added)
-
include/adt/dynamic_fifo.h (added)
-
include/adt/generic_char_map.h (added)
-
include/adt/generic_field.h (added)
-
include/adt/int_map.h (added)
-
include/adt/measured_strings.h (moved) (moved from uspace/lib/socket/include/net_err.h ) (1 diff)
-
include/err.h (modified) (2 diffs)
-
include/errno.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r2a786f9 rec1bdc8 89 89 generic/adt/list.o \ 90 90 generic/adt/hash_table.o \ 91 generic/adt/dynamic_fifo.c \ 92 generic/adt/measured_strings.c \ 93 generic/adt/char_map.c \ 91 94 generic/time.c \ 92 95 generic/err.c \ -
uspace/lib/c/include/adt/measured_strings.h
r2a786f9 rec1bdc8 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Common error processing codes and routines. 34 * Character string with measured length. 35 * The structure has been designed for serialization of character strings 36 * between modules. 35 37 */ 36 38 37 #ifndef __NET_ERR_H__38 #define __NET_ERR_H__39 #ifndef LIBC_MEASURED_STRINGS_H_ 40 #define LIBC_MEASURED_STRINGS_H_ 39 41 40 #include < errno.h>42 #include <sys/types.h> 41 43 42 #ifdef CONFIG_DEBUG 43 #include <stdio.h> 44 #include <str_error.h> 45 #endif 44 /** Type definition of the character string with measured length. 45 * @see measured_string 46 */ 47 typedef struct measured_string measured_string_t; 46 48 47 /** An actual stored error code. 49 /** Type definition of the character string with measured length pointer. 50 * @see measured_string 51 */ 52 typedef measured_string_t *measured_string_ref; 53 54 /** Character string with measured length. 48 55 * 56 * This structure has been designed for serialization of character strings 57 * between modules. 49 58 */ 50 #define ERROR_CODE error_check_return_value 59 struct measured_string { 60 /** Character string data. */ 61 char * value; 62 /** Character string length. */ 63 size_t length; 64 }; 51 65 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) 80 81 #endif 82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value)) 84 85 /** Error propagation 86 * 87 * Check if an error occurred and immediately exit the actual 88 * function returning the error code. 89 * 90 * @param[in] value The value to be checked. May be a function call. 91 * 92 */ 93 94 #define ERROR_PROPAGATE(value) \ 95 if (ERROR_OCCURRED(value)) \ 96 return ERROR_CODE 66 extern measured_string_ref measured_string_create_bulk(const char *, size_t); 67 extern measured_string_ref measured_string_copy(measured_string_ref); 68 extern int measured_strings_receive(measured_string_ref *, char **, size_t); 69 extern int measured_strings_reply(const measured_string_ref, size_t); 70 extern int measured_strings_return(int, measured_string_ref *, char **, size_t); 71 extern int measured_strings_send(int, const measured_string_ref, size_t); 97 72 98 73 #endif -
uspace/lib/c/include/err.h
r2a786f9 rec1bdc8 36 36 #define LIBC_ERR_H_ 37 37 38 #include <stdio.h> 39 #include <errno.h> 40 41 #ifdef CONFIG_DEBUG 42 #include <str_error.h> 43 #endif 44 38 45 #define errx(status, fmt, ...) { \ 39 46 printf((fmt), ##__VA_ARGS__); \ … … 41 48 } 42 49 50 51 /** An actual stored error code. */ 52 #define ERROR_CODE error_check_return_value 53 54 /** An error processing routines declaration. 55 * 56 * This has to be declared in the block where the error processing 57 * is desired. 58 */ 59 #define ERROR_DECLARE int ERROR_CODE 60 61 /** Store the value as an error code and checks if an error occurred. 62 * 63 * @param[in] value The value to be checked. May be a function call. 64 * @return False if the value indicates success (EOK). 65 * @return True otherwise. 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) 80 81 #endif 82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value)) 84 85 /** Error propagation 86 * 87 * Check if an error occurred and immediately exit the actual 88 * function returning the error code. 89 * 90 * @param[in] value The value to be checked. May be a function call. 91 * 92 */ 93 94 #define ERROR_PROPAGATE(value) \ 95 if (ERROR_OCCURRED(value)) \ 96 return ERROR_CODE 97 43 98 #endif 44 99 -
uspace/lib/c/include/errno.h
r2a786f9 rec1bdc8 56 56 #define EMLINK (-266) 57 57 58 /** An API function is called while another blocking function is in progress. */ 59 #define EINPROGRESS (-10036) 60 61 /** The socket identifier is not valid. */ 62 #define ENOTSOCK (-10038) 63 64 /** The destination address required. */ 65 #define EDESTADDRREQ (-10039) 66 67 /** Protocol is not supported. */ 68 #define EPROTONOSUPPORT (-10043) 69 70 /** Socket type is not supported. */ 71 #define ESOCKTNOSUPPORT (-10044) 72 73 /** Protocol family is not supported. */ 74 #define EPFNOSUPPORT (-10046) 75 76 /** Address family is not supported. */ 77 #define EAFNOSUPPORT (-10047) 78 79 /** Address is already in use. */ 80 #define EADDRINUSE (-10048) 81 82 /** The socket is not connected or bound. */ 83 #define ENOTCONN (-10057) 84 85 /** The requested operation was not performed. 86 * Try again later. 87 */ 88 #define TRY_AGAIN (-11002) 89 90 /** No data. 91 */ 92 #define NO_DATA (-11004) 93 58 94 #endif 59 95
Note:
See TracChangeset
for help on using the changeset viewer.
