[PATCH] Use ATTRIBUTE_PACKED in ree.c

Richard Earnshaw rearnsha@arm.com
Wed Nov 28 15:06:00 GMT 2012


On 28/11/12 15:05, Jakub Jelinek wrote:
> On Wed, Nov 28, 2012 at 03:02:12PM +0000, Richard Earnshaw wrote:
>>> #if (GCC_VERSION < 2007)
>>> # define __attribute__(x)
>>> #endif
>>> ...
>>> #ifndef ATTRIBUTE_PACKED
>>> # define ATTRIBUTE_PACKED __attribute__ ((packed))
>>> #endif
>>>
>>> So in theory it should expand to nothing for non-GCC compilers.
>>> I've tested (on a short testcase matching what the decl does)
>>> GCCs from 4.8 down back to 3.2 (we support 4.1+ only anyway now)
>>> and clang 3.0.
>>>
>>> 	Jakub
>>>
>>
>> That's not going to help if those other compilers need packedness to
>> eliminate padding.  The /old/ ARM ABI used to require that all
>> structs were padded out to 32 bits.
>>
>> It looks to me as though this code is just non-portable and as such
>> needs to be rewritten :-(
>
> Why?  There is no hard requirement that this must be 2 byte long instead of
> 4, it is a pure optimization, don't want to waste too much memory
> unnecessarily.
>
> 	Jakub
>


Ah, OK.  I read your mail as implying that it didn't work when it wasn't 
2 bytes long...

R.



More information about the Gcc-patches mailing list