home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / waitport.c < prev   
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.1 KB  |  92 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: waitport.c,v 1.7 1997/01/01 03:46:18 ldp Exp $
  4.     $Log: waitport.c,v $
  5.     Revision 1.7  1997/01/01 03:46:18  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.6  1996/12/10 13:51:56  aros
  11.     Moved all #include's in the first column so makedepend can see it.
  12.  
  13.     Revision 1.5  1996/10/24 15:50:59  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.4  1996/08/13 13:56:10  digulla
  17.     Replaced AROS_LA by AROS_LHA
  18.     Replaced some AROS_LH*I by AROS_LH*
  19.     Sorted and added includes
  20.  
  21.     Revision 1.3  1996/08/01 17:41:22  digulla
  22.     Added standard header for all files
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include "exec_intern.h"
  28. #include <exec/ports.h>
  29. #include <aros/libcall.h>
  30. #include <proto/exec.h>
  31.  
  32. /*****************************************************************************
  33.  
  34.     NAME */
  35.  
  36.     AROS_LH1(struct Message *, WaitPort,
  37.  
  38. /*  SYNOPSIS */
  39.     AROS_LHA(struct MsgPort *, port, A0),
  40.  
  41. /*  LOCATION */
  42.     struct ExecBase *, SysBase, 64, Exec)
  43.  
  44. /*  FUNCTION
  45.     Wait until a message arrives at the given port. If there is already
  46.     a message in it this function returns immediately.
  47.  
  48.     INPUTS
  49.     port    - Pointer to messageport.
  50.  
  51.     RESULT
  52.     Pointer to the first message that arrived at the port. The message
  53.     is _not_ removed from the port. GetMsg() does this for you.
  54.  
  55.     NOTES
  56.  
  57.     EXAMPLE
  58.  
  59.     BUGS
  60.  
  61.     SEE ALSO
  62.     WaitPort(), GetMsg()
  63.  
  64.     INTERNALS
  65.  
  66.     HISTORY
  67.  
  68. ******************************************************************************/
  69. {
  70.     AROS_LIBFUNC_INIT
  71.  
  72.     /*
  73.     No Disable() necessary here since emptiness can be checked
  74.     without and nobody is allowed to change the signal bit as soon
  75.     as the current task entered WaitPort() (and probably did not yet
  76.     have a chance to Disable()).
  77.     */
  78.  
  79.     /* Is messageport empty? */
  80.     while(port->mp_MsgList.lh_Head->ln_Succ==NULL)
  81.     /*
  82.         Yes. Wait for the signal to arrive. Remember that signals may
  83.         arrive without a message so check again.
  84.     */
  85.     Wait(1<<port->mp_SigBit);
  86.  
  87.     /* Return the first node in the list. */
  88.     return (struct Message *)port->mp_MsgList.lh_Head;
  89.     AROS_LIBFUNC_EXIT
  90. }
  91.  
  92.