2012-09-28 18:36:46 -04:00
|
|
|
/*******************************************************************************
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-08-04 14:24:59 -04:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
This file is part of the Sortix C Library.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-12-28 15:00:15 -05:00
|
|
|
x86/setjmp.S
|
2013-03-31 09:00:12 -04:00
|
|
|
Implement the assembly part of setjmp.
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2012-09-28 18:36:46 -04:00
|
|
|
*******************************************************************************/
|
2012-03-04 17:15:32 -05:00
|
|
|
|
2013-08-04 14:24:59 -04:00
|
|
|
#define SIG_SETMASK 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sigjmp_buf[0] = %ebx
|
|
|
|
* sigjmp_buf[1] = %esi
|
|
|
|
* sigjmp_buf[2] = %edi
|
|
|
|
* sigjmp_buf[3] = %ebp
|
|
|
|
* sigjmp_buf[4] = %esp
|
|
|
|
* sigjmp_buf[5] = <return-address>
|
|
|
|
* sigjmp_buf[6] = <non-zero if sigmask saved>
|
|
|
|
* sigjmp_buf[7...] = <saved sigmask if sigjmp_buf[6] != 0>
|
|
|
|
*/
|
|
|
|
|
2013-03-31 09:00:12 -04:00
|
|
|
.global setjmp
|
|
|
|
.type setjmp, @function
|
|
|
|
setjmp:
|
2013-08-04 14:24:59 -04:00
|
|
|
# setjmp saves the signal mask on Sortix
|
|
|
|
jmp 1f
|
|
|
|
.size setjmp, . - setjmp
|
|
|
|
|
|
|
|
.global sigsetjmp
|
|
|
|
.type sigsetjmp, @function
|
|
|
|
sigsetjmp:
|
|
|
|
movl 8(%esp), %edx
|
|
|
|
testl %edx, %edx
|
|
|
|
jz 2f
|
|
|
|
1: movl 4(%esp), %ecx
|
|
|
|
leal (7 * 4)(%ecx), %edx
|
|
|
|
pushl %edx # oldset
|
|
|
|
pushl $0 # set
|
|
|
|
pushl $0 # how (ignored because set is NULL)
|
|
|
|
call sigprocmask
|
|
|
|
addl $(3 * 4), %esp
|
|
|
|
movl $1, %edx
|
|
|
|
2: movl 4(%esp), %ecx
|
|
|
|
movl 0(%esp), %eax
|
|
|
|
movl %ebx, (0 * 4)(%ecx)
|
|
|
|
movl %esi, (1 * 4)(%ecx)
|
|
|
|
movl %edi, (2 * 4)(%ecx)
|
|
|
|
movl %ebp, (3 * 4)(%ecx)
|
|
|
|
movl %esp, (4 * 4)(%ecx)
|
|
|
|
movl %eax, (5 * 4)(%ecx)
|
|
|
|
movl %edx, (6 * 4)(%ecx)
|
2013-03-31 09:00:12 -04:00
|
|
|
xorl %eax, %eax
|
|
|
|
ret
|
2013-08-04 14:24:59 -04:00
|
|
|
.size sigsetjmp, . - sigsetjmp
|
2013-03-31 09:00:12 -04:00
|
|
|
|
|
|
|
.global longjmp
|
|
|
|
.type longjmp, @function
|
|
|
|
longjmp:
|
2013-08-04 14:24:59 -04:00
|
|
|
jmp siglongjmp
|
2013-03-31 09:00:12 -04:00
|
|
|
.size longjmp, . - longjmp
|
2013-08-04 14:24:59 -04:00
|
|
|
|
|
|
|
.global siglongjmp
|
|
|
|
.type siglongjmp, @function
|
|
|
|
siglongjmp:
|
|
|
|
movl 4(%esp), %ecx
|
|
|
|
movl 8(%esp), %eax
|
|
|
|
testl %eax, %eax
|
|
|
|
jnz 1f
|
|
|
|
movl $1, %eax
|
|
|
|
1: movl (6 * 4)(%ecx), %edx
|
|
|
|
testl %edx, %edx
|
|
|
|
jz 2f
|
|
|
|
pushl %eax
|
|
|
|
pushl %ecx
|
|
|
|
pushl $0 # oldset
|
|
|
|
leal (7 * 4)(%ecx), %edx
|
|
|
|
pushl %edx # set
|
|
|
|
pushl $SIG_SETMASK # how
|
|
|
|
call sigprocmask
|
|
|
|
addl $(3 * 4), %esp
|
|
|
|
popl %ecx
|
|
|
|
popl %eax
|
|
|
|
2: movl (0 * 4)(%ecx), %ebx
|
|
|
|
movl (1 * 4)(%ecx), %esi
|
|
|
|
movl (2 * 4)(%ecx), %edi
|
|
|
|
movl (3 * 4)(%ecx), %ebp
|
|
|
|
movl (4 * 4)(%ecx), %esp
|
|
|
|
movl (5 * 4)(%ecx), %edx
|
|
|
|
movl %edx, 0(%esp)
|
|
|
|
ret
|
|
|
|
.size siglongjmp, . - siglongjmp
|