Moved tests for dos.library functions into the 'dos' subdir.
[AROS.git] / rom / exec / createmsgport.c
blob92fc955bbdc8f2d02c17c24278d6044d0fb58653
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a new message port.
6 Lang: english
7 */
9 #include <exec/memory.h>
10 #include <exec/ports.h>
11 #include <exec/execbase.h>
12 #include <proto/exec.h>
14 #include "exec_util.h"
16 /*****************************************************************************
18 NAME */
20 AROS_LH0(struct MsgPort *, CreateMsgPort,
22 /* SYNOPSIS */
24 /* LOCATION */
25 struct ExecBase *, SysBase, 111, Exec)
27 /* FUNCTION
28 Create a new message port. A signal will be allocated and the message
29 port set to signal you task
31 INPUTS
33 RESULT
34 Pointer to messageport structure
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 ******************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct MsgPort *ret;
52 /* Allocate memory for struct MsgPort */
53 ret=(struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
54 if(ret!=NULL)
56 BYTE sb;
58 /* Allocate a signal bit */
59 sb=AllocSignal(-1);
60 if (sb != -1)
62 /* Initialize messageport structure */
63 InitMsgPort(ret);
64 /* Set signal bit. */
65 ret->mp_SigBit=sb;
66 /* Set task to send the signal to. */
67 ret->mp_SigTask=GET_THIS_TASK;
69 /* Now the port is ready for use. */
70 return ret;
72 /* Couldn't get the signal bit. Free the memory. */
73 FreeMem(ret,sizeof(struct MsgPort));
75 /* function failed */
76 return NULL;
77 AROS_LIBFUNC_EXIT
78 } /* CreateMsgPort */