From 8ce82a873ac1667ee4cbdc83b812a91e4ada0edf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Dec 2024 14:30:13 -0500 Subject: Add dylib abstraction to isolate platform-specific code --- src/dylib.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/dylib.h (limited to 'src/dylib.h') 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 +// 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 -- cgit v1.2.1