home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / setjmp.cpp < prev    next >
C/C++ Source or Header  |  1993-06-17  |  2KB  |  92 lines

  1. |
  2. | setjmp.cpp 
  3. |
  4.  
  5.     .globl ___mint
  6.  
  7. #ifdef __MBASE__
  8. #define Mint    __MBASE__@(___mint)
  9. #define Sigmask    __MBASE__@(__sigmask)
  10. #else
  11. #define Mint    ___mint
  12. #define Sigmask __sigmask
  13. #endif
  14.  
  15.     .text
  16.     .even
  17.     .globl _sigsetjmp
  18. _sigsetjmp:
  19.     movel    sp@(4), a0        | address of sigjmp_buf[]
  20. #ifdef __MSHORT__
  21.     movew    sp@(8), d0
  22.     extl    d0
  23. #else
  24.     movel    sp@(8), d0
  25. #endif
  26.     movel    d0, a0@(56)        | save sigmask for siglongjmp?
  27.     beq    SETJMP            | no -- call common code
  28.     movel    Sigmask, a0@(52)    | save tos emulation signal mask
  29. #ifdef __MSHORT__
  30.     tstw    Mint            | see if MiNT is active
  31. #else
  32.     tstl    Mint
  33. #endif
  34.     beq    SETJMP            | no -- call common code
  35.     movel    #0, sp@-        | add no signals to sigmask
  36.     movew    #0x116, sp@-        | Psigblock() system call
  37.     trap    #1            |
  38.     addqw    #6, sp
  39.     movel    d0, a0@(52)        | save MiNT signal mask
  40.     jmp    SETJMP            | call common code
  41.  
  42.     .globl _setjmp
  43. _setjmp:
  44.     movel    sp@(4),a0        | address of jmp_buf[]
  45.     movel    #0, a0@(56)        | do not restore sigmask on longjmp
  46. SETJMP:
  47.     movel    sp@,a0@            | save return address
  48.     moveml    d2-d7/a2-a7,a0@(4)    | save registers d2-d7/a2-a7
  49.     clrl    d0            | return value is 0
  50.     rts
  51.  
  52.     .globl _siglongjmp
  53. _siglongjmp:
  54.     .globl _longjmp
  55. _longjmp:
  56. #ifdef __MSHORT__
  57.     tstw    Mint            | see if MiNT is active
  58. #else
  59.     tstl    Mint
  60. #endif
  61.     beq    NOMINT            | no -- do not call sigreturn
  62.     movew    #0x11a, sp@-        | Psigreturn() system call
  63.     trap    #1            | (ignored if not in a sig handler)
  64.     addqw    #2, sp
  65. NOMINT:
  66.     movel    sp@(4),a0        | address of jmp_buf[]
  67.     tstl    a0@(56)            | want to restore sigmask?
  68.     beq    NORESTORE        | no -- skip restore code
  69.     movel    a0@(52), Sigmask    | restore tos emulation signal mask
  70. #ifdef __MSHORT__
  71.     tstw    Mint            | see if MiNT is active
  72. #else
  73.     tstl    Mint
  74. #endif
  75.     beq    NORESTORE        | no -- do not call sigsetmask
  76.     movel    a0@(52), sp@-        | restore signal mask
  77.     movew    #0x117, sp@-        | Psigsetmask() system call
  78.     trap    #1            |
  79.     addqw    #6, sp
  80. NORESTORE:
  81. #ifdef __MSHORT__
  82.     movew    sp@(8),d0        | value to return
  83. #else
  84.     movel    sp@(8),d0        | value to return
  85. #endif
  86.     bne    L1            | may not be 0
  87.     movl    #1, d0
  88. L1:
  89.     moveml    a0@(4),d2-d7/a2-a7    | restore saved reggies
  90.     movl    a0@,sp@            | and the saved return address
  91.     rts
  92.