home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u264.dms / in.adf / ARPPRO3.0 / PRO.RUN / _exit.c next >
Encoding:
C/C++ Source or Header  |  1992-04-18  |  1.7 KB  |  70 lines

  1. /* Created 11/08/87 by -=+SDB+=- from file provided by MANX */
  2. /* Copyright (C) 1987 by Scott Ballantyne */
  3. /* May be freely used by ARP supporters/users */
  4. /* If somebody were to modify the libraries to use ARP tracking, this would
  5.  * be even shorter (and so would the libraries)
  6.  */
  7.  
  8. #include <fcntl.h>
  9.  
  10. extern int _argc;
  11. extern char **_argv;
  12. extern struct WBStartup *WBenchMsg;
  13. extern void *MathBase, *MathTransBase;
  14. extern void *MathIeeeDoubBasBase, *MathIeeeDoubTransBase;
  15. extern void *_oldtrap, **_trapaddr;
  16.  
  17. void (*_cln)();
  18.  
  19. _exit(code)
  20. {
  21.     long ret = code;
  22.     register int fd;
  23.  
  24.     if (_devtab) {
  25.         for (fd = 0 ; fd < _numdev ; fd++)
  26.             close(fd);
  27.     }
  28.     if (_cln)               /* needed to block loading 2 instances of _exit() if c.lib/malloc() gets loaded instead */
  29.         (*_cln)();
  30. #if 0        /* is now Tracked */
  31.     if (_detach_curdir)                             /* for DETACHed programs */
  32.         UnLock(_detach_curdir);
  33. #endif
  34.     if (_trapaddr)                                  /* clean up signal handling */
  35.         *_trapaddr = _oldtrap;
  36.     if (MathTransBase)
  37.         _CloseLibrary(MathTransBase);
  38.     if (MathBase)
  39.         _CloseLibrary(MathBase);
  40.     if (MathIeeeDoubBasBase)
  41.         _CloseLibrary(MathIeeeDoubBasBase);
  42.     if (MathIeeeDoubTransBase)
  43.         _CloseLibrary(MathIeeeDoubTransBase);
  44.     {
  45. #asm
  46.     mc68881
  47.     move.l    4,a6                ;get ExecBase
  48.     btst.b    #4,$129(a6)                     ;check for 68881 flag in AttnFlags
  49.     beq        1$                    ;skip if not
  50.     move.l    a5,-(sp)
  51.     lea        2$,a5
  52.     jsr        -30(a6)                         ;do it in supervisor mode
  53.     move.l    (sp)+,a5
  54.     bra        1$
  55. 2$
  56.     clr.l    -(sp)
  57.     frestore (sp)+                          ;reset the ffp stuff
  58.     rte                            ;and return
  59. 1$
  60. #endasm
  61.     }
  62.     if (WBenchMsg)
  63.     {
  64.         _Forbid();
  65.         _ReplyMsg(WBenchMsg);
  66.     }
  67.     ArpExit( ret , 0L);     /* Exit, and free memory */
  68. }
  69.  
  70.