Skip to content

Commit c0e64e8

Browse files
committed
Add support for Motor OS
1 parent 29b6ad0 commit c0e64e8

6 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ version = "0.2"
2828
version = "0.61"
2929
features = ["Win32_Foundation"]
3030

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

3434
[dev-dependencies]

‎src/as_filename.rs‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub(crate) trait Sealed {
99
function: impl FnOnce(*const u16) -> Result<R, crate::Error>,
1010
) -> Result<R, crate::Error>;
1111

12-
#[cfg(unix)]
12+
#[cfg(any(unix, target_os = "motor"))]
1313
#[doc(hidden)]
1414
fn posix_filename<R>(
1515
self,
@@ -39,7 +39,7 @@ impl Sealed for &str {
3939
function(utf16.as_ptr())
4040
}
4141

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

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

85-
#[cfg(unix)]
85+
#[cfg(any(unix, target_os = "motor"))]
8686
fn posix_filename<R>(
8787
mut self,
8888
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,
@@ -120,12 +120,12 @@ mod std {
120120
function(utf16.as_ptr())
121121
}
122122

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

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

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

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

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

234-
#[cfg(unix)]
234+
#[cfg(any(unix, target_os = "motor"))]
235235
fn posix_filename<R>(
236236
self,
237237
function: impl FnOnce(*const core::ffi::c_char) -> Result<R, Error>,

‎src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ pub use as_symbol_name::AsSymbolName;
5555
pub mod changelog;
5656
mod error;
5757
pub mod os;
58-
#[cfg(any(unix, windows, libloading_docs))]
58+
#[cfg(any(unix, windows, target_os = "motor", libloading_docs))]
5959
mod safe;
6060
mod util;
6161

6262
pub use self::error::Error;
6363

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

6767
/// Converts a library name to a filename generally appropriate for use on the system.

‎src/os/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
//!
1111
//! ```ignore
1212
//! # extern crate libloading;
13-
//! #[cfg(unix)]
13+
//! #[cfg(any(unix, target_os = "motor"))]
1414
//! use libloading::os::unix::*;
1515
//! #[cfg(windows)]
1616
//! use libloading::os::windows::*;
1717
//! ```
1818
1919
/// UNIX implementation of dynamic library loading.
20-
#[cfg(any(unix, libloading_docs))]
20+
#[cfg(any(unix, target_os = "motor", libloading_docs))]
2121
#[cfg_attr(libloading_docs, doc(cfg(unix)))]
2222
pub mod unix;
2323

‎src/os/unix/consts.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mod posix {
5252
pub(super) const RTLD_LOCAL: c_int = !0;
5353
}
5454

55-
#[cfg(any(not(libloading_docs), unix))]
55+
#[cfg(any(not(libloading_docs), unix, target_os = "motor"))]
5656
mod posix {
5757
use cfg_if::cfg_if;
5858
use super::c_int;
@@ -62,7 +62,7 @@ mod posix {
6262
} else if #[cfg(target_os = "aix")] {
6363
pub(super) const RTLD_LAZY: c_int = 4;
6464
} else if #[cfg(any(
65-
target_os = "linux",
65+
target_os = "linux", target_os = "motor",
6666
target_os = "android",
6767
target_os = "emscripten",
6868

@@ -101,7 +101,7 @@ mod posix {
101101
if #[cfg(target_os = "haiku")] {
102102
pub(super) const RTLD_NOW: c_int = 1;
103103
} else if #[cfg(any(
104-
target_os = "linux",
104+
target_os = "linux", target_os = "motor",
105105
all(target_os = "android", target_pointer_width = "64"),
106106
target_os = "emscripten",
107107

@@ -149,8 +149,8 @@ mod posix {
149149
pub(super) const RTLD_GLOBAL: c_int = 0x10000;
150150
} else if #[cfg(any(
151151
target_env = "uclibc",
152-
all(target_os = "linux", target_arch = "mips"),
153-
all(target_os = "linux", target_arch = "mips64"),
152+
all(target_os = "linux", target_os = "motor", target_arch = "mips"),
153+
all(target_os = "linux", target_os = "motor", target_arch = "mips64"),
154154
target_os = "cygwin",
155155
))] {
156156
pub(super) const RTLD_GLOBAL: c_int = 4;
@@ -163,7 +163,7 @@ mod posix {
163163
))] {
164164
pub(super) const RTLD_GLOBAL: c_int = 8;
165165
} else if #[cfg(any(
166-
target_os = "linux",
166+
target_os = "linux", target_os = "motor",
167167
all(target_os = "android", target_pointer_width = "64"),
168168
target_os = "emscripten",
169169

@@ -207,7 +207,7 @@ mod posix {
207207
))] {
208208
pub(super) const RTLD_LOCAL: c_int = 4;
209209
} else if #[cfg(any(
210-
target_os = "linux",
210+
target_os = "linux", target_os = "motor",
211211
target_os = "android",
212212
target_os = "emscripten",
213213

‎src/safe.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(libloading_docs)]
22
use super::os::unix as imp; // the implementation used here doesn't matter particularly much...
3-
#[cfg(all(not(libloading_docs), unix))]
3+
#[cfg(all(not(libloading_docs), any(unix, target_os = "motor")))]
44
use super::os::unix as imp;
55
#[cfg(all(not(libloading_docs), windows))]
66
use super::os::windows as imp;

0 commit comments

Comments
 (0)