From 6038aeffed975f9b2664fe4403e87ce3a6010058 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 23 Jul 2015 09:24:09 -0400 Subject: [PATCH] hobject_t: typed MIN_* helpers Signed-off-by: Sage Weil --- src/common/hobject.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/common/hobject.h b/src/common/hobject.h index b5f8b363abc..d1d9c02abac 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -299,6 +299,21 @@ static inline int cmp(const hobject_t& l, const hobject_t& r, bool sort_bitwise) return cmp_nibblewise(l, r); } +// these are convenient +static inline hobject_t MAX_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) { + if (cmp(l, r, bitwise) >= 0) + return l; + else + return r; +} + +static inline hobject_t MIN_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) { + if (cmp(l, r, bitwise) <= 0) + return l; + else + return r; +} + typedef version_t gen_t; struct ghobject_t { @@ -440,4 +455,21 @@ static inline int cmp(const ghobject_t& l, const ghobject_t& r, return cmp_nibblewise(l, r); } +// these are convenient +static inline ghobject_t MAX_GHOBJ(const ghobject_t& l, const ghobject_t& r, + bool bitwise) { + if (cmp(l, r, bitwise) >= 0) + return l; + else + return r; +} + +static inline ghobject_t MIN_GHOBJ(const ghobject_t& l, const ghobject_t& r, + bool bitwise) { + if (cmp(l, r, bitwise) <= 0) + return l; + else + return r; +} + #endif -- 2.47.3