optional icu diff.
[AROS.git] / rom / dos / waitpkt.c
blob15cefc00205e6f1c3fe61f95dbdd60928620f0d0
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <dos/notify.h>
11 #include <proto/exec.h>
13 #include "dos_intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH0I(struct DosPacket *, WaitPkt,
22 /* SYNOPSIS */
23 /* void */
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 42, Dos)
28 /* FUNCTION
29 Wait for a packet to arrive at your process's pr_MsgPort. It will call
30 pr_PktWait if such a function is installed.
32 INPUTS
33 None.
35 RESULT
36 packet - The packet we received.
38 NOTES
39 The packet will be released from the port.
41 This function should NOT be used. It's there only for AmigaOS
42 compatibility.
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 struct Process *me = (struct Process *)FindTask(NULL);
58 ASSERT_VALID_PROCESS(me);
60 return internal_WaitPkt(&me->pr_MsgPort);
62 AROS_LIBFUNC_EXIT
63 } /* WaitPkt */
65 struct DosPacket *internal_WaitPkt(struct MsgPort *msgPort)
67 struct Message *msg = NULL;
68 struct Process *me = (struct Process *)FindTask(NULL);
70 if (__is_process(me))
73 * Call the packet wait function if the user has one installed.
74 * Unfortunately, in case of IOFS the user gets something completely different than
75 * a packet, but we cannot do anything about that...
77 if (me->pr_PktWait)
79 msg = AROS_UFC3(struct Message *, me->pr_PktWait,
80 AROS_UFCA(APTR, me->pr_PktWait, A0),
81 AROS_UFCA(struct MsgPort *, msgPort, A1),
82 AROS_UFCA(struct ExecBase *, SysBase, A6));
86 if (!msg)
88 /* Make sure we have a packet -- we may be woken up even if there is
89 not a packet for us as SIGF_DOS may be used and we may have another
90 message port that waits for packets, too. */
91 while ((msg = GetMsg(msgPort)) == NULL)
93 Wait(1 << msgPort->mp_SigBit);
97 D(bug("[DOS] WaitPkt(): got DOS packet 0x%p in message 0x%p\n", msg->mn_Node.ln_Name, msg));
98 return (struct DosPacket *)msg->mn_Node.ln_Name;