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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: putmsg.c,v 1.7 1997/01/01 03:46:13 ldp Exp $
  4.     $Log: putmsg.c,v $
  5.     Revision 1.7  1997/01/01 03:46:13  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.6  1996/12/10 13:51:50  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:54  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.4  1996/08/13 13:56:05  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:15  digulla
  22.     Added standard header for all files
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include "exec_intern.h"
  28. #include <aros/libcall.h>
  29. #include <exec/ports.h>
  30. #include <proto/exec.h>
  31.  
  32. /*****************************************************************************
  33.  
  34.     NAME */
  35.  
  36.     AROS_LH2(void, PutMsg,
  37.  
  38. /*  SYNOPSIS */
  39.     AROS_LHA(struct MsgPort *, port,    A0),
  40.     AROS_LHA(struct Message *, message, A1),
  41.  
  42. /*  LOCATION */
  43.     struct ExecBase *, SysBase, 61, Exec)
  44.  
  45. /*  FUNCTION
  46.     Sends a message to a given message port. Messages are not copied
  47.     from one task to another but must lie in shared memory instead.
  48.     Therefore the owner of the message may generally not reuse it before
  49.     it is returned. But this depends on the two tasks sharing the message.
  50.  
  51.     INPUTS
  52.     port    - Pointer to messageport.
  53.     message - Pointer to message.
  54.  
  55.     RESULT
  56.  
  57.     NOTES
  58.     It is legal to send a message from within interrupts.
  59.  
  60.     Messages may either trigger a signal at the owner of the messageport
  61.     or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
  62.  
  63.     EXAMPLE
  64.  
  65.     BUGS
  66.  
  67.     SEE ALSO
  68.     WaitPort(), GetMsg()
  69.  
  70.     INTERNALS
  71.  
  72.     HISTORY
  73.  
  74. ******************************************************************************/
  75. {
  76.     AROS_LIBFUNC_INIT
  77.  
  78.     /*
  79.     Messages may be sent from interrupts. Therefore the message list
  80.     of the message port must be protected with Disable().
  81.     */
  82.     Disable();
  83.  
  84.     /* Set the node type to NT_MESSAGE == sent message. */
  85.     message->mn_Node.ln_Type=NT_MESSAGE;
  86.  
  87.     /* Add it to the message list. */
  88.     AddTail(&port->mp_MsgList,&message->mn_Node);
  89.  
  90.     /* And trigger the action. */
  91.     switch(port->mp_Flags&PF_ACTION)
  92.     {
  93.     case PA_SIGNAL:
  94.     /* Send the signal */
  95.     Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
  96.     break;
  97.  
  98.     case PA_SOFTINT:
  99.     /* Raise a software interrupt */
  100.     Cause((struct Interrupt *)port->mp_SoftInt);
  101.     break;
  102.  
  103.     case PA_IGNORE:
  104.     /* Do nothing. */
  105.     break;
  106.     }
  107.  
  108.     /* All done. */
  109.     Enable();
  110.     AROS_LIBFUNC_EXIT
  111. }
  112.  
  113.