home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 122.lha / Arp_v1.1 / Libraries / Manx_SRC / _arpexit.c next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  1.2 KB  |  60 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, *MathIeeeDoubBasBase;
  14.  
  15. void (*_cln)();
  16.  
  17. _exit(code)
  18. {
  19.     long ret = code;
  20.     register int fd;
  21.  
  22.     if (_devtab) {
  23.         for (fd = 0 ; fd < _numdev ; fd++)
  24.             close(fd);
  25.     }
  26.     if (_cln)
  27.         (*_cln)();
  28.     if (MathTransBase)
  29.         _CloseLibrary(MathTransBase);
  30.     if (MathBase)
  31.         _CloseLibrary(MathBase);
  32.     if (MathIeeeDoubBasBase)
  33.         _CloseLibrary(MathIeeeDoubBasBase);
  34.     {
  35. #asm
  36.     mc68881
  37.     move.l    4,a6                ;get ExecBase
  38.     btst.b    #4,$129(a6)            ;check for 68881 flag in AttnFlags
  39.     beq        1$                    ;skip if not
  40.     move.l    a5,-(sp)
  41.     lea        2$,a5
  42.     jsr        -30(a6)                ;do it in supervisor mode
  43.     move.l    (sp)+,a5
  44.     bra        1$
  45. 2$
  46.     clr.l    -(sp)
  47.     frestore (sp)+                ;reset the ffp stuff
  48.     rte                            ;and return
  49. 1$
  50. #endasm
  51.     }
  52.     if (WBenchMsg)
  53.     {
  54.         _Forbid();
  55.         _ReplyMsg(WBenchMsg);
  56.     }
  57.     ArpExit( ret , 0L);    /* Exit, and free memory */
  58. }
  59.  
  60.