2023-09-28 02:57:14

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: + minmax-add-umina-b-and-umaxa-b.patch added to mm-nonmm-unstable branch

On Wed, Sep 27, 2023 at 10:30:33AM -0700, Andrew Morton wrote:
> +#define umin(x, y) \
> + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <)

kmin() and kmax() are (of course!) much better names.


2023-09-28 03:16:54

by Matthew Wilcox

[permalink] [raw]
Subject: Re: + minmax-add-umina-b-and-umaxa-b.patch added to mm-nonmm-unstable branch

On Wed, Sep 27, 2023 at 10:21:41PM +0300, Alexey Dobriyan wrote:
> On Wed, Sep 27, 2023 at 10:30:33AM -0700, Andrew Morton wrote:
> > +#define umin(x, y) \
> > + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <)
>
> kmin() and kmax() are (of course!) much better names.

it's unsigned, not user.

2023-09-28 09:53:48

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: + minmax-add-umina-b-and-umaxa-b.patch added to mm-nonmm-unstable branch

On Wed, Sep 27, 2023 at 09:00:37PM +0100, Matthew Wilcox wrote:
> On Wed, Sep 27, 2023 at 10:21:41PM +0300, Alexey Dobriyan wrote:
> > On Wed, Sep 27, 2023 at 10:30:33AM -0700, Andrew Morton wrote:
> > > +#define umin(x, y) \
> > > + __careful_cmp((x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull, <)
> >
> > kmin() and kmax() are (of course!) much better names.
>
> it's unsigned, not user.

Yes, but the same idea applies to signed types:

min, max require identical types
min_t force type
kmin, kmax are relaxed min/max versions if signednesses match.