File tree 3 files changed +35
-4
lines changed
3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -211,8 +211,10 @@ libc_bitflags!{
211
211
}
212
212
}
213
213
214
+ // On 64-bit android, sa_flags is c_uint while on 32-bit android, it is
215
+ // c_ulong.
214
216
// FIXME: https://github.com/rust-lang/libc/pull/511
215
- #[ cfg( target_os = "android" ) ]
217
+ #[ cfg( all ( target_os = "android" , target_pointer_width = "32" ) ) ]
216
218
libc_bitflags ! {
217
219
pub flags SaFlags : libc:: c_ulong {
218
220
SA_NOCLDSTOP as libc:: c_ulong,
@@ -225,6 +227,19 @@ libc_bitflags!{
225
227
}
226
228
}
227
229
230
+ #[ cfg( all( target_os = "android" , target_pointer_width = "64" ) ) ]
231
+ libc_bitflags ! {
232
+ pub flags SaFlags : libc:: c_uint {
233
+ SA_NOCLDSTOP as libc:: c_uint,
234
+ SA_NOCLDWAIT as libc:: c_uint,
235
+ SA_NODEFER as libc:: c_uint,
236
+ SA_ONSTACK as libc:: c_uint,
237
+ SA_RESETHAND as libc:: c_uint,
238
+ SA_RESTART as libc:: c_uint,
239
+ SA_SIGINFO as libc:: c_uint,
240
+ }
241
+ }
242
+
228
243
#[ repr( i32 ) ]
229
244
#[ derive( Clone , Copy , PartialEq ) ]
230
245
pub enum SigmaskHow {
Original file line number Diff line number Diff line change @@ -40,10 +40,10 @@ mod os {
40
40
pub const SO_LINGER : c_int = libc:: SO_LINGER ;
41
41
pub const SO_MARK : c_int = 36 ;
42
42
pub const SO_OOBINLINE : c_int = libc:: SO_OOBINLINE ;
43
- #[ cfg( not( target_arch="arm" ) ) ]
43
+ #[ cfg( not( any ( target_arch="arm" , target_os= "android" ) ) ) ]
44
44
pub const SO_PASSCRED : c_int = libc:: SO_PASSCRED ;
45
45
pub const SO_PEEK_OFF : c_int = 42 ;
46
- #[ cfg( not( target_arch="arm" ) ) ]
46
+ #[ cfg( not( any ( target_arch="arm" , target_os= "android" ) ) ) ]
47
47
pub const SO_PEERCRED : c_int = libc:: SO_PEERCRED ;
48
48
pub const SO_PRIORITY : c_int = 12 ;
49
49
pub const SO_PROTOCOL : c_int = 38 ;
@@ -57,7 +57,7 @@ mod os {
57
57
pub const SO_REUSEPORT : c_int = libc:: SO_REUSEPORT ;
58
58
pub const SO_RXQ_OVFL : c_int = 40 ;
59
59
pub const SO_SNDBUF : c_int = libc:: SO_SNDBUF ;
60
- #[ cfg( not( target_arch="arm" ) ) ]
60
+ #[ cfg( not( any ( target_arch="arm" , target_os= "android" ) ) ) ]
61
61
pub const SO_SNDBUFFORCE : c_int = libc:: SO_SNDBUFFORCE ;
62
62
pub const SO_TIMESTAMP : c_int = 29 ;
63
63
pub const SO_TYPE : c_int = libc:: SO_TYPE ;
Original file line number Diff line number Diff line change @@ -394,6 +394,7 @@ pub fn listen(sockfd: RawFd, backlog: usize) -> Result<()> {
394
394
/// Bind a name to a socket
395
395
///
396
396
/// [Further reading](http://man7.org/linux/man-pages/man2/bind.2.html)
397
+ #[ cfg( not( all( target_os="android" , target_pointer_width="64" ) ) ) ]
397
398
pub fn bind ( fd : RawFd , addr : & SockAddr ) -> Result < ( ) > {
398
399
let res = unsafe {
399
400
let ( ptr, len) = addr. as_ffi_pair ( ) ;
@@ -403,6 +404,21 @@ pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> {
403
404
Errno :: result ( res) . map ( drop)
404
405
}
405
406
407
+ /// Bind a name to a socket
408
+ ///
409
+ /// [Further reading](http://man7.org/linux/man-pages/man2/bind.2.html)
410
+ // Android has some weirdness. Its 64-bit bind takes a c_int instead of a
411
+ // socklen_t
412
+ #[ cfg( all( target_os="android" , target_pointer_width="64" ) ) ]
413
+ pub fn bind ( fd : RawFd , addr : & SockAddr ) -> Result < ( ) > {
414
+ let res = unsafe {
415
+ let ( ptr, len) = addr. as_ffi_pair ( ) ;
416
+ ffi:: bind ( fd, ptr, len as c_int )
417
+ } ;
418
+
419
+ Errno :: result ( res) . map ( drop)
420
+ }
421
+
406
422
/// Accept a connection on a socket
407
423
///
408
424
/// [Further reading](http://man7.org/linux/man-pages/man2/accept.2.html)
You can’t perform that action at this time.
0 commit comments