From cc046eb6825ae8b7b1921c4b3f9a3c9e671a289a Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Thu, 10 Oct 2002 21:18:23 +0000 Subject: [PATCH] Added macros ABS(), MIN() and MAX(), changed bits() to more portable version. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@160 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- include/common.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/common.h b/include/common.h index fd3b52a0..cf941e7c 100644 --- a/include/common.h +++ b/include/common.h @@ -51,7 +51,11 @@ #define C 1 #endif +#define ABS(a) (((a) < 0) ? (-(a)) : (a)) +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define MAX(a,b) (((a) < (b)) ? (b) : (a)) + #define bit(x) (1 << x) -#define bits(h,l) (((1 << (h + 1)) - 1) & ~((1 << l) - 1)) +#define bits(b1,b2) (((2 << ABS((b1) - (b2))) - 1) << MIN(b1,b2)) #endif /* COMMON_H */