O

Top  Previous  Next

offsetof

#include <stddef.h>

offsetof (

   type,

   member-designator

);

stand-alone

This macro expands to a constant expression of type size_t, which has the value of the offset in octets (eight-bit bytes) from the beginning of the structure type to member-designator. The member may not be a bit-field.

 

For example:

 

#include <stddef.h>

size_t ip;

struct s {

   char fill[4];

   int jim;

};

ip = offsetof(struct s, jim);

OUTPUT_PORT

#include <chan.h>

OUTPUT_PORT (

   portid,

   identifier

)

stand-alone

The OUTPUT_PORT macro takes the task’s output port selected by portid and associates the bound channel with an identifier; this identifier is an external variable of type CHAN. The macro may be used as a declaration in any file used to build a task.

 

Note that as the variable is external its name must be unique or the linker will report errors.

 

Portid can be:


an integer constant index into the task’s output port vector, selecting a particular port;

the name of a CONNECT statement in the configuration file, selecting the output port specification for this task.

 

See also INPUT_PORT, which includes a technique for accessing ports from several separately-compiled modules.

 

For example, given the following extract of a configuration file:

 

TASK A .... OUTS=4

TASK B ....

CONNECT control A[1] B[2]

 

The main function of A could include the following:

 

OUTPUT_PORT(control, control_out)

OUTPUT_PORT(3, data_out);

 

main(int argc, char *argv[], char *envp[],

     CHAN *in_ports[], int ins,

     CHAN *out_ports[], int outs) {

   ...

   chan_out_message(16, b, out_ports[1]);

   chan_out_message(16, b, &control_out); // same as above

   chan_out_message(12, b, out_ports[3]);

   chan_out_message(12, b, &data_out);    // same as above