summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2023-04-18 14:39:51 +0300
committerDavid Ahern <dsahern@kernel.org>2023-04-24 19:42:21 -0600
commit1865a60871fb44b842fb758172648b24dfc37394 (patch)
treec50bf27996d9d9e8a522132bfebfefe1314f1a06
parentf57ac749b0359c9239b09a6c80573d5a94245b5b (diff)
downloadiproute2-1865a60871fb44b842fb758172648b24dfc37394.tar.gz
utils: add max() definition
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>
-rw-r--r--include/utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/utils.h b/include/utils.h
index 2eb80b3e..0f1b3bef 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -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))))