Skip to content

Commit c5bc332

Browse files
kennytmcarllerche
authored andcommitted
Amend some files to make it compile on arm-linux-androideabi.
1 parent 386dfd6 commit c5bc332

File tree

16 files changed

+214
-97
lines changed

16 files changed

+214
-97
lines changed

nix-test/src/errno.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ assert_errno_eq(const char* err) {
142142
ERRNO_EQ(EKEYREJECTED);
143143
ERRNO_EQ(EOWNERDEAD);
144144
ERRNO_EQ(ENOTRECOVERABLE);
145+
#ifndef __ANDROID__
145146
ERRNO_EQ(ERFKILL);
146147
ERRNO_EQ(EHWPOISON);
147148
#endif
149+
#endif
148150

149151
#ifdef DARWIN
150152
ERRNO_EQ(ENOTSUP);

src/errno.rs

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -95,184 +95,184 @@ fn desc(errno: Errno) -> &'static str {
9595
EHOSTDOWN => "Host is down",
9696
EHOSTUNREACH => "No route to host",
9797

98-
#[cfg(target_os = "linux")]
98+
#[cfg(any(target_os = "linux", target_os = "android"))]
9999
ECHRNG => "Channel number out of range",
100100

101-
#[cfg(target_os = "linux")]
101+
#[cfg(any(target_os = "linux", target_os = "android"))]
102102
EL2NSYNC => "Level 2 not synchronized",
103103

104-
#[cfg(target_os = "linux")]
104+
#[cfg(any(target_os = "linux", target_os = "android"))]
105105
EL3HLT => "Level 3 halted",
106106

107-
#[cfg(target_os = "linux")]
107+
#[cfg(any(target_os = "linux", target_os = "android"))]
108108
EL3RST => "Level 3 reset",
109109

110-
#[cfg(target_os = "linux")]
110+
#[cfg(any(target_os = "linux", target_os = "android"))]
111111
ELNRNG => "Link number out of range",
112112

113-
#[cfg(target_os = "linux")]
113+
#[cfg(any(target_os = "linux", target_os = "android"))]
114114
EUNATCH => "Protocol driver not attached",
115115

116-
#[cfg(target_os = "linux")]
116+
#[cfg(any(target_os = "linux", target_os = "android"))]
117117
ENOCSI => "No CSI structure available",
118118

119-
#[cfg(target_os = "linux")]
119+
#[cfg(any(target_os = "linux", target_os = "android"))]
120120
EL2HLT => "Level 2 halted",
121121

122-
#[cfg(target_os = "linux")]
122+
#[cfg(any(target_os = "linux", target_os = "android"))]
123123
EBADE => "Invalid exchange",
124124

125-
#[cfg(target_os = "linux")]
125+
#[cfg(any(target_os = "linux", target_os = "android"))]
126126
EBADR => "Invalid request descriptor",
127127

128-
#[cfg(target_os = "linux")]
128+
#[cfg(any(target_os = "linux", target_os = "android"))]
129129
EXFULL => "Exchange full",
130130

131-
#[cfg(target_os = "linux")]
131+
#[cfg(any(target_os = "linux", target_os = "android"))]
132132
ENOANO => "No anode",
133133

134-
#[cfg(target_os = "linux")]
134+
#[cfg(any(target_os = "linux", target_os = "android"))]
135135
EBADRQC => "Invalid request code",
136136

137-
#[cfg(target_os = "linux")]
137+
#[cfg(any(target_os = "linux", target_os = "android"))]
138138
EBADSLT => "Invalid slot",
139139

140-
#[cfg(target_os = "linux")]
140+
#[cfg(any(target_os = "linux", target_os = "android"))]
141141
EBFONT => "Bad font file format",
142142

143-
#[cfg(target_os = "linux")]
143+
#[cfg(any(target_os = "linux", target_os = "android"))]
144144
ENOSTR => "Device not a stream",
145145

146-
#[cfg(target_os = "linux")]
146+
#[cfg(any(target_os = "linux", target_os = "android"))]
147147
ENODATA => "No data available",
148148

149-
#[cfg(target_os = "linux")]
149+
#[cfg(any(target_os = "linux", target_os = "android"))]
150150
ETIME => "Timer expired",
151151

152-
#[cfg(target_os = "linux")]
152+
#[cfg(any(target_os = "linux", target_os = "android"))]
153153
ENOSR => "Out of streams resources",
154154

155-
#[cfg(target_os = "linux")]
155+
#[cfg(any(target_os = "linux", target_os = "android"))]
156156
ENONET => "Machine is not on the network",
157157

158-
#[cfg(target_os = "linux")]
158+
#[cfg(any(target_os = "linux", target_os = "android"))]
159159
ENOPKG => "Package not installed",
160160

161-
#[cfg(target_os = "linux")]
161+
#[cfg(any(target_os = "linux", target_os = "android"))]
162162
EREMOTE => "Object is remote",
163163

164-
#[cfg(target_os = "linux")]
164+
#[cfg(any(target_os = "linux", target_os = "android"))]
165165
ENOLINK => "Link has been severed",
166166

167-
#[cfg(target_os = "linux")]
167+
#[cfg(any(target_os = "linux", target_os = "android"))]
168168
EADV => "Advertise error",
169169

170-
#[cfg(target_os = "linux")]
170+
#[cfg(any(target_os = "linux", target_os = "android"))]
171171
ESRMNT => "Srmount error",
172172

173-
#[cfg(target_os = "linux")]
173+
#[cfg(any(target_os = "linux", target_os = "android"))]
174174
ECOMM => "Communication error on send",
175175

176-
#[cfg(target_os = "linux")]
176+
#[cfg(any(target_os = "linux", target_os = "android"))]
177177
EPROTO => "Protocol error",
178178

179-
#[cfg(target_os = "linux")]
179+
#[cfg(any(target_os = "linux", target_os = "android"))]
180180
EMULTIHOP => "Multihop attempted",
181181

182-
#[cfg(target_os = "linux")]
182+
#[cfg(any(target_os = "linux", target_os = "android"))]
183183
EDOTDOT => "RFS specific error",
184184

185-
#[cfg(target_os = "linux")]
185+
#[cfg(any(target_os = "linux", target_os = "android"))]
186186
EBADMSG => "Not a data message",
187187

188-
#[cfg(target_os = "linux")]
188+
#[cfg(any(target_os = "linux", target_os = "android"))]
189189
EOVERFLOW => "Value too large for defined data type",
190190

191-
#[cfg(target_os = "linux")]
191+
#[cfg(any(target_os = "linux", target_os = "android"))]
192192
ENOTUNIQ => "Name not unique on network",
193193

194-
#[cfg(target_os = "linux")]
194+
#[cfg(any(target_os = "linux", target_os = "android"))]
195195
EBADFD => "File descriptor in bad state",
196196

197-
#[cfg(target_os = "linux")]
197+
#[cfg(any(target_os = "linux", target_os = "android"))]
198198
EREMCHG => "Remote address changed",
199199

200-
#[cfg(target_os = "linux")]
200+
#[cfg(any(target_os = "linux", target_os = "android"))]
201201
ELIBACC => "Can not acces a needed shared library",
202202

203-
#[cfg(target_os = "linux")]
203+
#[cfg(any(target_os = "linux", target_os = "android"))]
204204
ELIBBAD => "Accessing a corrupted shared library",
205205

206-
#[cfg(target_os = "linux")]
206+
#[cfg(any(target_os = "linux", target_os = "android"))]
207207
ELIBSCN => ".lib section in a.out corrupted",
208208

209-
#[cfg(target_os = "linux")]
209+
#[cfg(any(target_os = "linux", target_os = "android"))]
210210
ELIBMAX => "Attempting to link in too many shared libraries",
211211

212-
#[cfg(target_os = "linux")]
212+
#[cfg(any(target_os = "linux", target_os = "android"))]
213213
ELIBEXEC => "Cannot exec a shared library directly",
214214

215-
#[cfg(target_os = "linux")]
215+
#[cfg(any(target_os = "linux", target_os = "android"))]
216216
EILSEQ => "Illegal byte sequence",
217217

218-
#[cfg(target_os = "linux")]
218+
#[cfg(any(target_os = "linux", target_os = "android"))]
219219
ERESTART => "Interrupted system call should be restarted",
220220

221-
#[cfg(target_os = "linux")]
221+
#[cfg(any(target_os = "linux", target_os = "android"))]
222222
ESTRPIPE => "Streams pipe error",
223223

224-
#[cfg(target_os = "linux")]
224+
#[cfg(any(target_os = "linux", target_os = "android"))]
225225
EUSERS => "Too many users",
226226

227-
#[cfg(target_os = "linux")]
227+
#[cfg(any(target_os = "linux", target_os = "android"))]
228228
EOPNOTSUPP => "Operation not supported on transport endpoint",
229229

230-
#[cfg(target_os = "linux")]
230+
#[cfg(any(target_os = "linux", target_os = "android"))]
231231
ESTALE => "Stale file handle",
232232

233-
#[cfg(target_os = "linux")]
233+
#[cfg(any(target_os = "linux", target_os = "android"))]
234234
EUCLEAN => "Structure needs cleaning",
235235

236-
#[cfg(target_os = "linux")]
236+
#[cfg(any(target_os = "linux", target_os = "android"))]
237237
ENOTNAM => "Not a XENIX named type file",
238238

239-
#[cfg(target_os = "linux")]
239+
#[cfg(any(target_os = "linux", target_os = "android"))]
240240
ENAVAIL => "No XENIX semaphores available",
241241

242-
#[cfg(target_os = "linux")]
242+
#[cfg(any(target_os = "linux", target_os = "android"))]
243243
EISNAM => "Is a named type file",
244244

245-
#[cfg(target_os = "linux")]
245+
#[cfg(any(target_os = "linux", target_os = "android"))]
246246
EREMOTEIO => "Remote I/O error",
247247

248-
#[cfg(target_os = "linux")]
248+
#[cfg(any(target_os = "linux", target_os = "android"))]
249249
EDQUOT => "Quota exceeded",
250250

251-
#[cfg(target_os = "linux")]
251+
#[cfg(any(target_os = "linux", target_os = "android"))]
252252
ENOMEDIUM => "No medium found",
253253

254-
#[cfg(target_os = "linux")]
254+
#[cfg(any(target_os = "linux", target_os = "android"))]
255255
EMEDIUMTYPE => "Wrong medium type",
256256

257-
#[cfg(target_os = "linux")]
257+
#[cfg(any(target_os = "linux", target_os = "android"))]
258258
ECANCELED => "Operation canceled",
259259

260-
#[cfg(target_os = "linux")]
260+
#[cfg(any(target_os = "linux", target_os = "android"))]
261261
ENOKEY => "Required key not available",
262262

263-
#[cfg(target_os = "linux")]
263+
#[cfg(any(target_os = "linux", target_os = "android"))]
264264
EKEYEXPIRED => "Key has expired",
265265

266-
#[cfg(target_os = "linux")]
266+
#[cfg(any(target_os = "linux", target_os = "android"))]
267267
EKEYREVOKED => "Key has been revoked",
268268

269-
#[cfg(target_os = "linux")]
269+
#[cfg(any(target_os = "linux", target_os = "android"))]
270270
EKEYREJECTED => "Key was rejected by service",
271271

272-
#[cfg(target_os = "linux")]
272+
#[cfg(any(target_os = "linux", target_os = "android"))]
273273
EOWNERDEAD => "Owner died",
274274

275-
#[cfg(target_os = "linux")]
275+
#[cfg(any(target_os = "linux", target_os = "android"))]
276276
ENOTRECOVERABLE => "State not recoverable",
277277

278278
#[cfg(target_os = "linux")]
@@ -394,7 +394,7 @@ fn desc(errno: Errno) -> &'static str {
394394
}
395395
}
396396

