[MPlayer-dev-eng] [PATCH] (2nd try) encapsulating #define arguments

Moritz Bunkus moritz at bunkus.org
Tue Jan 14 01:02:27 CET 2003


Hi.

Alright, here's my second attempt. Only defines that use their
arguments in calculations or comparisons are changed.

Ok to commit?

-- 
 ==> Ciao, Mosu (Moritz Bunkus)
-------------- next part --------------
diff -Nur -X diffexcludes -x DOCS -x libdha main/drivers/radeon/radeon_vid.h main-define-arg-encap/drivers/radeon/radeon_vid.h
--- main/drivers/radeon/radeon_vid.h	2002-06-20 16:37:09.000000000 +0200
+++ main-define-arg-encap/drivers/radeon/radeon_vid.h	2003-01-14 00:34:02.000000000 +0100
@@ -52,11 +52,11 @@
 #define IMGFMT_BGR24 (IMGFMT_BGR|24)
 #define IMGFMT_BGR32 (IMGFMT_BGR|32)
 
-#define IMGFMT_IS_RGB(fmt) ((fmt&IMGFMT_RGB_MASK)==IMGFMT_RGB)
-#define IMGFMT_IS_BGR(fmt) ((fmt&IMGFMT_BGR_MASK)==IMGFMT_BGR)
+#define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB)
+#define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
 
-#define IMGFMT_RGB_DEPTH(fmt) (fmt&~IMGFMT_RGB)
-#define IMGFMT_BGR_DEPTH(fmt) (fmt&~IMGFMT_BGR)
+#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&~IMGFMT_RGB)
+#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&~IMGFMT_BGR)
 
 
 /* Planar YUV Formats */
diff -Nur -X diffexcludes -x DOCS -x libdha main/Gui/wm/ws.h main-define-arg-encap/Gui/wm/ws.h
--- main/Gui/wm/ws.h	2003-01-09 21:47:12.000000000 +0100
+++ main-define-arg-encap/Gui/wm/ws.h	2003-01-14 00:33:56.000000000 +0100
@@ -254,7 +254,7 @@
 extern void wsScreenSaverOn( Display *mDisplay );
 extern void wsScreenSaverOff( Display * mDisplay );
 
-#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( X > tX )&&( Y > tY )&&( X < bX )&&( Y < bY ) )
+#define wgIsRect( X,Y,tX,tY,bX,bY ) ( ( (X) > (tX) )&&( (Y) > (tY) )&&( (X) < (bX) )&&( (Y) < (bY) ) )
 
 #endif
 
diff -Nur -X diffexcludes -x DOCS -x libdha main/Gui/wm/wsxdnd.h main-define-arg-encap/Gui/wm/wsxdnd.h
--- main/Gui/wm/wsxdnd.h	2002-08-11 15:12:38.000000000 +0200
+++ main-define-arg-encap/Gui/wm/wsxdnd.h	2003-01-14 00:34:00.000000000 +0100
@@ -17,7 +17,7 @@
 #define XDND_ENTER_THREE_TYPES_SET(e,b)	(e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~0x1UL) | (((b) == 0) ? 0 : 0x1UL)
 #define XDND_ENTER_VERSION(e)		((e)->xclient.data.l[1] >> 24)
 #define XDND_ENTER_VERSION_SET(e,v)	(e)->xclient.data.l[1] = ((e)->xclient.data.l[1] & ~(0xFF << 24)) | ((v) << 24)
-#define XDND_ENTER_TYPE(e,i)		((e)->xclient.data.l[2 + i])	/* i => (0, 1, 2) */
+#define XDND_ENTER_TYPE(e,i)		((e)->xclient.data.l[2 + (i)])	/* i => (0, 1, 2) */
 
 /* XdndPosition */
 #define XDND_POSITION_SOURCE_WIN(e)	((e)->xclient.data.l[0])
