From 929394b1894a9e879df71c7234e0a242a6869f06 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Fri, 11 Oct 2002 07:54:46 +0000 Subject: [PATCH] Added bits_val() macro, fixed problem with operator priority in macro bit(). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@162 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- include/common.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/common.h b/include/common.h index cf941e7c..06a8b3ee 100644 --- a/include/common.h +++ b/include/common.h @@ -51,11 +51,12 @@ #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 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(b1,b2) (((2 << ABS((b1) - (b2))) - 1) << MIN(b1,b2)) +#define bit(b) (1 << (b)) +#define bits(b1,b2) (((2 << ABS((b1) - (b2))) - 1) << MIN(b1,b2)) +#define bits_val(b1,b2,v) (((v) << MIN(b1,b2)) & bits(b1,b2)) #endif /* COMMON_H */