Next: , Up: Defining Instruction Meta-classes   [Contents][Index]


4.2.2.1 Function Declaration

You should declare or define an instruction meta-class using the following macro.

Macro: QSMM_INSTR_META_CLASS (instr_meta_class_name)

This macro declares the prototype of a function named instr_meta_class_name that represents an instruction meta-class with the same name and is the event handler function of this instruction meta-class. You can prepend the macro with the static keyword to declare or define the static function. A pointer to the function has the type qsmm_instr_meta_class_func_t. The function has the return type int and the following arguments.

Function argument: qsmm_t qsmm

The handle of a multinode model containing the instruction meta-class.

Function argument: int qsmm_evt

The type of an event to process by the event handler function: QSMM_EVT_ENT_INIT, QSMM_EVT_ENT_DONE, QSMM_EVT_INSTR_CLASS_INIT, QSMM_EVT_INSTR_CLASS_DONE, QSMM_EVT_ENGINE_INIT, QSMM_EVT_ENGINE_DONE, or QSMM_EVT_ACTIVATE.

Function argument: int qsmm_node

The identifier of an executed node. Is a valid identifier for an event QSMM_EVT_ACTIVATE. For other events is equal to -1.

Function argument: void * qsmm_param_p

The user parameter of this event handler function. Is equal to the corresponding argument of qsmm_reg_instr_meta_class function called to register the instruction meta-class.

For example, declare the prototype of a static function representing the instruction meta-class ‘move’ as follows:

static QSMM_INSTR_META_CLASS(move);

Define the static function ‘move’ as follows:

static QSMM_INSTR_META_CLASS(move) {
    ...
}
Data type: qsmm_instr_meta_class_func_t

This is a type of a pointer to the event handler function of an instruction meta-class. The type has the following declaration:

typedef int
(*qsmm_instr_meta_class_func_t)(
    qsmm_t qsmm,
    int qsmm_evt,
    int qsmm_node,
    void *qsmm_param_p
);

See above for the description of arguments of that event handler function. To improve compatibility with future versions of QSMM library, avoid declaring event handler functions with this prototype explicitly—use the macro QSMM_INSTR_META_CLASS instead.


Next: , Up: Defining Instruction Meta-classes   [Contents][Index]