From: Alejandro Colomar Date: Thu, 27 Nov 2025 00:13:07 +0000 (+0100) Subject: lib/typetraits.h: maxof(), minof(): Use the compiler operators if available X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e608f0f0b945999887763f74ca80976a6404f29a;p=thirdparty%2Fshadow.git lib/typetraits.h: maxof(), minof(): Use the compiler operators if available Reviewed-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/lib/typetraits.h b/lib/typetraits.h index af952f86b..b259e9de9 100644 --- a/lib/typetraits.h +++ b/lib/typetraits.h @@ -11,12 +11,17 @@ #include "sizeof.h" +#if (__GNUC__ >= 16) +# define maxof(T) _Maxof(T) +# define minof(T) _Minof(T) +#else # define is_unsigned(x) ((typeof(x)) -1 > 1) # define is_signed(x) ((typeof(x)) -1 < 1) # define stype_max(T) ((T) (((((T) 1 << (WIDTHOF(T) - 2)) - 1) << 1) + 1)) # define utype_max(T) ((T) -1) # define maxof(T) ((T) (is_signed(T) ? stype_max(T) : utype_max(T))) # define minof(T) ((T) ~maxof(T)) +#endif #define is_same_type(a, b) \