397-
#[cfg(target_os = "linux")]
397+
#[cfg(any(target_os = "linux", target_os = "android"))]
398398
mod consts {
399399
#[derive(Debug, Clone, PartialEq, FromPrimitive, Copy)]
400400
pub enum Errno {
@@ -528,7 +528,10 @@ mod consts {
528528
EKEYREJECTED = 129,
529529
EOWNERDEAD = 130,
530530
ENOTRECOVERABLE = 131,
531+
532+
#[cfg(not(target_os = "android"))]
531533
ERFKILL = 132,
534+
#[cfg(not(target_os = "android"))]
532535
EHWPOISON = 133,
533536
}
534537

@@ -667,13 +670,8 @@ mod test {
667670
use libc::c_int;
668671

669672
macro_rules! check_errno {
670-
($errno:ident) => {{
671-
assert_errno_eq(stringify!($errno), $errno as c_int);
672-
}};
673-
674-
($errno:ident, $($rest:ident),+) => {{
675-
check_errno!($errno);
676-
check_errno!($($rest),*);
673+
($($errno:ident),+) => {{
674+
$(assert_errno_eq(stringify!($errno), $errno as c_int);)+
677675
}};
678676
}
679677

@@ -754,7 +752,7 @@ mod test {
754752
}
755753

756754
#[test]
757-
#[cfg(target_os = "linux")]
755+
#[cfg(any(target_os = "linux", target_os = "android"))]
758756
pub fn test_linux_errnos() {
759757
check_errno!(
760758
ECHRNG,
@@ -816,14 +814,19 @@ mod test {
816814
EKEYREVOKED,
817815
EKEYREJECTED,
818816
EOWNERDEAD,
819-
ENOTRECOVERABLE,
817+
ENOTRECOVERABLE);
818+
}
819+
820+
#[test]
821+
#[cfg(target_os = "linux")]
822+
pub fn test_linux_not_android_errnos() {
823+
check_errno!(
820824
ERFKILL,
821825
EHWPOISON);
822826
}
823827

824-
825828
#[test]
826-
#[cfg(target_os = "macos")]
829+
#[cfg(any(target_os = "macos", target_os = "ios"))]
827830
pub fn test_darwin_errnos() {
828831
check_errno!(
829832
ENOTSUP,

src/fcntl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod ffi {
1414
pub use libc::{open, fcntl};
1515
pub use self::os::*;
1616

17-
#[cfg(target_os = "linux")]
17+
#[cfg(any(target_os = "linux", target_os = "android"))]
1818
mod os {
1919
use libc::{c_int, c_short, off_t, pid_t};
2020

@@ -93,11 +93,11 @@ pub enum FcntlArg<'a> {
9393
F_SETLK(&'a flock),
9494
F_SETLKW(&'a flock),
9595
F_GETLK(&'a mut flock),
96-
#[cfg(target_os = "linux")]
96+
#[cfg(any(target_os = "linux", target_os = "android"))]
9797
F_OFD_SETLK(&'a flock),
98-
#[cfg(target_os = "linux")]
98+
#[cfg(any(target_os = "linux", target_os = "android"))]
9999
F_OFD_SETLKW(&'a flock),
100-
#[cfg(target_os = "linux")]
100+
#[cfg(any(target_os = "linux", target_os = "android"))]
101101
F_OFD_GETLK(&'a mut flock)
102102

103103
// TODO: Rest of flags
@@ -122,7 +122,7 @@ pub fn fcntl(fd: Fd, arg: FcntlArg) -> NixResult<()> {
122122
Ok(())
123123
}
124124

125-
#[cfg(target_os = "linux")]
125+
#[cfg(any(target_os = "linux", target_os = "android"))]
126126
mod consts {
127127
use libc::c_int;
128128

src/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub use self::os::*;
22

3-
#[cfg(target_os = "linux")]
3+
#[cfg(any(target_os = "linux", target_os = "android"))]
44
mod os {
55
use sys::utsname::uname;
66

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ pub mod features;
3232
#[cfg(unix)]
3333
pub mod fcntl;
3434

35-
#[cfg(target_os = "linux")]
35+
#[cfg(any(target_os = "linux", target_os = "android"))]
3636
pub mod mount;
3737

38-
#[cfg(target_os = "linux")]
38+
#[cfg(any(target_os = "linux", target_os = "android"))]
3939
pub mod sched;
4040

4141
#[cfg(unix)]

0 commit comments

Comments
 (0)