[Intel-gfx] Trimming down conditional compilation

Carl Worth cworth at cworth.org
Thu Mar 4 02:27:08 CET 2010


This isn't something to do before 2.11, but something I'd like to do
shortly after.

I want to go through the driver and reduce our usage of conditional
compilation, (use of macros like #if and #ifdef, etc.) as much as
possible. These various configurations make things harder to test and
maintain.

Of course, we've been getting rid of a lot recently anyway. Here are the
major occurrences left (after Daniel Vetter's recent patches) along with
a comparison to how things were in the 2.7.0 release:

				Occurrences of
				macro (by branch)
Macro				2.7.0	master
-----				------	-----
#if 0				67	51
INTEL_XVMC			35	26
XF86DRI				67	20
I830_ONLY			11	10
ARGB_CURSOR			 7	 5
#if 1				 7	 5
PIXEL_CENTRE_SAMPLE		 0	 3
DRI2INFOREC_VERSION >= 4	 0	 3

If anyone has any comments on which of those might be easy to get rid
of, or which really need to stick around, I'll be interested in seeing
that. The large number of "#if 0" looks pretty tempting to me.

Since I was looking, here are the counts of macros that have been
entirely eliminated since 2.7. Congratulations to all the code removers!

				Occurences of macro
Macro				in 2.7.0
-----				--------
XSERVER_LIBPCIACCESS		48
I830_USE_EXA			16
RANDR_12_INTERFACE		12
I830_USE_UXA			12
XF86DRM_MODE			11
RANDR_GET_CRTC_INTERFACE	10
I830_XV				10
I830_USE_XAA			 9
DRI2				 7
ALWAYS_SYNC			 7
I830DEBUG			 6
ALWAYS_FLUSH			 6
REG_DUMPER			 5
I2C_DEBUG			 4
SERVER_1_5			 3
EXA_VERSION_MINOR >= 2		 3
DO_SCANLINE_IMAGE_WRITE		 3
SERVER_1_5			 3

-Carl

PS. I obtained the above numbers with the following one-liner run in
xf86-video-intel/src, (and I manually ignored HAVE_CONFIG_H).

# Count macros occurring more than twice in the source files
grep '#if' * | sed -e 's/^[^:]*://' | sort | uniq -c | grep -v '^ *[12] ' | sort -n -r
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20100303/9e2223fd/attachment.sig>


More information about the Intel-gfx mailing list