summaryrefslogtreecommitdiffstats
path: root/src/lib.c
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/lib.c
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/lib.c')
-rw-r--r--src/lib.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/lib.c b/src/lib.c
index fcb6f6d..ac676bd 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -1,6 +1,7 @@
// Copyright 2012-2019 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
+#include "dylib.h"
#include "lilv_internal.h"
#include <lilv/lilv.h>
@@ -8,10 +9,6 @@
#include <serd/serd.h>
#include <zix/tree.h>
-#ifndef _WIN32
-# include <dlfcn.h>
-#endif
-
#include <stdint.h>
#include <stdlib.h>
@@ -37,33 +34,33 @@ lilv_lib_open(LilvWorld* world,
return NULL;
}
- dlerror();
- void* lib = dlopen(lib_path, RTLD_NOW);
+ dylib_error();
+ void* lib = dylib_open(lib_path, DYLIB_NOW);
if (!lib) {
- LILV_ERRORF("Failed to open library %s (%s)\n", lib_path, dlerror());
+ LILV_ERRORF("Failed to open library %s (%s)\n", lib_path, dylib_error());
serd_free(lib_path);
return NULL;
}
LV2_Descriptor_Function df =
- (LV2_Descriptor_Function)lilv_dlfunc(lib, "lv2_descriptor");
+ (LV2_Descriptor_Function)dylib_func(lib, "lv2_descriptor");
LV2_Lib_Descriptor_Function ldf =
- (LV2_Lib_Descriptor_Function)lilv_dlfunc(lib, "lv2_lib_descriptor");
+ (LV2_Lib_Descriptor_Function)dylib_func(lib, "lv2_lib_descriptor");
const LV2_Lib_Descriptor* desc = NULL;
if (ldf) {
desc = ldf(bundle_path, features);
if (!desc) {
LILV_ERRORF("Call to %s:lv2_lib_descriptor failed\n", lib_path);
- dlclose(lib);
+ dylib_close(lib);
serd_free(lib_path);
return NULL;
}
} else if (!df) {
LILV_ERRORF("No `lv2_descriptor' or `lv2_lib_descriptor' in %s\n",
lib_path);
- dlclose(lib);
+ dylib_close(lib);
serd_free(lib_path);
return NULL;
}
@@ -100,7 +97,7 @@ void
lilv_lib_close(LilvLib* lib)
{
if (--lib->refs == 0) {
- dlclose(lib->lib);
+ dylib_close(lib->lib);
ZixTreeIter* i = NULL;
if (lib->world->libs && !zix_tree_find(lib->world->libs, lib, &i)) {