[newlib-cygwin] Cygwin: signalfd: implement non-polling select
Václav Haisman
vhaisman@gmail.com
Tue Jan 15 09:51:00 GMT 2019
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?
More information about the Cygwin-developers
mailing list