[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] tools: Move the typesafe min/max helpers into xen-tools/libs.h
commit b7829ea3cb02112d96038b1b6fd9984b10d16396 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Thu Jul 19 16:42:07 2018 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Nov 5 17:07:11 2018 +0000 tools: Move the typesafe min/max helpers into xen-tools/libs.h ... rather than implementing them separately for libxc and libxl. They will shortly be wanted in libx86 as well. Fix up the style/consistency in the declaration, but no functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/include/xen-tools/libs.h | 38 ++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_private.h | 16 ---------------- tools/libxl/libxl_internal.h | 16 ---------------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/tools/include/xen-tools/libs.h b/tools/include/xen-tools/libs.h index 927e057389..cc7dfc8c64 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/libs.h @@ -21,4 +21,42 @@ #define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif +#ifndef min +#define min(x, y) \ + ({ \ + const typeof(x) _x = (x); \ + const typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + (_x < _y) ? _x : _y; \ + }) +#endif + +#ifndef max +#define max(x, y) \ + ({ \ + const typeof(x) _x = (x); \ + const typeof(y) _y = (y); \ + (void)(&_x == &_y); \ + (_x > _y) ? _x : _y; \ + }) +#endif + +#ifndef min_t +#define min_t(type, x, y) \ + ({ \ + const type _x = (x); \ + const type _y = (y); \ + (_x < _y) ? _x: _y; \ + }) +#endif + +#ifndef max_t +#define max_t(type, x, y) \ + ({ \ + const type _x = (x); \ + const type _y = (y); \ + (_x > _y) ? _x: _y; \ + }) +#endif + #endif /* __XEN_TOOLS_LIBS__ */ diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index 705eaa9385..adc3b6a571 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -405,22 +405,6 @@ int xc_ffs16(uint16_t x); int xc_ffs32(uint32_t x); int xc_ffs64(uint64_t x); -#define min(X, Y) ({ \ - const typeof (X) _x = (X); \ - const typeof (Y) _y = (Y); \ - (void) (&_x == &_y); \ - (_x < _y) ? _x : _y; }) -#define max(X, Y) ({ \ - const typeof (X) _x = (X); \ - const typeof (Y) _y = (Y); \ - (void) (&_x == &_y); \ - (_x > _y) ? _x : _y; }) - -#define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) - #define DOMPRINTF(fmt, args...) xc_dom_printf(dom->xch, fmt, ## args) #define DOMPRINTF_CALLED(xch) xc_dom_printf((xch), "%s: called", __FUNCTION__) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 153566acd0..ff889385fe 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -138,22 +138,6 @@ #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) #define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) -#define min(X, Y) ({ \ - const typeof (X) _x = (X); \ - const typeof (Y) _y = (Y); \ - (void) (&_x == &_y); \ - (_x < _y) ? _x : _y; }) -#define max(X, Y) ({ \ - const typeof (X) _x = (X); \ - const typeof (Y) _y = (Y); \ - (void) (&_x == &_y); \ - (_x > _y) ? _x : _y; }) - -#define min_t(type, x, y) \ - ({ const type _x = (x); const type _y = (y); _x < _y ? _x: _y; }) -#define max_t(type, x, y) \ - ({ const type _x = (x); const type _y = (y); _x > _y ? _x: _y; }) - #define LIBXL__LOGGING_ENABLED #ifdef LIBXL__LOGGING_ENABLED -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |