[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [Patch v3 1/2] tools/libxc: Shuffle definitions and uses of min()/max() macros
Move the typesafe min() macro from xc_dom_decompress_unsafe_xz.c to xc_private.h, and complement it with an equivalent max() macro. Replace current users of type unsafe MIN()/MAX() macros, and remove their scattered definitions. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx> CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- v3: Rebase on top of min_t()/max_t() changes. --- tools/libxc/xc_core_x86.c | 4 ---- tools/libxc/xc_dom_decompress_unsafe_xz.c | 6 ------ tools/libxc/xc_domain_restore.c | 2 +- tools/libxc/xc_private.h | 11 +++++++++++ tools/libxc/xg_private.h | 2 +- tools/libxc/xg_save_restore.h | 7 ------- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c index e328dcf..f05060a 100644 --- a/tools/libxc/xc_core_x86.c +++ b/tools/libxc/xc_core_x86.c @@ -24,10 +24,6 @@ #define GET_FIELD(_p, _f) ((dinfo->guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f)) -#ifndef MAX -#define MAX(_a, _b) ((_a) >= (_b) ? (_a) : (_b)) -#endif - int xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, unsigned long pfn) diff --git a/tools/libxc/xc_dom_decompress_unsafe_xz.c b/tools/libxc/xc_dom_decompress_unsafe_xz.c index 6be1f89..fe7a7f4 100644 --- a/tools/libxc/xc_dom_decompress_unsafe_xz.c +++ b/tools/libxc/xc_dom_decompress_unsafe_xz.c @@ -34,12 +34,6 @@ static inline u32 le32_to_cpup(const u32 *p) return cpu_to_le32(*p); } -#define min(x,y) ({ \ - const typeof(x) _x = (x); \ - const typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x < _y ? _x : _y; }) - #define __force #define always_inline diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index 071ab6a..e73e0a2 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -339,7 +339,7 @@ static xen_pfn_t *load_p2m_frame_list( /* Any remaining bytes of this chunk: read and discard. */ while ( chunk_bytes ) { - unsigned long sz = MIN(chunk_bytes, sizeof(xen_pfn_t)); + unsigned long sz = min_t(unsigned long, chunk_bytes, sizeof(xen_pfn_t)); if ( RDEXACT(io_fd, &p2m_fl_zero, sz) ) { PERROR("read-and-discard extended-info chunk bytes failed"); diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index c240a7c..ce7e81e 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -349,6 +349,17 @@ 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) \ diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h index e593364..1910361 100644 --- a/tools/libxc/xg_private.h +++ b/tools/libxc/xg_private.h @@ -159,7 +159,7 @@ static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m, /* Size in bytes of the pfn_to_mfn_frame_list */ #define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width)) #define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) * \ - MAX((sizeof (xen_pfn_t)), dinfo->guest_width)) + max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_width)) /* Masks for PTE<->PFN conversions */ #define MADDR_BITS_X86 ((dinfo->guest_width == 8) ? 52 : 44) diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h index aa93c13..bdd9009 100644 --- a/tools/libxc/xg_save_restore.h +++ b/tools/libxc/xg_save_restore.h @@ -392,10 +392,3 @@ static inline int get_platform_info(xc_interface *xch, uint32_t dom, else \ memset(&(_p)->x32._f[0], (_v), sizeof((_p)->x32._f)); \ } while (0) - -#ifndef MAX -#define MAX(_a, _b) ((_a) >= (_b) ? (_a) : (_b)) -#endif -#ifndef MIN -#define MIN(_a, _b) ((_a) <= (_b) ? (_a) : (_b)) -#endif -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |