2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Create a new message port.
8 #include <exec/memory.h>
9 #include <exec/ports.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <proto/exec.h>
14 /*****************************************************************************
18 AROS_LH0(struct MsgPort
*, CreateMsgPort
,
23 struct ExecBase
*, SysBase
, 111, Exec
)
26 Create a new message port. A signal will be allocated and the message
27 port set to signal you task
32 Pointer to messageport structure
44 ******************************************************************************/
50 /* Allocate memory for struct MsgPort */
51 ret
=(struct MsgPort
*)AllocMem(sizeof(struct MsgPort
),MEMF_PUBLIC
|MEMF_CLEAR
);
56 /* Allocate a signal bit */
60 /* Initialize messageport structure. First set signal bit. */
63 /* Clear the list of messages */
64 ret
->mp_MsgList
.lh_Head
=(struct Node
*)&ret
->mp_MsgList
.lh_Tail
;
65 /* ret->mp_MsgList.lh_Tail=NULL; */
66 ret
->mp_MsgList
.lh_TailPred
=(struct Node
*)&ret
->mp_MsgList
.lh_Head
;
68 /* Set port to type 'signalling' */
69 ret
->mp_Flags
=PA_SIGNAL
;
71 /* Set port to type MsgPort */
72 ret
->mp_Node
.ln_Type
= NT_MSGPORT
;
74 /* Finally set task to send the signal to. */
75 ret
->mp_SigTask
=SysBase
->ThisTask
;
77 /* Now the port is ready for use. */
80 /* Couldn't get the signal bit. Free the memory. */
81 FreeMem(ret
,sizeof(struct MsgPort
));