Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.mkd"
description = "Bindings around the platform's dynamic library loading primitives with greatly improved memory safety."
keywords = ["dlopen", "load", "shared", "dylib"]
categories = ["api-bindings"]
rust-version = "1.88.0"
rust-version = "1.95"
edition = "2021"
autotests = false
include = ["Cargo.toml", "LICENSE", "README.mkd", "src/**/*.rs", "tests/**/*.rs", "tests/ordinals.def"]
Expand All @@ -28,9 +28,6 @@ version = "0.2"
version = "0.61"
features = ["Win32_Foundation"]

[target.'cfg(unix)'.dependencies.cfg-if]
version = "1"

[dev-dependencies]
libc = "0.2"
static_assertions = "1.1"
Expand Down
80 changes: 47 additions & 33 deletions src/os/unix/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ mod posix {

#[cfg(any(not(libloading_docs), unix))]
mod posix {
use cfg_if::cfg_if;
use super::c_int;
cfg_if! {
if #[cfg(target_os = "haiku")] {
cfg_select! {
target_os = "haiku" => {
pub(super) const RTLD_LAZY: c_int = 0;
} else if #[cfg(target_os = "aix")] {
}
target_os = "aix" => {
pub(super) const RTLD_LAZY: c_int = 4;
} else if #[cfg(any(
}
any(
target_os = "linux",
target_os = "android",
target_os = "emscripten",
Expand All @@ -88,19 +89,21 @@ mod posix {
target_os = "nto",
target_os = "hurd",
target_os = "cygwin",
))] {
) => {
pub(super) const RTLD_LAZY: c_int = 1;
} else {
}
_ => {
compile_error!(
"Target has no known `RTLD_LAZY` value. Please submit an issue or PR adding it."
);
}
}

cfg_if! {
if #[cfg(target_os = "haiku")] {
cfg_select! {
target_os = "haiku" => {
pub(super) const RTLD_NOW: c_int = 1;
} else if #[cfg(any(
}
any(
target_os = "linux",
all(target_os = "android", target_pointer_width = "64"),
target_os = "emscripten",
Expand Down Expand Up @@ -128,41 +131,47 @@ mod posix {
target_os = "nto",
target_os = "hurd",
target_os = "cygwin",
))] {
) => {
pub(super) const RTLD_NOW: c_int = 2;
} else if #[cfg(all(target_os = "android",target_pointer_width = "32"))] {
}
all(target_os = "android",target_pointer_width = "32") => {
pub(super) const RTLD_NOW: c_int = 0;
} else {
}
_ => {
compile_error!(
"Target has no known `RTLD_NOW` value. Please submit an issue or PR adding it."
);
}
}

cfg_if! {
if #[cfg(any(
cfg_select! {
any(
target_os = "haiku",
all(target_os = "android",target_pointer_width = "32"),
))] {
) => {
pub(super) const RTLD_GLOBAL: c_int = 2;
} else if #[cfg(target_os = "aix")] {
}
target_os = "aix" => {
pub(super) const RTLD_GLOBAL: c_int = 0x10000;
} else if #[cfg(any(
}
any(
target_env = "uclibc",
all(target_os = "linux", target_arch = "mips"),
all(target_os = "linux", target_arch = "mips64"),
target_os = "cygwin",
))] {
) => {
pub(super) const RTLD_GLOBAL: c_int = 4;
} else if #[cfg(any(
}
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))] {
) => {
pub(super) const RTLD_GLOBAL: c_int = 8;
} else if #[cfg(any(
}
any(
target_os = "linux",
all(target_os = "android", target_pointer_width = "64"),
target_os = "emscripten",
Expand All @@ -181,32 +190,36 @@ mod posix {
target_os = "redox",
target_os = "nto",
target_os = "hurd",
))] {
) => {
pub(super) const RTLD_GLOBAL: c_int = 0x100;
} else {
}
_ => {
compile_error!(
"Target has no known `RTLD_GLOBAL` value. Please submit an issue or PR adding it."
);
}
}

cfg_if! {
if #[cfg(any(
cfg_select! {
any(
target_os = "netbsd",
target_os = "nto",
))] {
) => {
pub(super) const RTLD_LOCAL: c_int = 0x200;
} else if #[cfg(target_os = "aix")] {
}
target_os = "aix" => {
pub(super) const RTLD_LOCAL: c_int = 0x80000;
} else if #[cfg(any(
}
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))] {
) => {
pub(super) const RTLD_LOCAL: c_int = 4;
} else if #[cfg(any(
}
any(
target_os = "linux",
target_os = "android",
target_os = "emscripten",
Expand All @@ -227,9 +240,10 @@ mod posix {
target_os = "redox",
target_os = "hurd",
target_os = "cygwin",
))] {
) => {
pub(super) const RTLD_LOCAL: c_int = 0;
} else {
}
_ => {
compile_error!(
"Target has no known `RTLD_LOCAL` value. Please submit an issue or PR adding it."
);
Expand Down
12 changes: 5 additions & 7 deletions src/os/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,9 @@ impl Library {
/// consider using the [`Library::get_singlethreaded`] call.
#[inline(always)]
pub unsafe fn get<T>(&self, symbol: impl AsSymbolName) -> Result<Symbol<T>, crate::Error> {
#[cfg_attr(libloading_docs, allow(unused_extern_crates))]
#[cfg(libloading_docs)]
extern crate cfg_if;
cfg_if::cfg_if! {
cfg_select! {
// These targets are known to have MT-safe `dlerror`.
if #[cfg(any(
any(
target_os = "linux",
target_os = "android",
target_os = "openbsd",
Expand All @@ -288,9 +285,10 @@ impl Library {
target_os = "redox",
target_os = "fuchsia",
target_os = "cygwin",
))] {
) => {
self.get_singlethreaded(symbol)
} else {
}
_ => {
self.get_impl(symbol, || Err(crate::Error::DlSymUnknown))
}
}
Expand Down