Skip to content

Commit 0ba4e90

Browse files
committed
Support ESP-IDF without flags
Updates #1703
1 parent 5279428 commit 0ba4e90

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

Diff for: src/poll.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(all(
22
unix,
33
not(mio_unsupported_force_poll_poll),
4-
not(any(target_os = "solaris", target_os = "vita"))
4+
not(any(target_os = "espidf", target_os = "solaris", target_os = "vita")),
55
))]
66
use std::os::unix::io::{AsRawFd, RawFd};
77
#[cfg(all(debug_assertions, not(target_os = "wasi")))]
@@ -430,7 +430,7 @@ impl Poll {
430430
#[cfg(all(
431431
unix,
432432
not(mio_unsupported_force_poll_poll),
433-
not(any(target_os = "solaris", target_os = "vita"))
433+
not(any(target_os = "espidf", target_os = "solaris", target_os = "vita")),
434434
))]
435435
impl AsRawFd for Poll {
436436
fn as_raw_fd(&self) -> RawFd {
@@ -721,7 +721,7 @@ impl fmt::Debug for Registry {
721721
#[cfg(all(
722722
unix,
723723
not(mio_unsupported_force_poll_poll),
724-
not(any(target_os = "solaris", target_os = "vita"))
724+
not(any(target_os = "espidf", target_os = "solaris", target_os = "vita")),
725725
))]
726726
impl AsRawFd for Registry {
727727
fn as_raw_fd(&self) -> RawFd {
@@ -733,7 +733,7 @@ cfg_os_poll! {
733733
#[cfg(all(
734734
unix,
735735
not(mio_unsupported_force_poll_poll),
736-
not(any(target_os = "solaris", target_os = "vita")),
736+
not(any(target_os = "espidf", target_os = "solaris", target_os = "vita")),
737737
))]
738738
#[test]
739739
pub fn as_raw_fd() {

Diff for: src/sys/unix/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cfg_os_poll! {
3737

3838
cfg_io_source! {
3939
// Both `kqueue` and `epoll` don't need to hold any user space state.
40-
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "hermit", target_os = "solaris", target_os = "vita")))]
40+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "solaris", target_os = "vita")))]
4141
mod stateless_io_source {
4242
use std::io;
4343
#[cfg(target_os = "hermit")]
@@ -93,10 +93,10 @@ cfg_os_poll! {
9393
}
9494
}
9595

96-
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "hermit", target_os = "solaris",target_os = "vita")))]
96+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "solaris", target_os = "vita")))]
9797
pub(crate) use self::stateless_io_source::IoSourceState;
9898

99-
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "hermit", target_os = "solaris", target_os = "vita"))]
99+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "solaris", target_os = "vita"))]
100100
pub(crate) use self::selector::IoSourceState;
101101
}
102102

Diff for: src/sys/unix/selector/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,30 @@ pub(crate) use self::epoll::{event, Event, Events, Selector};
2222

2323
#[cfg(any(
2424
mio_unsupported_force_poll_poll,
25+
target_os = "espidf",
26+
target_os = "hermit",
2527
target_os = "solaris",
2628
target_os = "vita",
27-
target_os = "hermit"
2829
))]
2930
mod poll;
3031

3132
#[cfg(any(
3233
mio_unsupported_force_poll_poll,
34+
target_os = "espidf",
35+
target_os = "hermit",
3336
target_os = "solaris",
3437
target_os = "vita",
35-
target_os = "hermit"
3638
))]
3739
pub(crate) use self::poll::{event, Event, Events, Selector};
3840

3941
cfg_io_source! {
40-
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "hermit", target_os = "solaris", target_os = "vita"))]
42+
#[cfg(any(
43+
mio_unsupported_force_poll_poll,
44+
target_os = "espidf",
45+
target_os = "hermit",
46+
target_os = "solaris",
47+
target_os = "vita",
48+
))]
4149
pub(crate) use self::poll::IoSourceState;
4250
}
4351

Diff for: src/sys/unix/selector/poll.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
// Permission to use this code has been granted by original author:
44
// https://github.com/tokio-rs/mio/pull/1602#issuecomment-1218441031
55

