emacs-devel
[Top][All Lists]
Advanced

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

Re: [RFC, PATCH] shrink struct vectorlike_header #2


From: Andreas Rottmann
Subject: Re: [RFC, PATCH] shrink struct vectorlike_header #2
Date: Fri, 09 Nov 2012 19:04:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Nix <address@hidden> writes:

> On 8 Nov 2012, Paul Eggert spake thusly:
>> But better yet would be to omit the casts entirely.
>> This might let GCC do more optimizations safely.  That is,
>> change struct Lisp_Vector to be something like this:
>>
>> struct Lisp_Vector
>>   {
>>      struct vectorlike_header header;
>>      union
>>        {
>>           Lisp_Object contents[1];
>>           struct Lisp_Vector *next;
>>        } u;
>>   };
>>
>> Replace all current uses of 'contents'
>> with 'u.contents', and then use u.next
>> when you want to use the memory as a next field.
>
> It's a shame we can't use an unnamed union here:
>
> struct Lisp_Vector
>   {
>      struct vectorlike_header header;
>      union
>        {
>           Lisp_Object contents[1];
>           struct Lisp_Vector *next;
>        };
>   };
>
> No changes to source necessary.
>
> Downside: GCC extension :( which probably rules it out unless wrapped in
> compiler-specific macro trickery, and if you're doing that you might as
> well just unconditionally use a named union.
>
At least according to Wikipedia[0], anonymous unions and structs are
part of C11, so they're not compiler-specific any longer.  However,
given the newness of C11, similiar considerations regarding portability
to non-GCC compilers may still apply.

[0] http://en.wikipedia.org/wiki/C11_(C_standard_revision)

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.xx.vu/>



reply via email to

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