Register nameservers dynamically instead of writing them to disk. It is
[AROS.git] / rom / exec / waitport.c
blob34ddda6171d06ac1888fcbdceefba2a8d9fb832e
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Wait for a message on a port.
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include <exec/ports.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH1(struct Message *, WaitPort,
19 /* SYNOPSIS */
20 AROS_LHA(struct MsgPort *, port, A0),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 64, Exec)
25 /* FUNCTION
26 Wait until a message arrives at the given port. If there is already
27 a message in it this function returns immediately.
29 INPUTS
30 port - Pointer to messageport.
32 RESULT
33 Pointer to the first message that arrived at the port. The message
34 is _not_ removed from the port. GetMsg() does this for you.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 WaitPort(), GetMsg()
45 INTERNALS
47 ******************************************************************************/
49 AROS_LIBFUNC_INIT
51 ASSERT_VALID_PTR(port);
53 No Disable() necessary here since emptiness can be checked
54 without and nobody is allowed to change the signal bit as soon
55 as the current task entered WaitPort() (and probably did not yet
56 have a chance to Disable()).
59 /* Is messageport empty? */
60 while (IsListEmpty (&port->mp_MsgList))
63 Yes. Wait for the signal to arrive. Remember that signals may
64 arrive without a message so check again.
66 Wait(1<<port->mp_SigBit);
69 /* Return the first node in the list. */
70 return (struct Message *)port->mp_MsgList.lh_Head;
72 AROS_LIBFUNC_EXIT
73 } /* WaitPort() */