[newlib-cygwin] Cygwin: signalfd: implement non-polling select

Ryan Johnson ryan.johnson@cs.utoronto.ca
Wed Jan 16 14:09:00 GMT 2019


On 1/15/2019 4:22 AM, Corinna Vinschen wrote:
> 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.

Why not introduce a typedef in some convenient location the perl script 
doesn't examine, e.g.

typedef ucontext_t __attribute__((aligned(16))) aligned_ucontext_t;

And then use that in the struct?

Ryan



More information about the Cygwin-developers mailing list