aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/dl/dl_nix.c.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/dl/dl_nix.c.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/dl/dl_nix.c.v')
-rw-r--r--v_windows/v/vlib/dl/dl_nix.c.v43
1 files changed, 43 insertions, 0 deletions
diff --git a/v_windows/v/vlib/dl/dl_nix.c.v b/v_windows/v/vlib/dl/dl_nix.c.v
new file mode 100644
index 0000000..40f63b5
--- /dev/null
+++ b/v_windows/v/vlib/dl/dl_nix.c.v
@@ -0,0 +1,43 @@
+module dl
+
+#include <dlfcn.h>
+
+$if linux {
+ #flag -ldl
+}
+
+pub const (
+ rtld_now = C.RTLD_NOW
+ rtld_lazy = C.RTLD_LAZY
+)
+
+fn C.dlopen(filename &char, flags int) voidptr
+
+fn C.dlsym(handle voidptr, symbol &char) voidptr
+
+fn C.dlclose(handle voidptr) int
+
+fn C.dlerror() &char
+
+// open loads the dynamic shared object.
+pub fn open(filename string, flags int) voidptr {
+ return C.dlopen(&char(filename.str), flags)
+}
+
+// close frees a given shared object.
+pub fn close(handle voidptr) bool {
+ return C.dlclose(handle) == 0
+}
+
+// sym returns an address of a symbol in a given shared object.
+pub fn sym(handle voidptr, symbol string) voidptr {
+ return C.dlsym(handle, &char(symbol.str))
+}
+
+// dlerror provides a text error diagnostic message for functions in `dl`
+// it returns a human-readable string, describing the most recent error
+// that occurred from a call to one of the `dl` functions, since the last
+// call to dlerror()
+pub fn dlerror() string {
+ return unsafe { cstring_to_vstring(C.dlerror()) }
+}