Changeset: 03caf54dbcbf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=03caf54dbcbf Modified Files: monetdb5/mal/mal_linker.c monetdb5/mal/mal_module.c monetdb5/mal/mal_module.h Branch: oscar Log Message:
Search already known functions for function address. diffs (60 lines): diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c --- a/monetdb5/mal/mal_linker.c +++ b/monetdb5/mal/mal_linker.c @@ -72,6 +72,9 @@ getAddress(str modname, str fcnname) int idx=0; static int prev= -1; + if ((adr = findFunctionImplementation(fcnname)) != NULL) + return adr; + /* First try the last module loaded */ if( prev >= 0 && strcmp(filesLoaded[prev].modname, modname) == 0){ /* test if just pointer compare could work */ adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname); diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c --- a/monetdb5/mal/mal_module.c +++ b/monetdb5/mal/mal_module.c @@ -31,7 +31,31 @@ */ #define MODULE_HASH_SIZE 1024 -Module moduleIndex[MODULE_HASH_SIZE] = { NULL }; +static Module moduleIndex[MODULE_HASH_SIZE] = { NULL }; + +MALfcn +findFunctionImplementation(const char *cname) +{ + for (int i = 0; i < MODULE_HASH_SIZE; i++) { + if (moduleIndex[i] != NULL && moduleIndex[i]->space != NULL) { + for (int j = 0; j < MAXSCOPE; j++) { + Symbol s; + if ((s = moduleIndex[i]->space[j]) != NULL) { + do { + if (strcmp(s->def->binding, cname) == 0 && + s->def && + s->def->stmt && + s->def->stmt[0] && + s->def->stmt[0]->fcn) { + return s->def->stmt[0]->fcn; + } + } while ((s = s->peer) != NULL); + } + } + } + } + return NULL; +} BAT * getModules(void) diff --git a/monetdb5/mal/mal_module.h b/monetdb5/mal/mal_module.h --- a/monetdb5/mal/mal_module.h +++ b/monetdb5/mal/mal_module.h @@ -36,6 +36,7 @@ mal_export void getModuleList(Module mal_export void freeModuleList(Module* list); mal_export void dumpModules(stream *out); mal_export BAT *getModules(void); +mal_export MALfcn findFunctionImplementation(const char *cname); #define getSymbolIndex(N) (int)(*(char*)(N)) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list