Next: , Up: Instruction Meta-class Definition   [Contents][Index]


4.3.1 Function Declaration

You should normally 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 (see further on in this subsection). The function is declared as having the return type int and the following arguments.

Function argument: qsmm_t qsmm

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

Function argument: int qsmm_evt

The type of an event that should be processed by the event handler function. Can be one of these constants: 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, QSMM_EVT_ACTIVATE.

Function argument: int qsmm_node

The identifier of a node being executed. Is a valid identifier for 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 value of the corresponding argument of function qsmm_reg_instr_meta_class called to register the instruction meta-class.

For example, the prototype of a static function that represents instruction meta-class ‘move’ can be declared as follows:

static QSMM_INSTR_META_CLASS(move);

Static function ‘move’ can be defined as follows:

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

This is a type for the 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 a description of arguments of that event handler function. To improve compatibility with future versions of the library, avoid declaring the event handler functions with such prototype explicitly; use the macro QSMM_INSTR_META_CLASS instead.


Next: , Up: Instruction Meta-class Definition   [Contents][Index]