libcaps question

Matthew Dillon dillon at apollo.backplane.com
Sat Dec 13 15:54:05 PST 2003


:I realize this is a work in progress but I find this to be a little 
:difficult to keep track of.  Its probably just me :)
:
:    caps_port_t port;
:    port = malloc(sizeof(*port));
:    bzero(port, sizeof(*port));
:    lwkt_initport(&port->lport, curthread);
:    port->lport.mp_putport = cs_putport;
:    port->lport.mp_waitport = cs_waitport;
:    port->lport.mp_replyport = cs_replyport;
:    port->lport.mp_refs = 1;
:
:Basically I would be more comfortable if port were (caps_port_t *).
:
:It would make the sizeof easier to get correct later so I don't just
:accidentally allocate something that is the size of a pointer :).
:
:Dave

    Most of the kernel structural _t typedefs are pointers, so that is
    the convention I am using.  Use 'struct name' if you need the actual
    structural type instead of a pointer.

    So, e.g. thread_t, lwkt_msg_t, lwkt_port_t.

    There is a secondary reason for doing this and that is that we can,
    if necessary, 'typedef struct fubar *fubar_t;' and use fubar_t in 
    prototypes without having to bring in all the #include files necsesary
    for struct fubar.  This reduces #include file pollution.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list