[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-4.0-testing] Define ABS() library function. Use it.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1281541424 -3600
# Node ID 954754745f65f0a76519924184062958d62f6744
# Parent  1da5224a287564ac6f86faf8fea0c6a88faa4010
Define ABS() library function. Use it.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   21345:2077d6ad6078
xen-unstable date:        Tue May 11 11:19:23 2010 +0100
---
 xen/common/compat/memory.c |    2 +-
 xen/include/xen/lib.h      |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff -r 1da5224a2875 -r 954754745f65 xen/common/compat/memory.c
--- a/xen/common/compat/memory.c        Tue Aug 10 15:49:20 2010 +0100
+++ b/xen/common/compat/memory.c        Wed Aug 11 16:43:44 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 1da5224a2875 -r 954754745f65 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h     Tue Aug 10 15:49:20 2010 +0100
+++ b/xen/include/xen/lib.h     Wed Aug 11 16:43:44 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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.