home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Mint
/
mntlib32.zoo
/
setjmp.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-17
|
2KB
|
92 lines
|
| setjmp.cpp
|
.globl ___mint
#ifdef __MBASE__
#define Mint __MBASE__@(___mint)
#define Sigmask __MBASE__@(__sigmask)
#else
#define Mint ___mint
#define Sigmask __sigmask
#endif
.text
.even
.globl _sigsetjmp
_sigsetjmp:
movel sp@(4), a0 | address of sigjmp_buf[]
#ifdef __MSHORT__
movew sp@(8), d0
extl d0
#else
movel sp@(8), d0
#endif
movel d0, a0@(56) | save sigmask for siglongjmp?
beq SETJMP | no -- call common code
movel Sigmask, a0@(52) | save tos emulation signal mask
#ifdef __MSHORT__
tstw Mint | see if MiNT is active
#else
tstl Mint
#endif
beq SETJMP | no -- call common code
movel #0, sp@- | add no signals to sigmask
movew #0x116, sp@- | Psigblock() system call
trap #1 |
addqw #6, sp
movel d0, a0@(52) | save MiNT signal mask
jmp SETJMP | call common code
.globl _setjmp
_setjmp:
movel sp@(4),a0 | address of jmp_buf[]
movel #0, a0@(56) | do not restore sigmask on longjmp
SETJMP:
movel sp@,a0@ | save return address
moveml d2-d7/a2-a7,a0@(4) | save registers d2-d7/a2-a7
clrl d0 | return value is 0
rts
.globl _siglongjmp
_siglongjmp:
.globl _longjmp
_longjmp:
#ifdef __MSHORT__
tstw Mint | see if MiNT is active
#else
tstl Mint
#endif
beq NOMINT | no -- do not call sigreturn
movew #0x11a, sp@- | Psigreturn() system call
trap #1 | (ignored if not in a sig handler)
addqw #2, sp
NOMINT:
movel sp@(4),a0 | address of jmp_buf[]
tstl a0@(56) | want to restore sigmask?
beq NORESTORE | no -- skip restore code
movel a0@(52), Sigmask | restore tos emulation signal mask
#ifdef __MSHORT__
tstw Mint | see if MiNT is active
#else
tstl Mint
#endif
beq NORESTORE | no -- do not call sigsetmask
movel a0@(52), sp@- | restore signal mask
movew #0x117, sp@- | Psigsetmask() system call
trap #1 |
addqw #6, sp
NORESTORE:
#ifdef __MSHORT__
movew sp@(8),d0 | value to return
#else
movel sp@(8),d0 | value to return
#endif
bne L1 | may not be 0
movl #1, d0
L1:
moveml a0@(4),d2-d7/a2-a7 | restore saved reggies
movl a0@,sp@ | and the saved return address
rts