Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / exec / createmsgport.c
blob3af628cee7ffec702143735052561f7e5c1ed663
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a new message port.
6 Lang: english
7 */
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 /*****************************************************************************
16 NAME */
18 AROS_LH0(struct MsgPort *, CreateMsgPort,
20 /* SYNOPSIS */
22 /* LOCATION */
23 struct ExecBase *, SysBase, 111, Exec)
25 /* FUNCTION
26 Create a new message port. A signal will be allocated and the message
27 port set to signal you task
29 INPUTS
31 RESULT
32 Pointer to messageport structure
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 ******************************************************************************/
46 AROS_LIBFUNC_INIT
48 struct MsgPort *ret;
50 /* Allocate memory for struct MsgPort */
51 ret=(struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
52 if(ret!=NULL)
54 BYTE sb;
56 /* Allocate a signal bit */
57 sb=AllocSignal(-1);
58 if(sb!=-1)
60 /* Initialize messageport structure. First set signal bit. */
61 ret->mp_SigBit=sb;
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. */
78 return ret;
80 /* Couldn't get the signal bit. Free the memory. */
81 FreeMem(ret,sizeof(struct MsgPort));
83 /* function failed */
84 return NULL;
85 AROS_LIBFUNC_EXIT
86 } /* CreateMsgPort */