]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/typetraits.h: maxof(), minof(): Use the compiler operators if available
authorAlejandro Colomar <alx@kernel.org>
Thu, 27 Nov 2025 00:13:07 +0000 (01:13 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Thu, 9 Jul 2026 20:45:02 +0000 (22:45 +0200)
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/typetraits.h

index af952f86be23b412e4136a1b2fb8e8b850bd5498..b259e9de940e6f81fec2f9f51d689351c3457c12 100644 (file)
 #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)                                                    \