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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createmsgport.c,v 1.7 1997/01/08 04:07:58 ldp Exp $
  4.     $Log: createmsgport.c,v $
  5.     Revision 1.7  1997/01/08 04:07:58  ldp
  6.     Set port type
  7.  
  8.     Revision 1.6  1997/01/01 03:46:08  ldp
  9.     Committed Amiga native (support) code
  10.  
  11.     Changed clib to proto
  12.  
  13.     Revision 1.5  1996/12/10 13:51:42  aros
  14.     Moved all #include's in the first column so makedepend can see it.
  15.  
  16.     Revision 1.4  1996/10/24 15:50:46  aros
  17.     Use the official AROS macros over the __AROS versions.
  18.  
  19.     Revision 1.3  1996/08/01 17:41:08  digulla
  20.     Added standard header for all files
  21.  
  22.     Desc:
  23.     Lang: english
  24. */
  25. #include <exec/memory.h>
  26. #include <exec/ports.h>
  27. #include <exec/execbase.h>
  28. #include <aros/libcall.h>
  29. #include <proto/exec.h>
  30.  
  31. /*****************************************************************************
  32.  
  33.     NAME */
  34.  
  35.     AROS_LH0(struct MsgPort *, CreateMsgPort,
  36.  
  37. /*  SYNOPSIS */
  38.  
  39. /*  LOCATION */
  40.     struct ExecBase *, SysBase, 111, Exec)
  41.  
  42. /*  FUNCTION
  43.     Create a new message port. A signal will be allocated and the message
  44.     port set to signal you task
  45.  
  46.     INPUTS
  47.  
  48.     RESULT
  49.     Pointer to messageport structure
  50.  
  51.     NOTES
  52.  
  53.     EXAMPLE
  54.  
  55.     BUGS
  56.  
  57.     SEE ALSO
  58.  
  59.     INTERNALS
  60.  
  61.     HISTORY
  62.  
  63. ******************************************************************************/
  64. {
  65.     AROS_LIBFUNC_INIT
  66.  
  67.     struct MsgPort *ret;
  68.  
  69.     /* Allocate memory for struct MsgPort */
  70.     ret=(struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
  71.     if(ret!=NULL)
  72.     {
  73.     BYTE sb;
  74.  
  75.     /* Allocate a signal bit */
  76.     sb=AllocSignal(-1);
  77.     if(sb!=-1)
  78.     {
  79.         /* Initialize messageport structure. First set signal bit. */
  80.         ret->mp_SigBit=sb;
  81.  
  82.         /* Clear the list of messages */
  83.         ret->mp_MsgList.lh_Head=(struct Node *)&ret->mp_MsgList.lh_Tail;
  84.         /* ret->mp_MsgList.lh_Tail=NULL; */
  85.         ret->mp_MsgList.lh_TailPred=(struct Node *)&ret->mp_MsgList.lh_Head;
  86.  
  87.         /* Set port to type 'signalling' */
  88.         ret->mp_Flags=PA_SIGNAL;
  89.  
  90.         /* Set port to type MsgPort */
  91.         ret->mp_Node.ln_Type = NT_MSGPORT;
  92.  
  93.         /* Finally set task to send the signal to. */
  94.         ret->mp_SigTask=SysBase->ThisTask;
  95.  
  96.         /* Now the port is ready for use. */
  97.         return ret;
  98.     }
  99.     /* Couldn't get the signal bit. Free the memory. */
  100.     FreeMem(ret,sizeof(struct MsgPort));
  101.     }
  102.     /* function failed */
  103.     return NULL;
  104.     AROS_LIBFUNC_EXIT
  105. } /* CreateMsgPort */
  106.  
  107.