exec.library: Prevent recursive build
[AROS.git] / rom / exec / waitio.c
blobf97d5777f0c3c904b1055c141121c86508ec477e
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Wait until IO request completes.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <exec/io.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH1(LONG, WaitIO,
19 /* SYNOPSIS */
20 AROS_LHA(struct IORequest *, iORequest, A1),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 79, Exec)
25 /* FUNCTION
26 Waits until the I/O request is completed and removes it from the
27 reply port. If the message is already done when calling this function
28 it doesn't wait but just remove the message.
30 INPUTS
31 iORequest - Pointer to iorequest structure.
33 RESULT
34 Error state of I/O request.
36 NOTES
37 OpenDevice() notes explain LONG return type.
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 OpenDevice(), CloseDevice(), DoIO(), SendIO(), AbortIO(), CheckIO()
46 INTERNALS
48 ******************************************************************************/
50 AROS_LIBFUNC_INIT
53 The I/O request is still in use if it wasn't done quick
54 and isn't yet replied (ln_Type==NT_MESSAGE).
55 If it is still in use wait until it is complete.
56 Note that the port may be used for other things as well - so
57 don't just wait but repeat the check.
59 while(!(iORequest->io_Flags&IOF_QUICK)&&
60 iORequest->io_Message.mn_Node.ln_Type==NT_MESSAGE)
62 Wait at the reply port. Don't use WaitPort() - there may
63 already be other messages waiting at it.
65 Wait(1<<iORequest->io_Message.mn_ReplyPort->mp_SigBit);
68 If ln_Type is NT_REPLYMSG the I/O request must be removed from
69 the replyport's waiting queue.
71 if(iORequest->io_Message.mn_Node.ln_Type==NT_REPLYMSG)
73 /* Arbitrate for the message queue. */
74 Disable();
76 /* Remove the message */
77 Remove(&iORequest->io_Message.mn_Node);
78 Enable();
81 /* All done. Get returncode. */
82 return iORequest->io_Error;
84 AROS_LIBFUNC_EXIT
85 } /* WaitIO */