summaryrefslogtreecommitdiffstats
path: root/src/dylib.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-12-11 14:30:13 -0500
committerDavid Robillard <d@drobilla.net>2024-12-11 14:57:06 -0500
commit8ce82a873ac1667ee4cbdc83b812a91e4ada0edf (patch)
tree9b9ca40afd075df80d5addc7a1408a70a0755687 /src/dylib.h
parentb1b2a693ba14627a2170cecfd7ece313224888cd (diff)
downloadlilv-8ce82a873ac1667ee4cbdc83b812a91e4ada0edf.tar.gz
lilv-8ce82a873ac1667ee4cbdc83b812a91e4ada0edf.tar.bz2
lilv-8ce82a873ac1667ee4cbdc83b812a91e4ada0edf.zip
Add dylib abstraction to isolate platform-specific code
Diffstat (limited to 'src/dylib.h')
-rw-r--r--src/dylib.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dylib.h b/src/dylib.h
new file mode 100644
index 0000000..f2faade
--- /dev/null
+++ b/src/dylib.h
@@ -0,0 +1,35 @@
+// Copyright 2020-2024 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef LILV_DYLIB_H
+#define LILV_DYLIB_H
+
+/// Flags for dylib_open()
+enum DylibFlags {
+ DYLIB_LAZY = 1U << 0U, ///< Resolve symbols only when referenced
+ DYLIB_NOW = 1U << 1U, ///< Resolve all symbols on library load
+};
+
+/// An opaque dynamically loaded shared library
+typedef void DylibLib;
+
+/// A function from a shared library
+typedef void (*DylibFunc)(void);
+
+/// Open a shared library
+DylibLib*
+dylib_open(const char* filename, unsigned flags);
+
+/// Close a shared library opened with dylib_open()
+int
+dylib_close(DylibLib* handle);
+
+/// Return a human-readable description of any error since the last call
+const char*
+dylib_error(void);
+
+/// Return a pointer to a function in a shared library, or null
+DylibFunc
+dylib_func(DylibLib* handle, const char* symbol);
+
+#endif // LILV_DYLIB_H