PATCH: MS bitfield layout support for w32 targets - Take 2.

Danny Smith danny_r_smith_2001@yahoo.co.nz
Fri Apr 5 00:27:00 GMT 2002


Hello

The attached patch adds -mms-bitfields as a new target switch for cygwin
and mingw32. This switch provides w32 targets with option to use
MS-compatable storage layout for bitfields in structures, as introduced
by Alexandre Oliva in SH5 port (refer
http://gcc.gnu.org/ml/gcc-patches/2002-02/msg00402.html). 

The patch provide documentation and testcases, as requested.

The documentation for this switch in invoke.texi is a shameless copy of
the documentation for the TARGET_MS_BITFIELD_LAYOUT_P hook in tm.texi.

The testcase bf-ms-layout.c succeeds on all 10 tests for offsets of
fields within structures but fails on four of the 10 tests for alignment
of the structure as a whole. This is because of a problem in
stor_layout.c handling of item (ii) of the documented behaviour of the
target hook, namely:"a zero-sized bit-field will affect the alignment of
the whole enclosing structure". 

Work on fixing these failures is in progress.

The testcase bf-no-ms-layout.c is the same code  but switched to test
whether the changes do not affect gcc default packing.  This test succeeds.

If this patch is acceptable, where should the testcases go? gcc.dg was
suggested earlier.

Bootstapped and tested on i586-pc-mingw32.

Okay for mainline?

Danny

ChangeLog

2002-04-05  Danny Smith  <dannysmith@users.sourceforge.net>

	* config/i386/cygwin.h (MASK_MS_BITFIELD_LAYOUT): New mask for
	target switch -mms-bitfields.
	(TARGET_USE_MS_BITFIELD_LAYOUT): New define, using mask.
	(SUBTARGET_SWITCHES): Set mask, document -mms-bitfield switch.
	* config/i386/i386.c (ix86_ms_bitfield_layout_p): Add new hook
	function for TARGET_MS_BITFIELD_LAYOUT_P returning ...
	(TARGET_USE_MS_BITFIELD_LAYOUT): Define to 0 if not defined
	by subtarget.
	* doc/invoke.texi (-mms-bitfields): Document target switch.
	* testsuite/gcc.dg/bf-ms-layout.c: New file.
	* testsuite/gcc.dg/bf-no-ms-layout.c: New file.



http://www.sold.com.au - SOLD.com.au Auctions
- 1,000s of Bargains!
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bitfield-20020405.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020405/e5805f0a/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bf-ms-layout.c
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020405/e5805f0a/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bf-no-ms-layout.c
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020405/e5805f0a/attachment-0001.c>


More information about the Gcc-patches mailing list