From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: [PATCH 1/6] tools: Move the typesafe min/max helpers into xen-tools/libs.h
Date: Mon, 5 Nov 2018 11:21:02 +0000 [thread overview]
Message-ID: <1541416867-30253-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1541416867-30253-1-git-send-email-andrew.cooper3@citrix.com>
... 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@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
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 927e057..cc7dfc8 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 705eaa9..adc3b6a 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 153566a..ff88938 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
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-05 11:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 11:21 [PATCH 0/6] x86/emul: Use struct cpuid_policy for feature checks Andrew Cooper
2018-11-05 11:21 ` Andrew Cooper [this message]
2018-11-05 11:23 ` [PATCH 1/6] tools: Move the typesafe min/max helpers into xen-tools/libs.h Wei Liu
2018-11-05 11:21 ` [PATCH 2/6] libx86: Split x86_cpuid_policy_fill_native() out of calculate_raw_policy() Andrew Cooper
2018-11-06 13:44 ` Jan Beulich
2018-11-09 16:24 ` Andrew Cooper
2018-11-12 8:13 ` Jan Beulich
2018-11-06 16:31 ` Roger Pau Monné
2018-11-09 16:26 ` Andrew Cooper
2018-11-05 11:21 ` [PATCH 3/6] tools/x86emul: Use struct cpuid_policy in the userspace test harnesses Andrew Cooper
2018-11-06 15:25 ` Jan Beulich
2018-11-05 11:21 ` [PATCH 4/6] x86/emul: Pass a full cpuid_policy into x86_emulate() Andrew Cooper
2018-11-06 15:28 ` Jan Beulich
2018-11-05 11:21 ` [PATCH 5/6] x86/emul: Don't use the ->cpuid() hook for feature checks Andrew Cooper
2018-11-06 15:32 ` Jan Beulich
2018-11-05 11:21 ` [PATCH 6/6] x86/emul: dedup hvmemul_cpuid() and pv_emul_cpuid() Andrew Cooper
2018-11-06 15:38 ` Jan Beulich
2018-11-06 15:52 ` Andrew Cooper
2018-11-06 16:16 ` Jan Beulich
2018-11-09 17:16 ` Andrew Cooper
2018-11-12 8:17 ` Jan Beulich
2018-11-14 0:20 ` Woods, Brian
2018-11-14 7:47 ` Jan Beulich
2018-11-15 14:23 ` Andrew Cooper
2018-11-15 15:09 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541416867-30253-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).