diff --git a/Cargo.toml b/Cargo.toml index 181f91412..cf62b59d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/as_filename.rs b/src/as_filename.rs index 3a7d64a57..1827aa3df 100644 --- a/src/as_filename.rs +++ b/src/as_filename.rs @@ -9,7 +9,7 @@ pub(crate) trait Sealed { function: impl FnOnce(*const u16) -> Result, ) -> Result; - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] #[doc(hidden)] fn posix_filename( self, @@ -39,7 +39,7 @@ impl Sealed for &str { function(utf16.as_ptr()) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -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( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -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( mut self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -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}; @@ -120,12 +120,12 @@ mod std { function(utf16.as_ptr()) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, ) -> Result { - 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 { @@ -145,7 +145,7 @@ mod std { self.as_os_str().windows_filename(function) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -168,12 +168,12 @@ mod std { self.as_os_str().windows_filename(function) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, ) -> Result { - 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 { @@ -193,7 +193,7 @@ mod std { self.into_os_string().windows_filename(function) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -212,7 +212,7 @@ mod std { self.as_os_str().windows_filename(function) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, @@ -231,7 +231,7 @@ mod std { self.as_os_str().windows_filename(function) } - #[cfg(unix)] + #[cfg(any(unix, target_os = "motor"))] fn posix_filename( self, function: impl FnOnce(*const core::ffi::c_char) -> Result, diff --git a/src/error.rs b/src/error.rs index cfaa1f360..002f0f39e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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 { diff --git a/src/lib.rs b/src/lib.rs index 75637dc8a..f042c7e4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. diff --git a/src/os/mod.rs b/src/os/mod.rs index 710353f5e..5d2bf60c9 100644 --- a/src/os/mod.rs +++ b/src/os/mod.rs @@ -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; diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs index 46fd1a1c2..2ef81aac8 100644 --- a/src/os/unix/consts.rs +++ b/src/os/unix/consts.rs @@ -54,8 +54,8 @@ 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; @@ -63,6 +63,7 @@ mod posix { pub(super) const RTLD_LAZY: c_int = 4; } else if #[cfg(any( target_os = "linux", + target_os = "motor", target_os = "android", target_os = "emscripten", @@ -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", @@ -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", @@ -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", diff --git a/src/safe.rs b/src/safe.rs index f2b5c3837..7759d33b5 100644 --- a/src/safe.rs +++ b/src/safe.rs @@ -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;