]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/typetraits.h: Compact macros
authorAlejandro Colomar <alx@kernel.org>
Thu, 27 Nov 2025 00:06:13 +0000 (01:06 +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 fb3d970d97432c3a01d848138054c599629130c5..edb1c76d1fddf24489a46b89382c6261b9766660 100644 (file)
 #include "sizeof.h"
 
 
-#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 type_max(T)                                                           \
-(                                                                             \
-       (T) (is_signed(T) ? stype_max(T) : utype_max(T))                      \
-)
-
-#define type_min(T)                                                           \
-(                                                                             \
-       (T) ~type_max(T)                                                      \
-)
+# 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 type_max(T)     ((T) (is_signed(T) ? stype_max(T) : utype_max(T)))
+# define type_min(T)     ((T) ~type_max(T))
 
 
 #define is_same_type(a, b)                                                    \