summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2015-07-15 14:46:55 -0700
committerEric Anholt <eric@anholt.net>2015-07-15 14:47:39 -0700
commitd4620b7dd30e5cd398e10d8d5fb0e25f4cc65817 (patch)
tree0be14638ec54543bfa6aa8d13441bb03d1d1d28f
parent62861d12f9d3c1d3c61c7daa939239990b6a6c7f (diff)
downloadlibepoxy-d4620b7dd30e5cd398e10d8d5fb0e25f4cc65817.tar.gz
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.
-rw-r--r--src/dispatch_common.c19
-rw-r--r--src/dispatch_common.h9
-rwxr-xr-xsrc/gen_dispatch.py11
3 files changed, 15 insertions, 24 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index df167d4..013027f 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -675,25 +675,6 @@ epoxy_get_proc_address(const char *name)
#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(epoxy_glBegin)(GLenum primtype)
{
diff --git a/src/dispatch_common.h b/src/dispatch_common.h
index eea4e8f..676a4d5 100644
--- a/src/dispatch_common.h
+++ b/src/dispatch_common.h
@@ -66,6 +66,12 @@
# 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,
* since the function pointers depend on the device and pixel format
* of the current context.
@@ -165,9 +171,6 @@ bool epoxy_conservative_has_glx_extension(const char *name);
int epoxy_conservative_egl_version(void);
bool epoxy_conservative_has_egl_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);
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index b973415..2b2fe6f 100755
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -637,7 +637,7 @@ class Generator(object):
for human_name in sorted_providers:
enum = self.provider_enum[human_name]
self.outln(' {0},'.format(enum))
- self.outln('};')
+ self.outln('} PACKED;')
self.outln('')
def write_provider_enum_strings(self):
@@ -696,7 +696,14 @@ class Generator(object):
# something useful for the poor application developer before
# aborting. (In non-epoxy GL usage, the app developer would
# 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('}')