From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 502F9384A87E for ; Mon, 7 Sep 2020 14:06:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 502F9384A87E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A53751E509; Mon, 7 Sep 2020 10:06:16 -0400 (EDT) Subject: Re: [PATCH v2 01/10] Add handle_eintr to wrap EINTR handling in syscalls To: Kamil Rytarowski , gdb-patches@sourceware.org Cc: tom@tromey.com References: <20200904002905.13616-1-n54@gmx.com> <20200904002905.13616-2-n54@gmx.com> From: Simon Marchi Message-ID: Date: Mon, 7 Sep 2020 10:06:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904002905.13616-2-n54@gmx.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 14:06:18 -0000 On 2020-09-03 8:28 p.m., Kamil Rytarowski wrote: > gdbsupport/ChangeLog: > > * eintr.h: New file. > --- > gdbsupport/ChangeLog | 4 ++++ > gdbsupport/eintr.h | 41 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > create mode 100644 gdbsupport/eintr.h > > diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog > index a1960537384..d26000e36ac 100644 > --- a/gdbsupport/ChangeLog > +++ b/gdbsupport/ChangeLog > @@ -1,3 +1,7 @@ > +2020-09-04 Kamil Rytarowski > + > + * eintr.h: New file. > + > 2020-08-13 Simon Marchi > > * selftest.h (run_tests): Change parameter to array_view. > diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h > new file mode 100644 > index 00000000000..74b7038da60 > --- /dev/null > +++ b/gdbsupport/eintr.h > @@ -0,0 +1,41 @@ > +/* Utility for handling interrupted syscalls by signals. > + > + Copyright (C) 2020 Free Software Foundation, Inc. > + > + This file is part of GDB. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +#ifndef GDBSUPPORT_EINTR_H > +#define GDBSUPPORT_EINTR_H > + > +#include > + > +namespace gdb > +{ > +template > +inline Ret handle_eintr (const Ret &R, const Fun &F, const Args &... A) > +{ > + Ret ret; > + do > + { > + errno = 0; > + ret = F (A...); > + } > + while (ret == R && errno == EINTR); > + return ret; > +} > +} Can you document this function a little bit, including a usage example? I tried to apply it in gdb/linux-nat.c, function async_file_mark, but I'm not sure I'm doing it correctly. In particular, what should I pass as the `R` parameter? Does that make sense? gdb::handle_eintr (-1, ::write, linux_nat_event_pipe[1], "+", 1); Simon