[newlib-cygwin] Cygwin: _cygtls: Remove _cygtls::spinning

Takashi Yano tyan0@sourceware.org
Sun Dec 8 00:06:56 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0b6b450c64002dcdef09c10176ab181a17e09e52

commit 0b6b450c64002dcdef09c10176ab181a17e09e52
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sun Dec 8 08:28:46 2024 +0900

    Cygwin: _cygtls: Remove _cygtls::spinning
    
    There seems to be no rationale reason for _cygtls::spinning to exist,
    so it has been removed. _cygtls::spinning was introduced in the commit
    edc4f86ad282A, and this flag means that another thread is waiting to
    acquire _cygtls::stacklock. It is checked in the sig thread in _cygtls::
    interrupt_now(), and if spinning is true, the interrupt will be delayed.
    However, in this case, _cygtls::incyg is also set, so it is supposed to
    be covered by _cygtls::incyg flag and does not seem to add any value.
    
    If some problems happen in the signal handling, it might be a good idea
    to revert this commit and check if the issue will be fixed.
    
    Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/cygtls.cc               | 2 +-
 winsup/cygwin/exceptions.cc           | 5 ++---
 winsup/cygwin/local_includes/cygtls.h | 1 -
 winsup/cygwin/scripts/gendef          | 3 ---
 4 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index 2842c2733..bfaa19867 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -81,7 +81,7 @@ _cygtls::fixup_after_fork ()
       pop ();
       current_sig = 0;
     }
-  stacklock = spinning = 0;
+  stacklock = 0;
   signal_arrived = NULL;
   locals.select.sockevt = NULL;
   locals.cw_timer = NULL;
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 35a4a0b47..4dc4be278 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -920,9 +920,8 @@ _cygtls::interrupt_now (CONTEXT *cx, siginfo_t& si, void *handler,
 
   /* Delay the interrupt if we are
      1) somehow inside the DLL
-     2) in _sigfe (spinning is true) and about to enter cygwin DLL
-     3) in a Windows DLL.  */
-  if (incyg || spinning || inside_kernel (cx))
+     2) in a Windows DLL.  */
+  if (incyg || inside_kernel (cx))
     interrupted = false;
   else
     {
diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_includes/cygtls.h
index b7efcdae2..2d490646a 100644
--- a/winsup/cygwin/local_includes/cygtls.h
+++ b/winsup/cygwin/local_includes/cygtls.h
@@ -196,7 +196,6 @@ public: /* Do NOT remove this public: line, it's a marker for gentls_offsets. */
   waitq wq;
   int current_sig;
   unsigned incyg;
-  volatile unsigned spinning;
   volatile unsigned stacklock;
   __tlsstack_t *stackptr;
   __tlsstack_t stack[TLS_STACK_SIZE];
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 11cdf584a..521550175 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -134,7 +134,6 @@ _sigfe:						# stack is aligned on entry!
 	movq	%gs:8,%r10			# location of bottom of stack
 1:	movl	\$1,%r11d
 	xchgl	%r11d,_cygtls.stacklock(%r10)	# try to acquire lock
-	movl	%r11d,_cygtls.spinning(%r10)	# flag if we are waiting for lock
 	testl	%r11d,%r11d			# it will be zero
 	jz	2f				#  if so
 	pause
@@ -158,7 +157,6 @@ _sigbe:						# return here after cygwin syscall
 	movq	%gs:8,%r10			# address of bottom of tls
 1:	movl	\$1,%r11d
 	xchgl	%r11d,_cygtls.stacklock(%r10)	# try to acquire lock
-	movl	%r11d,_cygtls.spinning(%r10)	# flag if we are waiting for lock
 	testl	%r11d,%r11d			# it will be zero
 	jz	2f				#  if so
 	pause
@@ -258,7 +256,6 @@ sigdelayed:
 
 1:	movl	\$1,%r11d
 	xchgl	%r11d,_cygtls.stacklock(%r12)	# try to acquire lock
-	movl	%r11d,_cygtls.spinning(%r12)	# flag if we are waiting for lock
 	testl	%r11d,%r11d			# it will be zero
 	jz	2f				#  if so
 	pause


More information about the Cygwin-cvs mailing list