[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c14422500a4489a972aa917761b3100@AcuMS.aculab.com>
Date: Sun, 28 Jul 2024 18:23:17 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Linus Torvalds' <torvalds@...uxfoundation.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Jens Axboe
<axboe@...nel.dk>, "Matthew Wilcox (Oracle)" <willy@...radead.org>,
"Christoph Hellwig" <hch@...radead.org>, Andrew Morton
<akpm@...ux-foundation.org>, "Andy Shevchenko"
<andriy.shevchenko@...ux.intel.com>, Dan Carpenter
<dan.carpenter@...aro.org>, Arnd Bergmann <arnd@...nel.org>,
"Jason@...c4.com" <Jason@...c4.com>, "pedro.falcato@...il.com"
<pedro.falcato@...il.com>, Mateusz Guzik <mjguzik@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>, Lorenzo Stoakes
<lorenzo.stoakes@...cle.com>
Subject: RE: [PATCH v2 1/8] minmax: Put all the clamp() definitions together
From: Linus Torvalds
> Sent: 28 July 2024 18:25
...
> But I think even if we don't do that, I wonder if we can just do this:
>
> #define __cmp_once(op, x, y, unique_x, unique_y) ({ \
> typeof(x) unique_x = (x); \
> typeof(y) unique_y = (y); \
> static_assert(__types_ok(x, y), \
> ...
>
> and change it to
>
> #define __cmp_once(op, x, y, unique_x, unique_y) ({ \
> __auto_type unique_x = (x); \
> __auto_type unique_y = (y); \
> static_assert(__types_ok(unique_x, unique_y), \
> ...
>
> because while that may screw up the "constant integer" case (because
> it now goes through that "unique_XY" variable, maybe it doesn't? At
> least gcc has been known to deal with things like arguments to inline
> functions well enough (ie a constant argument means that the arguments
> shows as __builtin_constant_p(), and we already depend on that).
>
> That single change would cut down on duplication of 'x' and 'y'
> _enormously_. No?
IIRC the unique_x values can be tested with __builtin_constantp()
but will never be 'constant integer expressions' so can't be used
with static_assert() (etc).
I have thought about using typeof(unique_x) but the value 'x'.
That would be messy but only have one expansion of 'x'.
Might be doable if __COUNTER__ is passed as I did for min3().
I think it would be better to build on these changes - since they help.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists