revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / addport.c
blobe6663284598a7a1f3e6814881cb67edf1547f59d
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a port to the public list of ports.
6 Lang: english
7 */
9 #include <exec/ports.h>
10 #include <proto/exec.h>
12 #include "exec_intern.h"
13 #include "exec_debug.h"
15 /*****************************************************************************
17 NAME */
19 AROS_LH1(void, AddPort,
21 /* SYNOPSIS */
22 AROS_LHA(struct MsgPort *, port, A1),
24 /* LOCATION */
25 struct ExecBase *, SysBase, 59, Exec)
27 /* FUNCTION
28 Add a port to the public port list. The ln_Name and ln_Pri fields
29 must be initialized prior to calling this function, while
30 the port itself is reinitialized before adding. Therefore it's
31 not allowed to add an active port.
33 INPUTS
34 port - Pointer to messageport structure.
36 RESULT
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
51 ASSERT_VALID_PTR(port);
53 /* Arbitrate for the list of messageports. */
54 Forbid();
56 /* Yes, this is a messageport */
57 port->mp_Node.ln_Type=NT_MSGPORT;
59 /* Clear the list of messages */
60 #if defined(__AROSEXEC_SMP__)
61 EXEC_SPINLOCK_INIT(&port->mp_SpinLock);
62 #endif
63 NEWLIST(&port->mp_MsgList);
64 #if defined(__AROSEXEC_SMP__)
65 EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase)->PortListSpinLock, NULL, SPINLOCK_MODE_WRITE);
66 #endif
67 /* And add the actual port */
68 Enqueue(&SysBase->PortList,&port->mp_Node);
69 #if defined(__AROSEXEC_SMP__)
70 EXEC_SPINLOCK_UNLOCK(&PrivExecBase(SysBase)->PortListSpinLock);
71 #endif
73 /* All done */
74 Permit();
75 AROS_LIBFUNC_EXIT
76 } /* AddPort */