diff -Nur -X diffexcludes -x DOCS -x libdha main/libaf/af.h main-define-arg-encap/libaf/af.h
--- main/libaf/af.h	2003-01-10 02:45:34.000000000 +0100
+++ main-define-arg-encap/libaf/af.h	2003-01-14 00:34:04.000000000 +0100
@@ -247,8 +247,8 @@
 /* Macro for printing error messages */
 #ifndef af_msg
 #define af_msg(lev, args... ) \
-((lev<AF_MSG_WARN)?(fprintf(af_msg_cfg.err?af_msg_cfg.err:stderr, ## args )): \
-((lev<=af_msg_cfg.level)?(fprintf(af_msg_cfg.msg?af_msg_cfg.msg:stdout, ## args )):0))
+(((lev)<AF_MSG_WARN)?(fprintf(af_msg_cfg.err?af_msg_cfg.err:stderr, ## args )): \
+(((lev)<=af_msg_cfg.level)?(fprintf(af_msg_cfg.msg?af_msg_cfg.msg:stdout, ## args )):0))
 #endif
 
 #endif /* __aop_h__ */
diff -Nur -X diffexcludes -x DOCS -x libdha main/libaf/af_mp.h main-define-arg-encap/libaf/af_mp.h
--- main/libaf/af_mp.h	2003-01-03 13:36:14.000000000 +0100
+++ main-define-arg-encap/libaf/af_mp.h	2003-01-14 00:34:05.000000000 +0100
@@ -18,7 +18,7 @@
 #undef af_msg
 #endif
 #define af_msg(lev, args... ) \
-  mp_msg(MSGT_AFILTER,((lev<0)?(lev+3):((lev==0)?MSGL_INFO:(lev+5))), ##args )
+  mp_msg(MSGT_AFILTER,(((lev)<0)?((lev)+3):(((lev)==0)?MSGL_INFO:((lev)+5))), ##args )
 
 /* Decodes the format from mplayer format to libaf format */
 extern int af_format_decode(int format);
diff -Nur -X diffexcludes -x DOCS -x libdha main/libaf/af_resample.h main-define-arg-encap/libaf/af_resample.h
--- main/libaf/af_resample.h	2002-12-28 14:59:53.000000000 +0100
+++ main-define-arg-encap/libaf/af_resample.h	2003-01-14 00:43:27.000000000 +0100
@@ -66,8 +66,8 @@
 
 // Macro to add data to circular que 
 #define ADDQUE(xi,xq,in)\
-  xq[xi]=xq[xi+L]=(*in);\
-  xi=(xi-1)&(L-1);
+  xq[xi]=xq[(xi)+L]=*(in);\
+  xi=((xi)-1)&(L-1);
 
 #if defined(UP)
 
diff -Nur -X diffexcludes -x DOCS -x libdha main/libaf/filter.h main-define-arg-encap/libaf/filter.h
--- main/libaf/filter.h	2003-01-07 11:33:30.000000000 +0100
+++ main-define-arg-encap/libaf/filter.h	2003-01-14 00:34:07.000000000 +0100
@@ -63,7 +63,7 @@
    long. 
 */
 #define updateq(n,xi,xq,in)\
-  xq[xi]=xq[xi+n]=*in;\
-  xi=(++xi)&(n-1);
+  xq[xi]=(xq)[(xi)+(n)]=*(in);\
+  xi=(++(xi))&((n)-1);
 
 #endif
diff -Nur -X diffexcludes -x DOCS -x libdha main/libmpcodecs/img_format.h main-define-arg-encap/libmpcodecs/img_format.h
--- main/libmpcodecs/img_format.h	2002-08-01 14:39:07.000000000 +0200
+++ main-define-arg-encap/libmpcodecs/img_format.h	2003-01-14 00:34:09.000000000 +0100
@@ -24,11 +24,11 @@
 #define IMGFMT_BGR24 (IMGFMT_BGR|24)
 #define IMGFMT_BGR32 (IMGFMT_BGR|32)
 
-#define IMGFMT_IS_RGB(fmt) ((fmt&IMGFMT_RGB_MASK)==IMGFMT_RGB)
-#define IMGFMT_IS_BGR(fmt) ((fmt&IMGFMT_BGR_MASK)==IMGFMT_BGR)
+#define IMGFMT_IS_RGB(fmt) (((fmt)&IMGFMT_RGB_MASK)==IMGFMT_RGB)
+#define IMGFMT_IS_BGR(fmt) (((fmt)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
 
-#define IMGFMT_RGB_DEPTH(fmt) (fmt&~IMGFMT_RGB)
-#define IMGFMT_BGR_DEPTH(fmt) (fmt&~IMGFMT_BGR)
+#define IMGFMT_RGB_DEPTH(fmt) ((fmt)&~IMGFMT_RGB)
+#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&~IMGFMT_BGR)
 
 
 /* Planar YUV Formats */
diff -Nur -X diffexcludes -x DOCS -x libdha main/libmpdemux/asf.h main-define-arg-encap/libmpdemux/asf.h
--- main/libmpdemux/asf.h	2002-07-09 10:23:47.000000000 +0200
+++ main-define-arg-encap/libmpdemux/asf.h	2003-01-14 00:34:10.000000000 +0100
@@ -6,7 +6,7 @@
 #include "bswap.h"
 
 #ifndef MIN
-#define MIN(a,b) ((a<b)?a:b)
+#define MIN(a,b) (((a)<(b))?(a):(b))
 #endif
 
 ///////////////////////
diff -Nur -X diffexcludes -x DOCS -x libdha main/libmpeg2/attributes.h main-define-arg-encap/libmpeg2/attributes.h
--- main/libmpeg2/attributes.h	2001-03-04 22:01:53.000000000 +0100
+++ main-define-arg-encap/libmpeg2/attributes.h	2003-01-14 00:34:11.000000000 +0100
@@ -21,7 +21,7 @@
 
 /* use gcc attribs to align critical data structures */
 #ifdef ATTRIBUTE_ALIGNED_MAX
-#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
+#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < (align)) ? ATTRIBUTE_ALIGNED_MAX : (align))))
 #else
 #define ATTR_ALIGN(align)
 #endif
diff -Nur -X diffexcludes -x DOCS -x libdha main/mp_msg.h main-define-arg-encap/mp_msg.h
--- main/mp_msg.h	2002-10-01 08:45:08.000000000 +0200
+++ main-define-arg-encap/mp_msg.h	2003-01-14 00:33:53.000000000 +0100
@@ -93,7 +93,7 @@
 
 #ifdef TARGET_OS2
 // va_start/vsnprintf seems to be broken under OS2 :(
-#define mp_msg(mod,lev, fmt, args... ) do{if(lev<=mp_msg_levels[mod]) printf( fmt, ## args );}while(0)
+#define mp_msg(mod,lev, fmt, args... ) do{if((lev)<=mp_msg_levels[mod]) printf( fmt, ## args );}while(0)
 #define mp_dbg(mod,lev, args... ) 
 #else
 
@@ -108,19 +108,19 @@
 void mp_msg_c( int x, const char *format, ... );
 
 #ifdef __GNUC__
-#define mp_msg(mod,lev, args... ) mp_msg_c((mod<<8)|lev, ## args )
+#define mp_msg(mod,lev, args... ) mp_msg_c(((mod)<<8)|(lev), ## args )
 
 #ifdef MP_DEBUG
-#define mp_dbg(mod,lev, args... ) mp_msg_c((mod<<8)|lev, ## args )
+#define mp_dbg(mod,lev, args... ) mp_msg_c(((mod)<<8)|(lev), ## args )
 #else
 // these messages are only usefull for developers, disable them
 #define mp_dbg(mod,lev, args... ) 
 #endif
 #else // not GNU C
-#define mp_msg(mod,lev, ... ) mp_msg_c((mod<<8)|lev, __VA_ARGS__)
+#define mp_msg(mod,lev, ... ) mp_msg_c(((mod)<<8)|(lev), __VA_ARGS__)
 
 #ifdef MP_DEBUG
-#define mp_dbg(mod,lev, ... ) mp_msg_c((mod<<8)|lev, __VA_ARGS__)
+#define mp_dbg(mod,lev, ... ) mp_msg_c(((mod)<<8)|(lev), __VA_ARGS__)
 #else
 // these messages are only usefull for developers, disable them
 #define mp_dbg(mod,lev, ... ) 
diff -Nur -X diffexcludes -x DOCS -x libdha main/vidix/drivers/cyberblade_regs.h main-define-arg-encap/vidix/drivers/cyberblade_regs.h
--- main/vidix/drivers/cyberblade_regs.h	2003-01-03 13:26:17.000000000 +0100
+++ main-define-arg-encap/vidix/drivers/cyberblade_regs.h	2003-01-14 00:34:13.000000000 +0100
@@ -129,10 +129,10 @@
 
 int HACKBUCKET12345678;  /* Horrible hack to work around cache/speed issue */
 
-#define INB(addr) (HACKBUCKET12345678=*(cyberblade_reg_base+addr))
-#define INW(addr) (HACKBUCKET12345678=*(unsigned short *)(cyberblade_reg_base+addr))
-#define OUTB(addr,val) (*(cyberblade_reg_base+addr)=(val))
-#define OUTW(addr,val) (*(unsigned short *)(cyberblade_reg_base+addr)=(val))
+#define INB(addr) (HACKBUCKET12345678=*(cyberblade_reg_base+(addr)))
+#define INW(addr) (HACKBUCKET12345678=*(unsigned short *)(cyberblade_reg_base+(addr)))
+#define OUTB(addr,val) (*(cyberblade_reg_base+(addr))=(val))
+#define OUTW(addr,val) (*(unsigned short *)(cyberblade_reg_base+(addr))=(val))
 
 #define SRINB(reg) (OUTB(0x3c4,reg), INB(0x3c5))
 #define SROUTB(reg,val) (OUTW(0x3c4,((val)<<8)|(reg)))
diff -Nur -X diffexcludes -x DOCS -x libdha main/vidix/drivers/pm3_regs.h main-define-arg-encap/vidix/drivers/pm3_regs.h
--- main/vidix/drivers/pm3_regs.h	2002-06-01 01:17:43.000000000 +0200
+++ main-define-arg-encap/vidix/drivers/pm3_regs.h	2003-01-14 00:34:14.000000000 +0100
@@ -1060,10 +1060,10 @@
 extern void *pm3_reg_base;
 
 #define WRITE_REG(offset,val)				\
-    *(volatile unsigned long *)(((unsigned char *)(pm3_reg_base)) + offset) = (val)
+    *(volatile unsigned long *)(((unsigned char *)(pm3_reg_base)) + (offset)) = (val)
 	
 #define READ_REG(offset)					\
-    *(volatile unsigned long *)(((unsigned char *)(pm3_reg_base)) + offset)
+    *(volatile unsigned long *)(((unsigned char *)(pm3_reg_base)) + (offset))
 
 #define UPDATE_SET_REG(offset,val)				\
     {								\
@@ -1094,8 +1094,8 @@
 
 #define RAMDAC_SET_INDEX(index)					\
 {								\
-    SLOW_WRITE_REG (PM3RD_IndexHigh,(index>>8)&0xff);		\
-    SLOW_WRITE_REG (PM3RD_IndexLow,index&0xff);			\
+    SLOW_WRITE_REG (PM3RD_IndexHigh,((index)>>8)&0xff);		\
+    SLOW_WRITE_REG (PM3RD_IndexLow,(index)&0xff);			\
 }
 
 #define RAMDAC_SET_REG(index, data)				\


More information about the MPlayer-dev-eng mailing list