Commit 233d83d0 authored by dp-arm's avatar dp-arm
Browse files

Introduce MIN()/MAX() macros in utils.h



Change-Id: If88270bc9edb32634a793b1e1be6c4829f39b9c5
Signed-off-by: default avatardp-arm <dimitris.papastamos@arm.com>
parent 51faada7
...@@ -42,6 +42,20 @@ ...@@ -42,6 +42,20 @@
#define BIT(nr) (1UL << (nr)) #define BIT(nr) (1UL << (nr))
#define MIN(x, y) __extension__ ({ \
__typeof__(x) _x = (x); \
__typeof__(y) _y = (y); \
(void)(&_x == &_y); \
_x < _y ? _x : _y; \
})
#define MAX(x, y) __extension__ ({ \
__typeof__(x) _x = (x); \
__typeof__(y) _y = (y); \
(void)(&_x == &_y); \
_x > _y ? _x : _y; \
})
/* /*
* The round_up() macro rounds up a value to the given boundary in a * The round_up() macro rounds up a value to the given boundary in a
* type-agnostic yet type-safe manner. The boundary must be a power of two. * type-agnostic yet type-safe manner. The boundary must be a power of two.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment