Changeset 183b4a0 in mainline


Ignore:
Timestamp:
2007-09-15T07:01:47Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d79dcdb
Parents:
b3f598e
Message:

Add wrappers facilitating easy use of IPC_M_DATA_SEND calls and answers.

Location:
uspace/lib/libc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/ipc.c

    rb3f598e r183b4a0  
    5151#include <async.h>
    5252#include <fibril.h>
     53#include <assert.h>
    5354
    5455/**
     
    595596}
    596597
     598/** Wrapper for accepting the IPC_M_DATA_SEND calls.
     599 *
     600 * This wrapper only makes it more comfortable to accept IPC_M_DATA_SEND calls
     601 * so that the user doesn't have to remember the meaning of each IPC argument.
     602 *
     603 * So far, this wrapper is to be used from within a connection fibril.
     604 *
     605 * @param callid        Storage where the hash of the IPC_M_DATA_SEND call will
     606 *                      be stored.
     607 * @param call          Storage where the incoming call will be stored.
     608 * @param dst           Storage where the suggested destination address will
     609 *                      be stored. May be NULL.
     610 * @param size          Storage where the suggested size will be stored. May be
     611 *                      NULL
     612 *
     613 * @return              Non-zero on success, zero on failure.
     614 */
     615int ipc_data_send_accept(ipc_callid_t *callid, ipc_call_t *call, void **dst,
     616    size_t *size)
     617{
     618        assert(callid);
     619        assert(call);
     620
     621        *callid = async_get_call(call);
     622        if (IPC_GET_METHOD(*call) != IPC_M_DATA_SEND)
     623                return 0;
     624        if (dst)
     625                *dst = (void *) IPC_GET_ARG1(*call);
     626        if (size)
     627                *size = (size_t) IPC_GET_ARG3(*call);
     628        return 1;
     629}
     630
     631/** Wrapper for answering the IPC_M_DATA_SEND calls.
     632 *
     633 * This wrapper only makes it more comfortable to answer IPC_M_DATA_SEND calls
     634 * so that the user doesn't have to remember the meaning of each IPC argument.
     635 *
     636 * @param callid        Hash of the IPC_M_DATA_SEND call to answer.
     637 * @param call          Call structure with the request.
     638 * @param dst           Final destination address for the IPC_M_DATA_SEND call.
     639 * @param size          Final size for the IPC_M_DATA_SEND call.
     640 *
     641 * @return              Zero on success or a value from @ref errno.h on failure.
     642 */
     643ipcarg_t ipc_data_send_answer(ipc_callid_t callid, ipc_call_t *call, void *dst,     size_t size)
     644{
     645        IPC_SET_RETVAL(*call, EOK);
     646        IPC_SET_ARG1(*call, (ipcarg_t) dst);
     647        IPC_SET_ARG3(*call, (ipcarg_t) size);
     648        return ipc_answer(callid, call);
     649}
     650 
    597651/** @}
    598652 */
  • uspace/lib/libc/include/ipc/ipc.h

    rb3f598e r183b4a0  
    9292    ipcarg_t arg1);
    9393
     94extern int ipc_data_send_accept(ipc_callid_t *callid, ipc_call_t *call,
     95    void **dst, size_t *size);
     96extern ipcarg_t ipc_data_send_answer(ipc_callid_t callid, ipc_call_t *call,
     97    void *dst, size_t size);
     98
    9499#endif
    95100
Note: See TracChangeset for help on using the changeset viewer.