From 3a383713670a8a31c6a9c84e3729d88d27c718ab Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 29 Jul 2015 18:34:10 +0800 Subject: [PATCH] MSVC Builds: Support PACKED Define PACKED for Visual Studio builds, so that we can try to reduce our library size for Visual Studio builds. Add a ENDPACKED macro that is currently defined only for Visual Studio builds as packing is done via __pragma(pack(push,n), that should be popped when done. Signed-off-by: Emmanuele Bassi --- src/dispatch_common.h | 5 +++++ src/gen_dispatch.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/dispatch_common.h b/src/dispatch_common.h index 676a4d5..52743a6 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -68,8 +68,13 @@ #if defined(__GNUC__) #define PACKED __attribute__((__packed__)) +#define ENDPACKED +#elif defined (_MSC_VER) +#define PACKED __pragma(pack(push,1)) +#define ENDPACKED __pragma(pack(pop)) #else #define PACKED +#define ENDPACKED #endif /* On win32, we're going to need to keep a per-thread dispatch table, diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py index d40f851..dfce596 100755 --- a/src/gen_dispatch.py +++ b/src/gen_dispatch.py @@ -628,6 +628,7 @@ class Generator(object): # Writes the enum declaration for the list of providers # supported by gl_provider_resolver() + self.outln('') self.outln('enum {0}_provider {{'.format(self.target)) sorted_providers = sorted(self.provider_enum.keys()) @@ -640,6 +641,7 @@ class Generator(object): enum = self.provider_enum[human_name] self.outln(' {0},'.format(enum)) self.outln('} PACKED;') + self.outln('ENDPACKED') self.outln('') def write_provider_enum_strings(self):