+2004-03-08 Christopher Faylor <cgf@redhat.com>
+
+ * exceptions.cc (setup_handler): Avoid suspending a thread if it in a
+ cygwin function, in an exception, spinning, or locked.
+ * gendef (_sigfe): Move incyg setting earlier.
+ (sigreturn): Set incyg flag to avoid interrupting called cygwin
+ functions.
+ (sigdelayed): Ditto.
+ (stabilize_sig_stack): Ditto.
+
+ * sigproc.cc (proc_subproc): Don't restore process lock early in exec
+ case.
+
+ * cygtls.h: Reorganize fields in _cygtls slightly.
+ * tlsoffsets.h: Regenerate.
+
2004-03-06 Christopher Faylor <cgf@redhat.com>
* fork.cc (fork_parent): Save parent pid in a temporary variable since
feedback.
(semaphore::wait): Return return value from semaphore::_wait.
* thread.h (WAIT_SIGNALED): New definition.
- (pthread::cancelable_wait): Change declaration. Define do_sig_wait
+ (pthread::cancelable_wait): Change declaration. Define do_sig_wait
as false by default to not interfere with existing calls accidentally.
(semaphore::_wait): Declare int.
pushl %ebx
pushl %edx
1: movl %fs:4,%edx # location of bottom of stack
+ incl $tls::incyg(%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
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: incl $tls::incyg(%edx)
- movl \$4,%eax # have the lock, now increment the
+2: 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
.global _sigreturn
.stabs "sigreturn:F(0,1)",36,0,0,_sigreturn
_sigreturn:
+ movl %fs:4,%ebx
+ incl $tls::incyg(%ebx)
addl \$4,%esp # Remove argument
call _set_process_mask\@4
-1: movl %fs:4,%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
+1: movl \$1,%eax # potential lock value
+ lock xchgl %eax,$tls::stacklock(%ebx) # see if we can grab it
+ movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock
testl %eax,%eax # it will be zero
jz 2f # if so
xorl %eax,%eax # nope. not zero
call _low_priority_sleep # sleep
jmp 1b # and loop
-2: popl %ebx # saved errno
- testl %ebx,%ebx # Is it < 0
+2: popl %edx # saved errno
+ testl %edx,%edx # Is it < 0
jl 3f # yup. ignore it
- movl $tls::errno_addr(%edx),%eax
- movl %ebx,(%eax)
+ movl $tls::errno_addr(%ebx),%eax
+ movl %edx,(%eax)
3: movl \$-4,%eax # now decrement aux stack
- xadd %eax,$tls::stackptr(%edx) # and get pointer
+ xadd %eax,$tls::stackptr(%ebx) # and get pointer
xorl %ebp,%ebp
xchgl %ebp,-4(%eax) # get return address from signal stack
xchgl %ebp,28(%esp) # store real return address
- decl $tls::stacklock(%edx) # unlock
+ decl $tls::incyg(%ebx)
+ decl $tls::stacklock(%ebx) # unlock
popl %eax
popl %ebx
pushl %ebx
pushl %eax
movl %fs:4,%ebx
+ incl $tls::incyg(%ebx)
pushl $tls::saved_errno(%ebx) # saved errno
3: pushl $tls::oldmask(%ebx) # oldmask
pushl $tls::sig(%ebx) # signal argument
movl \$0,$tls::sig(%ebx) # zero the signal number as a
# flag to the signal handler thread
# that it is ok to set up sigsave
-4: ret
+4: decl $tls::incyg(%ebx)
+ ret
.global __ZN7_cygtls3popEv
__ZN7_cygtls3popEv:
.extern __ZN7_cygtls19call_signal_handlerEv
stabilize_sig_stack:
1: movl %fs:4,%edx
+ incl $tls::incyg(%edx)
movl \$1,%eax
lock xchgl %eax,$tls::stacklock(%edx)
movl %eax,$tls::spinning(%edx) # flag if we are waiting for lock
addl %edx,%eax # of tls block
call __ZN7_cygtls19call_signal_handlerEv
jmp 1b
-3: ret
+3: decl $tls::incyg(%edx)
+ ret
EOF
}
return $res;
//; $tls::pstackptr = 2704;
//; $tls::sig = -1040;
//; $tls::psig = 2708;
-//; $tls::stacklock = -1036;
-//; $tls::pstacklock = 2712;
+//; $tls::incyg = -1036;
+//; $tls::pincyg = 2712;
//; $tls::spinning = -1032;
//; $tls::pspinning = 2716;
-//; $tls::incyg = -1028;
-//; $tls::pincyg = 2720;
+//; $tls::stacklock = -1028;
+//; $tls::pstacklock = 2720;
//; $tls::stack = -1024;
//; $tls::pstack = 2724;
//; $tls::padding = 0;
#define tls_pstackptr (2704)
#define tls_sig (-1040)
#define tls_psig (2708)
-#define tls_stacklock (-1036)
-#define tls_pstacklock (2712)
+#define tls_incyg (-1036)
+#define tls_pincyg (2712)
#define tls_spinning (-1032)
#define tls_pspinning (2716)
-#define tls_incyg (-1028)
-#define tls_pincyg (2720)
+#define tls_stacklock (-1028)
+#define tls_pstacklock (2720)
#define tls_stack (-1024)
#define tls_pstack (2724)
#define tls_padding (0)