home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / exec / waitio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.3 KB  |  99 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: waitio.c,v 1.5 1996/10/24 15:50:59 aros Exp $
  4.     $Log: waitio.c,v $
  5.     Revision 1.5  1996/10/24 15:50:59  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:09  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:22  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include <exec/execbase.h>
  20. #include <exec/io.h>
  21. #include <aros/libcall.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH1(BYTE, WaitIO,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct IORequest *, iORequest, A1),
  32.  
  33. /*  LOCATION */
  34.     struct ExecBase *, SysBase, 79, Exec)
  35.  
  36. /*  FUNCTION
  37.     Waits until the I/O request is completed and removes it from the
  38.     reply port. If the message is already done when calling this function
  39.     it doesn't wait but just remove the message.
  40.  
  41.     INPUTS
  42.     iORequest - Pointer to iorequest structure.
  43.  
  44.     RESULT
  45.     Error state of I/O request.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.     OpenDevice(), CloseDevice(), DoIO(), SendIO(), AbortIO(), CheckIO()
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.  
  60. ******************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.  
  64.     /*
  65.     The I/O request is still in use if it wasn't done quick
  66.     and isn't yet replied (ln_Type==NT_MESSAGE).
  67.     If it is still in use wait until it is complete.
  68.     Note the the port may be used for other things as well - so
  69.     don't just wait but repeat the check.
  70.     */
  71.     while(!(iORequest->io_Flags&IOF_QUICK)&&
  72.       iORequest->io_Message.mn_Node.ln_Type==NT_MESSAGE)
  73.     /*
  74.         Wait at the reply port. Don't use WaitPort() - there may
  75.         already be other messages waiting at it.
  76.     */
  77.     Wait(1<<iORequest->io_Message.mn_ReplyPort->mp_SigBit);
  78.  
  79.     /*
  80.     If ln_Type is NT_REPLYMSG the I/O request must be removed from
  81.     the replyport's waiting queue.
  82.     */
  83.     if(iORequest->io_Message.mn_Node.ln_Type==NT_REPLYMSG)
  84.     {
  85.     /* Arbitrate for the message queue. */
  86.     Disable();
  87.  
  88.     /* Remove the message */
  89.     Remove(&iORequest->io_Message.mn_Node);
  90.     Enable();
  91.     }
  92.  
  93.     /* All done. Get returncode. */
  94.     return iORequest->io_Error;
  95.  
  96.     AROS_LIBFUNC_EXIT
  97. } /* WaitIO */
  98.  
  99.