Skip to content

Commit

Permalink
macro: add min() macro
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 23, 2021
1 parent 2092492 commit a1feaf2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lxc/macro.h
Expand Up @@ -737,4 +737,12 @@ static inline int PTR_RET(const void *ptr)
return 0;
}

#define min(x, y) \
({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void)(&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; \
})

#endif /* __LXC_MACRO_H */

0 comments on commit a1feaf2

Please sign in to comment.