Changeset ec1bdc8 in mainline for uspace/lib/c


Ignore:
Timestamp:
2010-09-26T18:57:30Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge from lp:~jakub/helenos/net.

Location:
uspace/lib/c
Files:
8 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r2a786f9 rec1bdc8  
    8989        generic/adt/list.o \
    9090        generic/adt/hash_table.o \
     91        generic/adt/dynamic_fifo.c \
     92        generic/adt/measured_strings.c \
     93        generic/adt/char_map.c \
    9194        generic/time.c \
    9295        generic/err.c \
  • uspace/lib/c/include/adt/measured_strings.h

    r2a786f9 rec1bdc8  
    2727 */
    2828
    29 /** @addtogroup net
    30  * @{
     29/** @addtogroup libc
     30 *  @{
    3131 */
    3232
    3333/** @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.
    3537 */
    3638
    37 #ifndef __NET_ERR_H__
    38 #define __NET_ERR_H__
     39#ifndef LIBC_MEASURED_STRINGS_H_
     40#define LIBC_MEASURED_STRINGS_H_
    3941
    40 #include <errno.h>
     42#include <sys/types.h>
    4143
    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 */
     47typedef struct measured_string measured_string_t;
    4648
    47 /** An actual stored error code.
     49/** Type definition of the character string with measured length pointer.
     50 *  @see measured_string
     51 */
     52typedef measured_string_t *measured_string_ref;
     53
     54/** Character string with measured length.
    4855 *
     56 * This structure has been designed for serialization of character strings
     57 * between modules.
    4958 */
    50 #define ERROR_CODE  error_check_return_value
     59struct measured_string {
     60        /** Character string data. */
     61        char * value;
     62        /** Character string length. */
     63        size_t length;
     64};
    5165
    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
     66extern measured_string_ref measured_string_create_bulk(const char *, size_t);
     67extern measured_string_ref measured_string_copy(measured_string_ref);
     68extern int measured_strings_receive(measured_string_ref *, char **, size_t);
     69extern int measured_strings_reply(const measured_string_ref, size_t);
     70extern int measured_strings_return(int, measured_string_ref *, char **, size_t);
     71extern int measured_strings_send(int, const measured_string_ref, size_t);
    9772
    9873#endif
  • uspace/lib/c/include/err.h

    r2a786f9 rec1bdc8  
    3636#define LIBC_ERR_H_
    3737
     38#include <stdio.h>
     39#include <errno.h>
     40
     41#ifdef CONFIG_DEBUG
     42#include <str_error.h>
     43#endif
     44
    3845#define errx(status, fmt, ...) { \
    3946        printf((fmt), ##__VA_ARGS__); \
     
    4148}
    4249
     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
    4398#endif
    4499
  • uspace/lib/c/include/errno.h

    r2a786f9 rec1bdc8  
    5656#define EMLINK        (-266)
    5757
     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
    5894#endif
    5995
Note: See TracChangeset for help on using the changeset viewer.