home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff290.lzh / IPC / IPC_Lib_Sources / LibFuncs.c < prev    next >
C/C++ Source or Header  |  1989-12-11  |  4KB  |  116 lines

  1. /*******************************************************************
  2.  *                                                                 *
  3.  *                           LibFuncs.c                            *
  4.  *                                                                 *
  5.  *           Basic Shared Library Functions                        *
  6.  *           for IPC Library Module                                *
  7.  *                                                                 *
  8.  *              Release  2.0 -- 1989 March 26                      *
  9.  *                                                                 *
  10.  *              Copyright 1988,1989 Peter Goodeve                  *
  11.  *                                                                 *
  12.  *  This source is freely distributable, but its functionality     *
  13.  *  should not be modified without prior consultation with the     *
  14.  *  author.  [Don't forget this is a SHARED library!]              *
  15.  *                                                                 *
  16.  *******************************************************************/
  17.  
  18. /*******************************************************************
  19.  *                                                                 *
  20.  *   This code has only been tested under Lattice 5.02.            *
  21.  *   It MUST be compiled with -b0 -v options                       *
  22.  *   (32 bit addressing & no stack check).                         *
  23.  *   The "__asm" keyword and associated mechanisms have been used  *
  24.  *   to allow direct passing of parameters in registers.           *
  25.  *                                                                 *
  26.  ******************************************************************/
  27.  
  28. /* As we're restricted to Lattice 5, use direct Exec calls: */
  29. #include <proto/exec.h>
  30.  
  31. #include <exec/types.h>
  32. #include <exec/libraries.h>
  33. #include <exec/memory.h>
  34. #include <exec/tasks.h>
  35.  
  36.  
  37.  
  38. /* In this version we are using direct addressing of global data exclusively,
  39.     so we don't bother to use the library structure for private data */
  40.  
  41. extern struct List PortList;  /* (IPCLib.c) All IPC Ports are on this list */
  42.  
  43. extern APTR SysBase; /* ...in c.o -- or LibTag if autoload */
  44.  
  45. extern UWORD libVersion;    /* in LibTables -- update as necessary */
  46. extern UWORD libRev;
  47.  
  48. APTR   seglist=NULL;
  49.  
  50.  
  51.  
  52. struct library * __asm libInitFunc(
  53.         register __a0 APTR seg, register __a6 APTR sys,
  54.         register __d0 struct Library * libp)
  55. {
  56.     SysBase = sys;
  57.     seglist=seg;
  58.     libp->lib_Version = libVersion;
  59.     libp->lib_Revision = libRev;
  60.  
  61.     NewList(&PortList);
  62.  
  63.     return libp;
  64. }
  65.  
  66.  
  67. struct Library * __asm libOpen(register __a6 struct Library * libp)
  68. {
  69.     libp->lib_OpenCnt++;
  70.     libp->lib_Flags &= ~LIBF_DELEXP;
  71.     return libp;
  72. }
  73.  
  74.  
  75. /* This is put first to avoid forward ref: */
  76. APTR __asm libExpunge(register __a6 struct Library * libp)
  77. {
  78.     char * lib_base;    /* generic pointer to be calculated */
  79.     if (libp->lib_OpenCnt) {
  80.         libp->lib_Flags |= LIBF_DELEXP;
  81.         return 0;
  82.     }
  83.  
  84.     /******************************************************/
  85.     /* IPC library must also check that there are no IPC Ports
  86.     on the list before allowing Expunge */
  87.  
  88.     if (PortList.lh_Head->ln_Succ) return 0;
  89.  
  90.     /******************************************************/
  91.  
  92.     /* CAUTION!: compiler generated code MUST use either SysBase
  93.        or AbsExecBase for access to the following! */
  94.     Remove((struct Node *)libp);
  95.     lib_base = ((char *)libp)-libp->lib_NegSize;
  96.     FreeMem(lib_base, (libp->lib_NegSize + libp->lib_PosSize));
  97.     return seglist;   /* for now */
  98. }
  99.  
  100.  
  101. APTR __asm libClose(register __a6 struct Library * libp)
  102. {
  103.     if (--libp->lib_OpenCnt || !(libp->lib_Flags & LIBF_DELEXP)) return 0;
  104.     else return libExpunge(libp);
  105. }
  106.  
  107.  
  108. ULONG libExtFunc()
  109. {
  110.     return 0;
  111. }
  112.  
  113.  
  114.             /*********************************************/
  115.  
  116.