summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-12-21 11:52:47 +0000
committermidipix <writeonce@midipix.org>2019-12-21 14:43:47 +0000
commit64a26cc67d6782d1ee8812c8c1307a2607144b97 (patch)
tree1ad968f07a44c49215395a58a828ca33e6616c27
parent2af0aaf1c0ae5ed331eb560acde54d076c2198e5 (diff)
downloadsltdl-64a26cc67d6782d1ee8812c8c1307a2607144b97.tar.bz2
sltdl-64a26cc67d6782d1ee8812c8c1307a2607144b97.tar.xz
lt_dlsym(), lt_dlclose(): initial implementation and integration.
-rw-r--r--include/sltdl/sltdl.h3
-rw-r--r--src/core/lt_path.c25
2 files changed, 28 insertions, 0 deletions
diff --git a/include/sltdl/sltdl.h b/include/sltdl/sltdl.h
index dea0be7..c178dea 100644
--- a/include/sltdl/sltdl.h
+++ b/include/sltdl/sltdl.h
@@ -39,6 +39,9 @@ lt_api lt_dlhandle lt_dlopen(const char *);
lt_api lt_dlhandle lt_dlopenext(const char *);
lt_api lt_dlhandle lt_dlopenadvise(const char *, struct lt_modctl *);
+lt_api void * lt_dlsym(lt_dlhandle, const char *);
+lt_api int lt_dlclose(lt_dlhandle);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/core/lt_path.c b/src/core/lt_path.c
index 37fec79..4981b1e 100644
--- a/src/core/lt_path.c
+++ b/src/core/lt_path.c
@@ -408,3 +408,28 @@ struct lt_modctx * lt_dlopenadvise(const char * module, struct lt_modctl * modct
(void)modctl;
return lt_dlopenext(module);
}
+
+void * lt_dlsym(struct lt_modctx * modctx, const char * symname)
+{
+ return dlsym(modctx->maddr,symname);
+}
+
+int lt_dlclose(struct lt_modctx * modctx)
+{
+ struct lt_modctx * pmod;
+
+ lt_slock();
+
+ for (pmod=lt_modv_head; pmod ; pmod=pmod->mnext) {
+ if (pmod == modctx) {
+ if (pmod->mrefs) {
+ pmod->mrefs--;
+ return lt_sunlock(0);
+ }
+
+ return lt_sunlock(-1);
+ }
+ }
+
+ return lt_sunlock(-1);
+}