Changeset e4f8c77 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (14 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (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 libposix.

Location:
uspace/lib/c
Files:
21 added
2 deleted
48 edited
5 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r5974661 re4f8c77  
    6868        generic/clipboard.c \
    6969        generic/devmap.c \
    70         generic/devmap_obsolete.c \
    7170        generic/devman.c \
    72         generic/devman_obsolete.c \
    7371        generic/device/hw_res.c \
    7472        generic/device/char_dev.c \
  • uspace/lib/c/arch/mips32/Makefile.common

    r5974661 re4f8c77  
    2727#
    2828
    29 GCC_CFLAGS += -mips3
     29GCC_CFLAGS += -mips3 -mabi=32
    3030
    3131ENDIANESS = LE
  • uspace/lib/c/arch/mips32/include/atomic.h

    r5974661 re4f8c77  
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/fibril.h

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/thread.h

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/tls.h

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/types.h

    r5974661 re4f8c77  
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/src/syscall.c

    r5974661 re4f8c77  
    2727 */
    2828
    29  /** @addtogroup libcmips32
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33   * @ingroup libcmips32eb       
     33  * @ingroup libcmips32
    3434 */
    3535
     
    6464}
    6565
    66  /** @}
     66/** @}
    6767 */
    68 
  • uspace/lib/c/arch/mips32/src/tls.c

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32eb/Makefile.common

    r5974661 re4f8c77  
    2727#
    2828
    29 GCC_CFLAGS += -mips3
     29GCC_CFLAGS += -mips3 -mabi=32
    3030
    3131ENDIANESS = BE
  • uspace/lib/c/arch/mips64/Makefile.common

    r5974661 re4f8c77  
    11#
    22# Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../../../..
    31 BINARY = fhc
     29GCC_CFLAGS += -mips3 -mabi=64
     30AFLAGS = -64
    3231
    33 SOURCES = \
    34         fhc.c
     32ENDIANESS = LE
    3533
    36 include $(USPACE_PREFIX)/Makefile.common
     34BFD_ARCH = mips:4000
     35BFD_NAME = elf64-tradlittlemips
  • uspace/lib/c/arch/mips64/Makefile.inc

    r5974661 re4f8c77  
    11#
    22# Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../../..
    31 EXTRA_CFLAGS = -Iinclude
    32 BINARY = char_ms
     29ARCH_SOURCES = \
     30        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
     32        arch/$(UARCH)/src/thread_entry.s \
     33        arch/$(UARCH)/src/syscall.c \
     34        arch/$(UARCH)/src/fibril.S \
     35        arch/$(UARCH)/src/tls.c \
     36        arch/$(UARCH)/src/stacktrace.c \
     37        arch/$(UARCH)/src/stacktrace_asm.S
    3338
    34 SOURCES = \
    35         proto/ps2.c \
    36         char_mouse.c \
    37         chardev.c
    38 
    39 include $(USPACE_PREFIX)/Makefile.common
     39.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/mips64/include/istate.h

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup libcmips64
    3130 * @{
    3231 */
     
    3433 */
    3534
    36 #ifndef ADBDEV_H_
    37 #define ADBDEV_H_
     35#ifndef LIBC_mips64__ISTATE_H_
     36#define LIBC_mips64__ISTATE_H_
    3837
    39 #include <sys/types.h>
    40 
    41 extern int adb_dev_init(void);
     38#include <arch/istate.h>
    4239
    4340#endif
    4441
    45 /**
    46  * @}
    47  */
    48 
     42/** @}
     43 */
  • uspace/lib/c/arch/mips64/src/stacktrace.c

    r5974661 re4f8c77  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
    3  * Copyright (c) 2010 Lenka Trochtova
     2 * Copyright (c) 2010 Jakub Jermar
     3 * Copyright (c) 2010 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    2828 */
    2929
    30 /** @addtogroup libc
     30/** @addtogroup libcmips64 mips64
     31 * @ingroup lc
    3132 * @{
    3233 */
     
    3435 */
    3536
    36 #ifndef LIBC_DEVMAN_OBSOLETE_H_
    37 #define LIBC_DEVMAN_OBSOLETE_H_
     37#include <sys/types.h>
     38#include <bool.h>
     39#include <errno.h>
    3840
    39 #include <ipc/devman.h>
    40 #include <async.h>
    41 #include <bool.h>
     41#include <stacktrace.h>
    4242
    43 extern int devman_obsolete_get_phone(devman_interface_t, unsigned int);
    44 extern void devman_obsolete_hangup_phone(devman_interface_t);
     43bool stacktrace_fp_valid(stacktrace_t *st, uintptr_t fp)
     44{
     45        (void) st; (void) fp;
     46        return false;
     47}
    4548
    46 extern int devman_obsolete_device_connect(devman_handle_t, unsigned int);
    47 extern int devman_obsolete_parent_device_connect(devman_handle_t, unsigned int);
     49int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
     50{
     51        (void) st; (void) fp; (void) prev;
     52        return ENOTSUP;
     53}
    4854
    49 #endif
     55int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
     56{
     57        (void) st; (void) fp; (void) ra;
     58        return ENOTSUP;
     59}
    5060
    5161/** @}
  • uspace/lib/c/generic/adt/hash_table.c

    r5974661 re4f8c77  
    6161        assert(max_keys > 0);
    6262       
    63         h->entry = malloc(m * sizeof(link_t));
     63        h->entry = malloc(m * sizeof(list_t));
    6464        if (!h->entry)
    6565                return false;
    6666       
    67         memset((void *) h->entry, 0,  m * sizeof(link_t));
     67        memset((void *) h->entry, 0,  m * sizeof(list_t));
    6868       
    6969        hash_count_t i;
     
    123123        assert(chain < h->entries);
    124124       
    125         link_t *cur;
    126         for (cur = h->entry[chain].next; cur != &h->entry[chain];
    127             cur = cur->next) {
     125        list_foreach(h->entry[chain], cur) {
    128126                if (h->op->compare(key, h->max_keys, cur)) {
    129127                        /*
     
    153151        assert(keys <= h->max_keys);
    154152       
    155         link_t *cur;
    156        
    157153        if (keys == h->max_keys) {
     154                link_t *cur;
     155               
    158156                /*
    159157                 * All keys are known, hash_table_find() can be used to find the
     
    176174        hash_index_t chain;
    177175        for (chain = 0; chain < h->entries; chain++) {
    178                 for (cur = h->entry[chain].next; cur != &h->entry[chain];
     176                link_t *cur;
     177               
     178                for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
    179179                    cur = cur->next) {
    180180                        if (h->op->compare(key, keys, cur)) {
     
    203203{
    204204        hash_index_t bucket;
    205         link_t *cur;
    206205       
    207206        for (bucket = 0; bucket < h->entries; bucket++) {
    208                 for (cur = h->entry[bucket].next; cur != &h->entry[bucket];
    209                     cur = cur->next) {
     207                list_foreach(h->entry[bucket], cur) {
    210208                        f(cur, arg);
    211209                }
  • uspace/lib/c/generic/adt/list.c

    r5974661 re4f8c77  
    3030 * @{
    3131 */
    32 /** @file
     32
     33/**
     34 * @file
     35 * @brief       Functions completing doubly linked circular list implementaion.
     36 *
     37 * This file contains some of the functions implementing doubly linked circular lists.
     38 * However, this ADT is mostly implemented in @ref list.h.
    3339 */
    3440
    3541#include <adt/list.h>
    36 
     42#include <bool.h>
    3743
    3844/** Check for membership
    3945 *
    40  * Check whether link is contained in the list head.
    41  * The membership is defined as pointer equivalence.
     46 * Check whether link is contained in a list.
     47 * Membership is defined as pointer equivalence.
    4248 *
    43  * @param link Item to look for.
    44  * @param head List to look in.
     49 * @param link  Item to look for.
     50 * @param list  List to look in.
    4551 *
    4652 * @return true if link is contained in head, false otherwise.
    4753 *
    4854 */
    49 int list_member(const link_t *link, const link_t *head)
     55int list_member(const link_t *link, const list_t *list)
    5056{
    51         int found = 0;
    52         link_t *hlp = head->next;
     57        bool found = false;
     58        link_t *hlp = list->head.next;
    5359       
    54         while (hlp != head) {
     60        while (hlp != &list->head) {
    5561                if (hlp == link) {
    56                         found = 1;
     62                        found = true;
    5763                        break;
    5864                }
     
    6369}
    6470
    65 
    6671/** Concatenate two lists
    6772 *
    68  * Concatenate lists head1 and head2, producing a single
    69  * list head1 containing items from both (in head1, head2
    70  * order) and empty list head2.
     73 * Concatenate lists @a list1 and @a list2, producing a single
     74 * list @a list1 containing items from both (in @a list1, @a list2
     75 * order) and empty list @a list2.
    7176 *
    72  * @param head1 First list and concatenated output
    73  * @param head2 Second list and empty output.
     77 * @param list1         First list and concatenated output
     78 * @param list2         Second list and empty output.
    7479 *
    7580 */
    76 void list_concat(link_t *head1, link_t *head2)
     81void list_concat(list_t *list1, list_t *list2)
    7782{
    78         if (list_empty(head2))
     83        if (list_empty(list2))
    7984                return;
    80        
    81         head2->next->prev = head1->prev;
    82         head2->prev->next = head1;
    83         head1->prev->next = head2->next;
    84         head1->prev = head2->prev;
    85         list_initialize(head2);
     85
     86        list2->head.next->prev = list1->head.prev;
     87        list2->head.prev->next = &list1->head;
     88        list1->head.prev->next = list2->head.next;
     89        list1->head.prev = list2->head.prev;
     90        list_initialize(list2);
    8691}
    87 
    8892
    8993/** Count list items
     
    9195 * Return the number of items in the list.
    9296 *
    93  * @param link List to count.
    94  *
    95  * @return Number of items in the list.
    96  *
     97 * @param list          List to count.
     98 * @return              Number of items in the list.
    9799 */
    98 unsigned int list_count(const link_t *link)
     100unsigned int list_count(const list_t *list)
    99101{
    100102        unsigned int count = 0;
    101         link_t *hlp = link->next;
    102103       
    103         while (hlp != link) {
     104        list_foreach(*list, link) {
    104105                count++;
    105                 hlp = hlp->next;
    106106        }
    107107       
  • uspace/lib/c/generic/adt/measured_strings.c

    r5974661 re4f8c77  
    4242#include <errno.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544
    4645/** Creates a new measured string bundled with a copy of the given string
     
    298297 * size has to be negotiated in advance.
    299298 *
    300  * @param[in] phone     The other module phone.
     299 * @param[in] exch      Exchange.
    301300 * @param[out] strings  The returned measured strings array.
    302301 * @param[out] data     The measured strings data. This memory block stores the
     
    305304 * @return              EOK on success.
    306305 * @return              EINVAL if the strings or data parameter is NULL.
    307  * @return              EINVAL if the phone or count parameter is not positive.
     306 * @return              EINVAL if the exch or count parameter is invalid.
    308307 * @return              EINVAL if the sent array differs in size.
    309308 * @return              ENOMEM if there is not enough memory left.
     
    311310 *                      async_data_read_start() function.
    312311 */
    313 int
    314 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data,
    315     size_t count)
     312int measured_strings_return(async_exch_t *exch, measured_string_t **strings,
     313    uint8_t **data, size_t count)
    316314{
    317315        size_t *lengths;
     
    320318        int rc;
    321319
    322         if ((phone < 0) || (!strings) || (!data) || (count <= 0))
     320        if ((exch == NULL) || (!strings) || (!data) || (count <= 0))
    323321                return EINVAL;
    324322
     
    327325                return ENOMEM;
    328326
    329         rc = async_obsolete_data_read_start(phone, lengths,
     327        rc = async_data_read_start(exch, lengths,
    330328            sizeof(size_t) * (count + 1));
    331329        if (rc != EOK) {
     
    352350                (*strings)[index].length = lengths[index];
    353351                if (lengths[index] > 0) {
    354                         rc = async_obsolete_data_read_start(phone, next, lengths[index]);
     352                        rc = async_data_read_start(exch, next, lengths[index]);
    355353                        if (rc != EOK) {
    356354                                free(lengths);
     
    376374 * size has to be negotiated in advance.
    377375 *
    378  * @param[in] phone     The other module phone.
     376 * @param[in] exch      Exchange.
    379377 * @param[in] strings   The measured strings array to be transferred.
    380378 * @param[in] count     The measured strings array size.
    381379 * @return              EOK on success.
    382380 * @return              EINVAL if the strings parameter is NULL.
    383  * @return              EINVAL if the phone or count parameter is not positive.
     381 * @return              EINVAL if the exch or count parameter is invalid.
    384382 * @return              Other error codes as defined for the
    385383 *                      async_data_write_start() function.
    386384 */
    387 int
    388 measured_strings_send(int phone, const measured_string_t *strings,
     385int measured_strings_send(async_exch_t *exch, const measured_string_t *strings,
    389386    size_t count)
    390387{
     
    393390        int rc;
    394391
    395         if ((phone < 0) || (!strings) || (count <= 0))
     392        if ((exch == NULL) || (!strings) || (count <= 0))
    396393                return EINVAL;
    397394
     
    400397                return ENOMEM;
    401398
    402         rc = async_obsolete_data_write_start(phone, lengths,
     399        rc = async_data_write_start(exch, lengths,
    403400            sizeof(size_t) * (count + 1));
    404401        if (rc != EOK) {
     
    411408        for (index = 0; index < count; index++) {
    412409                if (strings[index].length > 0) {
    413                         rc = async_obsolete_data_write_start(phone, strings[index].value,
     410                        rc = async_data_write_start(exch, strings[index].value,
    414411                            strings[index].length);
    415412                        if (rc != EOK)
     
    423420/** @}
    424421 */
    425 
  • uspace/lib/c/generic/adt/prodcons.c

    r5974661 re4f8c77  
    6161                fibril_condvar_wait(&pc->cv, &pc->mtx);
    6262       
    63         link_t *head = pc->list.next;
     63        link_t *head = list_first(&pc->list);
    6464        list_remove(head);
    6565       
  • uspace/lib/c/generic/async.c

    r5974661 re4f8c77  
    160160       
    161161        /** Messages that should be delivered to this fibril. */
    162         link_t msg_queue;
     162        list_t msg_queue;
    163163       
    164164        /** Identification of the opening call. */
     
    166166        /** Call data of the opening call. */
    167167        ipc_call_t call;
     168        /** Local argument or NULL if none. */
     169        void *carg;
    168170       
    169171        /** Identification of the closing call. */
     
    171173       
    172174        /** Fibril function that will be used to handle the connection. */
    173         void (*cfibril)(ipc_callid_t, ipc_call_t *);
     175        async_client_conn_t cfibril;
    174176} connection_t;
    175177
     
    213215 * @param callid Hash of the incoming call.
    214216 * @param call   Data of the incoming call.
    215  *
    216  */
    217 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
     217 * @param arg    Local argument
     218 *
     219 */
     220static void default_client_connection(ipc_callid_t callid, ipc_call_t *call,
     221    void *arg)
    218222{
    219223        ipc_answer_0(callid, ENOENT);
     
    226230 * @param callid Hash of the incoming call.
    227231 * @param call   Data of the incoming call.
     232 * @param arg    Local argument.
    228233 *
    229234 */
     
    233238
    234239static async_client_conn_t client_connection = default_client_connection;
    235 static async_client_conn_t interrupt_received = default_interrupt_received;
     240static async_interrupt_handler_t interrupt_received = default_interrupt_received;
    236241
    237242/** Setter for client_connection function pointer.
     
    250255 *             notification fibril.
    251256 */
    252 void async_set_interrupt_received(async_client_conn_t intr)
     257void async_set_interrupt_received(async_interrupt_handler_t intr)
    253258{
    254259        interrupt_received = intr;
     
    356361        wd->to_event.inlist = true;
    357362       
    358         link_t *tmp = timeout_list.next;
    359         while (tmp != &timeout_list) {
     363        link_t *tmp = timeout_list.head.next;
     364        while (tmp != &timeout_list.head) {
    360365                awaiter_t *cur
    361366                    = list_get_instance(tmp, awaiter_t, to_event.link);
     
    367372        }
    368373       
    369         list_append(&wd->to_event.link, tmp);
     374        list_insert_before(&wd->to_event.link, tmp);
    370375}
    371376
     
    564569        }
    565570       
    566         msg_t *msg = list_get_instance(conn->msg_queue.next, msg_t, link);
     571        msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link);
    567572        list_remove(&msg->link);
    568573       
     
    633638         */
    634639        fibril_connection->cfibril(fibril_connection->callid,
    635             &fibril_connection->call);
     640            &fibril_connection->call, fibril_connection->carg);
    636641       
    637642        /*
     
    670675        while (!list_empty(&fibril_connection->msg_queue)) {
    671676                msg_t *msg =
    672                     list_get_instance(fibril_connection->msg_queue.next, msg_t,
    673                     link);
     677                    list_get_instance(list_first(&fibril_connection->msg_queue),
     678                    msg_t, link);
    674679               
    675680                list_remove(&msg->link);
     
    704709 * @param cfibril       Fibril function that should be called upon opening the
    705710 *                      connection.
     711 * @param carg          Extra argument to pass to the connection fibril
    706712 *
    707713 * @return New fibril id or NULL on failure.
     
    710716fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash,
    711717    ipc_callid_t callid, ipc_call_t *call,
    712     async_client_conn_t cfibril)
     718    async_client_conn_t cfibril, void *carg)
    713719{
    714720        connection_t *conn = malloc(sizeof(*conn));
     
    725731        conn->callid = callid;
    726732        conn->close_callid = 0;
     733        conn->carg = carg;
    727734       
    728735        if (call)
     
    779786                /* Open new connection with fibril, etc. */
    780787                async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
    781                     callid, call, client_connection);
     788                    callid, call, client_connection, NULL);
    782789                return;
    783790        }
     
    799806        futex_down(&async_futex);
    800807       
    801         link_t *cur = timeout_list.next;
    802         while (cur != &timeout_list) {
     808        link_t *cur = list_first(&timeout_list);
     809        while (cur != NULL) {
    803810                awaiter_t *waiter =
    804811                    list_get_instance(cur, awaiter_t, to_event.link);
     
    806813                if (tv_gt(&waiter->to_event.expires, &tv))
    807814                        break;
    808                
    809                 cur = cur->next;
    810815               
    811816                list_remove(&waiter->to_event.link);
     
    821826                        fibril_add_ready(waiter->fid);
    822827                }
     828               
     829                cur = list_first(&timeout_list);
    823830        }
    824831       
     
    847854                suseconds_t timeout;
    848855                if (!list_empty(&timeout_list)) {
    849                         awaiter_t *waiter = list_get_instance(timeout_list.next,
    850                             awaiter_t, to_event.link);
     856                        awaiter_t *waiter = list_get_instance(
     857                            list_first(&timeout_list), awaiter_t, to_event.link);
    851858                       
    852859                        struct timeval tv;
     
    14141421 */
    14151422int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
    1416     sysarg_t arg3, async_client_conn_t client_receiver)
     1423    sysarg_t arg3, async_client_conn_t client_receiver, void *carg)
    14171424{
    14181425        if (exch == NULL)
     
    14281435        if (client_receiver != NULL)
    14291436                async_new_connection(task_hash, phone_hash, 0, NULL,
    1430                     client_receiver);
     1437                    client_receiver, carg);
    14311438       
    14321439        return EOK;
     
    17241731                 */
    17251732                exch = (async_exch_t *)
    1726                     list_get_instance(sess->exch_list.next, async_exch_t, sess_link);
     1733                    list_get_instance(list_first(&sess->exch_list),
     1734                    async_exch_t, sess_link);
     1735               
    17271736                list_remove(&exch->sess_link);
    17281737                list_remove(&exch->global_link);
     
    17361745                        exch = (async_exch_t *) malloc(sizeof(async_exch_t));
    17371746                        if (exch != NULL) {
    1738                                 list_initialize(&exch->sess_link);
    1739                                 list_initialize(&exch->global_link);
     1747                                link_initialize(&exch->sess_link);
     1748                                link_initialize(&exch->global_link);
    17401749                                exch->sess = sess;
    17411750                                exch->phone = sess->phone;
     
    17541763                                exch = (async_exch_t *) malloc(sizeof(async_exch_t));
    17551764                                if (exch != NULL) {
    1756                                         list_initialize(&exch->sess_link);
    1757                                         list_initialize(&exch->global_link);
     1765                                        link_initialize(&exch->sess_link);
     1766                                        link_initialize(&exch->global_link);
    17581767                                        exch->sess = sess;
    17591768                                        exch->phone = phone;
     
    17671776                                 */
    17681777                                exch = (async_exch_t *)
    1769                                     list_get_instance(inactive_exch_list.next, async_exch_t,
    1770                                     global_link);
     1778                                    list_get_instance(list_first(&inactive_exch_list),
     1779                                    async_exch_t, global_link);
     1780                               
    17711781                                list_remove(&exch->sess_link);
    17721782                                list_remove(&exch->global_link);
     
    18081818        async_sess_t *sess = exch->sess;
    18091819       
     1820        atomic_dec(&sess->refcnt);
     1821       
    18101822        if (sess->mgmt == EXCHANGE_SERIALIZE)
    18111823                fibril_mutex_unlock(&sess->mutex);
  • uspace/lib/c/generic/async_obsolete.c

    r5974661 re4f8c77  
    166166}
    167167
    168 void async_obsolete_serialize_start(void)
    169 {
    170         fibril_inc_sercount();
    171 }
    172 
    173 void async_obsolete_serialize_end(void)
    174 {
    175         fibril_dec_sercount();
    176 }
    177 
    178168/** Wrapper for IPC_M_DATA_WRITE calls using the async framework.
    179169 *
     
    240230 */
    241231int async_obsolete_connect_to_me(int phone, sysarg_t arg1, sysarg_t arg2,
    242     sysarg_t arg3, async_client_conn_t client_receiver)
     232    sysarg_t arg3, async_client_conn_t client_receiver, void *carg)
    243233{
    244234        sysarg_t task_hash;
     
    251241        if (client_receiver != NULL)
    252242                async_new_connection(task_hash, phone_hash, 0, NULL,
    253                     client_receiver);
     243                    client_receiver, carg);
    254244       
    255245        return EOK;
  • uspace/lib/c/generic/devman.c

    r5974661 re4f8c77  
    3535 */
    3636
     37#include <adt/list.h>
    3738#include <str.h>
    3839#include <ipc/services.h>
     
    194195       
    195196        exch = devman_exchange_begin(DEVMAN_DRIVER);
    196         async_connect_to_me(exch, 0, 0, 0, NULL);
     197        async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
    197198        devman_exchange_end(exch);
    198199       
     
    231232        }
    232233       
    233         link_t *link = match_ids->ids.next;
    234234        match_id_t *match_id = NULL;
    235235       
    236         while (link != &match_ids->ids) {
     236        list_foreach(match_ids->ids, link) {
    237237                match_id = list_get_instance(link, match_id_t, link);
    238238               
     
    255255                        return retval;
    256256                }
    257                
    258                 link = link->next;
    259257        }
    260258       
  • uspace/lib/c/generic/devmap.c

    r5974661 re4f8c77  
    187187       
    188188        exch = devmap_exchange_begin(DEVMAP_DRIVER);
    189         async_connect_to_me(exch, 0, 0, 0, NULL);
     189        async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
    190190        devmap_exchange_end(exch);
    191191       
  • uspace/lib/c/generic/fibril.c

    r5974661 re4f8c77  
    222222        fibril_t *dstf;
    223223        if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
    224                 dstf = list_get_instance(manager_list.next, fibril_t, link);
     224                dstf = list_get_instance(list_first(&manager_list), fibril_t,
     225                    link);
    225226                if (serialization_count && stype == FIBRIL_TO_MANAGER) {
    226227                        serialized_threads++;
     
    233234        } else {
    234235                if (!list_empty(&serialized_list)) {
    235                         dstf = list_get_instance(serialized_list.next, fibril_t,
    236                             link);
     236                        dstf = list_get_instance(list_first(&serialized_list),
     237                            fibril_t, link);
    237238                        serialized_threads--;
    238239                } else {
    239                         dstf = list_get_instance(ready_list.next, fibril_t,
    240                             link);
     240                        dstf = list_get_instance(list_first(&ready_list),
     241                            fibril_t, link);
    241242                }
    242243        }
     
    326327       
    327328        if (!list_empty(&manager_list))
    328                 list_remove(manager_list.next);
     329                list_remove(list_first(&manager_list));
    329330       
    330331        futex_up(&fibril_futex);
  • uspace/lib/c/generic/fibril_synch.c

    r5974661 re4f8c77  
    148148                fibril_t *f;
    149149       
    150                 assert(!list_empty(&fm->waiters));
    151                 tmp = fm->waiters.next;
     150                tmp = list_first(&fm->waiters);
     151                assert(tmp != NULL);
    152152                wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
    153153                wdp->active = true;
     
    279279       
    280280        while (!list_empty(&frw->waiters)) {
    281                 link_t *tmp = frw->waiters.next;
     281                link_t *tmp = list_first(&frw->waiters);
    282282                awaiter_t *wdp;
    283283                fibril_t *f;
     
    422422        futex_down(&async_futex);
    423423        while (!list_empty(&fcv->waiters)) {
    424                 tmp = fcv->waiters.next;
     424                tmp = list_first(&fcv->waiters);
    425425                wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
    426426                list_remove(&wdp->wu_event.link);
  • uspace/lib/c/generic/io/console.c

    r5974661 re4f8c77  
    7676bool console_kcon(void)
    7777{
    78 #if 0
    7978        return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE);
    80 #endif
    81        
    82         return false;
    8379}
    8480
  • uspace/lib/c/generic/io/io.c

    r5974661 re4f8c77  
    127127void __stdio_done(void)
    128128{
    129         link_t *link = files.next;
    130        
    131         while (link != &files) {
    132                 FILE *file = list_get_instance(link, FILE, link);
     129        while (!list_empty(&files)) {
     130                FILE *file = list_get_instance(list_first(&files), FILE, link);
    133131                fclose(file);
    134                 link = files.next;
    135132        }
    136133}
  • uspace/lib/c/generic/ipc.c

    r5974661 re4f8c77  
    458458        while (!list_empty(&queued_calls)) {
    459459                async_call_t *call =
    460                     list_get_instance(queued_calls.next, async_call_t, list);
     460                    list_get_instance(list_first(&queued_calls), async_call_t, list);
    461461                ipc_callid_t callid =
    462462                    ipc_call_async_internal(call->u.msg.phoneid, &call->u.msg.data);
     
    511511       
    512512        link_t *item;
    513         for (item = dispatched_calls.next; item != &dispatched_calls;
     513        for (item = dispatched_calls.head.next; item != &dispatched_calls.head;
    514514            item = item->next) {
    515515                async_call_t *call =
  • uspace/lib/c/generic/net/icmp_api.c

    r5974661 re4f8c77  
    4242#include <net/ip_codes.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <sys/types.h>
    4645#include <sys/time.h>
     
    5554 * timeout occurs.
    5655 *
    57  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     56 * @param[in] sess The ICMP session.
    5857 * @param[in] size      The message data length in bytes.
    5958 * @param[in] timeout   The timeout in milliseconds.
     
    7473 */
    7574int
    76 icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl,
     75icmp_echo_msg(async_sess_t *sess, size_t size, mseconds_t timeout, ip_ttl_t ttl,
    7776    ip_tos_t tos, int dont_fragment, const struct sockaddr *addr,
    7877    socklen_t addrlen)
     
    8382        if (addrlen <= 0)
    8483                return EINVAL;
    85 
    86         message_id = async_obsolete_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl,
     84       
     85        async_exch_t *exch = async_exchange_begin(sess);
     86       
     87        message_id = async_send_5(exch, NET_ICMP_ECHO, size, timeout, ttl,
    8788            tos, (sysarg_t) dont_fragment, NULL);
    88 
     89       
    8990        /* Send the address */
    90         async_obsolete_data_write_start(icmp_phone, addr, (size_t) addrlen);
     91        async_data_write_start(exch, addr, (size_t) addrlen);
     92       
     93        async_exchange_end(exch);
    9194
    9295        async_wait_for(message_id, &result);
  • uspace/lib/c/generic/net/icmp_common.c

    r5974661 re4f8c77  
    4545/** Connect to the ICMP module.
    4646 *
    47  * @param[in] timeout Connection timeout in microseconds, zero
    48  *                    for no timeout.
    49  *
    50  * @return ICMP module phone on success.
    51  * @return ETIMEOUT if the connection timeouted.
     47 * @return ICMP module session.
    5248 *
    5349 */
    54 int icmp_connect_module(suseconds_t timeout)
     50async_sess_t *icmp_connect_module(void)
    5551{
    56         return connect_to_service_timeout(SERVICE_ICMP, timeout);
     52        return connect_to_service(SERVICE_ICMP);
    5753}
    5854
  • uspace/lib/c/generic/net/modules.c

    r5974661 re4f8c77  
    4040
    4141#include <async.h>
    42 #include <async_obsolete.h>
    4342#include <malloc.h>
    4443#include <errno.h>
     
    4746#include <net/modules.h>
    4847#include <ns.h>
    49 #include <ns_obsolete.h>
    50 
    51 /** The time between connect requests in microseconds. */
    52 #define MODULE_WAIT_TIME  (10 * 1000)
    5348
    5449/** Answer a call.
     
    9893}
    9994
    100 /** Create bidirectional connection with the needed module service and registers
     95/** Create bidirectional connection with the needed module service and register
    10196 * the message receiver.
    10297 *
    103  * @param[in] need      The needed module service.
    104  * @param[in] arg1      The first parameter.
    105  * @param[in] arg2      The second parameter.
    106  * @param[in] arg3      The third parameter.
    107  * @param[in] client_receiver The message receiver.
    108  *
    109  * @return              The phone of the needed service.
    110  * @return              Other error codes as defined for the ipc_connect_to_me()
    111  *                      function.
    112  */
    113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    114     async_client_conn_t client_receiver)
    115 {
    116         return bind_service_timeout(need, arg1, arg2, arg3, client_receiver, 0);
    117 }
    118 
    119 /** Create bidirectional connection with the needed module service and registers
    120  * the message receiver.
    121  *
    122  * @param[in] need      The needed module service.
    123  * @param[in] arg1      The first parameter.
    124  * @param[in] arg2      The second parameter.
    125  * @param[in] arg3      The third parameter.
    126  * @param[in] client_receiver The message receiver.
    127  * @param[in] timeout   The connection timeout in microseconds. No timeout if
    128  *                      set to zero (0).
    129  *
    130  * @return              The phone of the needed service.
    131  * @return              ETIMEOUT if the connection timeouted.
    132  * @return              Other error codes as defined for the ipc_connect_to_me()
    133  *                      function.
    134  *
    135  */
    136 int bind_service_timeout(services_t need, sysarg_t arg1, sysarg_t arg2,
    137     sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
     98 * @param[in] need            Needed module service.
     99 * @param[in] arg1            First parameter.
     100 * @param[in] arg2            Second parameter.
     101 * @param[in] arg3            Third parameter.
     102 * @param[in] client_receiver Message receiver.
     103 *
     104 * @return Session to the needed service.
     105 * @return Other error codes as defined for the async_connect_to_me()
     106 *         function.
     107 *
     108 */
     109async_sess_t *bind_service(services_t need, sysarg_t arg1, sysarg_t arg2,
     110    sysarg_t arg3, async_client_conn_t client_receiver)
    138111{
    139112        /* Connect to the needed service */
    140         int phone = connect_to_service_timeout(need, timeout);
    141         if (phone >= 0) {
     113        async_sess_t *sess = connect_to_service(need);
     114        if (sess != NULL) {
    142115                /* Request the bidirectional connection */
    143                 int rc = async_obsolete_connect_to_me(phone, arg1, arg2, arg3, client_receiver);
     116                async_exch_t *exch = async_exchange_begin(sess);
     117                int rc = async_connect_to_me(exch, arg1, arg2, arg3,
     118                    client_receiver, NULL);
     119                async_exchange_end(exch);
     120               
    144121                if (rc != EOK) {
    145                         async_obsolete_hangup(phone);
    146                         return rc;
     122                        async_hangup(sess);
     123                        errno = rc;
     124                        return NULL;
    147125                }
    148126        }
    149127       
    150         return phone;
    151 }
    152 
    153 /** Connects to the needed module.
    154  *
    155  * @param[in] need      The needed module service.
    156  * @return              The phone of the needed service.
    157  */
    158 int connect_to_service(services_t need)
    159 {
    160         return connect_to_service_timeout(need, 0);
    161 }
    162 
    163 /** Connects to the needed module.
    164  *
    165  *  @param[in] need     The needed module service.
    166  *  @param[in] timeout  The connection timeout in microseconds. No timeout if
    167  *                      set to zero (0).
    168  *  @return             The phone of the needed service.
    169  *  @return             ETIMEOUT if the connection timeouted.
    170  */
    171 int connect_to_service_timeout(services_t need, suseconds_t timeout)
    172 {
    173         int phone;
    174 
    175         /* If no timeout is set */
    176         if (timeout <= 0)
    177                 return service_obsolete_connect_blocking(need, 0, 0);
    178        
    179         while (true) {
    180                 phone = service_obsolete_connect(need, 0, 0);
    181                 if ((phone >= 0) || (phone != ENOENT))
    182                         return phone;
    183 
    184                 /* Abort if no time is left */
    185                 if (timeout <= 0)
    186                         return ETIMEOUT;
    187 
    188                 /* Wait the minimum of the module wait time and the timeout */
    189                 usleep((timeout <= MODULE_WAIT_TIME) ?
    190                     timeout : MODULE_WAIT_TIME);
    191                 timeout -= MODULE_WAIT_TIME;
    192         }
    193 }
    194 
    195 /** Replies the data to the other party.
    196  *
    197  * @param[in] data      The data buffer to be sent.
     128        return sess;
     129}
     130
     131/** Connect to the needed module.
     132 *
     133 * @param[in] need Needed module service.
     134 *
     135 * @return Session to the needed service.
     136 * @return NULL if the connection timeouted.
     137 *
     138 */
     139async_sess_t *connect_to_service(services_t need)
     140{
     141        return service_connect_blocking(EXCHANGE_SERIALIZE, need, 0, 0);
     142}
     143
     144/** Reply the data to the other party.
     145 *
     146 * @param[in] data        The data buffer to be sent.
    198147 * @param[in] data_length The buffer length.
    199  * @return              EOK on success.
    200  * @return              EINVAL if the client does not expect the data.
    201  * @return              EOVERFLOW if the client does not expect all the data.
    202  *                      Only partial data are transfered.
    203  * @return              Other error codes as defined for the
    204  *                      async_data_read_finalize() function.
     148 *
     149 * @return EOK on success.
     150 * @return EINVAL if the client does not expect the data.
     151 * @return EOVERFLOW if the client does not expect all the data.
     152 *         Only partial data are transfered.
     153 * @return Other error codes as defined for the
     154 *         async_data_read_finalize() function.
     155 *
    205156 */
    206157int data_reply(void *data, size_t data_length)
     
    208159        size_t length;
    209160        ipc_callid_t callid;
    210 
     161       
    211162        /* Fetch the request */
    212163        if (!async_data_read_receive(&callid, &length))
    213164                return EINVAL;
    214 
     165       
    215166        /* Check the requested data size */
    216167        if (length < data_length) {
     
    218169                return EOVERFLOW;
    219170        }
    220 
     171       
    221172        /* Send the data */
    222173        return async_data_read_finalize(callid, data, data_length);
  • uspace/lib/c/generic/net/socket_client.c

    r5974661 re4f8c77  
    3939#include <assert.h>
    4040#include <async.h>
    41 #include <async_obsolete.h>
    4241#include <fibril_synch.h>
    4342#include <stdint.h>
     
    6564#define SOCKET_MAX_ACCEPTED_SIZE        0
    6665
    67 /** Default timeout for connections in microseconds. */
    68 #define SOCKET_CONNECT_TIMEOUT  (1 * 1000 * 1000)
    69 
    7066/**
    7167 * Maximum number of random attempts to find a new socket identifier before
     
    8783        /** Socket identifier. */
    8884        int socket_id;
    89         /** Parent module phone. */
    90         int phone;
     85        /** Parent module session. */
     86        async_sess_t *sess;
    9187        /** Parent module service. */
    9288        services_t service;
     
    147143/** Socket client library global data. */
    148144static struct socket_client_globals {
    149         /** TCP module phone. */
    150         int tcp_phone;
    151         /** UDP module phone. */
    152         int udp_phone;
    153 
    154 //      /** The last socket identifier.
    155 //       */
    156 //      int last_id;
     145        /** TCP module session. */
     146        async_sess_t *tcp_sess;
     147        /** UDP module session. */
     148        async_sess_t *udp_sess;
    157149
    158150        /** Active sockets. */
     
    167159        fibril_rwlock_t lock;
    168160} socket_globals = {
    169         .tcp_phone = -1,
    170         .udp_phone = -1,
    171 //      .last_id = 0,
     161        .tcp_sess = NULL,
     162        .udp_sess = NULL,
    172163        .sockets = NULL,
    173164        .lock = FIBRIL_RWLOCK_INITIALIZER(socket_globals.lock)
     
    203194 * @param[in] iid       The initial message identifier.
    204195 * @param[in] icall     The initial message call structure.
    205  */
    206 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall)
     196 * @param[in] arg       Local argument.
     197 */
     198static void socket_connection(ipc_callid_t iid, ipc_call_t * icall, void *arg)
    207199{
    208200        ipc_callid_t callid;
     
    282274}
    283275
    284 /** Returns the TCP module phone.
    285  *
    286  * Connects to the TCP module if necessary.
    287  *
    288  * @return              The TCP module phone.
    289  * @return              Other error codes as defined for the
    290  *                      bind_service_timeout() function.
    291  */
    292 static int socket_get_tcp_phone(void)
    293 {
    294         if (socket_globals.tcp_phone < 0) {
    295                 socket_globals.tcp_phone = bind_service_timeout(SERVICE_TCP,
    296                     0, 0, SERVICE_TCP, socket_connection,
    297                     SOCKET_CONNECT_TIMEOUT);
    298         }
    299 
    300         return socket_globals.tcp_phone;
    301 }
    302 
    303 /** Returns the UDP module phone.
    304  *
    305  * Connects to the UDP module if necessary.
    306  *
    307  * @return              The UDP module phone.
    308  * @return              Other error codes as defined for the
    309  *                      bind_service_timeout() function.
    310  */
    311 static int socket_get_udp_phone(void)
    312 {
    313         if (socket_globals.udp_phone < 0) {
    314                 socket_globals.udp_phone = bind_service_timeout(SERVICE_UDP,
    315                     0, 0, SERVICE_UDP, socket_connection,
    316                     SOCKET_CONNECT_TIMEOUT);
    317         }
    318 
    319         return socket_globals.udp_phone;
     276/** Return the TCP module session.
     277 *
     278 * Connect to the TCP module if necessary.
     279 *
     280 * @return The TCP module session.
     281 *
     282 */
     283static async_sess_t *socket_get_tcp_sess(void)
     284{
     285        if (socket_globals.tcp_sess == NULL) {
     286                socket_globals.tcp_sess = bind_service(SERVICE_TCP,
     287                    0, 0, SERVICE_TCP, socket_connection);
     288        }
     289
     290        return socket_globals.tcp_sess;
     291}
     292
     293/** Return the UDP module session.
     294 *
     295 * Connect to the UDP module if necessary.
     296 *
     297 * @return The UDP module session.
     298 *
     299 */
     300static async_sess_t *socket_get_udp_sess(void)
     301{
     302        if (socket_globals.udp_sess == NULL) {
     303                socket_globals.udp_sess = bind_service(SERVICE_UDP,
     304                    0, 0, SERVICE_UDP, socket_connection);
     305        }
     306
     307        return socket_globals.udp_sess;
    320308}
    321309
     
    333321        sockets = socket_get_sockets();
    334322        count = 0;
    335 //      socket_id = socket_globals.last_id;
    336323
    337324        do {
     
    346333                        if (socket_id < INT_MAX) {
    347334                                ++socket_id;
    348 /*                      } else if(socket_globals.last_id) {
    349  *                              socket_globals.last_id = 0;
    350  *                              socket_id = 1;
    351  */                     } else {
     335                        } else {
    352336                                return ELIMIT;
    353337                        }
    354338                }
    355339        } while (sockets_find(sockets, socket_id));
    356 
    357 //      last_id = socket_id
     340       
    358341        return socket_id;
    359342}
     
    362345 *
    363346 * @param[in,out] socket The socket to be initialized.
    364  * @param[in] socket_id The new socket identifier.
    365  * @param[in] phone     The parent module phone.
    366  * @param[in] service   The parent module service.
    367  */
    368 static void
    369 socket_initialize(socket_t *socket, int socket_id, int phone,
    370     services_t service)
     347 * @param[in] socket_id  The new socket identifier.
     348 * @param[in] sess       The parent module session.
     349 * @param[in] service    The parent module service.
     350 */
     351static void socket_initialize(socket_t *socket, int socket_id,
     352    async_sess_t *sess, services_t service)
    371353{
    372354        socket->socket_id = socket_id;
    373         socket->phone = phone;
     355        socket->sess = sess;
    374356        socket->service = service;
    375357        dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     
    396378 * @return              Other error codes as defined for the NET_SOCKET message.
    397379 * @return              Other error codes as defined for the
    398  *                      bind_service_timeout() function.
     380 *                      bind_service() function.
    399381 */
    400382int socket(int domain, int type, int protocol)
    401383{
    402384        socket_t *socket;
    403         int phone;
     385        async_sess_t *sess;
    404386        int socket_id;
    405387        services_t service;
     
    418400                        switch (protocol) {
    419401                        case IPPROTO_TCP:
    420                                 phone = socket_get_tcp_phone();
     402                                sess = socket_get_tcp_sess();
    421403                                service = SERVICE_TCP;
    422404                                break;
     
    433415                        switch (protocol) {
    434416                        case IPPROTO_UDP:
    435                                 phone = socket_get_udp_phone();
     417                                sess = socket_get_udp_sess();
    436418                                service = SERVICE_UDP;
    437419                                break;
     
    454436        }
    455437
    456         if (phone < 0)
    457                 return phone;
     438        if (sess == NULL)
     439                return ENOENT;
    458440
    459441        /* Create a new socket structure */
     
    472454                return socket_id;
    473455        }
    474 
    475         rc = (int) async_obsolete_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL,
     456       
     457        async_exch_t *exch = async_exchange_begin(sess);
     458        rc = (int) async_req_3_3(exch, NET_SOCKET, socket_id, 0, service, NULL,
    476459            &fragment_size, &header_size);
     460        async_exchange_end(exch);
     461       
    477462        if (rc != EOK) {
    478463                fibril_rwlock_write_unlock(&socket_globals.lock);
     
    485470
    486471        /* Finish the new socket initialization */
    487         socket_initialize(socket, socket_id, phone, service);
     472        socket_initialize(socket, socket_id, sess, service);
    488473        /* Store the new socket */
    489474        rc = sockets_add(socket_get_sockets(), socket_id, socket);
     
    494479                dyn_fifo_destroy(&socket->accepted);
    495480                free(socket);
    496                 async_obsolete_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0,
     481               
     482                exch = async_exchange_begin(sess);
     483                async_msg_3(exch, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0,
    497484                    service);
     485                async_exchange_end(exch);
     486               
    498487                return rc;
    499488        }
     
    539528
    540529        /* Request the message */
    541         message_id = async_obsolete_send_3(socket->phone, message,
     530        async_exch_t *exch = async_exchange_begin(socket->sess);
     531        message_id = async_send_3(exch, message,
    542532            (sysarg_t) socket->socket_id, arg2, socket->service, NULL);
    543533        /* Send the address */
    544         async_obsolete_data_write_start(socket->phone, data, datalength);
     534        async_data_write_start(exch, data, datalength);
     535        async_exchange_end(exch);
    545536
    546537        fibril_rwlock_read_unlock(&socket_globals.lock);
     
    599590
    600591        /* Request listen backlog change */
    601         result = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_LISTEN,
     592        async_exch_t *exch = async_exchange_begin(socket->sess);
     593        result = (int) async_req_3_0(exch, NET_SOCKET_LISTEN,
    602594            (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service);
     595        async_exchange_end(exch);
    603596
    604597        fibril_rwlock_read_unlock(&socket_globals.lock);
     
    670663                return socket_id;
    671664        }
    672         socket_initialize(new_socket, socket_id, socket->phone,
     665        socket_initialize(new_socket, socket_id, socket->sess,
    673666            socket->service);
    674667        result = sockets_add(socket_get_sockets(), new_socket->socket_id,
     
    682675
    683676        /* Request accept */
    684         message_id = async_obsolete_send_5(socket->phone, NET_SOCKET_ACCEPT,
     677        async_exch_t *exch = async_exchange_begin(socket->sess);
     678        message_id = async_send_5(exch, NET_SOCKET_ACCEPT,
    685679            (sysarg_t) socket->socket_id, 0, socket->service, 0,
    686680            new_socket->socket_id, &answer);
    687681
    688682        /* Read address */
    689         async_obsolete_data_read_start(socket->phone, cliaddr, *addrlen);
     683        async_data_read_start(exch, cliaddr, *addrlen);
     684        async_exchange_end(exch);
     685       
    690686        fibril_rwlock_write_unlock(&socket_globals.lock);
    691687        async_wait_for(message_id, &ipc_result);
     
    781777
    782778        /* Request close */
    783         rc = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_CLOSE,
     779        async_exch_t *exch = async_exchange_begin(socket->sess);
     780        rc = (int) async_req_3_0(exch, NET_SOCKET_CLOSE,
    784781            (sysarg_t) socket->socket_id, 0, socket->service);
     782        async_exchange_end(exch);
     783       
    785784        if (rc != EOK) {
    786785                fibril_rwlock_write_unlock(&socket_globals.lock);
     
    854853
    855854        /* Request send */
    856         message_id = async_obsolete_send_5(socket->phone, message,
     855        async_exch_t *exch = async_exchange_begin(socket->sess);
     856       
     857        message_id = async_send_5(exch, message,
    857858            (sysarg_t) socket->socket_id,
    858859            (fragments == 1 ? datalength : socket->data_fragment_size),
     
    861862        /* Send the address if given */
    862863        if (!toaddr ||
    863             (async_obsolete_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {
     864            (async_data_write_start(exch, toaddr, addrlen) == EOK)) {
    864865                if (fragments == 1) {
    865866                        /* Send all if only one fragment */
    866                         async_obsolete_data_write_start(socket->phone, data, datalength);
     867                        async_data_write_start(exch, data, datalength);
    867868                } else {
    868869                        /* Send the first fragment */
    869                         async_obsolete_data_write_start(socket->phone, data,
     870                        async_data_write_start(exch, data,
    870871                            socket->data_fragment_size - socket->header_size);
    871872                        data = ((const uint8_t *) data) +
     
    874875                        /* Send the middle fragments */
    875876                        while (--fragments > 1) {
    876                                 async_obsolete_data_write_start(socket->phone, data,
     877                                async_data_write_start(exch, data,
    877878                                    socket->data_fragment_size);
    878879                                data = ((const uint8_t *) data) +
     
    881882
    882883                        /* Send the last fragment */
    883                         async_obsolete_data_write_start(socket->phone, data,
     884                        async_data_write_start(exch, data,
    884885                            (datalength + socket->header_size) %
    885886                            socket->data_fragment_size);
    886887                }
    887888        }
     889       
     890        async_exchange_end(exch);
    888891
    889892        async_wait_for(message_id, &result);
     
    10271030                return 0;
    10281031        }
     1032       
     1033        async_exch_t *exch = async_exchange_begin(socket->sess);
    10291034
    10301035        /* Prepare lengths if more fragments */
     
    10391044
    10401045                /* Request packet data */
    1041                 message_id = async_obsolete_send_4(socket->phone, message,
     1046                message_id = async_send_4(exch, message,
    10421047                    (sysarg_t) socket->socket_id, 0, socket->service,
    10431048                    (sysarg_t) flags, &answer);
     
    10451050                /* Read the address if desired */
    10461051                if(!fromaddr ||
    1047                     (async_obsolete_data_read_start(socket->phone, fromaddr,
     1052                    (async_data_read_start(exch, fromaddr,
    10481053                    *addrlen) == EOK)) {
    10491054                        /* Read the fragment lengths */
    1050                         if (async_obsolete_data_read_start(socket->phone, lengths,
     1055                        if (async_data_read_start(exch, lengths,
    10511056                            sizeof(int) * (fragments + 1)) == EOK) {
    10521057                                if (lengths[fragments] <= datalength) {
     
    10551060                                        for (index = 0; index < fragments;
    10561061                                            ++index) {
    1057                                                 async_obsolete_data_read_start(
    1058                                                     socket->phone, data,
     1062                                                async_data_read_start(exch, data,
    10591063                                                    lengths[index]);
    10601064                                                data = ((uint8_t *) data) +
     
    10681072        } else { /* fragments == 1 */
    10691073                /* Request packet data */
    1070                 message_id = async_obsolete_send_4(socket->phone, message,
     1074                message_id = async_send_4(exch, message,
    10711075                    (sysarg_t) socket->socket_id, 0, socket->service,
    10721076                    (sysarg_t) flags, &answer);
     
    10741078                /* Read the address if desired */
    10751079                if (!fromaddr ||
    1076                     (async_obsolete_data_read_start(socket->phone, fromaddr,
    1077                         *addrlen) == EOK)) {
     1080                    (async_data_read_start(exch, fromaddr, *addrlen) == EOK)) {
    10781081                        /* Read all if only one fragment */
    1079                         async_obsolete_data_read_start(socket->phone, data, datalength);
     1082                        async_data_read_start(exch, data, datalength);
    10801083                }
    10811084        }
     1085       
     1086        async_exchange_end(exch);
    10821087
    10831088        async_wait_for(message_id, &ipc_result);
     
    11911196
    11921197        /* Request option value */
    1193         message_id = async_obsolete_send_3(socket->phone, NET_SOCKET_GETSOCKOPT,
     1198        async_exch_t *exch = async_exchange_begin(socket->sess);
     1199       
     1200        message_id = async_send_3(exch, NET_SOCKET_GETSOCKOPT,
    11941201            (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service,
    11951202            NULL);
    11961203
    11971204        /* Read the length */
    1198         if (async_obsolete_data_read_start(socket->phone, optlen,
     1205        if (async_data_read_start(exch, optlen,
    11991206            sizeof(*optlen)) == EOK) {
    12001207                /* Read the value */
    1201                 async_obsolete_data_read_start(socket->phone, value, *optlen);
    1202         }
     1208                async_data_read_start(exch, value, *optlen);
     1209        }
     1210       
     1211        async_exchange_end(exch);
    12031212
    12041213        fibril_rwlock_read_unlock(&socket_globals.lock);
  • uspace/lib/c/generic/ns.c

    r5974661 re4f8c77  
    4242{
    4343        async_exch_t *exch = async_exchange_begin(session_ns);
    44         int rc = async_connect_to_me(exch, service, 0, 0, NULL);
     44        int rc = async_connect_to_me(exch, service, 0, 0, NULL, NULL);
    4545        async_exchange_end(exch);
    4646       
  • uspace/lib/c/generic/str.c

    r5974661 re4f8c77  
    540540
    541541        dstr_size = str_size(dest);
     542        if (dstr_size >= size)
     543                return;
     544       
    542545        str_cpy(dest + dstr_size, size - dstr_size, src);
     546}
     547
     548/** Convert space-padded ASCII to string.
     549 *
     550 * Common legacy text encoding in hardware is 7-bit ASCII fitted into
     551 * a fixed-with byte buffer (bit 7 always zero), right-padded with spaces
     552 * (ASCII 0x20). Convert space-padded ascii to string representation.
     553 *
     554 * If the text does not fit into the destination buffer, the function converts
     555 * as many characters as possible and returns EOVERFLOW.
     556 *
     557 * If the text contains non-ASCII bytes (with bit 7 set), the whole string is
     558 * converted anyway and invalid characters are replaced with question marks
     559 * (U_SPECIAL) and the function returns EIO.
     560 *
     561 * Regardless of return value upon return @a dest will always be well-formed.
     562 *
     563 * @param dest          Destination buffer
     564 * @param size          Size of destination buffer
     565 * @param src           Space-padded ASCII.
     566 * @param n             Size of the source buffer in bytes.
     567 *
     568 * @return              EOK on success, EOVERFLOW if the text does not fit
     569 *                      destination buffer, EIO if the text contains
     570 *                      non-ASCII bytes.
     571 */
     572int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n)
     573{
     574        size_t sidx;
     575        size_t didx;
     576        size_t dlast;
     577        uint8_t byte;
     578        int rc;
     579        int result;
     580
     581        /* There must be space for a null terminator in the buffer. */
     582        assert(size > 0);
     583        result = EOK;
     584
     585        didx = 0;
     586        dlast = 0;
     587        for (sidx = 0; sidx < n; ++sidx) {
     588                byte = src[sidx];
     589                if (!ascii_check(byte)) {
     590                        byte = U_SPECIAL;
     591                        result = EIO;
     592                }
     593
     594                rc = chr_encode(byte, dest, &didx, size - 1);
     595                if (rc != EOK) {
     596                        assert(rc == EOVERFLOW);
     597                        dest[didx] = '\0';
     598                        return rc;
     599                }
     600
     601                /* Remember dest index after last non-empty character */
     602                if (byte != 0x20)
     603                        dlast = didx;
     604        }
     605
     606        /* Terminate string after last non-empty character */
     607        dest[dlast] = '\0';
     608        return result;
    543609}
    544610
  • uspace/lib/c/generic/task.c

    r5974661 re4f8c77  
    101101int task_spawnv(task_id_t *id, const char *path, const char *const args[])
    102102{
    103         /* Connect to a program loader. */
    104         loader_t *ldr = loader_connect();
    105         if (ldr == NULL)
    106                 return EREFUSED;
    107        
    108         /* Get task ID. */
    109         task_id_t task_id;
    110         int rc = loader_get_task_id(ldr, &task_id);
    111         if (rc != EOK)
    112                 goto error;
    113        
    114         /* Send spawner's current working directory. */
    115         rc = loader_set_cwd(ldr);
    116         if (rc != EOK)
    117                 goto error;
    118        
    119         /* Send program pathname. */
    120         rc = loader_set_pathname(ldr, path);
    121         if (rc != EOK)
    122                 goto error;
    123        
    124         /* Send arguments. */
    125         rc = loader_set_args(ldr, args);
    126         if (rc != EOK)
    127                 goto error;
    128        
    129103        /* Send default files */
    130104        fdi_node_t *files[4];
     
    150124        files[3] = NULL;
    151125       
     126        return task_spawnvf(id, path, args, files);
     127}
     128
     129/** Create a new task by running an executable from the filesystem.
     130 *
     131 * This is really just a convenience wrapper over the more complicated
     132 * loader API. Arguments are passed as a null-terminated array of strings.
     133 * Files are passed as null-terminated array of pointers to fdi_node_t.
     134 *
     135 * @param id    If not NULL, the ID of the task is stored here on success.
     136 * @param path  Pathname of the binary to execute.
     137 * @param argv  Command-line arguments.
     138 * @param files Standard files to use.
     139 *
     140 * @return Zero on success or negative error code.
     141 *
     142 */
     143int task_spawnvf(task_id_t *id, const char *path, const char *const args[],
     144    fdi_node_t *const files[])
     145{
     146        /* Connect to a program loader. */
     147        loader_t *ldr = loader_connect();
     148        if (ldr == NULL)
     149                return EREFUSED;
     150       
     151        /* Get task ID. */
     152        task_id_t task_id;
     153        int rc = loader_get_task_id(ldr, &task_id);
     154        if (rc != EOK)
     155                goto error;
     156       
     157        /* Send spawner's current working directory. */
     158        rc = loader_set_cwd(ldr);
     159        if (rc != EOK)
     160                goto error;
     161       
     162        /* Send program pathname. */
     163        rc = loader_set_pathname(ldr, path);
     164        if (rc != EOK)
     165                goto error;
     166       
     167        /* Send arguments. */
     168        rc = loader_set_args(ldr, args);
     169        if (rc != EOK)
     170                goto error;
     171       
     172        /* Send files */
    152173        rc = loader_set_files(ldr, files);
    153174        if (rc != EOK)
  • uspace/lib/c/include/adt/hash_table.h

    r5974661 re4f8c77  
    7575/** Hash table structure. */
    7676typedef struct {
    77         link_t *entry;
     77        list_t *entry;
    7878        hash_count_t entries;
    7979        hash_count_t max_keys;
  • uspace/lib/c/include/adt/list.h

    r5974661 re4f8c77  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3637#define LIBC_LIST_H_
    3738
     39#include <assert.h>
    3840#include <unistd.h>
    3941
    40 /** Doubly linked list head and link type. */
     42/** Doubly linked list link. */
    4143typedef struct link {
    4244        struct link *prev;  /**< Pointer to the previous item in the list. */
     
    4446} link_t;
    4547
     48/** Doubly linked list. */
     49typedef struct list {
     50        link_t head;  /**< List head. Does not have any data. */
     51} list_t;
     52
    4653/** Declare and initialize statically allocated list.
    4754 *
     
    5057 */
    5158#define LIST_INITIALIZE(name) \
    52         link_t name = { \
    53                 .prev = &name, \
    54                 .next = &name \
     59        list_t name = { \
     60                .head = { \
     61                        .prev = &(name).head, \
     62                        .next = &(name).head \
     63                } \
    5564        }
    5665
     
    5968
    6069#define list_foreach(list, iterator) \
    61         for (link_t *iterator = (list).next; \
    62             iterator != &(list); iterator = iterator->next)
     70        for (link_t *iterator = (list).head.next; \
     71            iterator != &(list).head; iterator = iterator->next)
     72
     73#define assert_link_not_used(link) \
     74        assert((link)->prev == NULL && (link)->next == NULL)
    6375
    6476/** Initialize doubly-linked circular list link
     
    7991 * Initialize doubly-linked circular list.
    8092 *
    81  * @param list Pointer to link_t structure representing the list.
    82  *
    83  */
    84 static inline void list_initialize(link_t *list)
    85 {
    86         list->prev = list;
    87         list->next = list;
     93 * @param list Pointer to list_t structure.
     94 *
     95 */
     96static inline void list_initialize(list_t *list)
     97{
     98        list->head.prev = &list->head;
     99        list->head.next = &list->head;
     100}
     101
     102/** Insert item before another item in doubly-linked circular list.
     103 *
     104 */
     105static inline void list_insert_before(link_t *lnew, link_t *lold)
     106{
     107        lnew->next = lold;
     108        lnew->prev = lold->prev;
     109        lold->prev->next = lnew;
     110        lold->prev = lnew;
     111}
     112
     113/** Insert item after another item in doubly-linked circular list.
     114 *
     115 */
     116static inline void list_insert_after(link_t *lnew, link_t *lold)
     117{
     118        lnew->prev = lold;
     119        lnew->next = lold->next;
     120        lold->next->prev = lnew;
     121        lold->next = lnew;
    88122}
    89123
     
    93127 *
    94128 * @param link Pointer to link_t structure to be added.
    95  * @param list Pointer to link_t structure representing the list.
    96  *
    97  */
    98 static inline void list_prepend(link_t *link, link_t *list)
    99 {
    100         link->next = list->next;
    101         link->prev = list;
    102         list->next->prev = link;
    103         list->next = link;
     129 * @param list Pointer to list_t structure.
     130 *
     131 */
     132static inline void list_prepend(link_t *link, list_t *list)
     133{
     134        list_insert_after(link, &list->head);
    104135}
    105136
     
    109140 *
    110141 * @param link Pointer to link_t structure to be added.
    111  * @param list Pointer to link_t structure representing the list.
    112  *
    113  */
    114 static inline void list_append(link_t *link, link_t *list)
    115 {
    116         link->prev = list->prev;
    117         link->next = list;
    118         list->prev->next = link;
    119         list->prev = link;
    120 }
    121 
    122 /** Insert item before another item in doubly-linked circular list.
    123  *
    124  */
    125 static inline void list_insert_before(link_t *link, link_t *list)
    126 {
    127         list_append(link, list);
    128 }
    129 
    130 /** Insert item after another item in doubly-linked circular list.
    131  *
    132  */
    133 static inline void list_insert_after(link_t *link, link_t *list)
    134 {
    135         list_prepend(list, link);
     142 * @param list Pointer to list_t structure.
     143 *
     144 */
     145static inline void list_append(link_t *link, list_t *list)
     146{
     147        list_insert_before(link, &list->head);
    136148}
    137149
     
    155167 * Query emptiness of doubly-linked circular list.
    156168 *
    157  * @param list Pointer to link_t structure representing the list.
    158  *
    159  */
    160 static inline int list_empty(link_t *list)
    161 {
    162         return (list->next == list);
    163 }
    164 
    165 /** Get head item of a list.
    166  *
    167  * @param list Pointer to link_t structure representing the list.
     169 * @param list Pointer to lins_t structure.
     170 *
     171 */
     172static inline int list_empty(list_t *list)
     173{
     174        return (list->head.next == &list->head);
     175}
     176
     177/** Get first item in list.
     178 *
     179 * @param list Pointer to list_t structure.
    168180 *
    169181 * @return Head item of the list.
     
    171183 *
    172184 */
    173 static inline link_t *list_head(link_t *list)
    174 {
    175         return ((list->next == list) ? NULL : list->next);
     185static inline link_t *list_first(list_t *list)
     186{
     187        return ((list->head.next == &list->head) ? NULL : list->head.next);
     188}
     189
     190/** Get last item in list.
     191 *
     192 * @param list Pointer to list_t structure.
     193 *
     194 * @return Head item of the list.
     195 * @return NULL if the list is empty.
     196 *
     197 */
     198static inline link_t *list_last(list_t *list)
     199{
     200        return ((list->head.prev == &list->head) ? NULL : list->head.prev);
    176201}
    177202
     
    230255}
    231256
    232 /** Get n-th item of a list.
     257/** Get n-th item in a list.
    233258 *
    234259 * @param list Pointer to link_t structure representing the list.
     
    239264 *
    240265 */
    241 static inline link_t *list_nth(link_t *list, unsigned int n)
     266static inline link_t *list_nth(list_t *list, unsigned int n)
    242267{
    243268        unsigned int cnt = 0;
     
    253278}
    254279
    255 extern int list_member(const link_t *, const link_t *);
    256 extern void list_concat(link_t *, link_t *);
    257 extern unsigned int list_count(const link_t *);
     280extern int list_member(const link_t *, const list_t *);
     281extern void list_concat(list_t *, list_t *);
     282extern unsigned int list_count(const list_t *);
    258283
    259284#endif
  • uspace/lib/c/include/adt/measured_strings.h

    r5974661 re4f8c77  
    4141
    4242#include <sys/types.h>
     43#include <async.h>
    4344
    4445/** Type definition of the character string with measured length.
     
    6465extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    6566extern int measured_strings_reply(const measured_string_t *, size_t);
    66 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t);
    67 extern int measured_strings_send(int, const measured_string_t *, size_t);
     67
     68extern int measured_strings_return(async_exch_t *, measured_string_t **,
     69    uint8_t **, size_t);
     70extern int measured_strings_send(async_exch_t *, const measured_string_t *,
     71    size_t);
    6872
    6973#endif
  • uspace/lib/c/include/adt/prodcons.h

    r5974661 re4f8c77  
    4242        fibril_mutex_t mtx;
    4343        fibril_condvar_t cv;
    44         link_t list;
     44        list_t list;
    4545} prodcons_t;
    4646
  • uspace/lib/c/include/async.h

    r5974661 re4f8c77  
    5353typedef void (*async_client_data_dtor_t)(void *);
    5454
    55 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
     55/** Client connection handler
     56 *
     57 * @param callid ID of incoming call or 0 if connection initiated from
     58 *               inside using async_connect_to_me()
     59 * @param call   Incoming call or 0 if connection initiated from inside
     60 * @param arg    Local argument passed from async_new_connection() or
     61 *               async_connect_to_me()
     62 */
     63typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *);
     64
     65/** Interrupt handler */
     66typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *);
    5667
    5768/** Exchange management style
     
    8899typedef struct {
    89100        /** List of inactive exchanges */
    90         link_t exch_list;
     101        list_t exch_list;
    91102       
    92103        /** Exchange management style */
     
    166177
    167178extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
    168     ipc_call_t *, async_client_conn_t);
     179    ipc_call_t *, async_client_conn_t, void *);
    169180
    170181extern void async_usleep(suseconds_t);
     
    177188
    178189extern void async_set_client_connection(async_client_conn_t);
    179 extern void async_set_interrupt_received(async_client_conn_t);
     190extern void async_set_interrupt_received(async_interrupt_handler_t);
    180191
    181192/*
     
    351362
    352363extern int async_connect_to_me(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
    353     async_client_conn_t);
     364    async_client_conn_t, void *);
    354365
    355366extern int async_hangup(async_sess_t *);
  • uspace/lib/c/include/async_obsolete.h

    r5974661 re4f8c77  
    4040#define LIBC_ASYNC_OBSOLETE_H_
    4141
    42 extern void async_obsolete_serialize_start(void);
    43 extern void async_obsolete_serialize_end(void);
    44 
    4542#define async_obsolete_send_0(phoneid, method, dataptr) \
    4643        async_obsolete_send_fast((phoneid), (method), 0, 0, 0, 0, (dataptr))
     
    198195
    199196extern int async_obsolete_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
    200     async_client_conn_t);
     197    async_client_conn_t, void *);
    201198extern int async_obsolete_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
    202199extern int async_obsolete_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
  • uspace/lib/c/include/bitops.h

    r5974661 re4f8c77  
    3838#include <sys/types.h>
    3939
     40/** Mask with bit @a n set. */
     41#define BIT_V(type, n) \
     42    ((type)1 << ((n) - 1))
     43
     44/** Mask with rightmost @a n bits set. */
     45#define BIT_RRANGE(type, n) \
     46    (BIT_V(type, (n) + 1) - 1)
     47
     48/** Mask with bits @a hi .. @a lo set. @a hi >= @a lo. */
     49#define BIT_RANGE(type, hi, lo) \
     50    (BIT_RRANGE(type, (hi) - (lo) + 1) << (lo))
     51
     52/** Extract range of bits @a hi .. @a lo from @a value. */
     53#define BIT_RANGE_EXTRACT(type, hi, lo, value) \
     54    (((value) >> (lo)) & BIT_RRANGE(type, (hi) - (lo) + 1))
    4055
    4156/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
  • uspace/lib/c/include/fibril_synch.h

    r5974661 re4f8c77  
    4545        fibril_owner_info_t oi;  /**< Keep this the first thing. */
    4646        int counter;
    47         link_t waiters;
     47        list_t waiters;
    4848} fibril_mutex_t;
    4949
     
    5555                .counter = 1, \
    5656                .waiters = { \
    57                         .prev = &name.waiters, \
    58                         .next = &name.waiters, \
     57                        .head = { \
     58                                .prev = &(name).waiters.head, \
     59                                .next = &(name).waiters.head, \
     60                        } \
    5961                } \
    6062        }
     
    6769        unsigned writers;
    6870        unsigned readers;
    69         link_t waiters;
     71        list_t waiters;
    7072} fibril_rwlock_t;
    7173
     
    7880                .writers = 0, \
    7981                .waiters = { \
    80                         .prev = &name.waiters, \
    81                         .next = &name.waiters, \
     82                        .head = { \
     83                                .prev = &(name).waiters.head, \
     84                                .next = &(name).waiters.head, \
     85                        } \
    8286                } \
    8387        }
     
    8791
    8892typedef struct {
    89         link_t waiters;
     93        list_t waiters;
    9094} fibril_condvar_t;
    9195
     
    9397        { \
    9498                .waiters = { \
    95                         .next = &name.waiters, \
    96                         .prev = &name.waiters, \
     99                        .head = { \
     100                                .next = &(name).waiters.head, \
     101                                .prev = &(name).waiters.head, \
     102                        } \
    97103                } \
    98104        }
  • uspace/lib/c/include/ipc/clipboard.h

    r5974661 re4f8c77  
    3636#define LIBC_IPC_CLIPBOARD_H_
    3737
     38#include <ipc/common.h>
     39
    3840typedef enum {
    3941        CLIPBOARD_PUT_DATA = IPC_FIRST_USER_METHOD,
  • uspace/lib/c/include/ipc/console.h

    r5974661 re4f8c77  
    4848        CONSOLE_SET_COLOR,
    4949        CONSOLE_SET_RGB_COLOR,
    50         CONSOLE_CURSOR_VISIBILITY,
    51         CONSOLE_KCON_ENABLE
     50        CONSOLE_CURSOR_VISIBILITY
    5251} console_request_t;
    5352
  • uspace/lib/c/include/ipc/devman.h

    r5974661 re4f8c77  
    7272 */
    7373typedef struct match_id_list {
    74         link_t ids;
     74        list_t ids;
    7575} match_id_list_t;
    7676
     
    9595{
    9696        match_id_t *mid = NULL;
    97         link_t *link = ids->ids.next;
     97        link_t *link = ids->ids.head.next;
    9898       
    99         while (link != &ids->ids) {
     99        while (link != &ids->ids.head) {
    100100                mid = list_get_instance(link, match_id_t,link);
    101101                if (mid->score < id->score) {
    102102                        break;
    103                 }       
     103                }
    104104                link = link->next;
    105105        }
     
    118118        match_id_t *id;
    119119       
    120         while(!list_empty(&ids->ids)) {
    121                 link = ids->ids.next;
    122                 list_remove(link);             
     120        while (!list_empty(&ids->ids)) {
     121                link = list_first(&ids->ids);
     122                list_remove(link);
    123123                id = list_get_instance(link, match_id_t, link);
    124                 delete_match_id(id);           
    125         }       
     124                delete_match_id(id);
     125        }
    126126}
    127127
  • uspace/lib/c/include/ipc/mouseev.h

    r5974661 re4f8c77  
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
    30  * @brief HelenOS generic uspace keyboard handler.
    31  * @ingroup kbd
     29/** @addtogroup mouse
     30 * @brief
    3231 * @{
    3332 */
     
    3534 */
    3635
    37 #ifndef LIBC_IPC_KBD_H_
    38 #define LIBC_IPC_KBD_H_
     36#ifndef LIBC_IPC_MOUSEEV_H_
     37#define LIBC_IPC_MOUSEEV_H_
    3938
    4039#include <ipc/common.h>
     
    4241
    4342typedef enum {
    44         KBD_YIELD = DEV_FIRST_CUSTOM_METHOD,
    45         KBD_RECLAIM
    46 } kbd_request_t;
     43        MOUSEEV_YIELD = DEV_FIRST_CUSTOM_METHOD,
     44        MOUSEEV_RECLAIM
     45} mouseev_request_t;
    4746
    4847typedef enum {
    49         KBD_EVENT = IPC_FIRST_USER_METHOD
    50 } kbd_notif_t;
     48        MOUSEEV_MOVE_EVENT = IPC_FIRST_USER_METHOD,
     49        MOUSEEV_BUTTON_EVENT
     50} mouseev_notif_t;
    5151
    5252#endif
  • uspace/lib/c/include/ipc/net.h

    r5974661 re4f8c77  
    335335#define IPC_GET_ERROR(call)  ((services_t) IPC_GET_ARG4(call))
    336336
    337 /** Return the phone message argument.
    338  *
    339  * @param[in] call Message call structure.
    340  *
    341  */
    342 #define IPC_GET_PHONE(call)  ((int) IPC_GET_ARG5(call))
    343 
    344337/** Set the device identifier in the message answer.
    345338 *
  • uspace/lib/c/include/ipc/services.h

    r5974661 re4f8c77  
    3838#define LIBC_SERVICES_H_
    3939
     40#include <fourcc.h>
     41
    4042typedef enum {
    41         SERVICE_NONE = 0,
    42         SERVICE_LOAD,
    43         SERVICE_PCI,
    44         SERVICE_VIDEO,
    45         SERVICE_CONSOLE,
    46         SERVICE_VFS,
    47         SERVICE_DEVMAP,
    48         SERVICE_DEVMAN,
    49         SERVICE_IRC,
    50         SERVICE_CLIPBOARD,
    51         SERVICE_NETWORKING,
    52         SERVICE_LO,
    53         SERVICE_NE2000,
    54         SERVICE_ETHERNET,
    55         SERVICE_NILDUMMY,
    56         SERVICE_IP,
    57         SERVICE_ARP,
    58         SERVICE_RARP,
    59         SERVICE_ICMP,
    60         SERVICE_UDP,
    61         SERVICE_TCP,
    62         SERVICE_SOCKET
     43        SERVICE_NONE       = 0,
     44        SERVICE_LOAD       = FOURCC('l', 'o', 'a', 'd'),
     45        SERVICE_VIDEO      = FOURCC('v', 'i', 'd', ' '),
     46        SERVICE_VFS        = FOURCC('v', 'f', 's', ' '),
     47        SERVICE_DEVMAP     = FOURCC('d', 'e', 'v', 'p'),
     48        SERVICE_DEVMAN     = FOURCC('d', 'e', 'v', 'n'),
     49        SERVICE_IRC        = FOURCC('i', 'r', 'c', ' '),
     50        SERVICE_CLIPBOARD  = FOURCC('c', 'l', 'i', 'p'),
     51        SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '),
     52        SERVICE_LO         = FOURCC('l', 'o', ' ', ' '),
     53        SERVICE_NE2000     = FOURCC('n', 'e', '2', 'k'),
     54        SERVICE_ETHERNET   = FOURCC('e', 't', 'h', ' '),
     55        SERVICE_NILDUMMY   = FOURCC('n', 'i', 'l', 'd'),
     56        SERVICE_IP         = FOURCC('i', 'p', 'v', '4'),
     57        SERVICE_ARP        = FOURCC('a', 'r', 'p', ' '),
     58        SERVICE_ICMP       = FOURCC('i', 'c', 'm', 'p'),
     59        SERVICE_UDP        = FOURCC('u', 'd', 'p', ' '),
     60        SERVICE_TCP        = FOURCC('t', 'c', 'p', ' ')
    6361} services_t;
    6462
  • uspace/lib/c/include/net/icmp_api.h

    r5974661 re4f8c77  
    4242#include <sys/types.h>
    4343#include <sys/time.h>
    44 
    4544#include <adt/measured_strings.h>
    4645#include <net/ip_codes.h>
    4746#include <net/icmp_codes.h>
    4847#include <net/icmp_common.h>
     48#include <async.h>
    4949
    5050/** @name ICMP module application interface
     
    5353/*@{*/
    5454
    55 extern int icmp_echo_msg(int, size_t, mseconds_t, ip_ttl_t, ip_tos_t, int,
    56     const struct sockaddr *, socklen_t);
     55extern int icmp_echo_msg(async_sess_t *, size_t, mseconds_t, ip_ttl_t, ip_tos_t,
     56    int, const struct sockaddr *, socklen_t);
    5757
    5858/*@}*/
  • uspace/lib/c/include/net/icmp_common.h

    r5974661 re4f8c77  
    4040#include <ipc/services.h>
    4141#include <sys/time.h>
     42#include <async.h>
    4243
    43 /** Default timeout for incoming connections in microseconds (1 sec). */
    44 #define ICMP_CONNECT_TIMEOUT  1000000
    45 
    46 extern int icmp_connect_module(suseconds_t);
     44extern async_sess_t *icmp_connect_module(void);
    4745
    4846#endif
  • uspace/lib/c/include/net/modules.h

    r5974661 re4f8c77  
    4646#include <sys/time.h>
    4747
    48 /** Connect to the needed module function type definition.
     48/** Connect to module function type definition.
    4949 *
    50  * @param[in] need The needed module service.
    51  *
    52  * @return The phone of the needed service.
     50 * @return Session to the service.
    5351 *
    5452 */
    55 typedef int connect_module_t(services_t need);
     53typedef async_sess_t *connect_module_t(services_t);
    5654
    5755extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t);
    58 extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
     56extern async_sess_t *bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
    5957    async_client_conn_t);
    60 extern int bind_service_timeout(services_t, sysarg_t, sysarg_t, sysarg_t,
    61     async_client_conn_t, suseconds_t);
    62 extern int connect_to_service(services_t);
    63 extern int connect_to_service_timeout(services_t, suseconds_t);
     58extern async_sess_t *connect_to_service(services_t);
    6459extern int data_reply(void *, size_t);
    6560extern void refresh_answer(ipc_call_t *, size_t *);
  • uspace/lib/c/include/str.h

    r5974661 re4f8c77  
    4848#define STR_BOUNDS(length)  ((length) << 2)
    4949
     50/**
     51 * Maximum size of a buffer needed to a string converted from space-padded
     52 * ASCII of size @a spa_size using spascii_to_str().
     53 */
     54#define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1)
     55
    5056extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
    5157extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
     
    7379extern void str_append(char *dest, size_t size, const char *src);
    7480
     81extern int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n);
    7582extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
    7683extern char *wstr_to_astr(const wchar_t *src);
  • uspace/lib/c/include/task.h

    r5974661 re4f8c77  
    3737
    3838#include <sys/types.h>
     39#include <vfs/vfs.h>
    3940
    4041typedef uint64_t task_id_t;
     
    5152extern task_id_t task_spawn(const char *, const char *const[], int *);
    5253extern int task_spawnv(task_id_t *, const char *path, const char *const []);
     54extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
     55    fdi_node_t *const []);
    5356extern int task_spawnl(task_id_t *, const char *path, ...);
    5457
Note: See TracChangeset for help on using the changeset viewer.