6-
use crate::sys::unix::selector::LOWEST_FD;
7-
use crate::sys::unix::waker::WakerInternal;
8-
use crate::{Interest, Token};
96
use std::collections::HashMap;
107
use std::fmt::{Debug, Formatter};
118
#[cfg(target_os = "hermit")]
129
use std::os::hermit::io::{AsRawFd, RawFd};
1310
#[cfg(unix)]
1411
use std::os::unix::io::{AsRawFd, RawFd};
15-
use std::sync::atomic::AtomicBool;
16-
use std::sync::atomic::{AtomicUsize, Ordering};
12+
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
1713
use std::sync::{Arc, Condvar, Mutex};
1814
use std::time::Duration;
1915
use std::{cmp, fmt, io};
2016

17+
use crate::sys::unix::selector::LOWEST_FD;
18+
use crate::sys::unix::waker::WakerInternal;
19+
use crate::{Interest, Token};
20+
2121
/// Unique id for use as `SelectorId`.
2222
#[cfg(debug_assertions)]
2323
static NEXT_ID: AtomicUsize = AtomicUsize::new(1);
@@ -74,6 +74,7 @@ impl Selector {
7474
pub fn wake(&self, token: Token) -> io::Result<()> {
7575
self.state.wake(token)
7676
}
77+
7778
cfg_io_source! {
7879
#[cfg(debug_assertions)]
7980
pub fn id(&self) -> usize {

Diff for: src/sys/unix/waker.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
target_os = "watchos",
1111
)
1212
)),
13-
not(any(target_os = "solaris", target_os = "vita", target_os = "hermit")),
13+
not(any(target_os = "espidf", target_os = "hermit", target_os = "solaris", target_os = "vita")),
1414
))]
1515
mod fdbased {
1616
#[cfg(all(
@@ -63,17 +63,17 @@ mod fdbased {
6363
target_os = "watchos",
6464
)
6565
)),
66-
not(any(target_os = "solaris", target_os = "vita", target_os = "hermit")),
66+
not(any(target_os = "espidf", target_os = "hermit", target_os = "solaris", target_os = "vita")),
6767
))]
6868
pub use self::fdbased::Waker;
6969

7070
#[cfg(all(
7171
not(mio_unsupported_force_waker_pipe),
7272
any(
73-
target_os = "linux",
7473
target_os = "android",
7574
target_os = "espidf",
76-
target_os = "hermit"
75+
target_os = "hermit",
76+
target_os = "linux",
7777
)
7878
))]
7979
mod eventfd {
@@ -123,7 +123,7 @@ mod eventfd {
123123
}
124124
}
125125

126-
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "hermit"))]
126+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit"))]
127127
pub fn ack_and_reset(&self) {
128128
let _ = self.reset();
129129
}
@@ -150,9 +150,12 @@ mod eventfd {
150150
}
151151

152152
#[cfg(all(
153-
mio_unsupported_force_poll_poll,
154153
not(mio_unsupported_force_waker_pipe),
155-
any(target_os = "linux", target_os = "android", target_os = "espidf")
154+
any(
155+
target_os = "android",
156+
target_os = "espidf",
157+
target_os = "linux",
158+
)
156159
))]
157160
pub(crate) use self::eventfd::WakerInternal;
158161

@@ -269,8 +272,9 @@ mod pipe {
269272

270273
#[cfg(any(
271274
mio_unsupported_force_poll_poll,
275+
target_os = "espidf",
272276
target_os = "solaris",
273-
target_os = "vita"
277+
target_os = "vita",
274278
))]
275279
pub fn ack_and_reset(&self) {
276280
self.empty();
@@ -316,9 +320,10 @@ pub(crate) use self::pipe::WakerInternal;
316320

317321
#[cfg(any(
318322
mio_unsupported_force_poll_poll,
323+
target_os = "espidf",
324+
target_os = "hermit",
319325
target_os = "solaris",
320326
target_os = "vita",
321-
target_os = "hermit"
322327
))]
323328
mod poll {
324329
use crate::sys::Selector;
@@ -347,8 +352,9 @@ mod poll {
347352

348353
#[cfg(any(
349354
mio_unsupported_force_poll_poll,
355+
target_os = "espidf",
356+
target_os = "hermit",
350357
target_os = "solaris",
351358
target_os = "vita",
352-
target_os = "hermit"
353359
))]
354360
pub use self::poll::Waker;

0 commit comments

Comments
 (0)