diff options
author | Christopher Faylor <me@cgf.cx> | 2010-08-01 23:10:52 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2010-08-01 23:10:52 +0400 |
commit | 0b6fbd396ca2f5448acb925a0b7f718676980d74 (patch) | |
tree | 0a31f9e9cd5c01589706e58e65356cd925aaea3b /winsup/cygwin/gendef | |
parent | 6defc805c3ca59f6a15d2ce0d52bd72efd2a4504 (diff) |
* exceptions.cc (_cygtls::interrupt_now): Revert to checking for "spinning"
when choosing to defer signal.
(_cygtls::call_signal_handler): Grab func when we have the lock.
* gendef: Update copyright.
(__sigbe): Simplify slightly.
(_sigdelayed): Grab a lock before manipulating stuff.
(_cygtls::pop): Properly return popped value.
(stabilize_sig_stack): Set incyg when we have the lock.
* sigproc.cc: Update copyright.
Diffstat (limited to 'winsup/cygwin/gendef')
-rwxr-xr-x | winsup/cygwin/gendef | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef index 15d9f4cee..e1fa0d9e4 100755 --- a/winsup/cygwin/gendef +++ b/winsup/cygwin/gendef @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2003, 2004, 2005, 2006, 2008 Red Hat, Inc. +# Copyright 2003, 2004, 2005, 2006, 2008, 2009, 2010 Red Hat, Inc. # # This file is part of Cygwin. # @@ -141,9 +141,8 @@ __sigfe: .global __sigbe __sigbe: # return here after cygwin syscall - pushl %edx - pushl %ebx pushl %eax # don't clobber + pushl %ebx # tls pointer 1: movl %fs:4,%ebx # address of bottom of tls movl \$1,%eax # potential lock value xchgl %eax,$tls::stacklock(%ebx) # see if we can grab it @@ -154,12 +153,10 @@ __sigbe: # return here after cygwin syscall jmp 1b # and loop 2: movl \$-4,%eax # now decrement aux stack xadd %eax,$tls::stackptr(%ebx) # and get pointer - xorl %edx,%edx - xchgl %edx,-4(%eax) # get return address from signal stack - xchgl %edx,8(%esp) # restore edx/real return address + movl -4(%eax),%eax # get return address from signal stack + xchgl %eax,4(%esp) # swap return address with saved eax decl $tls::incyg(%ebx) decl $tls::stacklock(%ebx) # release lock - popl %eax popl %ebx ret @@ -175,7 +172,7 @@ _sigreturn: movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock testl %eax,%eax # it will be zero jz 2f # if so - call _yield # sleep + call _yield # sleep jmp 1b # and loop 2: popl %edx # saved errno testl %edx,%edx # Is it < 0 @@ -211,7 +208,19 @@ _sigdelayed: pushl %ebx pushl %eax movl %fs:4,%ebx - incl $tls::incyg(%ebx) +1: movl \$1,%eax + xchgl %eax,$tls::stacklock(%ebx) + movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock + # If %eax is 1 then someone else has + # the lock but we want to flag that + # we're waiting for it. If %eax is 0 + # then we're not spinning and 0 will + # reflect that. + testl %eax,%eax + jz 2f + call _yield + jmp 1b +2: incl $tls::incyg(%ebx) pushl $tls::saved_errno(%ebx) # saved errno call _set_process_mask_delta pushl %eax @@ -225,21 +234,23 @@ _sigdelayed: call _reset_signal_arrived\@0 pushl \$_sigreturn # where to return - pushl $tls::func(%ebx) # signal func + pushl $tls::func(%ebx) # user-supplied signal func cmpl \$0,$tls::threadkill(%ebx)#pthread_kill signal? jnz 4f # yes. callee clears signal number 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: decl $tls::incyg(%ebx) - ret + decl $tls::stacklock(%ebx) + ret # return via signal handler - .global __ZN7_cygtls3popEv + .global __ZN7_cygtls3popEv __ZN7_cygtls3popEv: 1: pushl %ebx movl %eax,%ebx # this movl \$-4,%eax xadd %eax,$tls::pstackptr(%ebx) + movl -4(%eax),%eax popl %ebx ret @@ -269,7 +280,6 @@ __ZN7_cygtls6lockedEv: .extern __ZN7_cygtls19call_signal_handlerEv stabilize_sig_stack: movl %fs:4,%ebx - incl $tls::incyg(%ebx) 1: movl \$1,%eax xchgl %eax,$tls::stacklock(%ebx) movl %eax,$tls::spinning(%ebx) # flag if we are waiting for lock @@ -277,7 +287,8 @@ stabilize_sig_stack: jz 2f call _yield jmp 1b -2: cmpl \$0,$tls::sig(%ebx) +2: incl $tls::incyg(%ebx) + cmpl \$0,$tls::sig(%ebx) jz 3f decl $tls::stacklock(%ebx) # unlock movl \$-$tls::sizeof__cygtls,%eax # point to beginning |