2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Wait for a message on a port.
8 #include "exec_intern.h"
9 #include <exec/ports.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
17 AROS_LH1(struct Message
*, WaitPort
,
20 AROS_LHA(struct MsgPort
*, port
, A0
),
23 struct ExecBase
*, SysBase
, 64, Exec
)
26 Wait until a message arrives at the given port. If there is already
27 a message in it this function returns immediately.
30 port - Pointer to messageport.
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.
47 ******************************************************************************/
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
;