home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / __unlock.c,v < prev    next >
Encoding:
Text File  |  1992-08-09  |  3.8 KB  |  184 lines

  1. head    1.3;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.3
  10. date    92.08.09.20.40.01;    author amiga;    state Exp;
  11. branches;
  12. next    1.2;
  13.  
  14. 1.2
  15. date    92.07.28.02.50.59;    author mwild;    state Exp;
  16. branches;
  17. next    1.1;
  18.  
  19. 1.1
  20. date    92.05.14.19.55.40;    author mwild;    state Exp;
  21. branches;
  22. next    ;
  23.  
  24.  
  25. desc
  26. @UnLock() and Close() replacements
  27. @
  28.  
  29.  
  30. 1.3
  31. log
  32. @change to use 2.x header files by default
  33. @
  34. text
  35. @/*
  36.  *  This file is part of ixemul.library for the Amiga.
  37.  *  Copyright (C) 1991, 1992  Markus M. Wild
  38.  *
  39.  *  This library is free software; you can redistribute it and/or
  40.  *  modify it under the terms of the GNU Library General Public
  41.  *  License as published by the Free Software Foundation; either
  42.  *  version 2 of the License, or (at your option) any later version.
  43.  *
  44.  *  This library is distributed in the hope that it will be useful,
  45.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  46.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  47.  *  Library General Public License for more details.
  48.  *
  49.  *  You should have received a copy of the GNU Library General Public
  50.  *  License along with this library; if not, write to the Free
  51.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  52.  *
  53.  *  $Id: __unlock.c,v 1.2 1992/07/28 02:50:59 mwild Exp $
  54.  *
  55.  *  $Log: __unlock.c,v $
  56.  *  Revision 1.2  1992/07/28  02:50:59  mwild
  57.  *  call FreeDosObject instead of kfree() when > 1.3
  58.  *
  59.  *  Revision 1.1  1992/05/14  19:55:40  mwild
  60.  *  Initial revision
  61.  *
  62.  */
  63.  
  64. #define KERNEL
  65. #include "ixemul.h"
  66.  
  67.  
  68. extern int _dos20;
  69.  
  70.  
  71. #if __GNUC__ != 2
  72. #define alloca __builtin_alloca
  73. #endif
  74.  
  75. int
  76. __unlock (BPTR lock)
  77. {
  78.   struct StandardPacket *sp;
  79.   
  80.   sp = alloca(sizeof(*sp)+2);
  81.   sp = LONG_ALIGN (sp);
  82.   __init_std_packet(sp);
  83.  
  84.   sp->sp_Pkt.dp_Port = u.u_sync_mp;
  85.   sp->sp_Pkt.dp_Type = ACTION_FREE_LOCK;
  86.   sp->sp_Pkt.dp_Arg1 = lock;
  87.  
  88.   PutPacket (((struct FileLock *)BTOCPTR (lock))->fl_Task, sp);
  89.   __wait_sync_packet (sp);
  90.   
  91.   /* set up Result2 so that the IoErr() works */
  92.   ((struct Process *)FindTask (0))->pr_Result2 = sp->sp_Pkt.dp_Res2;
  93.  
  94.   return sp->sp_Pkt.dp_Res1;
  95. }
  96.  
  97. /* ATTENTION: name-clash between sysio-__close and DOS-__Close !! */
  98. int
  99. __Close (BPTR fh)
  100. {
  101.   struct StandardPacket *sp;
  102.   struct FileHandle *fhp = BTOCPTR (fh);
  103.   
  104.   /* only do this is not closing a dummy NIL: filehandle */
  105.   if (fhp->fh_Type)
  106.     {
  107.       sp = alloca(sizeof(*sp)+2);
  108.       sp = LONG_ALIGN (sp);
  109.       __init_std_packet(sp);
  110.  
  111.       sp->sp_Pkt.dp_Port = u.u_sync_mp;
  112.       sp->sp_Pkt.dp_Type = ACTION_END;
  113.       sp->sp_Pkt.dp_Arg1 = fhp->fh_Arg1;
  114.  
  115.       PutPacket (fhp->fh_Type, sp);
  116.       __wait_sync_packet (sp);
  117.     }
  118.   
  119.   if (! _dos20)
  120.     {
  121.       /* free our filehandle. skip over the hidden length-field at the
  122.        * start */
  123.       kfree (((unsigned long *)fhp) - 1);
  124.     }
  125.   else
  126.     FreeDosObject (DOS_FILEHANDLE, fhp);
  127.  
  128.   /* set up Result2 so that the IoErr() works */
  129.   ((struct Process *)FindTask (0))->pr_Result2 = sp->sp_Pkt.dp_Res2;
  130.  
  131.   return sp->sp_Pkt.dp_Res1;
  132. }
  133. @
  134.  
  135.  
  136. 1.2
  137. log
  138. @call FreeDosObject instead of kfree() when > 1.3
  139. @
  140. text
  141. @d19 1
  142. a19 1
  143.  *  $Id: __unlock.c,v 1.1 1992/05/14 19:55:40 mwild Exp $
  144. d22 3
  145. a32 17
  146. #define BASE_EXT_DECL
  147. #define BASE_PAR_DECL    
  148. #define BASE_PAR_DECL0    
  149. #define BASE_NAME    ix.ix_dos_base
  150. static __inline void 
  151. FreeDosObject (BASE_PAR_DECL unsigned long type,APTR ptr)
  152. {
  153.   BASE_EXT_DECL
  154.   register struct DosLibrary *a6 __asm("a6") = BASE_NAME;
  155.   register unsigned long d1 __asm("d1") = type;
  156.   register APTR d2 __asm("d2") = ptr;
  157.   __asm __volatile ("jsr a6@@(-0xea)"
  158.   : /* no output */
  159.   : "r" (a6), "r" (d1), "r" (d2)
  160.   : "a0","a1","d0","d1","d2", "memory");
  161. }
  162. #define DOS_FILEHANDLE    0
  163. @
  164.  
  165.  
  166. 1.1
  167. log
  168. @Initial revision
  169. @
  170. text
  171. @d19 1
  172. a19 1
  173.  *  $Id$
  174. d21 4
  175. a24 1
  176.  *  $Log$
  177. d30 21
  178. d99 8
  179. a106 3
  180.   /* free our filehandle. skip over the hidden length-field at the
  181.    * start */
  182.   kfree (((unsigned long *)fhp) - 1);
  183. @
  184.