Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ version = "0.2"
version = "0.61"
features = ["Win32_Foundation"]

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

[dev-dependencies]
Expand Down
26 changes: 13 additions & 13 deletions src/as_filename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) trait Sealed {
function: impl FnOnce(*const u16) -> Result<R, crate::Error>,
) -> Result<R, crate::Error>;

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
#[doc(hidden)]
fn posix_filename<R>(
self,
Expand Down Expand Up @@ -39,7 +39,7 @@ impl Sealed for &str {
function(utf16.as_ptr())
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -63,7 +63,7 @@ impl Sealed for &String {
self.as_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -82,7 +82,7 @@ impl Sealed for String {
self.as_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
mut self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -99,7 +99,7 @@ impl Sealed for String {
#[cfg(feature = "std")]
#[cfg_attr(libloading_docs, doc(cfg(feature = "std")))]
mod std {
use super::{Sealed, AsFilename};
use super::{AsFilename, Sealed};
use crate::Error;
use std::ffi::{OsStr, OsString};

Expand All @@ -120,12 +120,12 @@ mod std {
function(utf16.as_ptr())
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
) -> Result<R, Error> {
let bytes = std::os::unix::ffi::OsStrExt::as_bytes(self);
let bytes = self.as_encoded_bytes();
if crate::util::check_null_bytes(bytes)? {
function(bytes.as_ptr().cast())
} else {
Expand All @@ -145,7 +145,7 @@ mod std {
self.as_os_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -168,12 +168,12 @@ mod std {
self.as_os_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
) -> Result<R, Error> {
let mut bytes = std::os::unix::ffi::OsStringExt::into_vec(self);
let mut bytes = self.into_encoded_bytes();
if crate::util::check_null_bytes(&bytes)? {
function(bytes.as_ptr().cast())
} else {
Expand All @@ -193,7 +193,7 @@ mod std {
self.into_os_string().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -212,7 +212,7 @@ mod std {
self.as_os_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand All @@ -231,7 +231,7 @@ mod std {
self.as_os_str().windows_filename(function)
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "motor"))]
fn posix_filename<R>(
self,
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl From<&CStr> for DlError {
#[derive(Copy, Clone)]
pub struct WindowsError(pub(crate) i32);

impl core::error::Error for WindowsError { }
impl core::error::Error for WindowsError {}

impl core::fmt::Debug for WindowsError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ pub use as_symbol_name::AsSymbolName;
pub mod changelog;
mod error;
pub mod os;
#[cfg(any(unix, windows, libloading_docs))]
#[cfg(any(unix, windows, target_os = "motor", libloading_docs))]
mod safe;
mod util;

pub use self::error::Error;

#[cfg(any(unix, windows, libloading_docs))]
#[cfg(any(unix, windows, target_os = "motor", libloading_docs))]
pub use self::safe::{Library, Symbol};

/// Converts a library name to a filename generally appropriate for use on the system.
Expand Down
2 changes: 1 addition & 1 deletion src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! ```

/// UNIX implementation of dynamic library loading.
#[cfg(any(unix, libloading_docs))]
#[cfg(any(unix, target_os = "motor", libloading_docs))]
#[cfg_attr(libloading_docs, doc(cfg(unix)))]
pub mod unix;

Expand Down
6 changes: 5 additions & 1 deletion src/os/unix/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ mod posix {

#[cfg(any(not(libloading_docs), unix))]
mod posix {
use cfg_if::cfg_if;
use super::c_int;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(target_os = "haiku")] {
pub(super) const RTLD_LAZY: c_int = 0;
} else if #[cfg(target_os = "aix")] {
pub(super) const RTLD_LAZY: c_int = 4;
} else if #[cfg(any(
target_os = "linux",
target_os = "motor",
target_os = "android",
target_os = "emscripten",

Expand Down Expand Up @@ -102,6 +103,7 @@ mod posix {
pub(super) const RTLD_NOW: c_int = 1;
} else if #[cfg(any(
target_os = "linux",
target_os = "motor",
all(target_os = "android", target_pointer_width = "64"),
target_os = "emscripten",

Expand Down Expand Up @@ -164,6 +166,7 @@ mod posix {
pub(super) const RTLD_GLOBAL: c_int = 8;
} else if #[cfg(any(
target_os = "linux",
target_os = "motor",
all(target_os = "android", target_pointer_width = "64"),
target_os = "emscripten",

Expand Down Expand Up @@ -208,6 +211,7 @@ mod posix {
pub(super) const RTLD_LOCAL: c_int = 4;
} else if #[cfg(any(
target_os = "linux",
target_os = "motor",
target_os = "android",
target_os = "emscripten",

Expand Down
2 changes: 1 addition & 1 deletion src/safe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(libloading_docs)]
use super::os::unix as imp; // the implementation used here doesn't matter particularly much...
#[cfg(all(not(libloading_docs), unix))]
#[cfg(all(not(libloading_docs), any(unix, target_os = "motor")))]
use super::os::unix as imp;
#[cfg(all(not(libloading_docs), windows))]
use super::os::windows as imp;
Expand Down
Loading