Changeset 466e95f7 in mainline


Ignore:
Timestamp:
2012-10-03T21:08:54Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
faa45c17
Parents:
716185d
Message:

Add SYSIPC_OP macro to avoid repeating the same boilerplate code.

Location:
kernel/generic
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/sysipc_ops.h

    r716185d r466e95f7  
    3737
    3838#include <ipc/ipc.h>
     39
     40#define SYSIPC_OP(op, call, ...) \
     41        ({ \
     42                int rc = EOK; \
     43                \
     44                sysipc_ops_t *ops; \
     45                ops = sysipc_ops_get((call)->request_method); \
     46                if (ops->op) \
     47                        rc = ops->op((call), ##__VA_ARGS__); \
     48                rc; \
     49        })
    3950
    4051/**
     
    95106         * Invoked on:          all forgotten calls
    96107         */     
    97         void (* request_forget)(call_t *);
     108        int (* request_forget)(call_t *);
    98109
    99110        /**
     
    116127         * Invoked on:          all forgotten calls
    117128         */
    118         void (* answer_cleanup)(call_t *, ipc_data_t *);
     129        int (* answer_cleanup)(call_t *, ipc_data_t *);
    119130
    120131        /**
     
    143154
    144155extern int null_request_preprocess(call_t *, phone_t *);
    145 extern void null_request_forget(call_t *);
     156extern int null_request_forget(call_t *);
    146157extern int null_request_process(call_t *, answerbox_t *);
    147 extern void null_answer_cleanup(call_t *, ipc_data_t *);
     158extern int null_answer_cleanup(call_t *, ipc_data_t *);
    148159extern int null_answer_preprocess(call_t *, ipc_data_t *);
    149160extern int null_answer_process(call_t *);
  • kernel/generic/src/ipc/ipc.c

    r716185d r466e95f7  
    513513                irq_spinlock_unlock(&box->lock, true);
    514514
    515                 if (lst == &box->calls) {
    516                         sysipc_ops_t *ops;
    517 
    518                         ops = sysipc_ops_get(call->request_method);
    519                         if (ops->request_process)
    520                                 (void) ops->request_process(call, box);
    521                 }
     515                if (lst == &box->calls)
     516                        SYSIPC_OP(request_process, call, box);
    522517
    523518                ipc_data_t old = call->data;
     
    645640        atomic_dec(&call->caller_phone->active_calls);
    646641
    647         sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
    648         if (ops->request_forget)
    649                 ops->request_forget(call);
     642        SYSIPC_OP(request_forget, call);
    650643
    651644        ipc_call_release(call);
     
    716709        ASSERT(call->flags & (IPC_CALL_ANSWERED | IPC_CALL_NOTIF));
    717710
    718         sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
    719         if (ops->answer_process)
    720                 ops->answer_process(call);
     711        SYSIPC_OP(answer_process, call);
    721712
    722713        ipc_call_free(call);
  • kernel/generic/src/ipc/ops/clnestab.c

    r716185d r466e95f7  
    4545}
    4646
    47 static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     47static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    4848{
    4949        phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
     
    5757        }
    5858        mutex_unlock(&phone->lock);
     59
     60        return EOK;
    5961}
    6062
  • kernel/generic/src/ipc/ops/conctmeto.c

    r716185d r466e95f7  
    5454}
    5555
    56 static void request_forget(call_t *call)
     56static int request_forget(call_t *call)
    5757{
    5858        phone_dealloc(call->priv);
     59        return EOK;
    5960}
    6061
  • kernel/generic/src/ipc/ops/concttome.c

    r716185d r466e95f7  
    4949}
    5050
    51 static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     51static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    5252{
    5353        int phoneid = (int) IPC_GET_ARG5(*olddata);
     
    5555        if (phoneid >= 0)
    5656                phone_dealloc(phoneid);
     57
     58        return EOK;
    5759}
    5860
  • kernel/generic/src/ipc/ops/connclone.c

    r716185d r466e95f7  
    9797}
    9898
    99 static void answer_cleanup(call_t *answer, ipc_data_t *olddata)
     99static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    100100{
    101101        int phoneid = (int) IPC_GET_ARG1(*olddata);
     
    116116        }
    117117        mutex_unlock(&phone->lock);
     118
     119        return EOK;
    118120}
    119121
  • kernel/generic/src/ipc/sysipc.c

    r716185d r466e95f7  
    161161{
    162162        int rc = EOK;
    163         sysipc_ops_t *ops;
    164163
    165164        spinlock_lock(&answer->forget_lock);
     
    170169                spinlock_unlock(&answer->forget_lock);
    171170
    172                 ops = sysipc_ops_get(answer->request_method);
    173                 if (ops->answer_cleanup)
    174                         ops->answer_cleanup(answer, olddata);
    175 
     171                SYSIPC_OP(answer_cleanup, answer, olddata);
    176172                return rc;
    177173        } else {
     
    213209                return rc;
    214210
    215         ops = sysipc_ops_get(answer->request_method);
    216         if (ops->answer_preprocess)
    217                 rc = ops->answer_preprocess(answer, olddata);
    218        
    219         return rc;
     211        return SYSIPC_OP(answer_preprocess, answer, olddata);
    220212}
    221213
     
    230222static int request_preprocess(call_t *call, phone_t *phone)
    231223{
    232         int rc = EOK;
    233 
    234224        call->request_method = IPC_GET_IMETHOD(call->data);
    235 
    236         sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
    237         if (ops->request_preprocess)
    238                 rc = ops->request_preprocess(call, phone);
    239        
    240         return rc;
     225        return SYSIPC_OP(request_preprocess, call, phone);
    241226}
    242227
     
    256241                IPC_SET_RETVAL(call->data, EFORWARD);
    257242       
    258         sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
    259         if (ops->answer_process)
    260                 (void) ops->answer_process(call);
     243        SYSIPC_OP(answer_process, call);
    261244}
    262245
     
    273256static int process_request(answerbox_t *box, call_t *call)
    274257{
    275         int rc = EOK;
    276 
    277         sysipc_ops_t *ops = sysipc_ops_get(call->request_method);
    278         if (ops->request_process)
    279                 rc = ops->request_process(call, box);
    280        
    281         return rc;
     258        return SYSIPC_OP(request_process, call, box);
    282259}
    283260
  • kernel/generic/src/ipc/sysipc_ops.c

    r716185d r466e95f7  
    7676}
    7777
    78 void null_request_forget(call_t *call)
     78int null_request_forget(call_t *call)
    7979{
     80        return EOK;
    8081}
    8182
     
    8586}
    8687
    87 void null_answer_cleanup(call_t *call, ipc_data_t *data)
     88int null_answer_cleanup(call_t *call, ipc_data_t *data)
    8889{
     90        return EOK;
    8991}
    9092
Note: See TracChangeset for help on using the changeset viewer.