[En-Nut-Discussion] Cortex ih_xxx_interuptY code duplication, continued

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Wed Jul 18 18:35:44 CEST 2012


Hello,

if we accept the additional redirection for a common IrqCtl() function,
placement of IQR_HANDLER could be eased with a macro like

#ifdef NUT_PERFMON
#define sigEntry( x , y)                                     \
    static int x##IrqCtl(int cmd, void *param);              \
                                                             \
IRQ_HANDLER y = {                                            \
    0,         /* Interrupt counter, ir_count. */            \
    NULL,      /* Passed argument, ir_arg. */                \
    NULL,      /* Handler subroutine, ir_handler. */         \
    x##IrqCtl  /* Interrupt control, ir_ctl. */              \
};                                                           \
                                                             \
static void x##IrqEntry(void *arg)                           \
{                                                            \
    y.ir_count++;                                            \
    if (y.ir_handler) {                                      \
        (y.ir_handler) (y.ir_arg);                           \
    }                                                        \
}                                                            \
                                                             \
static int x##IrqCtl(int cmd, void *param)                   \
{                                                            \
    return IrqCtl(x##_IRQn, x##IrqEntry, &y, cmd, param);    \
}
#else
#define sigEntry( x , y)                                     \
static int x##IrqCtl(int cmd, void *param);                  \
                                                             \
IRQ_HANDLER y = {                                            \
    NULL,     /* Passed argument, ir_arg. */                 \
    NULL,      /* Handler subroutine, ir_handler. */         \
    x##IrqCtl  /* Interrupt control, ir_ctl. */              \
};                                                           \
                                                             \
static void x##IrqEntry(void *arg)                           \
{                                                            \
    if (y.ir_handler) {                                      \
        (y.ir_handler) (y.ir_arg);                           \
    }                                                        \
}                                                            \
                                                             \
static int x##IrqCtl(int cmd, void *param)                   \
{                                                            \
    return IrqCtl(x##_IRQn, x##IrqEntry, cmd, param);        \
}
#endif

in a common header and a call to that macro like

sigEntry(RTC, sig_RTC)

Having two arguments in the macro call may help with some special cases, but
I am not sure of the imprtance yet.

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------



More information about the En-Nut-Discussion mailing list