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

2012-10-23 Thread Didier Barvaux
> > The 2 first fields uses 1 byte with GCC/Clang while they use > > sizeof(unsigned int) bytes with TCC. GCC/Clang pack the bit fields > > on the smaller type available. So, sizeof(struct mystruct1) = 4 with > > GCC/Clang and sizeof(struct mystruct1) = 8 with TCC. > > I tried your "bitfield.c" t

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

2012-10-22 Thread Daniel Glöckner
On Mon, Oct 22, 2012 at 09:38:22PM +0200, Didier Barvaux wrote: > Please send your patch, it may be better than mine. Or maybe we can > create a third patch from ours and mine. By the way, ARM describes how to bit-fields should be laid out in http://infocenter.arm.com/help/topic/com.arm.doc.ihi004

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

2012-10-22 Thread grischka
Didier Barvaux wrote: On a structure such as: struct mystruct1 { unsigned int mystruct1_foo:4; unsigned int mystruct1_bar:4; uint8_t mystruct1_other; uint16_t mystruct1_other2; }; The 2 first fields uses 1 byte with GCC/Clang while they use sizeof(unsigned int) bytes wi

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

2012-10-22 Thread Didier Barvaux
> This was the very first patch that I ever wrote to tcc. Except I > didn't make it optional. I never submitted it because of that. > > Being able to pack data the same way that GCC (and MSVC for that > matter) does is very useful, especially in network code. Granted that > "officially" I think t

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

2012-10-22 Thread Michael B. Smith
0, 2012 3:59 PM To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] question about bit-fields Didier Barvaux wrote: > 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

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

2012-10-20 Thread Didier Barvaux
Grischka, > > 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. > > ... the way GCC does? > > > I added this mechanism because I want to use TCC to

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

2012-10-20 Thread grischka
Didier Barvaux wrote: 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. ... the way GCC does? I added this mechanism because I want to use TCC to compile

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

2012-10-20 Thread Didier Barvaux
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

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

2012-05-28 Thread Didier Barvaux
Hi, > > 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 mys

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

2012-05-27 Thread Michael Matz
Hi, On Sun, 27 May 2012, Michael Matz wrote: 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. Act

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

2012-05-27 Thread Rick C. Hodgin
Alright. Sounds good. I'm in. :-) Best regards, Rick C. Hodgin Original Message From: Michael Matz Sent: Sun, May 27, 2012 04:49 PM To: tinycc-devel@nongnu.org CC: Subject: Re: [Tinycc-devel] question about bit-fields >Hi, > >On Sun, 27 May 2012, Ric

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

2012-05-27 Thread Michael Matz
Hi, On Sun, 27 May 2012, Rick Hodgin wrote: Didier, You're able to take the code and modify that requirement. It seems straight-forward enough that TinyCC is (in memory at compile-time) determining the target size, regardless of the storage size, and using that for the storage size in memo

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

2012-05-27 Thread Rick Hodgin
ds). Best regards, Rick C. Hodgin --- On Sun, 5/27/12, Didier Barvaux wrote: > From: Didier Barvaux > Subject: Re: [Tinycc-devel] question about bit-fields > To: tinycc-devel@nongnu.org > Date: Sunday, May 27, 2012, 7:47 AM > > > > Is there an option or a declaration

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

2012-05-27 Thread Didier Barvaux
> > Is there an option or a declaration to make tcc compute the expected > > length for unsigned-int-based bit fields? > > No, there isn't. > > AFAIK the C standard says this is implementation-defined. > For portability don't use bitfields. Thank for your answer. I see the problem. I added a ch

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

2012-05-27 Thread Daniel Glöckner
On Sun, May 27, 2012 at 11:12:39AM +0200, Didier Barvaux wrote: > Is there an option or a declaration to make tcc compute the expected > length for unsigned-int-based bit fields? No, there isn't. AFAIK the C standard says this is implementation-defined. For portability don't use bitfields. Dan

[Tinycc-devel] question about bit-fields

2012-05-27 Thread Didier Barvaux
Hello all, I'm trying to build my project with tcc (yesterday's git version). It succeeds without any required change (cool!), but tests fail :( I narrowed the problem to bit-fields, and more especially to the length of some bit-fields. I created a small test program to explain the problem: $ ca