Provide the FreeBSD implementation for _UI_siglongjmp_cont on x86.
On FreeBSD, _NSIG is at least 128, so just pass a pointer to the
signal mask in the register.
Add my copyright.
diff --git a/src/setjmp/siglongjmp.c b/src/setjmp/siglongjmp.c
index ad35d26..4fee401 100644
--- a/src/setjmp/siglongjmp.c
+++ b/src/setjmp/siglongjmp.c
@@ -92,7 +92,8 @@
if (!resume_restores_sigmask (&c, wp) && wp[JB_MASK_SAVED])
{
/* sigmask was saved */
- if (UNW_NUM_EH_REGS < 4 || _NSIG >= 16 * sizeof (unw_word_t))
+#if defined(__linux__)
+ if (UNW_NUM_EH_REGS < 4 || _NSIG > 16 * sizeof (unw_word_t))
/* signal mask doesn't fit into EH arguments and we can't
put it on the stack without overwriting something
else... */
@@ -102,6 +103,12 @@
|| (_NSIG > 8 * sizeof (unw_word_t)
&& unw_set_reg (&c, UNW_REG_EH + 3, wp[JB_MASK + 1]) < 0))
abort ();
+#elif defined(__FreeBSD__)
+ if (unw_set_reg (&c, UNW_REG_EH + 2, &wp[JB_MASK]) < 0)
+ abort();
+#else
+#error Port me
+#endif
cont = &_UI_siglongjmp_cont;
}
diff --git a/src/x86/siglongjmp.S b/src/x86/siglongjmp.S
index b283aa2..32bba3b 100644
--- a/src/x86/siglongjmp.S
+++ b/src/x86/siglongjmp.S
@@ -1,6 +1,7 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+ Copyright (C) 2011 Konstantin Belousov <kib@FreeBSD.org>
This file is part of libunwind.
@@ -25,7 +26,11 @@
.globl _UI_siglongjmp_cont
+#if defined(__linux__)
#define SIG_SETMASK 2
+#elif defined(__FreeBSD__)
+#define SIG_SETMASK 3
+#endif
/* Stack layout at this point:
@@ -39,6 +44,7 @@
.type _UI_siglongjmp_cont, @function
_UI_siglongjmp_cont:
.cfi_startproc
+#ifdef __linux__
.cfi_register 8, 0 /* IP saved in EAX */
.cfi_def_cfa_offset 8
mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */
@@ -64,6 +70,22 @@
lea 8(%esp), %esp /* pop sigmask */
.cfi_adjust_cfa_offset -4
jmp *%edx
+#elif defined(__FreeBSD__)
+ pushl %eax
+ pushl %edx
+ pushl $0
+ pushl %ecx
+ pushl $SIG_SETMASK
+ movl $340,%eax
+ pushl %eax
+ int $0x80
+ addl $16,%esp
+ popl %eax
+ popl %edx
+ jmp *%edx
+#else
+#error Port me
+#endif
.cfi_endproc
.size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont
/* We do not need executable stack. */