aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-08-11 16:43:44 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-08-11 16:43:44 +0100
commit6007502b5726d833d15d06c231f4a46f001da3ca (patch)
treed0bdba93ef5472da5901ae21bf7b4b306d60df61
parentd55a8f1a65c111c65296ac34f99b7869d01c489a (diff)
downloadxen-6007502b5726d833d15d06c231f4a46f001da3ca.tar.gz
xen-6007502b5726d833d15d06c231f4a46f001da3ca.tar.bz2
xen-6007502b5726d833d15d06c231f4a46f001da3ca.zip
Define ABS() library function. Use it.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com> xen-unstable changeset: 21345:2077d6ad6078 xen-unstable date: Tue May 11 11:19:23 2010 +0100
-rw-r--r--xen/common/compat/memory.c2
-rw-r--r--xen/include/xen/lib.h5
2 files changed, 6 insertions, 1 deletions
diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c
index 4acbf7447a..2402984f1e 100644
--- a/xen/common/compat/memory.c
+++ b/xen/common/compat/memory.c
@@ -116,7 +116,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
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 --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index bca0d65df0..d21e8dd5c0 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -40,6 +40,11 @@ do { \
#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 )