Changeset 8aa2b3b in mainline for uspace/lib


Ignore:
Timestamp:
2011-04-03T15:41:33Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e2098dd7
Parents:
3a3d4ca (diff), b2a081ae (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 mainline changes.

Location:
uspace/lib
Files:
1 added
33 edited
3 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r3a3d4ca r8aa2b3b  
    8484        generic/io/io.c \
    8585        generic/io/printf.c \
     86        generic/io/log.c \
    8687        generic/io/klog.c \
    8788        generic/io/snprintf.c \
  • uspace/lib/c/arch/abs32le/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1111       
    1212        .text : {
    13                 *(.text);
    14                 *(.rodata*);
     13                *(.text .text.*);
     14                *(.rodata .rodata.*);
    1515        } :text
    1616       
  • uspace/lib/c/arch/amd64/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1616       
    1717        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     18                *(.text .text.*);
     19                *(.rodata .rodata.*);
    2020        } :text
    2121       
  • uspace/lib/c/arch/arm32/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/ia32/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1616       
    1717        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     18                *(.text .text.*);
     19                *(.rodata .rodata.*);
    2020        } :text
    2121       
  • uspace/lib/c/arch/ia64/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
     
    2323        .got : {
    2424                _gp = .;
    25                 *(.got*);
     25                *(.got .got.*);
    2626        } :data
    2727       
  • uspace/lib/c/arch/mips32/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/ppc32/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/sparc64/_link.ld.in

    r3a3d4ca r8aa2b3b  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/generic/adt/measured_strings.c

    r3a3d4ca r8aa2b3b  
    7474        new->length = length;
    7575        new->value = ((uint8_t *) new) + sizeof(measured_string_t);
    76         // append terminating zero explicitly - to be safe
     76        /* Append terminating zero explicitly - to be safe */
    7777        memcpy(new->value, string, new->length);
    7878        new->value[new->length] = '\0';
  • uspace/lib/c/generic/devman.c

    r3a3d4ca r8aa2b3b  
    147147                ret = devman_send_match_id(phone, match_id);
    148148                if (ret != EOK) {
    149                         printf("Driver failed to send match id, error %d\n",
    150                             ret);
    151149                        return ret;
    152150                }
     
    195193        }
    196194       
    197         devman_send_match_ids(phone, match_ids);
    198        
    199         async_wait_for(req, &retval);
    200        
    201         async_serialize_end();
    202        
     195        int match_ids_rc = devman_send_match_ids(phone, match_ids);
     196       
     197        async_wait_for(req, &retval);
     198       
     199        async_serialize_end();
     200       
     201        /* Prefer the answer to DEVMAN_ADD_FUNCTION in case of errors. */
     202        if ((match_ids_rc != EOK) && (retval == EOK)) {
     203                retval = match_ids_rc;
     204        }
     205
    203206        if (retval == EOK)
    204207                fun_handle = (int) IPC_GET_ARG1(answer);
     
    326329}
    327330
     331int devman_device_get_handle_by_class(const char *classname,
     332    const char *devname, devman_handle_t *handle, unsigned int flags)
     333{
     334        int phone = devman_get_phone(DEVMAN_CLIENT, flags);
     335
     336        if (phone < 0)
     337                return phone;
     338
     339        async_serialize_start();
     340
     341        ipc_call_t answer;
     342        aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
     343            flags, &answer);
     344
     345        sysarg_t retval = async_data_write_start(phone, classname,
     346            str_size(classname));
     347        if (retval != EOK) {
     348                async_wait_for(req, NULL);
     349                async_serialize_end();
     350                return retval;
     351        }
     352        retval = async_data_write_start(phone, devname,
     353            str_size(devname));
     354        if (retval != EOK) {
     355                async_wait_for(req, NULL);
     356                async_serialize_end();
     357                return retval;
     358        }
     359
     360        async_wait_for(req, &retval);
     361
     362        async_serialize_end();
     363
     364        if (retval != EOK) {
     365                if (handle != NULL)
     366                        *handle = (devman_handle_t) -1;
     367                return retval;
     368        }
     369
     370        if (handle != NULL)
     371                *handle = (devman_handle_t) IPC_GET_ARG1(answer);
     372
     373        return retval;
     374}
     375
    328376
    329377/** @}
  • uspace/lib/c/generic/net/packet.c

    r3a3d4ca r8aa2b3b  
    190190                }
    191191        }
    192         gpm_destroy(&pm_globals.packet_map);
     192        gpm_destroy(&pm_globals.packet_map, free);
    193193        /* leave locked */
    194194}
  • uspace/lib/c/generic/net/socket_client.c

    r3a3d4ca r8aa2b3b  
    749749        dyn_fifo_destroy(&socket->received);
    750750        dyn_fifo_destroy(&socket->accepted);
    751         sockets_exclude(socket_get_sockets(), socket->socket_id);
     751        sockets_exclude(socket_get_sockets(), socket->socket_id, free);
    752752}
    753753
  • uspace/lib/c/generic/vfs/vfs.c

    r3a3d4ca r8aa2b3b  
    756756{
    757757        struct stat stat;
    758         int rc;
    759 
    760         rc = fstat(fildes, &stat);
    761 
     758       
     759        int rc = fstat(fildes, &stat);
     760        if (rc != 0)
     761                return rc;
     762       
    762763        if (!stat.device)
    763764                return -1;
  • uspace/lib/c/include/adt/generic_char_map.h

    r3a3d4ca r8aa2b3b  
    4747#define GENERIC_CHAR_MAP_MAGIC_VALUE    0x12345622
    4848
     49/** Generic destructor function pointer. */
     50#define DTOR_T(identifier) \
     51        void (*identifier)(const void *)
     52
    4953/** Character string to generic type map declaration.
    5054 *  @param[in] name     Name of the map.
     
    6468        int name##_add(name##_t *, const uint8_t *, const size_t, type *); \
    6569        int name##_count(name##_t *); \
    66         void name##_destroy(name##_t *); \
    67         void name##_exclude(name##_t *, const uint8_t *, const size_t); \
     70        void name##_destroy(name##_t *, DTOR_T()); \
     71        void name##_exclude(name##_t *, const uint8_t *, const size_t, DTOR_T()); \
    6872        type *name##_find(name##_t *, const uint8_t *, const size_t); \
    6973        int name##_initialize(name##_t *); \
     
    8488             type *value) \
    8589        { \
    86                 int rc; \
    8790                int index; \
    8891                if (!name##_is_valid(map)) \
     
    9194                if (index < 0) \
    9295                        return index; \
    93                 rc = char_map_add(&map->names, name, length, index); \
    94                 if (rc != EOK) { \
    95                         name##_items_exclude_index(&map->values, index); \
    96                         return rc; \
    97                 } \
    98                 return EOK; \
     96                return char_map_add(&map->names, name, length, index); \
    9997        } \
    10098        \
     
    105103        } \
    106104        \
    107         void name##_destroy(name##_t *map) \
     105        void name##_destroy(name##_t *map, DTOR_T(dtor)) \
    108106        { \
    109107                if (name##_is_valid(map)) { \
    110108                        char_map_destroy(&map->names); \
    111                         name##_items_destroy(&map->values); \
     109                        name##_items_destroy(&map->values, dtor); \
    112110                } \
    113111        } \
    114112        \
    115113        void name##_exclude(name##_t *map, const uint8_t *name, \
    116             const size_t length) \
     114            const size_t length, DTOR_T(dtor)) \
    117115        { \
    118116                if (name##_is_valid(map)) { \
     
    121119                        if (index != CHAR_MAP_NULL) \
    122120                                name##_items_exclude_index(&map->values, \
    123                                      index); \
     121                                     index, dtor); \
    124122                } \
    125123        } \
  • uspace/lib/c/include/adt/generic_field.h

    r3a3d4ca r8aa2b3b  
    4646#define GENERIC_FIELD_MAGIC_VALUE               0x55667788
    4747
     48/** Generic destructor function pointer. */
     49#define DTOR_T(identifier) \
     50        void (*identifier)(const void *)
     51
    4852/** Generic type field declaration.
    4953 *
     
    6367        int name##_add(name##_t *, type *); \
    6468        int name##_count(name##_t *); \
    65         void name##_destroy(name##_t *); \
    66         void name##_exclude_index(name##_t *, int); \
     69        void name##_destroy(name##_t *, DTOR_T()); \
     70        void name##_exclude_index(name##_t *, int, DTOR_T()); \
    6771        type **name##_get_field(name##_t *); \
    6872        type *name##_get_index(name##_t *, int); \
     
    103107        } \
    104108        \
    105         void name##_destroy(name##_t *field) \
     109        void name##_destroy(name##_t *field, DTOR_T(dtor)) \
    106110        { \
    107111                if (name##_is_valid(field)) { \
    108112                        int index; \
    109113                        field->magic = 0; \
    110                         for (index = 0; index < field->next; index++) { \
    111                                 if (field->items[index]) \
    112                                         free(field->items[index]); \
     114                        if (dtor) { \
     115                                for (index = 0; index < field->next; index++) { \
     116                                        if (field->items[index]) \
     117                                                dtor(field->items[index]); \
     118                                } \
    113119                        } \
    114120                        free(field->items); \
     
    116122        } \
    117123         \
    118         void name##_exclude_index(name##_t *field, int index) \
     124        void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \
    119125        { \
    120126                if (name##_is_valid(field) && (index >= 0) && \
    121127                    (index < field->next) && (field->items[index])) { \
    122                         free(field->items[index]); \
     128                        if (dtor) \
     129                                dtor(field->items[index]); \
    123130                        field->items[index] = NULL; \
    124131                } \
  • uspace/lib/c/include/adt/int_map.h

    r3a3d4ca r8aa2b3b  
    4949#define INT_MAP_ITEM_MAGIC_VALUE        0x55667788
    5050
     51/** Generic destructor function pointer. */
     52#define DTOR_T(identifier) \
     53        void (*identifier)(const void *)
     54
    5155/** Integer to generic type map declaration.
    5256 *
     
    7276        \
    7377        int name##_add(name##_t *, int, type *); \
    74         void name##_clear(name##_t *); \
     78        void name##_clear(name##_t *, DTOR_T()); \
    7579        int name##_count(name##_t *); \
    76         void name##_destroy(name##_t *); \
    77         void name##_exclude(name##_t *, int); \
    78         void name##_exclude_index(name##_t *, int); \
     80        void name##_destroy(name##_t *, DTOR_T()); \
     81        void name##_exclude(name##_t *, int, DTOR_T()); \
     82        void name##_exclude_index(name##_t *, int, DTOR_T()); \
    7983        type *name##_find(name##_t *, int); \
    8084        int name##_update(name##_t *, int, int); \
     
    8286        int name##_initialize(name##_t *); \
    8387        int name##_is_valid(name##_t *); \
    84         void name##_item_destroy(name##_item_t *); \
     88        void name##_item_destroy(name##_item_t *, DTOR_T()); \
    8589        int name##_item_is_valid(name##_item_t *);
    8690
     
    115119        } \
    116120        \
    117         void name##_clear(name##_t *map) \
     121        void name##_clear(name##_t *map, DTOR_T(dtor)) \
    118122        { \
    119123                if (name##_is_valid(map)) { \
     
    122126                                if (name##_item_is_valid(&map->items[index])) { \
    123127                                        name##_item_destroy( \
    124                                             &map->items[index]); \
     128                                            &map->items[index], dtor); \
    125129                                } \
    126130                        } \
     
    135139        } \
    136140        \
    137         void name##_destroy(name##_t *map) \
     141        void name##_destroy(name##_t *map, DTOR_T(dtor)) \
    138142        { \
    139143                if (name##_is_valid(map)) { \
     
    143147                                if (name##_item_is_valid(&map->items[index])) { \
    144148                                        name##_item_destroy( \
    145                                             &map->items[index]); \
     149                                            &map->items[index], dtor); \
    146150                                } \
    147151                        } \
     
    150154        } \
    151155        \
    152         void name##_exclude(name##_t *map, int key) \
     156        void name##_exclude(name##_t *map, int key, DTOR_T(dtor)) \
    153157        { \
    154158                if (name##_is_valid(map)) { \
     
    158162                                    (map->items[index].key == key)) { \
    159163                                        name##_item_destroy( \
    160                                             &map->items[index]); \
    161                                 } \
    162                         } \
    163                 } \
    164         } \
    165         \
    166         void name##_exclude_index(name##_t *map, int index) \
     164                                            &map->items[index], dtor); \
     165                                } \
     166                        } \
     167                } \
     168        } \
     169        \
     170        void name##_exclude_index(name##_t *map, int index, DTOR_T(dtor)) \
    167171        { \
    168172                if (name##_is_valid(map) && (index >= 0) && \
    169173                    (index < map->next) && \
    170174                    name##_item_is_valid(&map->items[index])) { \
    171                         name##_item_destroy(&map->items[index]); \
     175                        name##_item_destroy(&map->items[index], dtor); \
    172176                } \
    173177        } \
     
    236240        } \
    237241        \
    238         void name##_item_destroy(name##_item_t *item) \
     242        void name##_item_destroy(name##_item_t *item, DTOR_T(dtor)) \
    239243        { \
    240244                if (name##_item_is_valid(item)) { \
    241245                        item->magic = 0; \
    242246                        if (item->value) { \
    243                                 free(item->value); \
     247                                if (dtor) \
     248                                        dtor(item->value); \
    244249                                item->value = NULL; \
    245250                        } \
  • uspace/lib/c/include/devman.h

    r3a3d4ca r8aa2b3b  
    5353extern int devman_device_get_handle(const char *, devman_handle_t *,
    5454    unsigned int);
     55extern int devman_device_get_handle_by_class(const char *, const char *,
     56    devman_handle_t *, unsigned int);
    5557
    5658extern int devman_add_device_to_class(devman_handle_t, const char *);
  • uspace/lib/c/include/io/log.h

    r3a3d4ca r8aa2b3b  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2011 Vojtech Horky
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup amd64
     30/** @addtogroup libc
    3031 * @{
    3132 */
    32 /** @file
    33  */
    3433
    35 #ifndef KERN_amd64_MEMSTR_H_
    36 #define KERN_amd64_MEMSTR_H_
     34#ifndef LIBC_IO_LOG_H_
     35#define LIBC_IO_LOG_H_
    3736
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     37#include <stdarg.h>
    3938
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
     39typedef enum {
     40        LVL_FATAL,
     41        LVL_ERROR,
     42        LVL_WARN,
     43        LVL_NOTE,
     44        LVL_DEBUG,
     45        LVL_DEBUG2,
     46
     47        /** For checking range of values */
     48        LVL_LIMIT
     49} log_level_t;
     50
     51extern int log_init(const char *, log_level_t);
     52extern void log_msg(log_level_t, const char *, ...);
     53extern void log_msgv(log_level_t, const char *, va_list);
    4254
    4355#endif
  • uspace/lib/c/include/ipc/devman.h

    r3a3d4ca r8aa2b3b  
    148148
    149149typedef enum {
    150         DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD
     150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
     151        DEVMAN_DEVICE_GET_HANDLE_BY_CLASS
    151152} client_to_devman_t;
    152153
  • uspace/lib/c/include/ipc/services.h

    r3a3d4ca r8aa2b3b  
    4747        SERVICE_DEVMAP,
    4848        SERVICE_DEVMAN,
    49         SERVICE_FHC,
    50         SERVICE_OBIO,
    51         SERVICE_APIC,
    52         SERVICE_I8259,
     49        SERVICE_IRC,
    5350        SERVICE_CLIPBOARD,
    5451        SERVICE_NETWORKING,
  • uspace/lib/drv/Makefile

    r3a3d4ca r8aa2b3b  
    3535        generic/driver.c \
    3636        generic/dev_iface.c \
     37        generic/log.c \
    3738        generic/remote_hw_res.c \
    3839        generic/remote_char_dev.c
  • uspace/lib/drv/generic/driver.c

    r3a3d4ca r8aa2b3b  
    273273       
    274274        res = driver->driver_ops->add_device(dev);
    275         if (res == EOK) {
    276                 printf("%s: new device with handle=%" PRIun " was added.\n",
    277                     driver->name, dev_handle);
    278         } else {
    279                 printf("%s: failed to add a new device with handle = %" PRIun ".\n",
    280                     driver->name, dev_handle);
     275        if (res != EOK)
    281276                delete_device(dev);
    282         }
    283277       
    284278        async_answer_0(iid, res);
     
    408402                            get_remote_method(rem_iface, iface_method_idx);
    409403                        if (iface_method_ptr == NULL) {
    410                                 // the interface has not such method
     404                                /* The interface has not such method */
    411405                                printf("%s: driver_connection_gen error - "
    412406                                    "invalid interface method.", driver->name);
  • uspace/lib/drv/generic/log.c

    r3a3d4ca r8aa2b3b  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup arm32
     29/** @addtogroup libdrv
    3030 * @{
    3131 */
    32 /** @file
    33  *  @brief Memory manipulating functions declarations.
     32
     33#include <io/log.h>
     34#include <stdarg.h>
     35
     36#include <ddf/log.h>
     37
     38/** Initialize the logging system.
     39 *
     40 * @param drv_name      Driver name, will be printed as part of message
     41 * @param level         Minimum message level to print
    3442 */
     43int ddf_log_init(const char *drv_name, log_level_t level)
     44{
     45        return log_init(drv_name, level);
     46}
    3547
    36 #ifndef KERN_arm32_MEMSTR_H_
    37 #define KERN_arm32_MEMSTR_H_
     48/** Log a driver message.
     49 *
     50 * @param level         Message verbosity level. Message is only printed
     51 *                      if verbosity is less than or equal to current
     52 *                      reporting level.
     53 * @param fmt           Format string (no trailing newline)
     54 */
     55void ddf_msg(log_level_t level, const char *fmt, ...)
     56{
     57        va_list args;
    3858
    39 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
    40 
    41 extern void memsetw(void *, size_t, uint16_t);
    42 extern void memsetb(void *, size_t, uint8_t);
    43 
    44 #endif
     59        va_start(args, fmt);
     60        log_msgv(level, fmt, args);
     61        va_end(args);
     62}
    4563
    4664/** @}
  • uspace/lib/drv/include/ddf/log.h

    r3a3d4ca r8aa2b3b  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup ia32
     29/** @addtogroup libdrv
    3030 * @{
    3131 */
    32 /** @file
    33  */
    3432
    35 #ifndef KERN_ia32_MEMSTR_H_
    36 #define KERN_ia32_MEMSTR_H_
     33#ifndef DDF_LOG_H_
     34#define DDF_LOG_H_
    3735
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     36#include <io/log.h>
    3937
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
     38extern int ddf_log_init(const char *, log_level_t);
     39extern void ddf_msg(log_level_t, const char *, ...);
    4240
    4341#endif
  • uspace/lib/fs/libfs.c

    r3a3d4ca r8aa2b3b  
    391391                                                if (lflag & L_CREATE)
    392392                                                        (void) ops->destroy(fn);
     393                                                else
     394                                                        (void) ops->node_put(fn);
    393395                                                async_answer_0(rid, rc);
    394396                                        } else {
     
    473475                                        if (lflag & L_CREATE)
    474476                                                (void) ops->destroy(fn);
     477                                        else
     478                                                (void) ops->node_put(fn);
    475479                                        async_answer_0(rid, rc);
    476480                                } else {
  • uspace/lib/net/generic/generic.c

    r3a3d4ca r8aa2b3b  
    106106                return EBADMEM;
    107107
    108         // request the address
     108        /* Request the address */
    109109        message_id = async_send_1(phone, (sysarg_t) message,
    110110            (sysarg_t) device_id, NULL);
     
    112112        async_wait_for(message_id, &result);
    113113
    114         // if not successful
     114        /* If not successful */
    115115        if ((string == EOK) && (result != EOK)) {
    116                 // clear the data
     116                /* Clear the data */
    117117                free(*address);
    118118                free(*data);
     
    242242                return EBADMEM;
    243243
    244         // request the translation
     244        /* Request the translation */
    245245        message_id = async_send_3(phone, (sysarg_t) message,
    246246            (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
     
    249249        async_wait_for(message_id, &result);
    250250
    251         // if not successful
     251        /* If not successful */
    252252        if ((string == EOK) && (result != EOK)) {
    253                 // clear the data
     253                /* Clear the data */
    254254                free(*translation);
    255255                free(*data);
  • uspace/lib/net/generic/net_checksum.c

    r3a3d4ca r8aa2b3b  
    5252uint16_t compact_checksum(uint32_t sum)
    5353{
    54         // shorten to the 16 bits
     54        /* Shorten to the 16 bits */
    5555        while (sum >> 16)
    5656                sum = (sum & 0xffff) + (sum >> 16);
     
    7272        size_t index;
    7373
    74         // sum all the 16 bit fields
     74        /* Sum all the 16 bit fields */
    7575        for (index = 0; index + 1 < length; index += 2)
    7676                seed += (data[index] << 8) + data[index + 1];
    7777
    78         // last odd byte with zero padding
     78        /* Last odd byte with zero padding */
    7979        if (index + 1 == length)
    8080                seed += data[index] << 8;
     
    9494        size_t index;
    9595
    96         // process full bytes
     96        /* Process full bytes */
    9797        while (length >= 8) {
    98                 // add the data
     98                /* Add the data */
    9999                seed ^= (*data) << 24;
    100100               
    101                 // for each added bit
     101                /* For each added bit */
    102102                for (index = 0; index < 8; ++index) {
    103                         // if the first bit is set
     103                        /* If the first bit is set */
    104104                        if (seed & 0x80000000) {
    105                                 // shift and divide the checksum
     105                                /* Shift and divide the checksum */
    106106                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    107107                        } else {
    108                                 // shift otherwise
     108                                /* shift otherwise */
    109109                                seed <<= 1;
    110110                        }
    111111                }
    112112               
    113                 // move to the next byte
     113                /* Move to the next byte */
    114114                ++data;
    115115                length -= 8;
    116116        }
    117117
    118         // process the odd bits
     118        /* Process the odd bits */
    119119        if (length > 0) {
    120                 // add the data with zero padding
     120                /* Add the data with zero padding */
    121121                seed ^= ((*data) & (0xff << (8 - length))) << 24;
    122122               
    123                 // for each added bit
     123                /* For each added bit */
    124124                for (index = 0; index < length; ++index) {
    125                         // if the first bit is set
     125                        /* If the first bit is set */
    126126                        if (seed & 0x80000000) {
    127                                 // shift and divide the checksum
     127                                /* Shift and divide the checksum */
    128128                                seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
    129129                        } else {
    130                                 // shift otherwise
     130                                /* Shift otherwise */
    131131                                seed <<= 1;
    132132                        }
     
    148148        size_t index;
    149149
    150         // process full bytes
     150        /* Process full bytes */
    151151        while (length >= 8) {
    152                 // add the data
     152                /* Add the data */
    153153                seed ^= (*data);
    154154               
    155                 // for each added bit
     155                /* For each added bit */
    156156                for (index = 0; index < 8; ++index) {
    157                         // if the last bit is set
     157                        /* If the last bit is set */
    158158                        if (seed & 1) {
    159                                 // shift and divide the checksum
     159                                /* Shift and divide the checksum */
    160160                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    161161                        } else {
    162                                 // shift otherwise
     162                                /* Shift otherwise */
    163163                                seed >>= 1;
    164164                        }
    165165                }
    166166               
    167                 // move to the next byte
     167                /* Move to the next byte */
    168168                ++data;
    169169                length -= 8;
    170170        }
    171171
    172         // process the odd bits
     172        /* Process the odd bits */
    173173        if (length > 0) {
    174                 // add the data with zero padding
     174                /* Add the data with zero padding */
    175175                seed ^= (*data) >> (8 - length);
    176176               
    177177                for (index = 0; index < length; ++index) {
    178                         // if the last bit is set
     178                        /* If the last bit is set */
    179179                        if (seed & 1) {
    180                                 // shift and divide the checksum
     180                                /* Shift and divide the checksum */
    181181                                seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
    182182                        } else {
    183                                 // shift otherwise
     183                                /* Shift otherwise */
    184184                                seed >>= 1;
    185185                        }
     
    198198uint16_t flip_checksum(uint16_t checksum)
    199199{
    200         // flip, zero is returned as 0xFFFF (not flipped)
     200        /* Flip, zero is returned as 0xFFFF (not flipped) */
    201201        checksum = ~checksum;
    202202        return checksum ? checksum : IP_CHECKSUM_ZERO;
     
    216216uint16_t ip_checksum(uint8_t *data, size_t length)
    217217{
    218         // compute, compact and flip the data checksum
     218        /* Compute, compact and flip the data checksum */
    219219        return flip_checksum(compact_checksum(compute_checksum(0, data,
    220220            length)));
  • uspace/lib/net/generic/packet_client.c

    r3a3d4ca r8aa2b3b  
    267267                return NULL;
    268268
    269         // get a new packet
     269        /* Get a new packet */
    270270        copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),
    271271            PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix,
     
    274274                return NULL;
    275275
    276         // get addresses
     276        /* Get addresses */
    277277        addrlen = packet_get_addr(packet, &src, &dest);
    278         // copy data
     278        /* Copy data */
    279279        if ((packet_copy_data(copy, packet_get_data(packet),
    280280            PACKET_DATA_LENGTH(packet)) == EOK) &&
    281             // copy addresses if present
     281            /* Copy addresses if present */
    282282            ((addrlen <= 0) ||
    283283            (packet_set_addr(copy, src, dest, addrlen) == EOK))) {
  • uspace/lib/net/il/ip_client.c

    r3a3d4ca r8aa2b3b  
    123123                return EOK;
    124124
    125         // TODO IPv6
     125        /* TODO IPv6 */
    126126/*      case AF_INET6:
    127127                if (addrlen != sizeof(struct sockaddr_in6))
     
    159159        size_t padding;
    160160
    161         // compute the padding if IP options are set
    162         // multiple of 4 bytes
     161        /*
     162         * Compute the padding if IP options are set
     163         * multiple of 4 bytes
     164         */
    163165        padding =  ipopt_length % 4;
    164166        if (padding) {
     
    167169        }
    168170
    169         // prefix the header
     171        /* Prefix the header */
    170172        data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding);
    171173        if (!data)
    172174                return ENOMEM;
    173175
    174         // add the padding
     176        /* Add the padding */
    175177        while (padding--)
    176178                data[sizeof(ip_header_t) + padding] = IPOPT_NOOP;
    177179
    178         // set the header
     180        /* Set the header */
    179181        header = (ip_header_t *) data;
    180182        header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) +
     
    256258                header_in->data_length = htons(data_length);
    257259                return EOK;
    258         // TODO IPv6
     260        /* TODO IPv6 */
    259261        } else {
    260262                return EINVAL;
  • uspace/lib/net/include/ip_client.h

    r3a3d4ca r8aa2b3b  
    5454    socklen_t, struct sockaddr *, socklen_t, size_t, void **, size_t *);
    5555
    56 // TODO ipopt manipulation
     56/* TODO ipopt manipulation */
    5757
    5858#endif
  • uspace/lib/net/tl/icmp_client.c

    r3a3d4ca r8aa2b3b  
    8181                *mtu = header->un.frag.mtu;
    8282
    83         // remove debug dump
     83        /* Remove debug dump */
    8484#ifdef CONFIG_DEBUG
    8585        printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
  • uspace/lib/net/tl/socket_core.c

    r3a3d4ca r8aa2b3b  
    9191        int packet_id;
    9292
    93         // if bound
     93        /* If bound */
    9494        if (socket->port) {
    95                 // release the port
     95                /* Release the port */
    9696                socket_port_release(global_sockets, socket);
    9797        }
    9898       
    99         // release all received packets
     99        /* Release all received packets */
    100100        while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
    101101                pq_release_remote(packet_phone, packet_id);
     
    107107                socket_release(socket);
    108108
    109         socket_cores_exclude(local_sockets, socket->socket_id);
     109        socket_cores_exclude(local_sockets, socket->socket_id, free);
    110110}
    111111
     
    166166        int rc;
    167167
    168         // create a wrapper
     168        /* Create a wrapper */
    169169        socket_ref = malloc(sizeof(*socket_ref));
    170170        if (!socket_ref)
     
    172172
    173173        *socket_ref = socket;
    174         // add the wrapper
     174        /* Add the wrapper */
    175175        rc = socket_port_map_add(&socket_port->map, key, key_length,
    176176            socket_ref);
     
    206206        int rc;
    207207
    208         // create a wrapper
     208        /* Create a wrapper */
    209209        socket_port = malloc(sizeof(*socket_port));
    210210        if (!socket_port)
     
    221221                goto fail;
    222222       
    223         // register the incomming port
     223        /* Register the incoming port */
    224224        rc = socket_ports_add(global_sockets, port, socket_port);
    225225        if (rc < 0)
     
    230230
    231231fail:
    232         socket_port_map_destroy(&socket_port->map);
     232        socket_port_map_destroy(&socket_port->map, free);
    233233        free(socket_port);
    234234        return rc;
     
    277277               
    278278                address_in = (struct sockaddr_in *) addr;
    279                 // find the socket
     279                /* Find the socket */
    280280                socket = socket_cores_find(local_sockets, socket_id);
    281281                if (!socket)
    282282                        return ENOTSOCK;
    283283               
    284                 // bind a free port?
     284                /* Bind a free port? */
    285285                if (address_in->sin_port <= 0)
    286286                        return socket_bind_free_port(global_sockets, socket,
    287287                             free_ports_start, free_ports_end, last_used_port);
    288288               
    289                 // try to find the port
     289                /* Try to find the port */
    290290                socket_port = socket_ports_find(global_sockets,
    291291                    ntohs(address_in->sin_port));
    292292                if (socket_port) {
    293                         // already used
     293                        /* Already used */
    294294                        return EADDRINUSE;
    295295                }
    296296               
    297                 // if bound
     297                /* If bound */
    298298                if (socket->port) {
    299                         // release the port
     299                        /* Release the port */
    300300                        socket_port_release(global_sockets, socket);
    301301                }
     
    306306               
    307307        case AF_INET6:
    308                 // TODO IPv6
     308                /* TODO IPv6 */
    309309                break;
    310310        }
     
    333333        int index;
    334334
    335         // from the last used one
     335        /* From the last used one */
    336336        index = last_used_port;
    337337       
     
    339339                ++index;
    340340               
    341                 // til the range end
     341                /* Till the range end */
    342342                if (index >= free_ports_end) {
    343                         // start from the range beginning
     343                        /* Start from the range beginning */
    344344                        index = free_ports_start - 1;
    345345                        do {
    346346                                ++index;
    347                                 // til the last used one
     347                                /* Till the last used one */
    348348                                if (index >= last_used_port) {
    349                                         // none found
     349                                        /* None found */
    350350                                        return ENOTCONN;
    351351                                }
    352352                        } while (socket_ports_find(global_sockets, index));
    353353                       
    354                         // found, break immediately
     354                        /* Found, break immediately */
    355355                        break;
    356356                }
     
    384384                        socket_id = 1;
    385385                        ++count;
    386                 // only this branch for last_id
     386                /* Only this branch for last_id */
    387387                } else {
    388388                        if (socket_id < INT_MAX) {
     
    425425                return EINVAL;
    426426       
    427         // store the socket
     427        /* Store the socket */
    428428        if (*socket_id <= 0) {
    429429                positive = (*socket_id == 0);
     
    441441                return ENOMEM;
    442442       
    443         // initialize
     443        /* Initialize */
    444444        socket->phone = app_phone;
    445445        socket->port = -1;
     
    493493        int accepted_id;
    494494
    495         // find the socket
     495        /* Find the socket */
    496496        socket = socket_cores_find(local_sockets, socket_id);
    497497        if (!socket)
    498498                return ENOTSOCK;
    499499       
    500         // destroy all accepted sockets
     500        /* Destroy all accepted sockets */
    501501        while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
    502502                socket_destroy(packet_phone, accepted_id, local_sockets,
     
    535535        next_packet = pq_next(packet);
    536536        if (!next_packet) {
    537                 // write all if only one fragment
     537                /* Write all if only one fragment */
    538538                rc = data_reply(packet_get_data(packet),
    539539                    packet_get_data_length(packet));
    540540                if (rc != EOK)
    541541                        return rc;
    542                 // store the total length
     542                /* Store the total length */
    543543                *length = packet_get_data_length(packet);
    544544        } else {
    545                 // count the packet fragments
     545                /* Count the packet fragments */
    546546                fragments = 1;
    547547                next_packet = pq_next(packet);
     
    549549                        ++fragments;
    550550               
    551                 // compute and store the fragment lengths
     551                /* Compute and store the fragment lengths */
    552552                lengths = (size_t *) malloc(sizeof(size_t) * fragments +
    553553                    sizeof(size_t));
     
    565565                }
    566566               
    567                 // write the fragment lengths
     567                /* Write the fragment lengths */
    568568                rc = data_reply(lengths, sizeof(int) * (fragments + 1));
    569569                if (rc != EOK) {
     
    573573                next_packet = packet;
    574574               
    575                 // write the fragments
     575                /* Write the fragments */
    576576                for (index = 0; index < fragments; ++index) {
    577577                        rc = data_reply(packet_get_data(next_packet),
     
    584584                }
    585585               
    586                 // store the total length
     586                /* Store the total length */
    587587                *length = lengths[fragments];
    588588                free(lengths);
     
    636636                return;
    637637       
    638         // find ports
     638        /* Find ports */
    639639        socket_port = socket_ports_find(global_sockets, socket->port);
    640640        if (socket_port) {
    641                 // find the socket
     641                /* Find the socket */
    642642                socket_ref = socket_port_map_find(&socket_port->map,
    643643                    socket->key, socket->key_length);
     
    646646                        --socket_port->count;
    647647                       
    648                         // release if empty
     648                        /* Release if empty */
    649649                        if (socket_port->count <= 0) {
    650                                 // destroy the map
    651                                 socket_port_map_destroy(&socket_port->map);
    652                                 // release the port
     650                                /* Destroy the map */
     651                                socket_port_map_destroy(&socket_port->map, free);
     652                                /* Release the port */
    653653                                socket_ports_exclude(global_sockets,
    654                                     socket->port);
     654                                    socket->port, free);
    655655                        } else {
    656                                 // remove
     656                                /* Remove */
    657657                                socket_port_map_exclude(&socket_port->map,
    658                                     socket->key, socket->key_length);
     658                                    socket->key, socket->key_length, free);
    659659                        }
    660660                }
     
    685685        int rc;
    686686
    687         // find ports
     687        /* Find ports */
    688688        socket_port = socket_ports_find(global_sockets, port);
    689689        if (!socket_port)
    690690                return ENOENT;
    691691       
    692         // add the socket
     692        /* Add the socket */
    693693        rc = socket_port_add_core(socket_port, socket, key, key_length);
    694694        if (rc != EOK)
  • uspace/lib/net/tl/tl_common.c

    r3a3d4ca r8aa2b3b  
    182182                        else
    183183                                packet_dimensions_exclude(packet_dimensions,
    184                                     DEVICE_INVALID_ID);
     184                                    DEVICE_INVALID_ID, free);
    185185                }
    186186        }
     
    255255        int length;
    256256
    257         // detach the first packet and release the others
     257        /* Detach the first packet and release the others */
    258258        next = pq_detach(packet);
    259259        if (next)
     
    262262        length = packet_get_addr(packet, &src, NULL);
    263263        if ((length > 0) && (!error) && (icmp_phone >= 0) &&
    264             // set both addresses to the source one (avoids the source address
    265             // deletion before setting the destination one)
     264            /*
     265             * Set both addresses to the source one (avoids the source address
     266             * deletion before setting the destination one)
     267             */
    266268            (packet_set_addr(packet, src, src, (size_t) length) == EOK)) {
    267269                return EOK;
     
    299301                return EINVAL;
    300302
    301         // get the data length
     303        /* Get the data length */
    302304        if (!async_data_write_receive(&callid, &length))
    303305                return EINVAL;
    304306
    305         // get a new packet
     307        /* Get a new packet */
    306308        *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len,
    307309            prefix + dimension->prefix, dimension->suffix);
     
    309311                return ENOMEM;
    310312
    311         // allocate space in the packet
     313        /* Allocate space in the packet */
    312314        data = packet_suffix(*packet, length);
    313315        if (!data) {
     
    316318        }
    317319
    318         // read the data into the packet
     320        /* Read the data into the packet */
    319321        rc = async_data_write_finalize(callid, data, length);
    320322        if (rc != EOK) {
     
    323325        }
    324326       
    325         // set the packet destination address
     327        /* Set the packet destination address */
    326328        rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen);
    327329        if (rc != EOK) {
  • uspace/lib/packet/generic/packet_server.c

    r3a3d4ca r8aa2b3b  
    112112    size_t max_content, size_t max_suffix)
    113113{
    114         // clear the packet content
     114        /* Clear the packet content */
    115115        bzero(((void *) packet) + sizeof(packet_t),
    116116            packet->length - sizeof(packet_t));
    117117       
    118         // clear the packet header
     118        /* Clear the packet header */
    119119        packet->order = 0;
    120120        packet->metric = 0;
     
    151151        assert(fibril_mutex_is_locked(&ps_globals.lock));
    152152
    153         // already locked
     153        /* Already locked */
    154154        packet = (packet_t *) mmap(NULL, length, PROTO_READ | PROTO_WRITE,
    155155            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
  • uspace/lib/softint/generic/multiplication.c

    r3a3d4ca r8aa2b3b  
    109109         * result does not fit in signed one */
    110110        if (SOFTINT_CHECK_OF && ((t2 < t1) || (t2 & (1ull << 63)))) {
    111                 // error, overflow
     111                /* Error, overflow */
    112112                return (neg ? INT64_MIN : INT64_MAX);
    113113        }
Note: See TracChangeset for help on using the changeset viewer.