Mailing List Archive

[xen-unstable] Define ABS() library function. Use it.
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1273573163 -3600
# Node ID 2077d6ad60780bbe0631c0dee1ef2e2b8eb03867
# Parent e984d995f360d101b188fc4973243e2e4048e0c4
Define ABS() library function. Use it.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
---
xen/common/compat/memory.c | 2 +-
xen/include/xen/lib.h | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)

diff -r e984d995f360 -r 2077d6ad6078 xen/common/compat/memory.c
--- a/xen/common/compat/memory.c Tue May 11 11:10:24 2010 +0100
+++ b/xen/common/compat/memory.c Tue May 11 11:19:23 2010 +0100
@@ -116,7 +116,7 @@ int compat_memory_op(unsigned int cmd, X

start_extent = cmp.xchg.nr_exchanged;
end_extent = (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.xchg)) /
- (((1U << __builtin_abs(order_delta)) + 1) *
+ (((1U << ABS(order_delta)) + 1) *
sizeof(*space));
if ( end_extent == 0 )
{
diff -r e984d995f360 -r 2077d6ad6078 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h Tue May 11 11:10:24 2010 +0100
+++ b/xen/include/xen/lib.h Tue May 11 11:19:23 2010 +0100
@@ -39,6 +39,11 @@ do {
#else
#define ASSERT(p) ((void)0)
#endif
+
+#define ABS(_x) ({ \
+ typeof(_x) __x = (_x); \
+ (__x < 0) ? -__x : __x; \
+})

#define SWAP(_a, _b) \
do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog