[Mesa-dev] [PATCH 3/7] mesa: Shrink the size of the enum string lookup struct.

Kenneth Graunke kenneth at whitecape.org
Sat Sep 21 09:03:28 PDT 2013


On 09/21/2013 07:59 AM, Brian Paul wrote:
> On Fri, Sep 20, 2013 at 7:52 PM, Eric Anholt <eric at anholt.net> wrote:
>> Since it's only used for debug information, we can misalign the struct and
>> save the disk space.  Another 19k on a 64-bit build.
>> ---
>>  src/mapi/glapi/gen/gl_enums.py | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mapi/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py
>> index e1ab600..6f54b06 100644
>> --- a/src/mapi/glapi/gen/gl_enums.py
>> +++ b/src/mapi/glapi/gen/gl_enums.py
>> @@ -47,8 +47,8 @@ class PrintGlEnums(gl_XML.gl_print_base):
>>          print '#include "main/imports.h"'
>>          print '#include "main/mtypes.h"'
>>          print ''
>> -        print 'typedef struct {'
>> -        print '   size_t offset;'
>> +        print 'typedef struct __attribute__((__packed__)) {'
> 
> I don't know if that'll work with MSVC. To be safe, we should probably
> wrap that in a #ifdef gcc test.
> 
> -Brian

Good catch - that doesn't work on MSVC.

Apparently on MSVC you do:
#pragma pack(push,1)
...
#pragma pack(pop)

Clang apparently supports either method.

Is it supposed to be __attribute__((__packed__)) or
__attribute__((packed))?  I see both floating around the internet.

--Ken


More information about the mesa-dev mailing list