Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r47b7006 r64d2b10  
    4242 * You should be able to write very simple multithreaded programs, the async
    4343 * framework will automatically take care of most synchronization problems.
     44 *
     45 * Default semantics:
     46 * - async_send_*(): Send asynchronously. If the kernel refuses to send
     47 *                   more messages, [ try to get responses from kernel, if
     48 *                   nothing found, might try synchronous ]
    4449 *
    4550 * Example of use (pseudo C):
     
    122127
    123128/**
    124  * Structures of this type are used to group information about
    125  * a call and about a message queue link.
     129 * Structures of this type are used to group information about a call and a
     130 * message queue link.
    126131 */
    127132typedef struct {
     
    151156        /** Link to the client tracking structure. */
    152157        client_t *client;
    153        
     158
    154159        /** Messages that should be delivered to this fibril. */
    155160        link_t msg_queue;
     
    168173
    169174/** Identifier of the incoming connection handled by the current fibril. */
    170 static fibril_local connection_t *FIBRIL_connection;
     175fibril_local connection_t *FIBRIL_connection;
    171176
    172177static void *default_client_data_constructor(void)
     
    197202{
    198203        assert(FIBRIL_connection);
     204
    199205        return FIBRIL_connection->client->data;
    200206}
    201207
    202 /** Default fibril function that gets called to handle new connection.
    203  *
    204  * This function is defined as a weak symbol - to be redefined in user code.
    205  *
    206  * @param callid Hash of the incoming call.
    207  * @param call   Data of the incoming call.
    208  *
    209  */
    210 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
    211 {
    212         ipc_answer_0(callid, ENOENT);
    213 }
     208static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
     209static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call);
    214210
    215211/**
     
    217213 */
    218214static async_client_conn_t client_connection = default_client_connection;
    219 
    220 /** Default fibril function that gets called to handle interrupt notifications.
    221  *
    222  * This function is defined as a weak symbol - to be redefined in user code.
    223  *
    224  * @param callid Hash of the incoming call.
    225  * @param call   Data of the incoming call.
    226  *
    227  */
    228 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
    229 {
    230 }
    231215
    232216/**
     
    240224static LIST_INITIALIZE(timeout_list);
    241225
    242 #define CLIENT_HASH_TABLE_BUCKETS  32
    243 #define CONN_HASH_TABLE_BUCKETS    32
    244 
    245 static hash_index_t client_hash(unsigned long key[])
     226#define CLIENT_HASH_TABLE_BUCKETS       32
     227#define CONN_HASH_TABLE_BUCKETS         32
     228
     229static hash_index_t client_hash(unsigned long *key)
    246230{
    247231        assert(key);
    248         return (((key[0]) >> 4) % CLIENT_HASH_TABLE_BUCKETS);
     232        return (((*key) >> 4) % CLIENT_HASH_TABLE_BUCKETS);
    249233}
    250234
    251235static int client_compare(unsigned long key[], hash_count_t keys, link_t *item)
    252236{
    253         client_t *client = hash_table_get_instance(item, client_t, link);
    254         return (key[0] == client->in_task_hash);
     237        client_t *cl = hash_table_get_instance(item, client_t, link);
     238        return (key[0] == cl->in_task_hash);
    255239}
    256240
     
    273257 *
    274258 */
    275 static hash_index_t conn_hash(unsigned long key[])
     259static hash_index_t conn_hash(unsigned long *key)
    276260{
    277261        assert(key);
    278         return (((key[0]) >> 4) % CONN_HASH_TABLE_BUCKETS);
     262        return (((*key) >> 4) % CONN_HASH_TABLE_BUCKETS);
    279263}
    280264
     
    290274static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item)
    291275{
    292         connection_t *conn = hash_table_get_instance(item, connection_t, link);
    293         return (key[0] == conn->in_phone_hash);
     276        connection_t *hs = hash_table_get_instance(item, connection_t, link);
     277        return (key[0] == hs->in_phone_hash);
    294278}
    295279
     
    306290        free(hash_table_get_instance(item, connection_t, link));
    307291}
     292
    308293
    309294/** Operations for the connection hash table. */
     
    326311        link_t *tmp = timeout_list.next;
    327312        while (tmp != &timeout_list) {
    328                 awaiter_t *cur
    329                     = list_get_instance(tmp, awaiter_t, to_event.link);
     313                awaiter_t *cur;
    330314               
     315                cur = list_get_instance(tmp, awaiter_t, to_event.link);
    331316                if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires))
    332317                        break;
    333                
    334318                tmp = tmp->next;
    335319        }
     
    348332 *
    349333 * @return False if the call doesn't match any connection.
    350  * @return True if the call was passed to the respective connection fibril.
     334 *         True if the call was passed to the respective connection fibril.
    351335 *
    352336 */
     
    485469                         * the first IPC_M_PHONE_HUNGUP call and continues to
    486470                         * call async_get_call_timeout(). Repeat
    487                          * IPC_M_PHONE_HUNGUP until the caller notices.
     471                         * IPC_M_PHONE_HUNGUP until the caller notices. 
    488472                         */
    489473                        memset(call, 0, sizeof(ipc_call_t));
     
    492476                        return conn->close_callid;
    493477                }
    494                
     478
    495479                if (usecs)
    496480                        async_insert_timeout(&conn->wdata);
     
    530514}
    531515
     516/** Default fibril function that gets called to handle new connection.
     517 *
     518 * This function is defined as a weak symbol - to be redefined in user code.
     519 *
     520 * @param callid Hash of the incoming call.
     521 * @param call   Data of the incoming call.
     522 *
     523 */
     524static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
     525{
     526        ipc_answer_0(callid, ENOENT);
     527}
     528
     529/** Default fibril function that gets called to handle interrupt notifications.
     530 *
     531 * This function is defined as a weak symbol - to be redefined in user code.
     532 *
     533 * @param callid Hash of the incoming call.
     534 * @param call   Data of the incoming call.
     535 *
     536 */
     537static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
     538{
     539}
     540
    532541/** Wrapper for client connection fibril.
    533542 *
     
    542551static int connection_fibril(void *arg)
    543552{
     553        unsigned long key;
     554        client_t *cl;
     555        link_t *lnk;
     556        bool destroy = false;
     557
    544558        /*
    545559         * Setup fibril-local connection pointer.
    546560         */
    547561        FIBRIL_connection = (connection_t *) arg;
    548        
    549         futex_down(&async_futex);
    550        
     562
    551563        /*
    552564         * Add our reference for the current connection in the client task
     
    554566         * hash in a new tracking structure.
    555567         */
    556        
    557         unsigned long key = FIBRIL_connection->in_task_hash;
    558         link_t *lnk = hash_table_find(&client_hash_table, &key);
    559        
    560         client_t *client;
    561        
     568        futex_down(&async_futex);
     569        key = FIBRIL_connection->in_task_hash;
     570        lnk = hash_table_find(&client_hash_table, &key);
    562571        if (lnk) {
    563                 client = hash_table_get_instance(lnk, client_t, link);
    564                 client->refcnt++;
     572                cl = hash_table_get_instance(lnk, client_t, link);
     573                cl->refcnt++;
    565574        } else {
    566                 client = malloc(sizeof(client_t));
    567                 if (!client) {
     575                cl = malloc(sizeof(client_t));
     576                if (!cl) {
    568577                        ipc_answer_0(FIBRIL_connection->callid, ENOMEM);
    569578                        futex_up(&async_futex);
    570579                        return 0;
    571580                }
    572                
    573                 client->in_task_hash = FIBRIL_connection->in_task_hash;
    574                
     581                cl->in_task_hash = FIBRIL_connection->in_task_hash;
    575582                async_serialize_start();
    576                 client->data = async_client_data_create();
     583                cl->data = async_client_data_create();
    577584                async_serialize_end();
    578                
    579                 client->refcnt = 1;
    580                 hash_table_insert(&client_hash_table, &key, &client->link);
    581         }
    582        
     585                cl->refcnt = 1;
     586                hash_table_insert(&client_hash_table, &key, &cl->link);
     587        }
    583588        futex_up(&async_futex);
    584        
    585         FIBRIL_connection->client = client;
    586        
     589
     590        FIBRIL_connection->client = cl;
     591
    587592        /*
    588593         * Call the connection handler function.
     
    594599         * Remove the reference for this client task connection.
    595600         */
    596         bool destroy;
    597        
    598601        futex_down(&async_futex);
    599        
    600         if (--client->refcnt == 0) {
     602        if (--cl->refcnt == 0) {
    601603                hash_table_remove(&client_hash_table, &key, 1);
    602604                destroy = true;
    603         } else
    604                 destroy = false;
    605        
     605        }
    606606        futex_up(&async_futex);
    607        
     607
    608608        if (destroy) {
    609                 if (client->data)
    610                         async_client_data_destroy(client->data);
    611                
    612                 free(client);
    613         }
    614        
     609                if (cl->data)
     610                        async_client_data_destroy(cl->data);
     611                free(cl);
     612        }
     613
    615614        /*
    616615         * Remove myself from the connection hash table.
     
    625624         */
    626625        while (!list_empty(&FIBRIL_connection->msg_queue)) {
    627                 msg_t *msg =
    628                     list_get_instance(FIBRIL_connection->msg_queue.next, msg_t,
    629                     link);
     626                msg_t *msg;
    630627               
     628                msg = list_get_instance(FIBRIL_connection->msg_queue.next,
     629                    msg_t, link);
    631630                list_remove(&msg->link);
    632631                ipc_answer_0(msg->callid, EHANGUP);
     
    671670                if (callid)
    672671                        ipc_answer_0(callid, ENOMEM);
    673                
    674672                return (uintptr_t) NULL;
    675673        }
     
    719717static void handle_call(ipc_callid_t callid, ipc_call_t *call)
    720718{
    721         /* Unrouted call - take some default action */
     719        /* Unrouted call - do some default behaviour */
    722720        if ((callid & IPC_CALLID_NOTIFICATION)) {
    723721                process_notification(callid, call);
    724                 return;
     722                goto out;
    725723        }
    726724       
     
    728726        case IPC_M_CONNECT_ME:
    729727        case IPC_M_CONNECT_ME_TO:
    730                 /* Open new connection with fibril, etc. */
     728                /* Open new connection with fibril etc. */
    731729                async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
    732730                    callid, call, client_connection);
    733                 return;
     731                goto out;
    734732        }
    735733       
    736734        /* Try to route the call through the connection hash table */
    737735        if (route_call(callid, call))
    738                 return;
     736                goto out;
    739737       
    740738        /* Unknown call from unknown phone - hang it up */
    741739        ipc_answer_0(callid, EHANGUP);
     740        return;
     741       
     742out:
     743        ;
    742744}
    743745
     
    752754        link_t *cur = timeout_list.next;
    753755        while (cur != &timeout_list) {
    754                 awaiter_t *waiter =
    755                     list_get_instance(cur, awaiter_t, to_event.link);
     756                awaiter_t *waiter;
    756757               
     758                waiter = list_get_instance(cur, awaiter_t, to_event.link);
    757759                if (tv_gt(&waiter->to_event.expires, &tv))
    758760                        break;
    759                
     761
    760762                cur = cur->next;
    761                
     763
    762764                list_remove(&waiter->to_event.link);
    763765                waiter->to_event.inlist = false;
     
    786788        while (true) {
    787789                if (fibril_switch(FIBRIL_FROM_MANAGER)) {
    788                         futex_up(&async_futex);
     790                        futex_up(&async_futex); 
    789791                        /*
    790792                         * async_futex is always held when entering a manager
     
    809811                                continue;
    810812                        } else
    811                                 timeout = tv_sub(&waiter->to_event.expires, &tv);
     813                                timeout = tv_sub(&waiter->to_event.expires,
     814                                    &tv);
    812815                } else
    813816                        timeout = SYNCH_NO_TIMEOUT;
    814817               
    815818                futex_up(&async_futex);
    816                
     819
    817820                atomic_inc(&threads_in_ipc_wait);
    818821               
     
    822825               
    823826                atomic_dec(&threads_in_ipc_wait);
    824                
     827
    825828                if (!callid) {
    826829                        handle_expired_timeouts();
     
    872875/** Initialize the async framework.
    873876 *
    874  */
    875 void __async_init(void)
     877 * @return Zero on success or an error code.
     878 */
     879int __async_init(void)
    876880{
    877881        if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 1,
    878             &client_hash_table_ops))
    879                 abort();
    880        
    881         if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_BUCKETS, 1,
    882             &conn_hash_table_ops))
    883                 abort();
     882            &client_hash_table_ops) || !hash_table_create(&conn_hash_table,
     883            CONN_HASH_TABLE_BUCKETS, 1, &conn_hash_table_ops)) {
     884                return ENOMEM;
     885        }
     886
     887        _async_sess_init();
     888       
     889        return 0;
    884890}
    885891
     
    894900 * @param retval Value returned in the answer.
    895901 * @param data   Call data of the answer.
    896  *
    897902 */
    898903static void reply_received(void *arg, int retval, ipc_call_t *data)
     
    942947    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
    943948{
    944         amsg_t *msg = malloc(sizeof(amsg_t));
     949        amsg_t *msg = malloc(sizeof(*msg));
    945950       
    946951        if (!msg)
     
    951956       
    952957        msg->wdata.to_event.inlist = false;
    953        
    954         /*
    955          * We may sleep in the next method,
    956          * but it will use its own means
    957          */
     958        /* We may sleep in the next method, but it will use its own mechanism */
    958959        msg->wdata.active = true;
    959960       
     
    986987    ipc_call_t *dataptr)
    987988{
    988         amsg_t *msg = malloc(sizeof(amsg_t));
     989        amsg_t *msg = malloc(sizeof(*msg));
    989990       
    990991        if (!msg)
     
    995996       
    996997        msg->wdata.to_event.inlist = false;
    997        
    998         /*
    999          * We may sleep in the next method,
    1000          * but it will use its own means
    1001          */
     998        /* We may sleep in next method, but it will use its own mechanism */
    1002999        msg->wdata.active = true;
    10031000       
     
    10981095void async_usleep(suseconds_t timeout)
    10991096{
    1100         amsg_t *msg = malloc(sizeof(amsg_t));
     1097        amsg_t *msg = malloc(sizeof(*msg));
    11011098       
    11021099        if (!msg)
     
    13101307}
    13111308
    1312 int async_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod,
    1313     sysarg_t arg1, sysarg_t arg2, unsigned int mode)
     1309int async_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
     1310    sysarg_t arg1, sysarg_t arg2, int mode)
    13141311{
    13151312        return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode);
    13161313}
    13171314
    1318 int async_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod,
     1315int async_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
    13191316    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
    1320     unsigned int mode)
     1317    int mode)
    13211318{
    13221319        return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4,
     
    14311428}
    14321429
    1433 /** Wrapper for IPC_M_SHARE_IN calls using the async framework.
    1434  *
    1435  * @param phoneid Phone that will be used to contact the receiving side.
    1436  * @param dst     Destination address space area base.
    1437  * @param size    Size of the destination address space area.
    1438  * @param arg     User defined argument.
    1439  * @param flags   Storage for the received flags. Can be NULL.
    1440  *
    1441  * @return Zero on success or a negative error code from errno.h.
    1442  *
     1430/** Wrapper for making IPC_M_SHARE_IN calls using the async framework.
     1431 *
     1432 * @param phoneid       Phone that will be used to contact the receiving side.
     1433 * @param dst           Destination address space area base.
     1434 * @param size          Size of the destination address space area.
     1435 * @param arg           User defined argument.
     1436 * @param flags         Storage where the received flags will be stored. Can be
     1437 *                      NULL.
     1438 *
     1439 * @return              Zero on success or a negative error code from errno.h.
    14431440 */
    14441441int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
    1445     unsigned int *flags)
    1446 {
     1442    int *flags)
     1443{
     1444        int res;
    14471445        sysarg_t tmp_flags;
    1448         int res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
     1446        res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
    14491447            (sysarg_t) size, arg, NULL, &tmp_flags);
    1450        
    14511448        if (flags)
    1452                 *flags = (unsigned int) tmp_flags;
    1453        
     1449                *flags = tmp_flags;
    14541450        return res;
    14551451}
     
    14571453/** Wrapper for receiving the IPC_M_SHARE_IN calls using the async framework.
    14581454 *
    1459  * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN
    1460  * calls so that the user doesn't have to remember the meaning of each IPC
    1461  * argument.
     1455 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN calls
     1456 * so that the user doesn't have to remember the meaning of each IPC argument.
    14621457 *
    14631458 * So far, this wrapper is to be used from within a connection fibril.
    14641459 *
    1465  * @param callid Storage for the hash of the IPC_M_SHARE_IN call.
    1466  * @param size   Destination address space area size.
    1467  *
    1468  * @return True on success, false on failure.
    1469  *
    1470  */
    1471 bool async_share_in_receive(ipc_callid_t *callid, size_t *size)
    1472 {
     1460 * @param callid        Storage where the hash of the IPC_M_SHARE_IN call will
     1461 *                      be stored.
     1462 * @param size          Destination address space area size.   
     1463 *
     1464 * @return              Non-zero on success, zero on failure.
     1465 */
     1466int async_share_in_receive(ipc_callid_t *callid, size_t *size)
     1467{
     1468        ipc_call_t data;
     1469       
    14731470        assert(callid);
    14741471        assert(size);
    1475        
    1476         ipc_call_t data;
     1472
    14771473        *callid = async_get_call(&data);
    1478        
    14791474        if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
    1480                 return false;
    1481        
     1475                return 0;
    14821476        *size = (size_t) IPC_GET_ARG2(data);
    1483         return true;
     1477        return 1;
    14841478}
    14851479
    14861480/** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework.
    14871481 *
    1488  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
    1489  * calls so that the user doesn't have to remember the meaning of each IPC
    1490  * argument.
    1491  *
    1492  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    1493  * @param src    Source address space base.
    1494  * @param flags  Flags to be used for sharing. Bits can be only cleared.
    1495  *
    1496  * @return Zero on success or a value from @ref errno.h on failure.
    1497  *
    1498  */
    1499 int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
     1482 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
     1483 * so that the user doesn't have to remember the meaning of each IPC argument.
     1484 *
     1485 * @param callid        Hash of the IPC_M_DATA_READ call to answer.
     1486 * @param src           Source address space base.
     1487 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     1488 *
     1489 * @return              Zero on success or a value from @ref errno.h on failure.
     1490 */
     1491int async_share_in_finalize(ipc_callid_t callid, void *src, int flags)
    15001492{
    15011493        return ipc_share_in_finalize(callid, src, flags);
    15021494}
    15031495
    1504 /** Wrapper for IPC_M_SHARE_OUT calls using the async framework.
    1505  *
    1506  * @param phoneid Phone that will be used to contact the receiving side.
    1507  * @param src     Source address space area base address.
    1508  * @param flags   Flags to be used for sharing. Bits can be only cleared.
    1509  *
    1510  * @return Zero on success or a negative error code from errno.h.
    1511  *
    1512  */
    1513 int async_share_out_start(int phoneid, void *src, unsigned int flags)
     1496/** Wrapper for making IPC_M_SHARE_OUT calls using the async framework.
     1497 *
     1498 * @param phoneid       Phone that will be used to contact the receiving side.
     1499 * @param src           Source address space area base address.
     1500 * @param flags         Flags to be used for sharing. Bits can be only cleared.
     1501 *
     1502 * @return              Zero on success or a negative error code from errno.h.
     1503 */
     1504int async_share_out_start(int phoneid, void *src, int flags)
    15141505{
    15151506        return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
     
    15191510/** Wrapper for receiving the IPC_M_SHARE_OUT calls using the async framework.
    15201511 *
    1521  * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT
    1522  * calls so that the user doesn't have to remember the meaning of each IPC
    1523  * argument.
     1512 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT calls
     1513 * so that the user doesn't have to remember the meaning of each IPC argument.
    15241514 *
    15251515 * So far, this wrapper is to be used from within a connection fibril.
    15261516 *
    1527  * @param callid Storage for the hash of the IPC_M_SHARE_OUT call.
    1528  * @param size   Storage for the source address space area size.
    1529  * @param flags  Storage for the sharing flags.
    1530  *
    1531  * @return True on success, false on failure.
    1532  *
    1533  */
    1534 bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags)
    1535 {
     1517 * @param callid        Storage where the hash of the IPC_M_SHARE_OUT call will
     1518 *                      be stored.
     1519 * @param size          Storage where the source address space area size will be
     1520 *                      stored.
     1521 * @param flags         Storage where the sharing flags will be stored.
     1522 *
     1523 * @return              Non-zero on success, zero on failure.
     1524 */
     1525int async_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags)
     1526{
     1527        ipc_call_t data;
     1528       
    15361529        assert(callid);
    15371530        assert(size);
    15381531        assert(flags);
    1539        
    1540         ipc_call_t data;
     1532
    15411533        *callid = async_get_call(&data);
    1542        
    15431534        if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
    1544                 return false;
    1545        
     1535                return 0;
    15461536        *size = (size_t) IPC_GET_ARG2(data);
    1547         *flags = (unsigned int) IPC_GET_ARG3(data);
    1548         return true;
     1537        *flags = (int) IPC_GET_ARG3(data);
     1538        return 1;
    15491539}
    15501540
    15511541/** Wrapper for answering the IPC_M_SHARE_OUT calls using the async framework.
    15521542 *
    1553  * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT
    1554  * calls so that the user doesn't have to remember the meaning of each IPC
    1555  * argument.
    1556  *
    1557  * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    1558  * @param dst    Destination address space area base address.
    1559  *
    1560  * @return Zero on success or a value from @ref errno.h on failure.
    1561  *
     1543 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls
     1544 * so that the user doesn't have to remember the meaning of each IPC argument.
     1545 *
     1546 * @param callid        Hash of the IPC_M_DATA_WRITE call to answer.
     1547 * @param dst           Destination address space area base address.   
     1548 *
     1549 * @return              Zero on success or a value from @ref errno.h on failure.
    15621550 */
    15631551int async_share_out_finalize(ipc_callid_t callid, void *dst)
     
    15661554}
    15671555
    1568 /** Wrapper for IPC_M_DATA_READ calls using the async framework.
    1569  *
    1570  * @param phoneid Phone that will be used to contact the receiving side.
    1571  * @param dst     Address of the beginning of the destination buffer.
    1572  * @param size    Size of the destination buffer.
    1573  *
    1574  * @return Zero on success or a negative error code from errno.h.
    1575  *
     1556
     1557/** Wrapper for making IPC_M_DATA_READ calls using the async framework.
     1558 *
     1559 * @param phoneid       Phone that will be used to contact the receiving side.
     1560 * @param dst           Address of the beginning of the destination buffer.
     1561 * @param size          Size of the destination buffer.
     1562 *
     1563 * @return              Zero on success or a negative error code from errno.h.
    15761564 */
    15771565int async_data_read_start(int phoneid, void *dst, size_t size)
     
    15831571/** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework.
    15841572 *
    1585  * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ
    1586  * calls so that the user doesn't have to remember the meaning of each IPC
    1587  * argument.
     1573 * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ calls
     1574 * so that the user doesn't have to remember the meaning of each IPC argument.
    15881575 *
    15891576 * So far, this wrapper is to be used from within a connection fibril.
    15901577 *
    1591  * @param callid Storage for the hash of the IPC_M_DATA_READ.
    1592  * @param size   Storage for the maximum size. Can be NULL.
    1593  *
    1594  * @return True on success, false on failure.
    1595  *
    1596  */
    1597 bool async_data_read_receive(ipc_callid_t *callid, size_t *size)
    1598 {
     1578 * @param callid        Storage where the hash of the IPC_M_DATA_READ call will
     1579 *                      be stored.
     1580 * @param size          Storage where the maximum size will be stored. Can be
     1581 *                      NULL.
     1582 *
     1583 * @return              Non-zero on success, zero on failure.
     1584 */
     1585int async_data_read_receive(ipc_callid_t *callid, size_t *size)
     1586{
     1587        ipc_call_t data;
     1588       
    15991589        assert(callid);
    1600        
    1601         ipc_call_t data;
     1590
    16021591        *callid = async_get_call(&data);
    1603        
    16041592        if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ)
    1605                 return false;
    1606        
     1593                return 0;
    16071594        if (size)
    16081595                *size = (size_t) IPC_GET_ARG2(data);
    1609        
    1610         return true;
     1596        return 1;
    16111597}
    16121598
    16131599/** Wrapper for answering the IPC_M_DATA_READ calls using the async framework.
    16141600 *
    1615  * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ
    1616  * calls so that the user doesn't have to remember the meaning of each IPC
    1617  * argument.
    1618  *
    1619  * @param callid Hash of the IPC_M_DATA_READ call to answer.
    1620  * @param src    Source address for the IPC_M_DATA_READ call.
    1621  * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
    1622  *               the maximum size announced by the sender.
    1623  *
    1624  * @return Zero on success or a value from @ref errno.h on failure.
    1625  *
     1601 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls
     1602 * so that the user doesn't have to remember the meaning of each IPC argument.
     1603 *
     1604 * @param callid        Hash of the IPC_M_DATA_READ call to answer.
     1605 * @param src           Source address for the IPC_M_DATA_READ call.
     1606 * @param size          Size for the IPC_M_DATA_READ call. Can be smaller than
     1607 *                      the maximum size announced by the sender.
     1608 *
     1609 * @return              Zero on success or a value from @ref errno.h on failure.
    16261610 */
    16271611int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
     
    16631647}
    16641648
    1665 /** Wrapper for IPC_M_DATA_WRITE calls using the async framework.
     1649/** Wrapper for making IPC_M_DATA_WRITE calls using the async framework.
    16661650 *
    16671651 * @param phoneid Phone that will be used to contact the receiving side.
     
    16801664/** Wrapper for receiving the IPC_M_DATA_WRITE calls using the async framework.
    16811665 *
    1682  * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE
    1683  * calls so that the user doesn't have to remember the meaning of each IPC
    1684  * argument.
     1666 * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE calls
     1667 * so that the user doesn't have to remember the meaning of each IPC argument.
    16851668 *
    16861669 * So far, this wrapper is to be used from within a connection fibril.
    16871670 *
    1688  * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
    1689  * @param size   Storage for the suggested size. May be NULL.
    1690  *
    1691  * @return True on success, false on failure.
    1692  *
    1693  */
    1694 bool async_data_write_receive(ipc_callid_t *callid, size_t *size)
    1695 {
     1671 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will
     1672 *               be stored.
     1673 * @param size   Storage where the suggested size will be stored. May be
     1674 *               NULL
     1675 *
     1676 * @return Non-zero on success, zero on failure.
     1677 *
     1678 */
     1679int async_data_write_receive(ipc_callid_t *callid, size_t *size)
     1680{
     1681        ipc_call_t data;
     1682       
    16961683        assert(callid);
    16971684       
    1698         ipc_call_t data;
    16991685        *callid = async_get_call(&data);
    1700        
    17011686        if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE)
    1702                 return false;
     1687                return 0;
    17031688       
    17041689        if (size)
    17051690                *size = (size_t) IPC_GET_ARG2(data);
    17061691       
    1707         return true;
     1692        return 1;
    17081693}
    17091694
    17101695/** Wrapper for answering the IPC_M_DATA_WRITE calls using the async framework.
    17111696 *
    1712  * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE
    1713  * calls so that the user doesn't have to remember the meaning of each IPC
    1714  * argument.
     1697 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls
     1698 * so that the user doesn't have to remember the meaning of each IPC argument.
    17151699 *
    17161700 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
     
    18081792 *
    18091793 */
    1810 void async_data_write_void(sysarg_t retval)
     1794void async_data_write_void(const int retval)
    18111795{
    18121796        ipc_callid_t callid;
Note: See TracChangeset for help on using the changeset viewer.