Changeset b910455 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-04-07T09:46:11Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6639ae1
Parents:
f6bffee (diff), 8e80d3f (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/c
Files:
1 added
23 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rf6bffee rb910455  
    7676        generic/io/io.c \
    7777        generic/io/printf.c \
     78        generic/io/log.c \
    7879        generic/io/klog.c \
    7980        generic/io/snprintf.c \
  • uspace/lib/c/arch/abs32le/_link.ld.in

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

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

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

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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    1515       
    1616        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     17                *(.text .text.*);
     18                *(.rodata .rodata.*);
    1919        } :text
    2020       
  • uspace/lib/c/arch/mips32/include/atomic.h

    rf6bffee rb910455  
    7070                "       sc %0, %1\n"
    7171                "       beq %0, %4, 1b\n"       /* if the atomic operation failed, try again */
    72                 /*      nop     */              /* nop is inserted automatically by compiler */
    7372                "       nop\n"
    7473                : "=&r" (tmp),
  • uspace/lib/c/arch/ppc32/_link.ld.in

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

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

    rf6bffee rb910455  
    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/async.c

    rf6bffee rb910455  
    15781578 */
    15791579int
    1580 async_data_read_start_flexible(int phoneid, void *dst, size_t size, int flags)
     1580async_data_read_start_generic(int phoneid, void *dst, size_t size, int flags)
    15811581{
    15821582        return async_req_3_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
     
    16771677 */
    16781678int
    1679 async_data_write_start_flexible(int phoneid, const void *src, size_t size,
     1679async_data_write_start_generic(int phoneid, const void *src, size_t size,
    16801680    int flags)
    16811681{
  • uspace/lib/c/generic/devman.c

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    378378       
    379379        req = async_send_1(vfs_phone, VFS_IN_READ, fildes, &answer);
    380         rc = async_data_read_start_flexible(vfs_phone, (void *) buf, nbyte,
     380        rc = async_data_read_start_generic(vfs_phone, (void *) buf, nbyte,
    381381            IPC_XF_RESTRICT);
    382382        if (rc != EOK) {
     
    408408       
    409409        req = async_send_1(vfs_phone, VFS_IN_WRITE, fildes, &answer);
    410         rc = async_data_write_start_flexible(vfs_phone, (void *) buf, nbyte,
     410        rc = async_data_write_start_generic(vfs_phone, (void *) buf, nbyte,
    411411            IPC_XF_RESTRICT);
    412412        if (rc != EOK) {
     
    758758{
    759759        struct stat stat;
    760         int rc;
    761 
    762         rc = fstat(fildes, &stat);
    763 
     760       
     761        int rc = fstat(fildes, &stat);
     762        if (rc != 0)
     763                return rc;
     764       
    764765        if (!stat.device)
    765766                return -1;
  • uspace/lib/c/include/adt/generic_char_map.h

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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/async.h

    rf6bffee rb910455  
    341341
    342342#define async_data_read_start(p, buf, len) \
    343         async_data_read_start_flexible((p), (buf), (len), IPC_XF_NONE)
    344 
    345 extern int async_data_read_start_flexible(int, void *, size_t, int);
     343        async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE)
     344
     345extern int async_data_read_start_generic(int, void *, size_t, int);
    346346extern bool async_data_read_receive(ipc_callid_t *, size_t *);
    347347extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
     
    383383
    384384#define async_data_write_start(p, buf, len) \
    385         async_data_write_start_flexible((p), (buf), (len), IPC_XF_NONE)
    386 
    387 extern int async_data_write_start_flexible(int, const void *, size_t, int);
     385        async_data_write_start_generic((p), (buf), (len), IPC_XF_NONE)
     386
     387extern int async_data_write_start_generic(int, const void *, size_t, int);
    388388extern bool async_data_write_receive(ipc_callid_t *, size_t *);
    389389extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
  • uspace/lib/c/include/devman.h

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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

    rf6bffee rb910455  
    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,
Note: See TracChangeset for help on using the changeset viewer.