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

commit 3dbc8c3fbdc99d3f0f68fab8ba2a814ecdc27e17
Author:     Corinna Vinschen <cori...@vinschen.de>
AuthorDate: Sat Nov 23 12:23:15 2024 +0100
Commit:     Corinna Vinschen <cori...@vinschen.de>
CommitDate: Sat Nov 23 12:23:15 2024 +0100

    Cygwin: cygtls: rename sig to current_sig
    
    The currently handled signal in a thread is called _cygtls::sig.
    The variable name "sig" is used pretty often in the Cygwin source.
    This makes it tricky to distinguish the currently handled signal
    from any other usage of "sig".
    
    Therefore, rename _cygtls::sig to _cygtls::current_sig
    
    Signed-off-by: Corinna Vinschen <cori...@vinschen.de>

Diff:
---
 winsup/cygwin/cygtls.cc               |  4 ++--
 winsup/cygwin/cygwait.cc              |  4 ++--
 winsup/cygwin/exceptions.cc           | 24 +++++++++++++-----------
 winsup/cygwin/local_includes/cygtls.h |  2 +-
 winsup/cygwin/scripts/gendef          |  2 +-
 winsup/cygwin/signal.cc               |  2 +-
 6 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index afaee8e97787..2842c273360d 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -76,10 +76,10 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void 
*))
 void
 _cygtls::fixup_after_fork ()
 {
-  if (sig)
+  if (current_sig)
     {
       pop ();
-      sig = 0;
+      current_sig = 0;
     }
   stacklock = spinning = 0;
   signal_arrived = NULL;
diff --git a/winsup/cygwin/cygwait.cc b/winsup/cygwin/cygwait.cc
index dbbe1db6e1f4..80c0e971c77d 100644
--- a/winsup/cygwin/cygwait.cc
+++ b/winsup/cygwin/cygwait.cc
@@ -82,9 +82,9 @@ cygwait (HANDLE object, PLARGE_INTEGER timeout, unsigned mask)
        /* all set */;
       else
        {
-         int sig = _my_tls.sig;
+         int sig = _my_tls.current_sig;
          if (is_cw_sig_cont && sig == SIGCONT)
-           _my_tls.sig = 0;
+           _my_tls.current_sig = 0;
          if (!sig)
            continue;
          if (is_cw_sig_eintr || (is_cw_sig_cont && sig == SIGCONT))
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 60c1f594f8d4..3b31e65c101a 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -891,8 +891,9 @@ sig_handle_tty_stop (int sig, siginfo_t *, void *)
       sigproc_printf ("process %d stopped by signal %d", myself->pid, sig);
       /* FIXME! This does nothing to suspend anything other than the main
         thread. */
-      /* Use special cygwait parameter to handle SIGCONT.  _main_tls.sig will
-        be cleared under lock when SIGCONT is detected.  */
+      /* Use special cygwait parameter to handle SIGCONT.
+         _main_tls.current_sig will be cleared under lock when SIGCONT is
+        detected.  */
       pthread::suspend_all_except_self ();
       DWORD res = cygwait (NULL, cw_infinite, cw_sig_cont);
       pthread::resume_all ();
@@ -952,7 +953,8 @@ _cygtls::interrupt_setup (siginfo_t& si, void *handler, 
struct sigaction& siga)
     }
 
   infodata = si;
-  this->sig = si.si_signo; /* Should always be last thing set to avoid race */
+  /* current_sig should always be last thing set to avoid race */
+  this->current_sig = si.si_signo;
 
   if (incyg)
     set_signal_arrived ();
@@ -976,10 +978,10 @@ sigpacket::setup_handler (void *handler, struct 
sigaction& siga, _cygtls *tls)
   CONTEXT cx;
   bool interrupted = false;
 
-  if (tls->sig)
+  if (tls->current_sig)
     {
       sigproc_printf ("trying to send signal %d but signal %d already armed",
-                     si.si_signo, tls->sig);
+                     si.si_signo, tls->current_sig);
       goto out;
     }
 
@@ -1432,14 +1434,14 @@ _cygtls::handle_SIGCONT ()
      before exiting the loop.  */
   bool sigsent = false;
   while (1)
-    if (sig)           /* Assume that it's ok to just test sig outside of a
+    if (current_sig)   /* Assume that it's ok to just test sig outside of a
                           lock since setup_handler does it this way.  */
       yield ();                /* Attempt to schedule another thread.  */
     else if (sigsent)
       break;           /* SIGCONT has been recognized by other thread */
     else
       {
-       sig = SIGCONT;
+       current_sig = SIGCONT;
        set_signal_arrived (); /* alert sig_handle_tty_stop */
        sigsent = true;
       }
@@ -1675,7 +1677,7 @@ _cygtls::call_signal_handler ()
   while (1)
     {
       lock ();
-      if (!sig)
+      if (!current_sig)
        {
          unlock ();
          break;
@@ -1686,7 +1688,7 @@ _cygtls::call_signal_handler ()
       if (retaddr () == (__tlsstack_t) sigdelayed)
        pop ();
 
-      debug_only_printf ("dealing with signal %d", sig);
+      debug_only_printf ("dealing with signal %d", current_sig);
       this_sa_flags = sa_flags;
 
       sigset_t this_oldmask = set_process_mask_delta ();
@@ -1699,7 +1701,7 @@ _cygtls::call_signal_handler ()
        }
 
       /* Save information locally on stack to pass to handler. */
-      int thissig = sig;
+      int thissig = current_sig;
       siginfo_t thissi = infodata;
       void (*thisfunc) (int, siginfo_t *, void *) = func;
 
@@ -1768,7 +1770,7 @@ _cygtls::call_signal_handler ()
       int this_errno = saved_errno;
       reset_signal_arrived ();
       incyg = false;
-      sig = 0;         /* Flag that we can accept another signal */
+      current_sig = 0; /* Flag that we can accept another signal */
       unlock ();       /* unlock signal stack */
 
       /* Alternate signal stack requested for this signal and alternate signal
diff --git a/winsup/cygwin/local_includes/cygtls.h 
b/winsup/cygwin/local_includes/cygtls.h
index f67e9136c326..28bbe60f0f40 100644
--- a/winsup/cygwin/local_includes/cygtls.h
+++ b/winsup/cygwin/local_includes/cygtls.h
@@ -192,7 +192,7 @@ public: /* Do NOT remove this public: line, it's a marker 
for gentls_offsets. */
   class cygthread *_ctinfo;
   class san *andreas;
   waitq wq;
-  int sig;
+  int current_sig;
   unsigned incyg;
   unsigned spinning;
   unsigned stacklock;
diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 968ef2b08ffc..720325fdd475 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -374,7 +374,7 @@ stabilize_sig_stack:
        pause
        jmp     1b
 2:     incl    _cygtls.incyg(%r12)
-       cmpl    \$0,_cygtls.sig(%r12)
+       cmpl    \$0,_cygtls.current_sig(%r12)
        jz      3f
        decl    _cygtls.stacklock(%r12)         # release lock
        movq    \$_cygtls.start_offset,%rcx     # point to beginning
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 9ee6cf9959a0..a7af604df38d 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -634,7 +634,7 @@ do_wait:
              if (info)
                *info = _my_tls.infodata;
              res = _my_tls.infodata.si_signo;
-             _my_tls.sig = 0;
+             _my_tls.current_sig = 0;
              if (_my_tls.retaddr () == (__tlsstack_t) sigdelayed)
                _my_tls.pop ();
              _my_tls.unlock ();

Reply via email to