home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / library / createport.c < prev    next >
C/C++ Source or Header  |  1996-10-01  |  2KB  |  68 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  $Id: createport.c,v 1.2 1994/06/19 15:09:29 rluebbert Exp $
  20.  *
  21.  *  $Log: createport.c,v $
  22.  *  Revision 1.2  1994/06/19  15:09:29  rluebbert
  23.  *  *** empty log message ***
  24.  *
  25.  */
  26.  
  27. #define _KERNEL
  28. #include "ixemul.h"
  29. #include "kprintf.h"
  30.  
  31. #include <string.h>
  32.  
  33. #include <exec/ports.h>
  34.  
  35. struct MsgPort *
  36. CreatePort(unsigned char *name, long pri)
  37. {
  38.   int sigBit;
  39.   struct MsgPort *port;
  40.   
  41.   if ((sigBit = AllocSignal(-1)) == -1) return 0;
  42.   
  43.   port = (struct MsgPort *) kmalloc (sizeof (struct MsgPort));
  44.   if (! port)
  45.     {
  46.       FreeSignal (sigBit);
  47.       errno = ENOMEM;
  48.       KPRINTF (("&errno = %lx, errno = %ld\n", &errno, errno));
  49.       return 0;
  50.     }
  51.     
  52.   memset(port, 0, sizeof (struct MsgPort));
  53.   
  54.   port->mp_Node.ln_Name = (char *) name;
  55.   port->mp_Node.ln_Pri = pri;
  56.   port->mp_Node.ln_Type = NT_MSGPORT;
  57.   
  58.   port->mp_Flags = PA_SIGNAL;
  59.   port->mp_SigBit = sigBit;
  60.   port->mp_SigTask = FindTask (0);
  61.   
  62.   if (name)
  63.     AddPort (port);
  64.   else
  65.     NewList (&(port->mp_MsgList));  
  66.   return port;
  67. }
  68.