FD_{SET,ISSET,CLR} macros from sys/select.h triggerring gcc's -Wsign-conversion warnings

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Aug 3 14:29:35 GMT 2020


On Aug  3 15:27, Petr Skocik via Cygwin wrote:
> Thanks for the patch, Corinna!
> 
> I also reported it to Musl which has very similar code (I guess because
> of the same FreeBSD origins)
> and it's been pointed out to me by Alexander Monakov that the int-cast
> results in worse codegen because then the modulos/divisions need signed
> division instructions and can no longer be optimized to shifts and masks
> (glibc does the int-cast still).
> 
> In light of that, if I were the maintainer, I think I'd just just make
> the macros into inline functions (POSIX says it's unspecified whether
> they're functions or macros) and cast the filedescriptor number to
> unsigned internally or something similar.

I thought about that as well, but I'd like to keep it as close to FreeBSD
as possible.  In theory, it would be even better to revert the additional
cast and just live with the gcc warnings.

> (The issue could well be attributed to gcc, too, because, arguably, (the
> implicit) -Wno-system-headers should have silenced it even without the
> explicit casts.)

I didn't realize that.  It's weird behaviour.

> Anyway, sorry for all the fuss about such a negligible issue, but I
> guess fixing it (in whatever way) does make
> the lib a tiny bit more pleasant to use.

No worries.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


More information about the Cygwin mailing list