Skip to content

Commit a0053b5

Browse files
coolreader18Thomasdezeeuw
authored andcommitted
Backport redox compilation to 0.3
1 parent 3b4214d commit a0053b5

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ all-features = true
1919
version = "0.3.3"
2020
features = ["handleapi", "ws2def", "ws2ipdef", "ws2tcpip", "minwindef"]
2121

22-
[target."cfg(any(unix, target_os = \"redox\"))".dependencies]
22+
[target."cfg(unix)".dependencies]
2323
cfg-if = "1.0"
2424
libc = { version = "0.2.66", features = ["align"] }
2525

26-
[target."cfg(target_os = \"redox\")".dependencies]
27-
redox_syscall = "0.1.38"
28-
2926
[dev-dependencies]
3027
tempdir = "0.3"
3128

src/socket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl Socket {
373373
///
374374
/// The `TCP_MAXSEG` option denotes the TCP Maximum Segment
375375
/// Size and is only available on TCP sockets.
376-
#[cfg(unix)]
376+
#[cfg(all(unix, not(target_os = "redox")))]
377377
pub fn mss(&self) -> io::Result<u32> {
378378
self.inner.mss()
379379
}
@@ -382,7 +382,7 @@ impl Socket {
382382
///
383383
/// The `TCP_MAXSEG` option denotes the TCP Maximum Segment
384384
/// Size and is only available on TCP sockets.
385-
#[cfg(unix)]
385+
#[cfg(all(unix, not(target_os = "redox")))]
386386
pub fn set_mss(&self, mss: u32) -> io::Result<()> {
387387
self.inner.set_mss(mss)
388388
}

src/sys/unix.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ pub use libc::c_int;
3131
// Used in `Domain`.
3232
pub(crate) use libc::{AF_INET, AF_INET6};
3333
// Used in `Type`.
34-
pub(crate) use libc::{SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_STREAM};
34+
#[cfg(not(target_os = "redox"))]
35+
pub(crate) use libc::SOCK_RAW;
36+
pub(crate) use libc::{SOCK_DGRAM, SOCK_SEQPACKET, SOCK_STREAM};
3537
// Used in `Protocol`.
3638
pub(crate) use libc::{IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_TCP, IPPROTO_UDP};
3739

@@ -131,8 +133,9 @@ impl_debug!(
131133
crate::Type,
132134
libc::SOCK_STREAM,
133135
libc::SOCK_DGRAM,
136+
#[cfg(not(target_os = "redox"))]
134137
libc::SOCK_RAW,
135-
#[cfg(not(target_os = "haiku"))]
138+
#[cfg(not(any(target_os = "haiku", target_os = "redox")))]
136139
libc::SOCK_RDM,
137140
libc::SOCK_SEQPACKET,
138141
/* TODO: add these optional bit OR-ed flags:
@@ -534,13 +537,15 @@ impl Socket {
534537
unsafe { self.setsockopt(libc::IPPROTO_IP, libc::IP_TTL, ttl as c_int) }
535538
}
536539

540+
#[cfg(not(target_os = "redox"))]
537541
pub fn mss(&self) -> io::Result<u32> {
538542
unsafe {
539543
let raw: c_int = self.getsockopt(libc::IPPROTO_TCP, libc::TCP_MAXSEG)?;
540544
Ok(raw as u32)
541545
}
542546
}
543547

548+
#[cfg(not(target_os = "redox"))]
544549
pub fn set_mss(&self, mss: u32) -> io::Result<()> {
545550
unsafe { self.setsockopt(libc::IPPROTO_TCP, libc::TCP_MAXSEG, mss as c_int) }
546551
}

0 commit comments

Comments
 (0)