|
From: <mr...@mr...> - 2005-05-30 19:10:22
|
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/05/30 21:09:38+02:00 mr...@fo... =
# allow modules to import own symbols
# fix aliased symbol loading
# =
# kernel/module.c
# 2005/05/30 21:09:38+02:00 mr...@fo... +19 -12
# allow modules to import own symbols
# fix aliased symbol loading
# =
diff -Nru a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c 2005-05-30 21:10:08 +02:00
+++ b/kernel/module.c 2005-05-30 21:10:08 +02:00
@@ -1,5 +1,5 @@
/**
- Copyright (C) 2001, 2002, 2003 Michael Ahlberg, M=C3=A5ns Rullg=C3=A5rd
+ Copyright (C) 2005 Michael Ahlberg, M=C3=A5ns Rullg=C3=A5rd
=
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -122,7 +122,7 @@
/* Open module */
module->handle =3D dlopen(module->filename, RTLD_NOW);
if(!module->handle){
- fputs(dlerror(), stderr);
+ tc2_print("module", TC2_PRINT_ERROR, "%s\n", dlerror());
return -1;
}
=
@@ -397,7 +397,7 @@
tc2_module *module;
tc2_symbol_t *sym;
=
- kprint("get_symbol", TC2_PRINT_DEBUG + 2, "%s: Getting symbol: %s\n",
+ kprint("get_symbol", TC2_PRINT_DEBUG, "%s: getting symbol: %s\n",
cmod->module->name, csym);
=
if(tchash_find(avail_syms, csym, -1, &module) !=3D 0){
@@ -405,14 +405,16 @@
return NULL;
}
=
- pthread_mutex_lock(&module->mut);
- if(!module->loaded){
- _tc2_request(TC2_LOAD_MODULE, cmod, 0, interface, NULL);
- while(!module->loaded)
- pthread_cond_wait(&module->cond, &module->mut);
- module->autoclean =3D 1;
+ if(cmod !=3D module){
+ pthread_mutex_lock(&module->mut);
+ if(!module->loaded){
+ _tc2_request(TC2_LOAD_MODULE, cmod, 0, interface, NULL);
+ while(!module->loaded)
+ pthread_cond_wait(&module->cond, &module->mut);
+ module->autoclean =3D 1;
+ }
+ pthread_mutex_unlock(&module->mut);
}
- pthread_mutex_unlock(&module->mut);
=
if(tchash_find(loaded_syms, csym, -1, &sym)){
kprint("module", TC2_PRINT_ERROR,
@@ -422,15 +424,20 @@
}
=
if(sym->type =3D=3D TC2_TYPE_ALIAS){
- if(!(sym =3D get_symbol(cmod, interface, sym->sym)))
+ char *ai =3D strdup(sym->sym);
+ kprint("get_symbol", TC2_PRINT_DEBUG, "%s is an alias for %s\n",
+ csym, sym->sym);
+ *strchr(ai, ':') =3D 0;
+ if(!(sym =3D get_symbol(cmod, ai, sym->sym)))
return NULL;
+ free(ai);
}
=
/* Update dependency table */
if(cmod)
tc2_add_dep(cmod, module);
=
- kprint("get_symbol", TC2_PRINT_DEBUG + 2, "%s: Got symbol: %s -> %p\n",
+ kprint("get_symbol", TC2_PRINT_DEBUG, "%s: got symbol: %s -> %p\n",
cmod->module->name, csym, sym->sym);
=
return sym;
|