]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
utils: add max() definition
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 18 Apr 2023 11:39:51 +0000 (14:39 +0300)
committerDavid Ahern <dsahern@kernel.org>
Tue, 25 Apr 2023 01:42:21 +0000 (19:42 -0600)
There is already a min() definition, add this below it.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
include/utils.h

index 2eb80b3e487ced3854c5f52438d8de36236d00fa..0f1b3bef34d8293ec2ebab61c9f2492e84896065 100644 (file)
@@ -284,6 +284,14 @@ unsigned int print_name_and_link(const char *fmt,
        _min1 < _min2 ? _min1 : _min2; })
 #endif
 
+#ifndef max
+# define max(x, y) ({                  \
+       typeof(x) _max1 = (x);          \
+       typeof(y) _max2 = (y);          \
+       (void) (&_max1 == &_max2);      \
+       _max1 < _max2 ? _max2 : _max1; })
+#endif
+
 #ifndef __check_format_string
 # define __check_format_string(pos_str, pos_args) \
        __attribute__ ((format (printf, (pos_str), (pos_args))))