summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2022-11-18 00:37:12 +0000
committerOmar Rizwan <omar@omar.website>2022-11-18 00:37:12 +0000
commit316ff618bb042168b3dff6fa14ed91c710d1595a (patch)
tree0bfe972cee61abbc96e1ede23f001e8d39c1500d
parentDon't need to reset C now that it's namespaced (diff)
downloadfolk-316ff618bb042168b3dff6fa14ed91c710d1595a.tar.gz
folk-316ff618bb042168b3dff6fa14ed91c710d1595a.zip
Add loadlib to c.tcl
-rw-r--r--lib/c.tcl15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/c.tcl b/lib/c.tcl
index 8469b84e..f8f8d03b 100644
--- a/lib/c.tcl
+++ b/lib/c.tcl
@@ -161,7 +161,20 @@ namespace eval c {
}]
return $handle
}
- namespace export create
+
+ set loader [create]
+ $loader include <dlfcn.h>
+ $loader proc loadlibImpl {char* filename} void* {
+ return dlopen(filename, RTLD_NOW);
+ }
+ $loader compile
+ proc loadlib {filename} {
+ if {[loadlibImpl $filename] == "(void*) 0x0"} {
+ error "Failed to dlopen $filename"
+ }
+ }
+
+ namespace export *
namespace ensemble create
}