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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: waitport.c,v 1.5 1996/10/24 15:50:59 aros Exp $
  4.     $Log: waitport.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:10  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_intern.h"
  20. #include <exec/ports.h>
  21. #include <aros/libcall.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH1(struct Message *, WaitPort,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct MsgPort *, port, A0),
  32.  
  33. /*  LOCATION */
  34.     struct ExecBase *, SysBase, 64, Exec)
  35.  
  36. /*  FUNCTION
  37.     Wait until a message arrives at the given port. If there is already
  38.     a message in it this function returns immediately.
  39.  
  40.     INPUTS
  41.     port    - Pointer to messageport.
  42.  
  43.     RESULT
  44.     Pointer to the first message that arrived at the port. The message
  45.     is _not_ removed from the port. GetMsg() does this for you.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.     WaitPort(), GetMsg()
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.  
  60. ******************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.  
  64.     /*
  65.     No Disable() necessary here since emptiness can be checked
  66.     without and nobody is allowed to change the signal bit as soon
  67.     as the current task entered WaitPort() (and probably did not yet
  68.     have a chance to Disable()).
  69.     */
  70.  
  71.     /* Is messageport empty? */
  72.     while(port->mp_MsgList.lh_Head->ln_Succ==NULL)
  73.     /*
  74.         Yes. Wait for the signal to arrive. Remember that signals may
  75.         arrive without a message so check again.
  76.     */
  77.     Wait(1<<port->mp_SigBit);
  78.  
  79.     /* Return the first node in the list. */
  80.     return (struct Message *)port->mp_MsgList.lh_Head;
  81.     AROS_LIBFUNC_EXIT
  82. }
  83.  
  84.