Skip to content

Commit d344477

Browse files
committed
Fix libnative
1 parent efbb15d commit d344477

File tree

6 files changed

+68
-70
lines changed

6 files changed

+68
-70
lines changed

src/libnative/io/c_unix.rs

+43-42
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,42 @@ pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD};
1919

2020
use libc;
2121

22-
#[cfg(target_os = "macos")]
23-
#[cfg(target_os = "ios")]
24-
#[cfg(target_os = "freebsd")]
25-
#[cfg(target_os = "dragonfly")]
22+
#[cfg(any(target_os = "macos",
23+
target_os = "ios",
24+
target_os = "freebsd",
25+
target_os = "dragonfly"))]
2626
pub static FIONBIO: libc::c_ulong = 0x8004667e;
27-
#[cfg(target_os = "linux", target_arch = "x86")]
28-
#[cfg(target_os = "linux", target_arch = "x86_64")]
29-
#[cfg(target_os = "linux", target_arch = "arm")]
30-
#[cfg(target_os = "android")]
27+
#[cfg(any(all(target_os = "linux",
28+
any(target_arch = "x86",
29+
target_arch = "x86_64",
30+
target_arch = "arm")),
31+
target_os = "android"))]
3132
pub static FIONBIO: libc::c_ulong = 0x5421;
32-
#[cfg(target_os = "linux", target_arch = "mips")]
33-
#[cfg(target_os = "linux", target_arch = "mipsel")]
33+
#[cfg(all(target_os = "linux",
34+
any(target_arch = "mips", target_arch = "mipsel")))]
3435
pub static FIONBIO: libc::c_ulong = 0x667e;
3536

36-
#[cfg(target_os = "macos")]
37-
#[cfg(target_os = "ios")]
38-
#[cfg(target_os = "freebsd")]
39-
#[cfg(target_os = "dragonfly")]
37+
#[cfg(any(target_os = "macos",
38+
target_os = "ios",
39+
target_os = "freebsd",
40+
target_os = "dragonfly"))]
4041
pub static FIOCLEX: libc::c_ulong = 0x20006601;
41-
#[cfg(target_os = "linux", target_arch = "x86")]
42-
#[cfg(target_os = "linux", target_arch = "x86_64")]
43-
#[cfg(target_os = "linux", target_arch = "arm")]
44-
#[cfg(target_os = "android")]
42+
#[cfg(any(all(target_os = "linux",
43+
any(target_arch = "x86",
44+
target_arch = "x86_64",
45+
target_arch = "arm")),
46+
target_os = "android"))]
4547
pub static FIOCLEX: libc::c_ulong = 0x5451;
46-
#[cfg(target_os = "linux", target_arch = "mips")]
47-
#[cfg(target_os = "linux", target_arch = "mipsel")]
48+
#[cfg(all(target_os = "linux",
49+
any(target_arch = "mips", target_arch = "mipsel")))]
4850
pub static FIOCLEX: libc::c_ulong = 0x6601;
4951

50-
#[cfg(target_os = "macos")]
51-
#[cfg(target_os = "ios")]
52-
#[cfg(target_os = "freebsd")]
53-
#[cfg(target_os = "dragonfly")]
52+
#[cfg(any(target_os = "macos",
53+
target_os = "ios",
54+
target_os = "freebsd",
55+
target_os = "dragonfly"))]
5456
pub static MSG_DONTWAIT: libc::c_int = 0x80;
55-
#[cfg(target_os = "linux")]
56-
#[cfg(target_os = "android")]
57+
#[cfg(any(target_os = "linux", target_os = "android"))]
5758
pub static MSG_DONTWAIT: libc::c_int = 0x40;
5859

5960
pub static WNOHANG: libc::c_int = 1;
@@ -86,8 +87,7 @@ extern {
8687
pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int;
8788
}
8889

89-
#[cfg(target_os = "macos")]
90-
#[cfg(target_os = "ios")]
90+
#[cfg(any(target_os = "macos", target_os = "ios"))]
9191
mod select {
9292
pub static FD_SETSIZE: uint = 1024;
9393

@@ -101,10 +101,10 @@ mod select {
101101
}
102102
}
103103

104-
#[cfg(target_os = "android")]
105-
#[cfg(target_os = "freebsd")]
106-
#[cfg(target_os = "dragonfly")]
107-
#[cfg(target_os = "linux")]
104+
#[cfg(any(target_os = "android",
105+
target_os = "freebsd",
106+
target_os = "dragonfly",
107+
target_os = "linux"))]
108108
mod select {
109109
use std::uint;
110110
use libc;
@@ -123,10 +123,11 @@ mod select {
123123
}
124124
}
125125

126-
#[cfg(target_os = "linux", target_arch = "x86")]
127-
#[cfg(target_os = "linux", target_arch = "x86_64")]
128-
#[cfg(target_os = "linux", target_arch = "arm")]
129-
#[cfg(target_os = "android")]
126+
#[cfg(any(all(target_os = "linux",
127+
any(target_arch = "x86",
128+
target_arch = "x86_64",
129+
target_arch = "arm")),
130+
target_os = "android"))]
130131
mod signal {
131132
use libc;
132133

@@ -173,8 +174,8 @@ mod signal {
173174
}
174175
}
175176

