diff options
author | Chia-I Wu <olv@lunarg.com> | 2010-12-24 15:06:41 +0800 |
---|---|---|
committer | Chia-I Wu <olv@lunarg.com> | 2010-12-24 17:33:49 +0800 |
commit | e6a7ef3ca6d7f1843a7ea3f873c8f16fe9efc48e (patch) | |
tree | 2d7e3bc66b180e579967357be6867f0371cd53b4 /src/mapi/mapi/mapi_abi.py | |
parent | 897bff67734ec9ab213191386cdf09ddd051aebb (diff) |
mapi: Add and use entry_get_public.
Given a dispatch slot, entry_get_public returns the address of the
corresponding public entry point. There may be more than one of them.
But since they are all equivalent, it is fine to return any one of them.
With entry_get_public, the address of any public entry point can be
calculated at runtime when an assembly dispatcher is used. There is no
need to have a mapping table in such case. This omits the unnecessary
relocations from the binary.
Diffstat (limited to 'src/mapi/mapi/mapi_abi.py')
-rw-r--r-- | src/mapi/mapi/mapi_abi.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py index 0949219c2c..5c212420a8 100644 --- a/src/mapi/mapi/mapi_abi.py +++ b/src/mapi/mapi/mapi_abi.py @@ -378,6 +378,19 @@ class ABIPrinter(object): return '\n\n'.join(dispatches) + def c_public_initializer(self, prefix): + """Return the initializer for public dispatch functions.""" + names = [] + for ent in self.entries: + if ent.alias: + continue + + name = '%s(mapi_func) %s' % (self.indent, + self._c_function_call(ent, prefix)) + names.append(name) + + return ',\n'.join(names) + def c_stub_string_pool(self): """Return the string pool for use by stubs.""" # sort entries by their names @@ -400,9 +413,8 @@ class ABIPrinter(object): """Return the initializer for struct mapi_stub array.""" stubs = [] for ent in self.entries_sorted_by_names: - stubs.append('%s{ (mapi_func) %s, %d, (void *) %d }' % ( - self.indent, self._c_function_call(ent, prefix), - ent.slot, pool_offsets[ent])) + stubs.append('%s{ (void *) %d, %d, NULL }' % ( + self.indent, pool_offsets[ent], ent.slot)) return ',\n'.join(stubs) @@ -526,6 +538,10 @@ class ABIPrinter(object): print print '#ifdef MAPI_TMP_PUBLIC_ENTRIES' print self.c_public_dispatches(self.prefix_lib) + print + print 'static const mapi_func public_entries[] = {' + print self.c_public_initializer(self.prefix_lib) + print '};' print '#undef MAPI_TMP_PUBLIC_ENTRIES' print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */' |