On 02/21/2014 02:43 PM, Matt Turner wrote: > On Fri, Feb 21, 2014 at 2:25 PM, Kenneth Graunke <kenn...@whitecape.org> > wrote: >> Generally, I only use PACKED when something -relies- on a particular >> memory layout. Is it really worth second guessing the compiler here? >> Presumably it had a reason for choosing a larger size other than sheer >> stupidity... > > We're not second guessing the compiler. > > The C99 spec says the type of an enum is implementation defined. > Adding __attribute__((__packed__)) to an enum has the same behavior as > gcc's -fshort-enum flag, but the flag would obviously cover all enums. > The gcc non-bugs page [0] says that they don't want to make > -fshort-enums the default because of [ABI] incompatibilities with > other compilers. They suggest setting a field width of the enum in a > struct, but in general that seems prone to errors (e.g., adding a > 256th value to an enum, but having specified an 8-bit field width on > the enum field) that using packed wouldn't have. Since we aren't > likely to hit that, would you rather me just set a field width? > > [0] http://gcc.gnu.org/onlinedocs/gcc/Non-bugs.html#index-fshort-enums-3868
Okay, that's bordering more on 'stupidity' than I thought. These enums are only ever used internally, so ABI compatibility is completely irrelevant. And they do get copied around a fair bit. __attribute__((packed)) seems nicer than making every user of the value specify a field width. It would be nice to add your explanation here to the commit message. Acked-by: Kenneth Graunke <kenn...@whitecape.org> Alternatively, just compiling i965 with -fshort-enums might make sense. Perhaps other people have thoughts.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev