[PATCH 01/10] Add handle_eintr to wrap EINTR handling in syscalls

Kamil Rytarowski kamil@netbsd.org
Thu Sep 3 21:10:21 GMT 2020


On 03.09.2020 16:17, Tom Tromey wrote:
>>>>>> "Kamil" == Kamil Rytarowski <n54@gmx.com> writes:
> 
> Kamil> +2020-03-17  Kamil Rytarowski  <n54@gmx.com>
> Kamil> +
> Kamil> +	* eintr.h: Add handle_eintr.
> 
> Kamil> +template <typename Fun, typename... Args>
> Kamil> +inline decltype (auto) handle_eintr (const Fun &F, const Args &... A)
> 
> I like this, but from what I read it seems that "decltype(auto)" is
> C++14 -- but gdb is still C++11.
> 

OK, I have downgraded this to C++11.

> 
> Kamil> +{
> Kamil> +  decltype (F (A...)) ret;
> Kamil> +  do
> Kamil> +    {
> Kamil> +      errno = 0;
> Kamil> +      ret = F (A...);
> Kamil> +    }
> Kamil> +  while (ret == -1 && errno == EINTR);
> 
> Also this seems to assume that "ret" is comparable to an int anyway.
> So maybe just assuming int everywhere would be ok.
> 

This assumption is not always valid, e.g. read(2) returns ssize_t.

I've added in the template flexibility of the returned type as it could
be e.g. nullptr for fopen(3).

> Tom
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20200903/85e24606/attachment.sig>


More information about the Gdb-patches mailing list