176-
#[cfg(target_os = "linux", target_arch = "mips")]
177-
#[cfg(target_os = "linux", target_arch = "mipsel")]
177+
#[cfg(all(target_os = "linux",
178+
any(target_arch = "mips", target_arch = "mipsel")))]
178179
mod signal {
179180
use libc;
180181

@@ -215,10 +216,10 @@ mod signal {
215216
}
216217
}
217218

218-
#[cfg(target_os = "macos")]
219-
#[cfg(target_os = "ios")]
220-
#[cfg(target_os = "freebsd")]
221-
#[cfg(target_os = "dragonfly")]
219+
#[cfg(any(target_os = "macos",
220+
target_os = "ios",
221+
target_os = "freebsd",
222+
target_os = "dragonfly"))]
222223
mod signal {
223224
use libc;
224225

src/libnative/io/file_unix.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,15 @@ impl rtio::RtioFileStream for FileDesc {
130130
fn datasync(&mut self) -> IoResult<()> {
131131
return super::mkerr_libc(os_datasync(self.fd()));
132132

133-
#[cfg(target_os = "macos")]
134-
#[cfg(target_os = "ios")]
133+
#[cfg(any(target_os = "macos", target_os = "ios"))]
135134
fn os_datasync(fd: c_int) -> c_int {
136135
unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) }
137136
}
138137
#[cfg(target_os = "linux")]
139138
fn os_datasync(fd: c_int) -> c_int {
140139
retry(|| unsafe { libc::fdatasync(fd) })
141140
}
142-
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))]
141+
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
143142
fn os_datasync(fd: c_int) -> c_int {
144143
retry(|| unsafe { libc::fsync(fd) })
145144
}
@@ -445,14 +444,14 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
445444
// FileStat times are in milliseconds
446445
fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 }
447446

448-
#[cfg(not(target_os = "linux"), not(target_os = "android"))]
447+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
449448
fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 }
450-
#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
449+
#[cfg(any(target_os = "linux", target_os = "android"))]
451450
fn flags(_stat: &libc::stat) -> u64 { 0 }
452451

453-
#[cfg(not(target_os = "linux"), not(target_os = "android"))]
452+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
454453
fn gen(stat: &libc::stat) -> u64 { stat.st_gen as u64 }
455-
#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
454+
#[cfg(any(target_os = "linux", target_os = "android"))]
456455
fn gen(_stat: &libc::stat) -> u64 { 0 }
457456

458457
rtio::FileStat {

src/libnative/io/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ pub mod file;
4848
#[path = "file_windows.rs"]
4949
pub mod file;
5050

51-
#[cfg(target_os = "macos")]
52-
#[cfg(target_os = "ios")]
53-
#[cfg(target_os = "freebsd")]
54-
#[cfg(target_os = "dragonfly")]
55-
#[cfg(target_os = "android")]
56-
#[cfg(target_os = "linux")]
51+
#[cfg(any(target_os = "macos",
52+
target_os = "ios",
53+
target_os = "freebsd",
54+
target_os = "dragonfly",
55+
target_os = "android",
56+
target_os = "linux"))]
5757
#[path = "timer_unix.rs"]
5858
pub mod timer;
5959

src/libnative/io/net.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,20 @@ impl TcpStream {
282282
}
283283
}
284284

285-
#[cfg(target_os = "macos")]
286-
#[cfg(target_os = "ios")]
285+
#[cfg(any(target_os = "macos", target_os = "ios"))]
287286
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
288287
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
289288
seconds as libc::c_int)
290289
}
291-
#[cfg(target_os = "freebsd")]
292-
#[cfg(target_os = "dragonfly")]
290+
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
293291
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
294292
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
295293
seconds as libc::c_int)
296294
}
297-
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"),
298-
not(target_os = "dragonfly"))]
295+
#[cfg(not(any(target_os = "macos",
296+
target_os = "ios",
297+
target_os = "freebsd",
298+
target_os = "dragonfly")))]
299299
fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
300300
Ok(())
301301
}

src/libnative/io/process.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -840,18 +840,17 @@ fn free_handle(_handle: *mut ()) {
840840
#[cfg(unix)]
841841
fn translate_status(status: c_int) -> rtio::ProcessExit {
842842
#![allow(non_snake_case)]
843-
#[cfg(target_os = "linux")]
844-
#[cfg(target_os = "android")]
843+
#[cfg(any(target_os = "linux", target_os = "android"))]
845844
mod imp {
846845
pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 }
847846
pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff }
848847
pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
849848
}
850849

851-
#[cfg(target_os = "macos")]
852-
#[cfg(target_os = "ios")]
853-
#[cfg(target_os = "freebsd")]
854-
#[cfg(target_os = "dragonfly")]
850+
#[cfg(any(target_os = "macos",
851+
target_os = "ios",
852+
target_os = "freebsd",
853+
target_os = "dragonfly"))]
855854
mod imp {
856855
pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
857856
pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 }

src/libnative/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ pub use task::NativeTaskBuilder;
7777
pub mod io;
7878
pub mod task;
7979

80-
#[cfg(windows)]
81-
#[cfg(android)]
80+
#[cfg(any(windows, android))]
8281
static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
83-
#[cfg(unix, not(android))]
82+
#[cfg(all(unix, not(android)))]
8483
static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
8584

8685
#[lang = "start"]

0 commit comments

Comments
 (0)