Use __attribute__((packed)) to reduce our data size.

Since our provider enums are small, we can store them as bytes or
shorts if we just let the compiler know that it's OK.  Saves 20kb in
the compiled library.
macos/v1.5.9
Eric Anholt 9 years ago
parent 62861d12f9
commit d4620b7dd3
  1. 19
      src/dispatch_common.c
  2. 9
      src/dispatch_common.h
  3. 11
      src/gen_dispatch.py

@ -675,25 +675,6 @@ epoxy_get_proc_address(const char *name)
#endif #endif
} }
void
epoxy_print_failure_reasons(const char *name,
const char **provider_names,
const int *providers)
{
int i;
fprintf(stderr, "No provider of %s found. Requires one of:\n", name);
for (i = 0; providers[i] != 0; i++)
fprintf(stderr, " %s\n",
provider_names[providers[i]]);
if (providers[0] == 0) {
fprintf(stderr, " No known providers. This is likely a bug "
"in libepoxy code generation\n");
}
}
WRAPPER_VISIBILITY (void) WRAPPER_VISIBILITY (void)
WRAPPER(epoxy_glBegin)(GLenum primtype) WRAPPER(epoxy_glBegin)(GLenum primtype)
{ {

@ -66,6 +66,12 @@
# endif # endif
#endif #endif
#if defined(__GNUC__)
#define PACKED __attribute__((__packed__))
#else
#define PACKED
#endif
/* On win32, we're going to need to keep a per-thread dispatch table, /* On win32, we're going to need to keep a per-thread dispatch table,
* since the function pointers depend on the device and pixel format * since the function pointers depend on the device and pixel format
* of the current context. * of the current context.
@ -165,9 +171,6 @@ bool epoxy_conservative_has_glx_extension(const char *name);
int epoxy_conservative_egl_version(void); int epoxy_conservative_egl_version(void);
bool epoxy_conservative_has_egl_extension(const char *name); bool epoxy_conservative_has_egl_extension(const char *name);
bool epoxy_conservative_has_wgl_extension(const char *name); bool epoxy_conservative_has_wgl_extension(const char *name);
void epoxy_print_failure_reasons(const char *name,
const char **provider_names,
const int *providers);
bool epoxy_extension_in_string(const char *extension_list, const char *ext); bool epoxy_extension_in_string(const char *extension_list, const char *ext);

@ -637,7 +637,7 @@ class Generator(object):
for human_name in sorted_providers: for human_name in sorted_providers:
enum = self.provider_enum[human_name] enum = self.provider_enum[human_name]
self.outln(' {0},'.format(enum)) self.outln(' {0},'.format(enum))
self.outln('};') self.outln('} PACKED;')
self.outln('') self.outln('')
def write_provider_enum_strings(self): def write_provider_enum_strings(self):
@ -696,7 +696,14 @@ class Generator(object):
# something useful for the poor application developer before # something useful for the poor application developer before
# aborting. (In non-epoxy GL usage, the app developer would # aborting. (In non-epoxy GL usage, the app developer would
# call into some blank stub function and segfault). # call into some blank stub function and segfault).
self.outln(' epoxy_print_failure_reasons(name, enum_strings, (const int *)providers);') self.outln(' fprintf(stderr, "No provider of %s found. Requires one of:\\n", name);')
self.outln(' for (i = 0; providers[i] != 0; i++) {')
self.outln(' fprintf(stderr, " %s\\n", enum_strings[providers[i]]);')
self.outln(' }')
self.outln(' if (providers[0] == {0}_provider_terminator) {{'.format(self.target))
self.outln(' fprintf(stderr, " No known providers. This is likely a bug "')
self.outln(' "in libepoxy code generation\\n");')
self.outln(' }')
self.outln(' abort();') self.outln(' abort();')
self.outln('}') self.outln('}')

Loading…
Cancel
Save