1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/libc/x86/setjmp.S

108 lines
2.6 KiB
ArmAsm
Raw Normal View History

2012-09-28 18:36:46 -04:00
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
This file is part of the Sortix C Library.
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.
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.
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/>.
x86/setjmp.S
2013-03-31 09:00:12 -04:00
Implement the assembly part of setjmp.
2012-09-28 18:36:46 -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:
# 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
.size sigsetjmp, . - sigsetjmp
2013-03-31 09:00:12 -04:00
.global longjmp
.type longjmp, @function
longjmp:
jmp siglongjmp
2013-03-31 09:00:12 -04:00
.size longjmp, . - longjmp
.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