OSDN Git Service

* cygtls.h (_cygtls::interrupt_now): Subsume interruptible().
authorcgf <cgf>
Tue, 20 Dec 2005 00:31:50 +0000 (00:31 +0000)
committercgf <cgf>
Tue, 20 Dec 2005 00:31:50 +0000 (00:31 +0000)
(interruptible): Delete.
(setup_handler): Remove interruptible call and just use return from
interrupt_now.

winsup/cygwin/ChangeLog
winsup/cygwin/exceptions.cc

index 8ccb374..5a383ea 100644 (file)
@@ -1,5 +1,12 @@
 2005-12-19  Christopher Faylor  <cgf@timesys.com>
 
+       * cygtls.h (_cygtls::interrupt_now): Subsume interruptible().
+       (interruptible): Delete.
+       (setup_handler): Remove interruptible call and just use return from
+       interrupt_now.
+
+2005-12-19  Christopher Faylor  <cgf@timesys.com>
+
        * fhandler.h (set_console_state_for_spawn): Add an argument to the
        declaration.
        * fhandler_console.cc (set_console_state_for_spawn): Ditto for the
index 9b989ee..46c742b 100644 (file)
@@ -659,14 +659,16 @@ sig_handle_tty_stop (int sig)
 }
 
 bool
-interruptible (DWORD pc)
+_cygtls::interrupt_now (CONTEXT *cx, int sig, void *handler,
+                       struct sigaction& siga)
 {
   int res;
+  bool interrupted;
   MEMORY_BASIC_INFORMATION m;
 
   memset (&m, 0, sizeof m);
-  if (!VirtualQuery ((LPCVOID) pc, &m, sizeof m))
-    sigproc_printf ("couldn't get memory info, pc %p, %E", pc);
+  if (!VirtualQuery ((LPCVOID) cx->Eip, &m, sizeof m))
+    sigproc_printf ("couldn't get memory info, pc %p, %E", cx->Eip);
 
   char *checkdir = (char *) alloca (windows_system_directory_length + 4);
   memset (checkdir, 0, sizeof (checkdir));
@@ -684,10 +686,22 @@ interruptible (DWORD pc)
   else
     res = !strncasematch (windows_system_directory, checkdir,
                          windows_system_directory_length);
-  sigproc_printf ("pc %p, h %p, interruptible %d", pc, h, res);
+  sigproc_printf ("pc %p, h %p, interruptible %d", cx->Eip, h, res);
 # undef h
-  return res;
+
+  if (!res || (incyg || spinning || locked ()))
+    interrupted = false;
+  else
+    {
+      push ((__stack_t) cx->Eip);
+      interrupt_setup (sig, handler, siga);
+      cx->Eip = pop ();
+      SetThreadContext (*this, cx); /* Restart the thread in a new location */
+      interrupted = true;
+    }
+  return interrupted;
 }
+
 void __stdcall
 _cygtls::interrupt_setup (int sig, void *handler, struct sigaction& siga)
 {
@@ -711,17 +725,6 @@ _cygtls::interrupt_setup (int sig, void *handler, struct sigaction& siga)
                  sig, res);
 }
 
-bool
-_cygtls::interrupt_now (CONTEXT *ctx, int sig, void *handler,
-                       struct sigaction& siga)
-{
-  push ((__stack_t) ctx->Eip);
-  interrupt_setup (sig, handler, siga);
-  ctx->Eip = pop ();
-  SetThreadContext (*this, ctx); /* Restart the thread in a new location */
-  return 1;
-}
-
 extern "C" void __stdcall
 set_sig_errno (int e)
 {
@@ -789,8 +792,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls)
       cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
       if (!GetThreadContext (hth, &cx))
        system_printf ("couldn't get context of main thread, %E");
-      else if (interruptible (cx.Eip) &&
-              !(tls->incyg || tls->spinning || tls->locked ()))
+      else
        interrupted = tls->interrupt_now (&cx, sig, handler, siga);
 
       res = ResumeThread (hth);