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.
macos/v1.5.9
Chun-wei Fan 10 years ago committed by Eric Anholt
parent 7d5e8e9d56
commit e9f68fe3a3
  1. 16
      src/gen_dispatch.py

@ -577,8 +577,11 @@ class Generator(object):
self.outln(' };') self.outln(' };')
self.outln(' static const uint16_t entrypoints[] = {') self.outln(' static const uint16_t entrypoints[] = {')
for provider in providers: if len(providers) > 1:
self.outln(' {0} /* "{1}" */,'.format(self.entrypoint_string_offset[provider.name], provider.name)) 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(' };')
self.outln(' return {0}_provider_resolver(entrypoint_strings + {1} /* "{2}" */,'.format(self.target, self.outln(' return {0}_provider_resolver(entrypoint_strings + {1} /* "{2}" */,'.format(self.target,
@ -698,8 +701,8 @@ class Generator(object):
self.outln('') self.outln('')
single_resolver_proto = '{0}_single_resolver(enum {0}_provider provider, uint16_t entrypoint_offset)'.format(self.target) single_resolver_proto = '{0}_single_resolver(enum {0}_provider provider, uint16_t entrypoint_offset)'.format(self.target)
self.outln('static void *') self.outln('EPOXY_NOINLINE static void *')
self.outln('{0} __attribute__((noinline));'.format(single_resolver_proto)) self.outln('{0};'.format(single_resolver_proto))
self.outln('') self.outln('')
self.outln('static void *') self.outln('static void *')
self.outln('{0}'.format(single_resolver_proto)) self.outln('{0}'.format(single_resolver_proto))
@ -728,6 +731,11 @@ class Generator(object):
self.outln('#include "dispatch_common.h"') self.outln('#include "dispatch_common.h"')
self.outln('#include "epoxy/{0}.h"'.format(self.target)) self.outln('#include "epoxy/{0}.h"'.format(self.target))
self.outln('') 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 {') self.outln('struct dispatch_table {')
for func in self.sorted_functions: for func in self.sorted_functions:

Loading…
Cancel
Save