[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] question about bit-fields

From: Didier Barvaux
Subject: Re: [Tinycc-devel] question about bit-fields
Date: Sat, 20 Oct 2012 19:51:01 +0200

Hello all,

> > > If one changes anything at all then it only makes sense to change
> > > it so as to be layout compatible with GCC.  A third layout (GCC,
> > > TCC-old, TCC-new) wouldn't help.  Although the rules of GCC are
> > > relatively obscure and complex in corner cases.
> > 
> > Actually I have to correct myself here.  After studying the layout
> > code a bit I see that TCC implements mostly microsoft's bit-field
> > layout.  We don't want to get rid of that capability, so GCCs layout
> > (which is PCC layout for i386 and arm AAPCS, and funky layout for
> > legacy arm) would have to be implemented in addition.
> OK, I'll give it a try during the next week.

Hum, 'next week' is well over, but here is the patch! :)

Please find attached, a patch that modify TCC so that it can pack bit
fields the way GCC does. The mechanism is optional and off by default.
It can be enabled with the -fgcc-packing option.

I added this mechanism because I want to use TCC to compile some code
that manages IPv4 headers [1]. The code uses the 'struct iphdr' of the
GNU libc, and relies on its size doing exactly 20 bytes. TCC does not
compute the structure length the same way GCC does, and the program

Someone told me that I can add code to mimic the behaviour of GCC. The
attached patch is an attempt to do so. It is probably not very good as
I didn't known TCC's codebase before, but it seems to work. I'm open
for comments on it. I tested my modifications with the attached test


[1] http://rohc-lib.org/

Attachment: bitfield_gcc_packing.patch
Description: Text Data

Attachment: bitfield.c
Description: Text Data

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]