Changeset 241f1985 in mainline for uspace/lib/c


Ignore:
Timestamp:
2019-08-31T10:45:17Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
102f641
Parents:
f92b315
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-08-23 22:04:34)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-31 10:45:17)
Message:

Correcting failure from previous merge

The commits from Michal Koutný from the branch system-daemon
where built on a old version of Helenos. Because of this
many types and API functions have changed. This commit
upgrades the merge code

Location:
uspace/lib/c
Files:
14 edited

Legend:

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

    rf92b315 r241f1985  
    9999#include <async.h>
    100100#include "../private/async.h"
    101 #include "../private/ns.h"
    102101#undef _LIBC_ASYNC_C_
    103102
     
    114113#include <stdbool.h>
    115114#include <stdlib.h>
     115#include <stdatomic.h>
    116116#include <mem.h>
    117 #include <stdlib.h>
    118117#include <macros.h>
    119118#include <as.h>
     
    174173    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
    175174{
    176         async_sess_t *session = (async_sess_t *) malloc(sizeof(async_sess_t));
     175        async_sess_t *session = (async_sess_t *) calloc(1, sizeof(async_sess_t));
    177176
    178177        if (session != NULL) {
    179                 session->iface = 0;
    180178                session->mgmt = mgmt;
    181179                session->phone = phone;
     
    189187                list_initialize(&session->exch_list);
    190188                fibril_mutex_initialize(&session->mutex);
    191                 atomic_set(&session->refcnt, 0);
    192                 &session.exchanges = 0;
    193189        } else {
    194190                errno = ENOMEM;
     
    198194}
    199195
    200 int async_session_phone(async_sess_t *sess)
     196cap_phone_handle_t async_session_phone(async_sess_t *sess)
    201197{
    202198        return sess->phone;
     
    859855        }
    860856
    861         async_sess_t *sess = create_session(phone, mgmt, iface, arg2, arg3);
     857        async_sess_t *sess = create_session(phone, iface & IFACE_EXCHANGE_MASK, iface, arg2, arg3);
    862858        if (sess == NULL) {
    863859                ipc_hangup(phone);
    864860        }
     861        sess->iface = iface;
    865862
    866863        return sess;
     
    912909        if (rc != EOK) {
    913910                errno = rc;
    914                 free(sess);
    915911                return NULL;
    916912        }
    917913
    918         async_sess_t *sess = create_session(phone, mgmt, iface, arg2, arg3);
     914        async_sess_t *sess = create_session(phone, iface & IFACE_EXCHANGE_MASK, iface, arg2, arg3);
    919915        if (sess == NULL) {
    920916                ipc_hangup(phone);
    921917        }
     918        sess->iface = iface;
    922919
    923920        return sess;
  • uspace/lib/c/generic/async/server.c

    rf92b315 r241f1985  
    216216}
    217217
    218 static async_client_conn_t implicit_connection = NULL;
     218static async_port_handler_t implicit_connection = NULL;
     219
     220/** Setter for implicit_connection function pointer.
     221 *
     222 * @param conn Function that will implement a new connection fibril for
     223 *             unrouted calls.
     224 *
     225 */
     226void async_set_implicit_connection(async_port_handler_t conn)
     227{
     228        assert(implicit_connection == NULL);
     229        implicit_connection = conn;
     230}
     231
     232
    219233static fibril_rmutex_t client_mutex;
    220234static hash_table_t client_hash_table;
     
    969983                return;
    970984        } else if (implicit_connection != NULL) {
    971                 async_new_connection(call->in_task_id, call->in_phone_hash,
    972                     callid, call, implicit_connection, NULL);
     985                connection_t *conn = calloc(1, sizeof(connection_t));
     986                if (!conn) {
     987                        ipc_answer_0(call->cap_handle, ENOMEM);
     988                        return;
     989                }
     990
     991                async_new_connection(conn, call->task_id, call, implicit_connection, NULL);
    973992                return;
    974993        }
     
    17491768        async_sess_t *sess = create_session(phandle, mgmt, 0, 0, 0);
    17501769        if (sess == NULL) {
    1751                 ipc_hangup(phone);
     1770                ipc_hangup(phandle);
    17521771                async_answer_0(&call, errno);
    17531772        } else {
  • uspace/lib/c/generic/ns.c

    rf92b315 r241f1985  
    5959}
    6060
    61 /*
    62  * XXX ns does not know about session_primary, so we create an extra session for
    63  * actual communicaton
    64  */
    65 static async_sess_t *sess_primary = NULL;
    66 
    6761errno_t service_register(service_t service, iface_t iface,
    6862    async_port_handler_t handler, void *data)
     
    9690        async_set_fallback_port_handler(handler, data);
    9791
    98         async_sess_t *sess = get_session_primary();
    99         if (sess == NULL)
    100                 return EIO;
    101 
    102         async_exch_t *exch = async_exchange_begin(sess);
     92        async_exch_t *exch = ns_exchange_begin();
    10393
    10494        ipc_call_t answer;
     
    10696        errno_t rc = async_connect_to_me(exch, INTERFACE_ANY, service, 0);
    10797
    108         async_exchange_end(exch);
     98        ns_exchange_end(exch);
    10999
    110100        if (rc != EOK) {
     
    138128        async_sess_args_set(sess, iface, arg3, 0);
    139129
    140         return csess;
     130        return sess;
    141131}
    142132
     
    164154errno_t ns_ping(void)
    165155{
    166         async_exch_t *exch = ns_exchange_begin(sess);
     156        async_exch_t *exch = ns_exchange_begin();
    167157        errno_t rc = async_req_0_0(exch, NS_PING);
    168158        ns_exchange_end(exch);
  • uspace/lib/c/generic/private/async.h

    rf92b315 r241f1985  
    4242#include <time.h>
    4343#include <stdbool.h>
     44#include <stdatomic.h>
    4445
    4546/** Session data */
     
    106107
    107108extern void async_reply_received(ipc_call_t *);
    108 extern async_sess_t *create_session(int, exch_mgmt_t,
     109extern async_sess_t *create_session(cap_phone_handle_t, exch_mgmt_t,
    109110        sysarg_t, sysarg_t, sysarg_t);
    110 extern int async_session_phone(async_sess_t *);
     111extern cap_phone_handle_t async_session_phone(async_sess_t *);
    111112
    112113#endif
  • uspace/lib/c/generic/private/taskman.h

    rf92b315 r241f1985  
    3636#define LIBC_PRIVATE_TASKMAN_H_
    3737
    38 #include <async.h>
     38#include "async.h"
    3939
    4040extern async_sess_t *session_taskman;
  • uspace/lib/c/generic/task.c

    rf92b315 r241f1985  
    385385        if (rc == EOK || rc == EINTR) {
    386386                if (wait->flags & TASK_WAIT_EXIT && texit)
    387                         *texit = ipc_get_arg1(wait->result);
     387                        *texit = ipc_get_arg1(&wait->result);
    388388                if (wait->flags & TASK_WAIT_RETVAL && retval)
    389                         *retval = ipc_get_arg2(wait->result);
     389                        *retval = ipc_get_arg2(&wait->result);
    390390               
    391391        }
     
    394394                /* Is there another wait to be done? Wait for it! */
    395395                int old_flags = wait->flags;
    396                 wait->flags = ipc_get_arg3(wait->result);
     396                wait->flags = ipc_get_arg3(&wait->result);
    397397                if (wait->flags != 0 && (old_flags & TASK_WAIT_BOTH)) {
    398398                        rc = task_setup_wait(wait->tid, wait);
     
    438438                return EIO;
    439439
    440         errno_t rc = (int) async_req_2_0(exch, TASKMAN_RETVAL, val, wait_for_exit);
     440        errno_t rc = async_req_2_0(exch, TASKMAN_RETVAL, val, wait_for_exit);
    441441        taskman_exchange_end(exch);
    442442       
  • uspace/lib/c/generic/task_event.c

    rf92b315 r241f1985  
    3737#include <macros.h>
    3838#include <task.h>
     39#include <assert.h>
    3940
    4041#include "private/taskman.h"
     
    4243static task_event_handler_t task_event_handler = NULL;
    4344
    44 static void taskman_task_event(ipc_callid_t iid, ipc_call_t *icall)
     45static void taskman_task_event(ipc_call_t *icall)
    4546{
    4647        task_id_t tid = (task_id_t)
    47             MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
    48         int flags = IPC_GET_ARG3(*icall);
    49         task_exit_t texit = IPC_GET_ARG4(*icall);
    50         int retval = IPC_GET_ARG5(*icall);
     48            MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall));
     49        int flags = ipc_get_arg3(icall);
     50        task_exit_t texit = ipc_get_arg4(icall);
     51        int retval = ipc_get_arg5(icall);
    5152
    5253        task_event_handler(tid, flags, texit, retval);
    5354
    54         async_answer_0(iid, EOK);
     55        async_answer_0(icall, EOK);
    5556}
    5657
    57 static void taskman_event_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     58static void taskman_event_conn(ipc_call_t *icall, void *arg)
    5859{
    5960        /* Accept connection */
    60         async_answer_0(iid, EOK);
     61        async_answer_0(icall, EOK);
    6162
    6263        while (true) {
    6364                ipc_call_t call;
    64                 ipc_callid_t callid = async_get_call(&call);
    65 
    66                 if (!IPC_GET_IMETHOD(call)) {
     65               
     66                if (!async_get_call(&call) || !ipc_get_imethod(&call)) {
    6767                        /* Hangup, end of game */
    6868                        break;
    6969                }
    7070
    71                 switch (IPC_GET_IMETHOD(call)) {
     71                switch (ipc_get_imethod(&call)) {
    7272                case TASKMAN_EV_TASK:
    73                         taskman_task_event(callid, &call);
     73                        taskman_task_event(&call);
    7474                        break;
    7575                default:
    76                         async_answer_0(callid, ENOTSUP);
     76                        async_answer_0(&call, ENOTSUP);
    7777                        break;
    7878                }
     
    8383 * Blocks, calls handler in another fibril
    8484 */
    85 int task_register_event_handler(task_event_handler_t handler, bool past_events)
     85errno_t task_register_event_handler(task_event_handler_t handler, bool past_events)
    8686{
    8787        /*
     
    9797        aid_t req = async_send_1(exch, TASKMAN_EVENT_CALLBACK, past_events, NULL);
    9898
    99         int rc = async_connect_to_me(exch, 0, 0, 0, taskman_event_conn, NULL);
     99        port_id_t port;
     100        errno_t rc = async_create_callback_port(exch, INTERFACE_TASKMAN_CB, 0, 0,
     101                taskman_event_conn, NULL, &port);
    100102        taskman_exchange_end(exch);
    101103
     
    104106        }
    105107
    106         sysarg_t retval;
     108        errno_t retval;
    107109        async_wait_for(req, &retval);
    108110        return retval;
  • uspace/lib/c/generic/taskman.c

    rf92b315 r241f1985  
    103103        assert(exch);
    104104
    105         async_sess_t *sess = async_connect_me_to(EXCHANGE_ATOMIC,
    106             exch, TASKMAN_CONNECT_TO_NS, 0, 0);
     105        async_sess_t *sess = async_connect_me_to(exch, INTERFACE_NS,
     106                TASKMAN_CONNECT_TO_NS, 0);
    107107        async_exchange_end(exch);
    108108
     
    116116
    117117        async_exch_t *exch = async_exchange_begin(session_taskman);
    118         async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE,
    119             exch, TASKMAN_CONNECT_TO_LOADER, 0, 0);
     118        async_sess_t *sess = async_connect_me_to(exch, INTERFACE_LOADER,
     119            TASKMAN_CONNECT_TO_LOADER, 0);
    120120        async_exchange_end(exch);
    121121
     
    136136 * @return EOK on success, otherwise propagated error code
    137137 */
    138 int taskman_intro_loader(void)
     138errno_t taskman_intro_loader(void)
    139139{
    140140        assert(session_taskman);
    141141
    142142        async_exch_t *exch = async_exchange_begin(session_taskman);
    143         int rc = async_connect_to_me(
    144             exch, TASKMAN_LOADER_CALLBACK, 0, 0, NULL, NULL);
     143        errno_t rc = async_connect_to_me(exch, INTERFACE_LOADER, TASKMAN_LOADER_CALLBACK, 0);
    145144        async_exchange_end(exch);
    146145
     
    152151 * @return EOK on success, otherwise propagated error code
    153152 */
    154 int taskman_intro_ns(void)
     153errno_t taskman_intro_ns(void)
    155154{
    156155        assert(session_taskman);
     
    159158        aid_t req = async_send_0(exch, TASKMAN_I_AM_NS, NULL);
    160159
    161         int rc = async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
     160        errno_t rc = async_connect_to_me(exch, INTERFACE_NS, 0, 0);
    162161        taskman_exchange_end(exch);
    163162
     
    166165        }
    167166
    168         sysarg_t retval;
     167        errno_t retval;
    169168        async_wait_for(req, &retval);
    170169        return retval;
  • uspace/lib/c/generic/taskman_noasync.c

    rf92b315 r241f1985  
    3333 */
    3434
    35 #define LIBC_ASYNC_C_
    36 #include <ipc/ipc.h>
    3735#include "private/async.h"
    3836#include "private/taskman.h"
    39 #undef LIBC_ASYNC_C_
     37
     38#undef _LIBC_ASYNC_H_
     39#include <ipc/ipc.h>
     40#define _LIBC_ASYNC_H_
    4041
    4142#include <errno.h>
     
    5051 * @return EOK on success, otherwise propagated error code
    5152 */
    52 int taskman_intro_ns_noasync(void)
     53errno_t taskman_intro_ns_noasync(void)
    5354{
    5455        assert(session_taskman);
    55         int phone = async_session_phone(session_taskman);
     56        cap_phone_handle_t phone = async_session_phone(session_taskman);
    5657
    57         ipc_call_async_0(phone, TASKMAN_I_AM_NS, NULL, NULL, false);
     58        ipc_call_async_0(phone, TASKMAN_I_AM_NS, NULL);
    5859
    59         ipc_call_async_3(phone, IPC_M_CONNECT_TO_ME, 0, 0, 0, NULL, NULL, false);
     60        ipc_call_async_3(phone, IPC_M_CONNECT_TO_ME, 0, 0, 0, NULL);
    6061
    6162        /*
     
    6768
    6869
    69 void task_retval_noasync(int retval)
     70void task_retval_noasync(errno_t retval)
    7071{
    7172        assert(session_taskman);
    72         int phone = async_session_phone(session_taskman);
     73        cap_phone_handle_t phone = async_session_phone(session_taskman);
    7374
    7475        /* Just send it and don't wait for an answer. */
    75         ipc_call_async_2(phone, TASKMAN_RETVAL, retval, false,
    76             NULL, NULL, false);
     76        ipc_call_async_2(phone, TASKMAN_RETVAL, retval, false, NULL);
    7777}
    7878
  • uspace/lib/c/include/adt/dyn_array.h

    rf92b315 r241f1985  
    4141typedef struct {
    4242        /** Data buffer of array */
    43         uint8_t *_data;
     43        void *_data;
    4444        /** Size on bytes of a single item */
    4545        size_t _item_size;
  • uspace/lib/c/include/async.h

    rf92b315 r241f1985  
    132132extern void async_put_client_data_by_id(task_id_t);
    133133
    134 extern void async_set_implicit_connection(async_client_conn_t);
     134extern void async_set_implicit_connection(async_port_handler_t);
    135135
    136136extern errno_t async_create_port(iface_t, async_port_handler_t, void *,
  • uspace/lib/c/include/ipc/services.h

    rf92b315 r241f1985  
    5555#define SERVICE_NAME_CLIPBOARD "clipboard"
    5656#define SERVICE_NAME_CORECFG  "corecfg"
     57#define SERVICE_NAME_DEVMAN   "devman"
    5758#define SERVICE_NAME_DHCP     "net/dhcp"
    5859#define SERVICE_NAME_DNSR     "net/dnsr"
  • uspace/lib/c/include/task.h

    rf92b315 r241f1985  
    7676
    7777/* Implemented in task_event.c */
    78 extern int task_register_event_handler(task_event_handler_t, bool);
     78extern errno_t task_register_event_handler(task_event_handler_t, bool);
    7979
    8080#endif
  • uspace/lib/c/include/taskman.h

    rf92b315 r241f1985  
    4040/* Internal functions to be used by loader only */
    4141extern async_sess_t *taskman_get_session(void);
    42 extern int taskman_intro_loader(void);
     42extern errno_t taskman_intro_loader(void);
    4343
    4444/* Internal functions to be used by NS only */
    45 extern int taskman_intro_ns(void);
     45extern errno_t taskman_intro_ns(void);
    4646
    4747#endif
Note: See TracChangeset for help on using the changeset viewer.