diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7d4abb490..bc0a15c94 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2003-11-28 Christopher Faylor + + * pinfo.h (_pinfo::getthread2signal): Remove obsolete function. + * cygtls.h (_threadinfo): Define tid more precisely. + (_threadinfo::operator HANDLE): Define. + * exceptions.cc (_threadinfo::interupt_now): Use _threadinfo HANDLE + operator to derive thread handle. + (setup_handler): Ditto. + * sigproc.cc: Reorganize includes. + 2003-11-28 Christopher Faylor * pinfo.h (_pinfo::getsig): Remove obsolete function, here and diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 8f900e9f0..c0ab189b9 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -34,7 +34,7 @@ struct _threadinfo sigset_t sigwait_mask; siginfo_t *sigwait_info; siginfo_t infodata; - void *tid; + struct pthread *tid; struct _threadinfo *prev, *next; __stack_t stack[8]; int sig; @@ -51,6 +51,7 @@ struct _threadinfo __attribute__((regparm(3))); void __stdcall interrupt_setup (int sig, void *handler, struct sigaction& siga, __stack_t retaddr) __attribute__((regparm(3))); + operator HANDLE () const {return tid->win32_obj_id;} }; #pragma pack(pop) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 059b570e5..ef2bf2270 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -745,7 +745,7 @@ _threadinfo::interrupt_now (CONTEXT *ctx, int sig, void *handler, push (0); interrupt_setup (sig, handler, siga, (__stack_t) ctx->Eip); ctx->Eip = (DWORD) sigdelayed; - SetThreadContext (myself->getthread2signal (), ctx); /* Restart the thread in a new location */ + SetThreadContext (*this, ctx); /* Restart the thread in a new location */ return 1; } @@ -801,7 +801,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _threadinfo *tls) } DWORD res; - HANDLE hth = myself->getthread2signal (); + HANDLE hth = (HANDLE) *tls; /* Suspend the thread which will receive the signal. But first ensure that this thread doesn't have any mutos. (FIXME: Someday we should just grab diff --git a/winsup/cygwin/how-signals-work.txt b/winsup/cygwin/how-signals-work.txt index b890e31a8..f5cb04aff 100644 --- a/winsup/cygwin/how-signals-work.txt +++ b/winsup/cygwin/how-signals-work.txt @@ -6,17 +6,11 @@ On process startup, cygwin starts a secondary thread that deals with signals. This thread contains a loop which blocks waiting for information to show up on a pipe whose handle (sendsig) is currently stored in _pinfo (this may change). -If one of these is activated, then the the signal handler inspects an -array of integers looking for a non-zero value. The array corresponds -to the normal UNIX signals + two extra locations for internal usage. -This array is located in the 'sigtodo' array in the procinfo class. - -The signal thread uses the InterlockedDecrement function to atomically -inspect elements of the array. If one one of the elements of the array -is non-zero, then cygwin checks to see if the user has blocked the -signal by inspecting the process signal mask. If the signal is blocked, -then the current array element is reincremented and the next element is -checked. +Communication on the sendsig pipe is via the 'sigelem' structure. This +structure is filled out by the sig_send function with information about the +signal being sent, such as (as of this writing) the signal number, the +originating pid, the originating thread, and the address of the mask to +use (this may change). If the signal is not blocked, then the function "sig_handle" is called with the signal number as an argument. This is a fairly straightforward diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index b2e8af3e3..02313492a 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -114,11 +114,6 @@ public: sig_mask = mask; } - inline HANDLE getthread2signal () - { - return hMainThread; - } - void commune_recv (); commune_result commune_send (DWORD, ...); bool alive (); diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 0aeb4d8cb..d3d80753c 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -20,8 +20,6 @@ details. */ #include #include "cygerrno.h" #include "sync.h" -#include "cygtls.h" -#include "sigproc.h" #include "pinfo.h" #include "security.h" #include "path.h" @@ -29,9 +27,11 @@ details. */ #include "dtable.h" #include "cygheap.h" #include "child_info_magic.h" -#include "perthread.h" #include "shared_info.h" #include "cygthread.h" +#include "cygtls.h" +#include "sigproc.h" +#include "perthread.h" /* * Convenience defines