2018-08-29 08:21:01 -05:00
|
|
|
#![allow(missing_docs, nonstandard_style)]
|
2014-10-10 10:11:49 -07:00
|
|
|
|
2022-05-19 17:21:20 -04:00
|
|
|
use crate::ffi::CStr;
|
2019-02-11 04:23:21 +09:00
|
|
|
use crate::io::ErrorKind;
|
|
|
|
|
2017-11-01 12:32:13 -07:00
|
|
|
pub use self::rand::hashmap_random_keys;
|
|
|
|
|
2021-07-29 20:18:22 +03:00
|
|
|
#[cfg(not(target_os = "espidf"))]
|
2016-02-04 13:56:59 -08:00
|
|
|
#[macro_use]
|
|
|
|
pub mod weak;
|
|
|
|
|
2018-11-03 11:15:48 -07:00
|
|
|
pub mod alloc;
|
2016-04-25 13:39:05 -07:00
|
|
|
pub mod android;
|
2016-09-29 22:00:44 +00:00
|
|
|
pub mod args;
|
2021-04-24 17:50:40 +02:00
|
|
|
#[path = "../unix/cmath.rs"]
|
2017-11-01 12:59:40 -07:00
|
|
|
pub mod cmath;
|
2016-09-21 19:50:30 +00:00
|
|
|
pub mod env;
|
2015-02-02 21:39:14 -08:00
|
|
|
pub mod fd;
|
2015-05-05 16:35:15 -07:00
|
|
|
pub mod fs;
|
2020-09-19 18:03:10 +02:00
|
|
|
pub mod futex;
|
2019-02-08 20:42:34 +01:00
|
|
|
pub mod io;
|
2020-10-07 01:01:12 +02:00
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
|
|
pub mod kernel_copy;
|
2017-09-06 16:01:51 +02:00
|
|
|
#[cfg(target_os = "l4re")]
|
|
|
|
mod l4re;
|
2022-03-17 12:28:31 +01:00
|
|
|
pub mod locks;
|
2016-09-22 00:10:37 +00:00
|
|
|
pub mod memchr;
|
2017-08-17 13:23:00 +02:00
|
|
|
#[cfg(not(target_os = "l4re"))]
|
2015-02-05 16:50:11 -08:00
|
|
|
pub mod net;
|
2017-09-06 16:01:51 +02:00
|
|
|
#[cfg(target_os = "l4re")]
|
|
|
|
pub use self::l4re::net;
|
2014-09-30 17:03:56 -07:00
|
|
|
pub mod os;
|
2021-06-21 11:44:59 +02:00
|
|
|
pub mod os_str;
|
2016-09-21 19:11:39 +00:00
|
|
|
pub mod path;
|
2015-05-05 16:35:15 -07:00
|
|
|
pub mod pipe;
|
|
|
|
pub mod process;
|
2016-02-17 13:56:16 -08:00
|
|
|
pub mod rand;
|
2014-11-23 19:21:17 -08:00
|
|
|
pub mod stack_overflow;
|
2015-02-24 23:27:20 -08:00
|
|
|
pub mod stdio;
|
2014-11-23 19:21:17 -08:00
|
|
|
pub mod thread;
|
2020-07-12 11:37:11 +02:00
|
|
|
pub mod thread_local_dtor;
|
2020-07-12 11:45:04 +02:00
|
|
|
pub mod thread_local_key;
|
2022-04-25 15:19:50 +02:00
|
|
|
pub mod thread_parker;
|
2015-01-13 21:24:26 -08:00
|
|
|
pub mod time;
|
2014-10-10 10:11:49 -07:00
|
|
|
|
2022-02-09 23:54:38 -05:00
|
|
|
#[cfg(target_os = "espidf")]
|
2021-07-29 20:18:22 +03:00
|
|
|
pub fn init(argc: isize, argv: *const *const u8) {}
|
|
|
|
|
2022-02-09 23:54:38 -05:00
|
|
|
#[cfg(not(target_os = "espidf"))]
|
2021-04-11 07:05:39 +02:00
|
|
|
// SAFETY: must be called only once during runtime initialization.
|
2021-04-18 07:19:39 +02:00
|
|
|
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
|
2021-04-11 23:48:10 +02:00
|
|
|
pub unsafe fn init(argc: isize, argv: *const *const u8) {
|
2020-09-27 00:00:00 +00:00
|
|
|
// The standard streams might be closed on application startup. To prevent
|
|
|
|
// std::io::{stdin, stdout,stderr} objects from using other unrelated file
|
|
|
|
// resources opened later, we reopen standards streams when they are closed.
|
2021-04-11 07:05:39 +02:00
|
|
|
sanitize_standard_fds();
|
2020-09-27 00:00:00 +00:00
|
|
|
|
2015-10-07 23:11:25 +01:00
|
|
|
// By default, some platforms will send a *signal* when an EPIPE error
|
2015-09-08 15:53:46 -07:00
|
|
|
// would otherwise be delivered. This runtime doesn't install a SIGPIPE
|
|
|
|
// handler, causing it to kill the program, which isn't exactly what we
|
|
|
|
// want!
|
|
|
|
//
|
|
|
|
// Hence, we set SIGPIPE to ignore when the program starts up in order
|
|
|
|
// to prevent this problem.
|
2021-04-11 07:05:39 +02:00
|
|
|
reset_sigpipe();
|
2016-01-09 18:20:33 +00:00
|
|
|
|
2021-04-11 23:48:10 +02:00
|
|
|
stack_overflow::init();
|
|
|
|
args::init(argc, argv);
|
|
|
|
|
2022-05-19 17:21:20 -04:00
|
|
|
// Normally, `thread::spawn` will call `Thread::set_name` but since this thread
|
|
|
|
// already exists, we have to call it ourselves. We only do this on macos
|
|
|
|
// because some unix-like operating systems such as Linux share process-id and
|
|
|
|
// thread-id for the main thread and so renaming the main thread will rename the
|
|
|
|
// process and we only want to enable this on platforms we've tested.
|
|
|
|
if cfg!(target_os = "macos") {
|
|
|
|
thread::Thread::set_name(&CStr::from_bytes_with_nul_unchecked(b"main\0"));
|
|
|
|
}
|
|
|
|
|
2021-04-11 23:48:10 +02:00
|
|
|
unsafe fn sanitize_standard_fds() {
|
2022-06-04 11:34:02 +02:00
|
|
|
// fast path with a single syscall for systems with poll()
|
|
|
|
#[cfg(not(any(
|
|
|
|
miri,
|
|
|
|
target_os = "emscripten",
|
|
|
|
target_os = "fuchsia",
|
|
|
|
target_os = "vxworks",
|
|
|
|
// The poll on Darwin doesn't set POLLNVAL for closed fds.
|
|
|
|
target_os = "macos",
|
|
|
|
target_os = "ios",
|
2022-03-23 16:05:01 +00:00
|
|
|
target_os = "watchos",
|
2022-06-04 11:34:02 +02:00
|
|
|
target_os = "redox",
|
|
|
|
target_os = "l4re",
|
2022-02-09 23:54:38 -05:00
|
|
|
target_os = "horizon",
|
2022-06-04 11:34:02 +02:00
|
|
|
)))]
|
|
|
|
'poll: {
|
|
|
|
use crate::sys::os::errno;
|
|
|
|
let pfds: &mut [_] = &mut [
|
|
|
|
libc::pollfd { fd: 0, events: 0, revents: 0 },
|
|
|
|
libc::pollfd { fd: 1, events: 0, revents: 0 },
|
|
|
|
libc::pollfd { fd: 2, events: 0, revents: 0 },
|
|
|
|
];
|
|
|
|
|
|
|
|
while libc::poll(pfds.as_mut_ptr(), 3, 0) == -1 {
|
2022-06-07 21:30:07 +02:00
|
|
|
match errno() {
|
|
|
|
libc::EINTR => continue,
|
|
|
|
libc::EINVAL | libc::EAGAIN | libc::ENOMEM => {
|
|
|
|
// RLIMIT_NOFILE or temporary allocation failures
|
|
|
|
// may be preventing use of poll(), fall back to fcntl
|
|
|
|
break 'poll;
|
2020-09-28 10:32:05 +02:00
|
|
|
}
|
2022-06-07 21:30:07 +02:00
|
|
|
_ => libc::abort(),
|
2022-06-04 11:34:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for pfd in pfds {
|
|
|
|
if pfd.revents & libc::POLLNVAL == 0 {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
|
|
|
|
// If the stream is closed but we failed to reopen it, abort the
|
|
|
|
// process. Otherwise we wouldn't preserve the safety of
|
|
|
|
// operations on the corresponding Rust object Stdin, Stdout, or
|
|
|
|
// Stderr.
|
2020-09-27 00:00:00 +00:00
|
|
|
libc::abort();
|
|
|
|
}
|
2022-06-04 11:34:02 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// fallback in case poll isn't available or limited by RLIMIT_NOFILE
|
|
|
|
#[cfg(not(any(
|
|
|
|
// The standard fds are always available in Miri.
|
|
|
|
miri,
|
|
|
|
target_os = "emscripten",
|
|
|
|
target_os = "fuchsia",
|
|
|
|
target_os = "vxworks",
|
|
|
|
target_os = "l4re",
|
2022-02-09 23:54:38 -05:00
|
|
|
target_os = "horizon",
|
2022-06-04 11:34:02 +02:00
|
|
|
)))]
|
|
|
|
{
|
|
|
|
use crate::sys::os::errno;
|
|
|
|
for fd in 0..3 {
|
|
|
|
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
|
2020-09-28 10:32:05 +02:00
|
|
|
if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
|
|
|
|
// If the stream is closed but we failed to reopen it, abort the
|
|
|
|
// process. Otherwise we wouldn't preserve the safety of
|
|
|
|
// operations on the corresponding Rust object Stdin, Stdout, or
|
|
|
|
// Stderr.
|
|
|
|
libc::abort();
|
|
|
|
}
|
|
|
|
}
|
2020-09-27 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-22 23:49:57 -08:00
|
|
|
unsafe fn reset_sigpipe() {
|
2022-02-09 23:54:38 -05:00
|
|
|
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "horizon")))]
|
2021-09-16 15:20:44 +02:00
|
|
|
rtassert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
2016-01-22 23:49:57 -08:00
|
|
|
}
|
2016-01-09 18:20:33 +00:00
|
|
|
}
|
2015-09-08 15:53:46 -07:00
|
|
|
|
2021-04-11 07:05:39 +02:00
|
|
|
// SAFETY: must be called only once during runtime cleanup.
|
2021-04-18 07:19:39 +02:00
|
|
|
// NOTE: this is not guaranteed to run, for example when the program aborts.
|
2021-04-11 23:20:01 +02:00
|
|
|
pub unsafe fn cleanup() {
|
|
|
|
stack_overflow::cleanup();
|
|
|
|
}
|
2021-04-11 07:05:39 +02:00
|
|
|
|
2016-03-21 16:54:53 -07:00
|
|
|
#[cfg(target_os = "android")]
|
2019-02-11 04:23:21 +09:00
|
|
|
pub use crate::sys::android::signal;
|
2016-03-21 16:54:53 -07:00
|
|
|
#[cfg(not(target_os = "android"))]
|
|
|
|
pub use libc::signal;
|
|
|
|
|
2015-01-31 20:24:36 -08:00
|
|
|
pub fn decode_error_kind(errno: i32) -> ErrorKind {
|
2020-12-03 20:39:33 +00:00
|
|
|
use ErrorKind::*;
|
2015-01-31 20:24:36 -08:00
|
|
|
match errno as libc::c_int {
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::E2BIG => ArgumentListTooLong,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::EADDRINUSE => AddrInUse,
|
|
|
|
libc::EADDRNOTAVAIL => AddrNotAvailable,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EBUSY => ResourceBusy,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::ECONNABORTED => ConnectionAborted,
|
|
|
|
libc::ECONNREFUSED => ConnectionRefused,
|
|
|
|
libc::ECONNRESET => ConnectionReset,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EDEADLK => Deadlock,
|
|
|
|
libc::EDQUOT => FilesystemQuotaExceeded,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::EEXIST => AlreadyExists,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EFBIG => FileTooLarge,
|
|
|
|
libc::EHOSTUNREACH => HostUnreachable,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::EINTR => Interrupted,
|
|
|
|
libc::EINVAL => InvalidInput,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EISDIR => IsADirectory,
|
|
|
|
libc::ELOOP => FilesystemLoop,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::ENOENT => NotFound,
|
|
|
|
libc::ENOMEM => OutOfMemory,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::ENOSPC => StorageFull,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::ENOSYS => Unsupported,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EMLINK => TooManyLinks,
|
2022-02-10 23:49:27 +09:00
|
|
|
libc::ENAMETOOLONG => InvalidFilename,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::ENETDOWN => NetworkDown,
|
|
|
|
libc::ENETUNREACH => NetworkUnreachable,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::ENOTCONN => NotConnected,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::ENOTDIR => NotADirectory,
|
|
|
|
libc::ENOTEMPTY => DirectoryNotEmpty,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::EPIPE => BrokenPipe,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::EROFS => ReadOnlyFilesystem,
|
|
|
|
libc::ESPIPE => NotSeekable,
|
|
|
|
libc::ESTALE => StaleNetworkFileHandle,
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::ETIMEDOUT => TimedOut,
|
2021-04-30 17:05:01 +01:00
|
|
|
libc::ETXTBSY => ExecutableFileBusy,
|
|
|
|
libc::EXDEV => CrossesDevices,
|
2020-12-03 20:39:33 +00:00
|
|
|
|
2021-06-18 18:46:50 +01:00
|
|
|
libc::EACCES | libc::EPERM => PermissionDenied,
|
2015-01-31 20:24:36 -08:00
|
|
|
|
|
|
|
// These two constants can have the same value on some systems,
|
|
|
|
// but different values on others, so we can't use a match
|
|
|
|
// clause
|
2020-12-03 20:39:33 +00:00
|
|
|
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => WouldBlock,
|
2015-01-31 20:24:36 -08:00
|
|
|
|
2020-12-03 20:39:33 +00:00
|
|
|
_ => Uncategorized,
|
2015-01-31 20:24:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 08:56:56 -07:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub trait IsMinusOne {
|
|
|
|
fn is_minus_one(&self) -> bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! impl_is_minus_one {
|
|
|
|
($($t:ident)*) => ($(impl IsMinusOne for $t {
|
|
|
|
fn is_minus_one(&self) -> bool {
|
|
|
|
*self == -1
|
|
|
|
}
|
|
|
|
})*)
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_is_minus_one! { i8 i16 i32 i64 isize }
|
|
|
|
|
2019-02-11 04:23:21 +09:00
|
|
|
pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
|
|
|
|
if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) }
|
2015-02-02 21:39:14 -08:00
|
|
|
}
|
|
|
|
|
2019-02-11 04:23:21 +09:00
|
|
|
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
|
2016-06-28 08:56:56 -07:00
|
|
|
where
|
|
|
|
T: IsMinusOne,
|
|
|
|
F: FnMut() -> T,
|
2015-02-02 21:39:14 -08:00
|
|
|
{
|
|
|
|
loop {
|
|
|
|
match cvt(f()) {
|
|
|
|
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
|
|
|
other => return other,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 23:07:04 +00:00
|
|
|
|
2022-04-09 16:13:25 +02:00
|
|
|
#[allow(dead_code)] // Not used on all platforms.
|
2020-10-20 00:00:00 +00:00
|
|
|
pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> {
|
|
|
|
if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) }
|
|
|
|
}
|
|
|
|
|
2021-05-13 18:59:41 +01:00
|
|
|
// libc::abort() will run the SIGABRT handler. That's fine because anyone who
|
|
|
|
// installs a SIGABRT handler already has to expect it to run in Very Bad
|
|
|
|
// situations (eg, malloc crashing).
|
|
|
|
//
|
|
|
|
// Current glibc's abort() function unblocks SIGABRT, raises SIGABRT, clears the
|
|
|
|
// SIGABRT handler and raises it again, and then starts to get creative.
|
|
|
|
//
|
|
|
|
// See the public documentation for `intrinsics::abort()` and `process::abort()`
|
|
|
|
// for further discussion.
|
|
|
|
//
|
|
|
|
// There is confusion about whether libc::abort() flushes stdio streams.
|
|
|
|
// libc::abort() is required by ISO C 99 (7.14.1.1p5) to be async-signal-safe,
|
|
|
|
// so flushing streams is at least extremely hard, if not entirely impossible.
|
|
|
|
//
|
|
|
|
// However, some versions of POSIX (eg IEEE Std 1003.1-2001) required abort to
|
|
|
|
// do so. In 1003.1-2004 this was fixed.
|
|
|
|
//
|
|
|
|
// glibc's implementation did the flush, unsafely, before glibc commit
|
|
|
|
// 91e7cf982d01 `abort: Do not flush stdio streams [BZ #15436]' by Florian
|
|
|
|
// Weimer. According to glibc's NEWS:
|
|
|
|
//
|
|
|
|
// The abort function terminates the process immediately, without flushing
|
|
|
|
// stdio streams. Previous glibc versions used to flush streams, resulting
|
|
|
|
// in deadlocks and further data corruption. This change also affects
|
|
|
|
// process aborts as the result of assertion failures.
|
|
|
|
//
|
|
|
|
// This is an accurate description of the problem. The only solution for
|
|
|
|
// program with nontrivial use of C stdio is a fixed libc - one which does not
|
|
|
|
// try to flush in abort - since even libc-internal errors, and assertion
|
|
|
|
// failures generated from C, will go via abort().
|
|
|
|
//
|
|
|
|
// On systems with old, buggy, libcs, the impact can be severe for a
|
|
|
|
// multithreaded C program. It is much less severe for Rust, because Rust
|
|
|
|
// stdlib doesn't use libc stdio buffering. In a typical Rust program, which
|
|
|
|
// does not use C stdio, even a buggy libc::abort() is, in fact, safe.
|
2020-05-17 19:37:44 +02:00
|
|
|
pub fn abort_internal() -> ! {
|
|
|
|
unsafe { libc::abort() }
|
2016-09-30 23:07:04 +00:00
|
|
|
}
|
2020-11-10 19:01:21 +01:00
|
|
|
|
|
|
|
cfg_if::cfg_if! {
|
|
|
|
if #[cfg(target_os = "android")] {
|
2022-07-16 19:33:54 +03:00
|
|
|
#[link(name = "dl", kind = "static", modifiers = "-bundle",
|
|
|
|
cfg(target_feature = "crt-static"))]
|
|
|
|
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
|
|
|
|
#[link(name = "log", cfg(not(target_feature = "crt-static")))]
|
2020-11-10 19:01:21 +01:00
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "freebsd")] {
|
|
|
|
#[link(name = "execinfo")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "netbsd")] {
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "rt")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] {
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "solaris")] {
|
|
|
|
#[link(name = "socket")]
|
|
|
|
#[link(name = "posix4")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "illumos")] {
|
|
|
|
#[link(name = "socket")]
|
|
|
|
#[link(name = "posix4")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
#[link(name = "nsl")]
|
|
|
|
// Use libumem for the (malloc-compatible) allocator
|
|
|
|
#[link(name = "umem")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "macos")] {
|
|
|
|
#[link(name = "System")]
|
|
|
|
// res_init and friends require -lresolv on macOS/iOS.
|
2021-06-23 16:26:46 -04:00
|
|
|
// See #41582 and https://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
|
2020-11-10 19:01:21 +01:00
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
2022-03-23 16:05:01 +00:00
|
|
|
} else if #[cfg(any(target_os = "ios", target_os = "watchos"))] {
|
2020-11-10 19:01:21 +01:00
|
|
|
#[link(name = "System")]
|
|
|
|
#[link(name = "objc")]
|
|
|
|
#[link(name = "Security", kind = "framework")]
|
|
|
|
#[link(name = "Foundation", kind = "framework")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "fuchsia")] {
|
|
|
|
#[link(name = "zircon")]
|
|
|
|
#[link(name = "fdio")]
|
|
|
|
extern "C" {}
|
2021-09-14 20:50:35 -04:00
|
|
|
} else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] {
|
|
|
|
#[link(name = "dl")]
|
|
|
|
extern "C" {}
|
2020-11-10 19:01:21 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 20:18:22 +03:00
|
|
|
|
2021-10-19 17:59:59 +02:00
|
|
|
#[cfg(any(target_os = "espidf", target_os = "horizon"))]
|
2021-07-29 20:18:22 +03:00
|
|
|
mod unsupported {
|
|
|
|
use crate::io;
|
|
|
|
|
|
|
|
pub fn unsupported<T>() -> io::Result<T> {
|
|
|
|
Err(unsupported_err())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn unsupported_err() -> io::Error {
|
2021-08-08 01:04:33 -07:00
|
|
|
io::const_io_error!(io::ErrorKind::Unsupported, "operation not supported on this platform",)
|
2021-07-29 20:18:22 +03:00
|
|
|
}
|
|
|
|
}
|