[newlib-cygwin] Cygwin: signalfd: implement non-polling select
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Jan 15 11:22:00 GMT 2019
On Jan 15 10:50, Václav Haisman wrote:
> On Mon, 14 Jan 2019 at 17:19, Corinna Vinschen <corinna@sourceware.org> wrote:
> >
> > https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f42776fa781de858a927bc03aa966a0f3096b581
> >
> > commit f42776fa781de858a927bc03aa966a0f3096b581
> > Author: Corinna Vinschen <corinna@vinschen.de>
> > Date: Mon Jan 14 17:19:37 2019 +0100
> >
> > Cygwin: signalfd: implement non-polling select
> >
> > Allow the signal thread to recognize we're called in consequence of
> > select on a signalfd. If the signal is part of the wait mask, don't
> > call any signal handler and don't remove the signal from the queue,
> > so a subsequent read (or sigwaitinfo/sigtimedwait) still gets the
> > signal. Instead, just signal the event object at
> > _cygtls::signalfd_select_wait for the thread running select.
> >
> > The addition of signalfd_select_wait to _cygtls unearthed the alignment
> > problem of the context member again. To make sure this doesn't get lost,
> > improve the related comment in the header file so that this (hopefully)
> > doesn't get lost (again).
> >
> > Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
> > [...]
> >
> > diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
> > index 39dba13..65a905c 100644
> > --- a/winsup/cygwin/cygtls.h
> > +++ b/winsup/cygwin/cygtls.h
> > @@ -189,8 +189,11 @@ public:
> > stack_t altstack;
> > siginfo_t *sigwait_info;
> > HANDLE signal_arrived;
> > + HANDLE signalfd_select_wait;
> > bool will_wait_for_signal;
> > - long __align; /* Needed to align context to 16 byte. */
> > + /* context MUST be aligned to 16 byte, otherwise RtlCaptureContext fails.
> > + If you prepend cygtls members here, make sure context stays 16 byte
> > + aligned. */
> > ucontext_t context;
> >[...]
> Would it not better to do this with `ucontext_t context
> __attribute__((__aligned__(16)));` instead?
In theory yes, but it doesn't work. The simple perl parser in
gentls_offsets doesn't understand __attribute__ and screws up,
so generating tlsoffsets{64}.h fails.
I'm not good at perl. My attempts to fix the parser to let
__attribute__ statements slip through unchanged failed so far.
Right now what it does is:
ucontext_t context __attribute__((__aligned__(16)));
in the input is mangled to
ucontext_t context__attribute____aligned__16;
in the output. Any help appreciated.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20190115/bfcd902d/attachment.sig>
More information about the Cygwin-developers
mailing list