{
CONTEXT cx;
bool interrupted = false;
- bool locked = false;
if (tls->sig)
{
for (int i = 0; i < CALL_HANDLER_RETRY; i++)
{
tls->lock ();
- locked = true;
- if (tls->stackptr > tls->stack)
+ if (tls->incyg || tls->in_exception ())
{
tls->reset_exception ();
tls->interrupt_setup (sig, handler, siga);
sigproc_printf ("interrupted known cygwin routine");
interrupted = true;
+ tls->unlock ();
break;
}
tls->unlock ();
- locked = false;
DWORD res;
HANDLE hth = (HANDLE) *tls;
since we don't want to stall the signal handler. FIXME: Will this result in
noticeable delays?
If the thread is already suspended (which can occur when a program has called
- SuspendThread on itself then just queue the signal. */
+ SuspendThread on itself) then just queue the signal. */
#ifndef DEBUGGING
sigproc_printf ("suspending mainthread");
#endif
res = SuspendThread (hth);
/* Just set pending if thread is already suspended */
- if (res || tls->stackptr > tls->stack)
+ if (res || tls->incyg)
{
(void) ResumeThread (hth);
break;
}
out:
- if (locked)
- tls->unlock ();
if (interrupted && tls->event)
{
HANDLE h = tls->event;
sigset_t this_oldmask = oldmask;
int this_errno = saved_errno;
set_process_mask (newmask);
+ incyg--;
sig = 0;
sigfunc (thissig);
+ incyg++;
set_process_mask (this_oldmask);
if (this_errno >= 0)
set_errno (this_errno);
movl \$1,%eax # potential lock value
lock xchgl %eax,$tls::stacklock(%edx) # see if we can grab it
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
- orl %eax,%eax # it will be zero
+ testl %eax,%eax # it will be zero
jz 2f # if so
xorl %eax,%eax # nope. It was not zero
call _low_priority_sleep # should be a short-time thing, so
jmp 1b # sleep and loop
-2: movl \$4,%eax # have the lock, now increment the
+2: incl $tls::incyg(%edx)
+ movl \$4,%eax # have the lock, now increment the
xadd %eax,$tls::stackptr(%edx) # stack pointer and get pointer
leal __sigbe,%ebx # new place to return to
xchgl %ebx,12(%esp) # exchange with real return value
movl \$1,%eax # potential lock value
lock xchgl %eax,$tls::stacklock(%edx) # see if we can grab it
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
- orl %eax,%eax # it will be zero
+ testl %eax,%eax # it will be zero
jz 2f # if so
xorl %eax,%eax # nope. not zero
call _low_priority_sleep # sleep
xorl %ebx,%ebx
xchgl %ebx,-4(%eax) # get return address from signal stack
xchgl %ebx,8(%esp) # restore ebx/real return address
+ decl $tls::incyg(%edx)
decl $tls::stacklock(%edx) # release lock
popl %eax
popl %edx
movl \$1,%eax # potential lock value
lock xchgl %eax,$tls::stacklock(%edx) # see if we can grab it
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
- orl %eax,%eax # it will be zero
+ testl %eax,%eax # it will be zero
jz 2f # if so
xorl %eax,%eax # nope. not zero
call _low_priority_sleep # sleep
movl %eax,%edi
1: movl \$1,%eax
lock xchgl %eax,$tls::pstacklock(%edi)
- orl %eax,%eax
+ testl %eax,%eax
jz 2f
xorl %eax,%eax
call _low_priority_sleep
movl \$1,%eax
lock xchgl %eax,$tls::stacklock(%edx)
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
- orl %eax,%eax
+ testl %eax,%eax
jz 2f
xorl %eax,%eax
call _low_priority_sleep
//;# autogenerated: Do not edit.
-//; $tls::sizeof__cygtls = 3744;
-//; $tls::func = -3744;
+//; $tls::sizeof__cygtls = 3748;
+//; $tls::func = -3748;
//; $tls::pfunc = 0;
-//; $tls::saved_errno = -3740;
+//; $tls::saved_errno = -3744;
//; $tls::psaved_errno = 4;
-//; $tls::sa_flags = -3736;
+//; $tls::sa_flags = -3740;
//; $tls::psa_flags = 8;
-//; $tls::oldmask = -3732;
+//; $tls::oldmask = -3736;
//; $tls::poldmask = 12;
-//; $tls::newmask = -3728;
+//; $tls::newmask = -3732;
//; $tls::pnewmask = 16;
-//; $tls::event = -3724;
+//; $tls::event = -3728;
//; $tls::pevent = 20;
-//; $tls::errno_addr = -3720;
+//; $tls::errno_addr = -3724;
//; $tls::perrno_addr = 24;
-//; $tls::initialized = -3716;
+//; $tls::initialized = -3720;
//; $tls::pinitialized = 28;
-//; $tls::sigmask = -3712;
+//; $tls::sigmask = -3716;
//; $tls::psigmask = 32;
-//; $tls::sigwait_mask = -3708;
+//; $tls::sigwait_mask = -3712;
//; $tls::psigwait_mask = 36;
-//; $tls::sigwait_info = -3704;
+//; $tls::sigwait_info = -3708;
//; $tls::psigwait_info = 40;
-//; $tls::threadkill = -3700;
+//; $tls::threadkill = -3704;
//; $tls::pthreadkill = 44;
-//; $tls::infodata = -3696;
+//; $tls::infodata = -3700;
//; $tls::pinfodata = 48;
-//; $tls::tid = -3548;
+//; $tls::tid = -3552;
//; $tls::ptid = 196;
-//; $tls::local_clib = -3544;
+//; $tls::local_clib = -3548;
//; $tls::plocal_clib = 200;
-//; $tls::locals = -2616;
+//; $tls::locals = -2620;
//; $tls::plocals = 1128;
-//; $tls::prev = -1048;
+//; $tls::prev = -1052;
//; $tls::pprev = 2696;
-//; $tls::next = -1044;
+//; $tls::next = -1048;
//; $tls::pnext = 2700;
-//; $tls::stackptr = -1040;
+//; $tls::stackptr = -1044;
//; $tls::pstackptr = 2704;
-//; $tls::sig = -1036;
+//; $tls::sig = -1040;
//; $tls::psig = 2708;
-//; $tls::stacklock = -1032;
+//; $tls::stacklock = -1036;
//; $tls::pstacklock = 2712;
-//; $tls::spinning = -1028;
+//; $tls::spinning = -1032;
//; $tls::pspinning = 2716;
+//; $tls::incyg = -1028;
+//; $tls::pincyg = 2720;
//; $tls::stack = -1024;
-//; $tls::pstack = 2720;
+//; $tls::pstack = 2724;
//; $tls::padding = 0;
-//; $tls::ppadding = 3744;
+//; $tls::ppadding = 3748;
//; __DATA__
-#define tls_func (-3744)
+#define tls_func (-3748)
#define tls_pfunc (0)
-#define tls_saved_errno (-3740)
+#define tls_saved_errno (-3744)
#define tls_psaved_errno (4)
-#define tls_sa_flags (-3736)
+#define tls_sa_flags (-3740)
#define tls_psa_flags (8)
-#define tls_oldmask (-3732)
+#define tls_oldmask (-3736)
#define tls_poldmask (12)
-#define tls_newmask (-3728)
+#define tls_newmask (-3732)
#define tls_pnewmask (16)
-#define tls_event (-3724)
+#define tls_event (-3728)
#define tls_pevent (20)
-#define tls_errno_addr (-3720)
+#define tls_errno_addr (-3724)
#define tls_perrno_addr (24)
-#define tls_initialized (-3716)
+#define tls_initialized (-3720)
#define tls_pinitialized (28)
-#define tls_sigmask (-3712)
+#define tls_sigmask (-3716)
#define tls_psigmask (32)
-#define tls_sigwait_mask (-3708)
+#define tls_sigwait_mask (-3712)
#define tls_psigwait_mask (36)
-#define tls_sigwait_info (-3704)
+#define tls_sigwait_info (-3708)
#define tls_psigwait_info (40)
-#define tls_threadkill (-3700)
+#define tls_threadkill (-3704)
#define tls_pthreadkill (44)
-#define tls_infodata (-3696)
+#define tls_infodata (-3700)
#define tls_pinfodata (48)
-#define tls_tid (-3548)
+#define tls_tid (-3552)
#define tls_ptid (196)
-#define tls_local_clib (-3544)
+#define tls_local_clib (-3548)
#define tls_plocal_clib (200)
-#define tls_locals (-2616)
+#define tls_locals (-2620)
#define tls_plocals (1128)
-#define tls_prev (-1048)
+#define tls_prev (-1052)
#define tls_pprev (2696)
-#define tls_next (-1044)
+#define tls_next (-1048)
#define tls_pnext (2700)
-#define tls_stackptr (-1040)
+#define tls_stackptr (-1044)
#define tls_pstackptr (2704)
-#define tls_sig (-1036)
+#define tls_sig (-1040)
#define tls_psig (2708)
-#define tls_stacklock (-1032)
+#define tls_stacklock (-1036)
#define tls_pstacklock (2712)
-#define tls_spinning (-1028)
+#define tls_spinning (-1032)
#define tls_pspinning (2716)
+#define tls_incyg (-1028)
+#define tls_pincyg (2720)
#define tls_stack (-1024)
-#define tls_pstack (2720)
+#define tls_pstack (2724)
#define tls_padding (0)
-#define tls_ppadding (3744)
+#define tls_ppadding (3748)