summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2015-06-05 14:06:23 +0800
committerEric Anholt <eric@anholt.net>2015-06-05 17:51:08 -0700
commite9f68fe3a34e769ac2f3e5d4b92c1358edd7af5c (patch)
treebece99208d1d4558d198b250d92d60af612d33c4
parent7d5e8e9d5604736601e28f4c8530759fc537fd12 (diff)
downloadlibepoxy-e9f68fe3a34e769ac2f3e5d4b92c1358edd7af5c.tar.gz
Fix generated code for building on MSVC 2013
This updates the script to generate code that is buildable by Visual Studio 2013 by: -Using a macro to define the compiler-specific way to do noinline for a function, and use it when needed. -Avoid using empty arrays and structs as that is a C99 feature that will likely be never support on Visual Studio as it is now an optional feature of C11.
-rwxr-xr-xsrc/gen_dispatch.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index 92f6358..326fdbc 100755
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -577,8 +577,11 @@ class Generator(object):
self.outln(' };')
self.outln(' static const uint16_t entrypoints[] = {')
- for provider in providers:
- self.outln(' {0} /* "{1}" */,'.format(self.entrypoint_string_offset[provider.name], provider.name))
+ if len(providers) > 1:
+ for provider in providers:
+ self.outln(' {0} /* "{1}" */,'.format(self.entrypoint_string_offset[provider.name], provider.name))
+ else:
+ self.outln(' 0 /* None */,')
self.outln(' };')
self.outln(' return {0}_provider_resolver(entrypoint_strings + {1} /* "{2}" */,'.format(self.target,
@@ -698,8 +701,8 @@ class Generator(object):
self.outln('')
single_resolver_proto = '{0}_single_resolver(enum {0}_provider provider, uint16_t entrypoint_offset)'.format(self.target)
- self.outln('static void *')
- self.outln('{0} __attribute__((noinline));'.format(single_resolver_proto))
+ self.outln('EPOXY_NOINLINE static void *')
+ self.outln('{0};'.format(single_resolver_proto))
self.outln('')
self.outln('static void *')
self.outln('{0}'.format(single_resolver_proto))
@@ -728,6 +731,11 @@ class Generator(object):
self.outln('#include "dispatch_common.h"')
self.outln('#include "epoxy/{0}.h"'.format(self.target))
self.outln('')
+ self.outln('#ifdef __GNUC__')
+ self.outln('#define EPOXY_NOINLINE __attribute__((noinline))')
+ self.outln('#elif defined (_MSC_VER)')
+ self.outln('#define EPOXY_NOINLINE __declspec(noinline)')
+ self.outln('#endif')
self.outln('struct dispatch_table {')
for func in self.sorted_functions: