Re: linux/bitops.h

From: H. Peter Anvin
Date: Wed May 04 2016 - 20:31:26 EST


On 05/04/16 15:06, John Denker wrote:
On 05/04/2016 02:56 PM, H. Peter Anvin wrote:
Beware that shifting by an amount >= the number of bits in the
word remains Undefined Behavior.

This construct has been supported as a rotate since at least gcc2.

How then should we understand the story told in commit d7e35dfa?
Is the story wrong?

At the very least, something inconsistent is going on. There
are 8 functions. Why did d7e35dfa change one of them but
not the other 7?

Yes. d7e35dfa is baloney IMNSHO. All it does is produce worse code, and the description even says so.

As I said, gcc has treated the former code as idiomatic since gcc 2, so that support is beyond ancient.

-hpa