From: David Laight <David.Laight@ACULAB.COM>
To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Cc: 'Linus Torvalds' <torvalds@linuxfoundation.org>,
'Jens Axboe' <axboe@kernel.dk>,
"'Matthew Wilcox (Oracle)'" <willy@infradead.org>,
'Christoph Hellwig' <hch@infradead.org>,
'Andrew Morton' <akpm@linux-foundation.org>,
'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>,
'Dan Carpenter' <dan.carpenter@linaro.org>,
'Arnd Bergmann' <arnd@kernel.org>,
"'Jason@zx2c4.com'" <Jason@zx2c4.com>,
"'pedro.falcato@gmail.com'" <pedro.falcato@gmail.com>,
'Mateusz Guzik' <mjguzik@gmail.com>,
"'linux-mm@kvack.org'" <linux-mm@kvack.org>,
'Lorenzo Stoakes' <lorenzo.stoakes@oracle.com>
Subject: [PATCH v2 7/8] minmax: Use __auto_type
Date: Sun, 28 Jul 2024 14:23:52 +0000 [thread overview]
Message-ID: <431f7c45e7294d4da4f8abcd57ce7b5e@AcuMS.aculab.com> (raw)
In-Reply-To: <402c3c617c29465c898b1af55e3c6095@AcuMS.aculab.com>
Replacing 'typeof(x) _x = (x)' with '__auto_type _x = (x)' removes
one expansion of 'x'.
Signed-off-by: David Laight <david.laight@aculab.com>
---
New patch for v2
include/linux/minmax.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/linux/minmax.h b/include/linux/minmax.h
index ad57c8eddc8a..cb3515824a64 100644
--- a/include/linux/minmax.h
+++ b/include/linux/minmax.h
@@ -47,9 +47,9 @@
#define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
#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), \
+ __auto_type unique_x = (x); \
+ __auto_type unique_y = (y); \
+ _Static_assert(__types_ok(x, y), \
#op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \
__cmp(op, unique_x, unique_y); })
@@ -131,18 +131,18 @@
* @y: value2
*/
#define min_not_zero(x, y) ({ \
- typeof(x) __x = (x); \
- typeof(y) __y = (y); \
+ __auto_type __x = (x); \
+ __auto_type __y = (y); \
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
#define __clamp(val, lo, hi) \
((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))
#define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \
- typeof(val) unique_val = (val); \
- typeof(lo) unique_lo = (lo); \
- typeof(hi) unique_hi = (hi); \
- _Static_assert(__if_constexpr((lo) <= (hi), (lo) <= (hi), true), \
+ __auto_type unique_val = (val); \
+ __auto_type unique_lo = (lo); \
+ __auto_type unique_hi = (hi); \
+ _Static_assert(__if_constexpr((lo) <= (hi), (lo) <= (hi), true), \
"clamp() low limit " #lo " greater than high limit " #hi); \
_Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \
_Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \
--
2.17.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2024-07-28 14:24 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-28 14:15 [PATCH v2 0/8] minmax: reduce compilation time David Laight
2024-07-28 14:17 ` [PATCH v2 1/8] minmax: Put all the clamp() definitions together David Laight
2024-07-28 17:24 ` Linus Torvalds
2024-07-28 18:11 ` David Laight
2024-07-28 19:55 ` Linus Torvalds
2024-07-28 20:09 ` David Laight
2024-07-28 20:13 ` Linus Torvalds
2024-07-28 20:22 ` David Laight
2024-07-28 20:31 ` Linus Torvalds
2024-07-28 22:13 ` David Laight
2024-07-28 22:22 ` Linus Torvalds
2024-07-29 8:01 ` David Laight
2024-07-28 21:01 ` Linus Torvalds
2024-07-28 21:53 ` David Laight
2024-07-29 4:15 ` Linus Torvalds
2024-07-29 22:25 ` Arnd Bergmann
2024-07-29 23:21 ` Linus Torvalds
2024-07-30 1:52 ` Linus Torvalds
2024-07-30 3:59 ` Linus Torvalds
2024-07-30 10:10 ` Arnd Bergmann
2024-07-30 14:14 ` Arnd Bergmann
2024-07-30 18:02 ` Linus Torvalds
2024-07-30 19:52 ` Linus Torvalds
2024-07-30 21:47 ` David Laight
2024-07-30 22:44 ` Linus Torvalds
2024-07-30 23:03 ` Linus Torvalds
2024-07-31 8:09 ` David Laight
2024-07-31 10:50 ` Arnd Bergmann
2024-07-31 15:38 ` Linus Torvalds
2024-07-31 15:56 ` David Laight
2024-07-31 16:04 ` Linus Torvalds
2024-12-04 13:15 ` Geert Uytterhoeven
2024-12-04 17:16 ` David Laight
2024-07-30 16:35 ` Linus Torvalds
2024-07-30 16:46 ` Linus Torvalds
2024-07-30 12:03 ` David Laight
2024-07-28 18:23 ` David Laight
2024-07-28 14:18 ` [PATCH v2 2/8] minmax: Use _Static_assert() instead of static_assert() David Laight
2024-07-28 17:51 ` Christophe JAILLET
2024-07-28 18:12 ` David Laight
2024-07-28 14:19 ` [PATCH v2 3/8] compiler.h: Add __if_constexpr(expr, if_const, if_not_const) David Laight
2024-07-28 14:20 ` [PATCH v2 4/8] minmax: Simplify signedness check David Laight
2024-07-28 16:57 ` Linus Torvalds
2024-07-28 18:14 ` David Laight
2024-07-28 20:13 ` David Laight
2024-07-28 14:21 ` [PATCH v2 5/8] minmax: Factor out the zero-extension logic from umin/umax David Laight
2024-07-28 14:22 ` [PATCH v2 6/8] minmax: Optimise _Static_assert() check in clamp() David Laight
2024-07-28 14:23 ` David Laight [this message]
2024-07-28 16:59 ` [PATCH v2 7/8] minmax: Use __auto_type Linus Torvalds
2024-07-28 14:24 ` [PATCH v2 8/8] minmax: minmax: Add __types_ok3() and optimise defines with 3 arguments David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=431f7c45e7294d4da4f8abcd57ce7b5e@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@kernel.org \
--cc=axboe@kernel.dk \
--cc=dan.carpenter@linaro.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mjguzik@gmail.com \
--cc=pedro.falcato@gmail.com \
--cc=torvalds@linuxfoundation.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox