* fork.cc (fork_parent): Save parent pid in a temporary variable since child

could conceivably exit before function returns, rendering the child's shared
memory area invalid.
* cygtls.h (_cygtls::incyg): Declare new field.
(_cygtls::in_exception): Define new function.
* exceptions.cc (setup_handler): Remove locked flag.  Use 'incyg' flag and
in_exception function to determine when we're in a cygwin function.
(_cygtls::call_signal_handler): Decrement incyg flag prior to calling a
handler.  Increment it on return.
* gendef (_sigfe): Increment incyg flag.  Use testl for zero testing rather
than orl, for consistency.
(_sigbe): Decrement incyg flag.  Use testl for zero testing rather than orl,
for consistency.
(_cygtls::pop): Use testl for zero testing rather than orl, for consistency.
(stabilize_sig_stack): Ditto.
This commit is contained in:
Christopher Faylor
2004-03-07 04:57:47 +00:00
parent 2942097ac2
commit 3a1ccfc8c7
6 changed files with 95 additions and 65 deletions

View File

@ -95,12 +95,13 @@ __sigfe:
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
@ -120,7 +121,7 @@ __sigbe:
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
@ -130,6 +131,7 @@ __sigbe:
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
@ -145,7 +147,7 @@ _sigreturn:
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
@ -220,7 +222,7 @@ __ZN7_cygtls4lockEv:
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
@ -244,7 +246,7 @@ stabilize_sig_stack:
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