RE: [PATCH v2 1/8] minmax: Put all the clamp() definitions together

From: David Laight
Date: Sun Jul 28 2024 - 16:23:48 EST


..
> But I'm inclined to just do that too. Bite the bullet, get rid of the
> whole "has to be a C constant expression" pain.

At least you can 'just do it' :-)

IIRC some of the MIN() need to be min() and others are used for
constants so would need an initial #ifndef MIN test to maintain
bisection without having a single patch that changes all the
files at once.

MIN() (and probably your MIN_T()) ought to have a check for
being a constant in order to stop misuse.
Perhaps just:
#define MIN(x,y) \
(__builtin_choose_expr((x)+(y), 0, 0) + ((x) < (y} ? (x) : (y)))

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)