Rollup merge of #40317 - malbarbo:update-libc, r=alexcrichton
Update libc to 0.2.21 Update to include android aarch64 and x86 improvements.
This commit is contained in:
commit
e857e296c1
@ -1 +1 @@
|
||||
Subproject commit 64d954c6a76e896fbf7ed5c17e77c40e388abe84
|
||||
Subproject commit 05a2d197356ef253dfd985166576619ac9b6947f
|
@ -14,22 +14,24 @@
|
||||
|
||||
use fmt;
|
||||
|
||||
#[cfg(any(target_os = "android",
|
||||
target_os = "emscripten",
|
||||
#[cfg(any(target_os = "emscripten",
|
||||
all(target_os = "linux", any(target_arch = "aarch64",
|
||||
target_arch = "arm",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "s390x")),
|
||||
all(target_os = "android", any(target_arch = "aarch64",
|
||||
target_arch = "arm")),
|
||||
all(target_os = "fuchsia", target_arch = "aarch64")))]
|
||||
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
|
||||
#[cfg(not(any(target_os = "android",
|
||||
target_os = "emscripten",
|
||||
#[cfg(not(any(target_os = "emscripten",
|
||||
all(target_os = "linux", any(target_arch = "aarch64",
|
||||
target_arch = "arm",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64",
|
||||
target_arch = "s390x")),
|
||||
all(target_os = "android", any(target_arch = "aarch64",
|
||||
target_arch = "arm")),
|
||||
all(target_os = "fuchsia", target_arch = "aarch64"))))]
|
||||
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
|
||||
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
|
||||
|
@ -641,7 +641,7 @@ impl UnixListener {
|
||||
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
||||
let (addr, len) = sockaddr_un(path)?;
|
||||
|
||||
cvt(libc::bind(*inner.as_inner(), &addr as *const _ as *const _, len))?;
|
||||
cvt(libc::bind(*inner.as_inner(), &addr as *const _ as *const _, len as _))?;
|
||||
cvt(libc::listen(*inner.as_inner(), 128))?;
|
||||
|
||||
Ok(UnixListener(inner))
|
||||
@ -920,7 +920,7 @@ impl UnixDatagram {
|
||||
let socket = UnixDatagram::unbound()?;
|
||||
let (addr, len) = sockaddr_un(path)?;
|
||||
|
||||
cvt(libc::bind(*socket.0.as_inner(), &addr as *const _ as *const _, len))?;
|
||||
cvt(libc::bind(*socket.0.as_inner(), &addr as *const _ as *const _, len as _))?;
|
||||
|
||||
Ok(socket)
|
||||
}
|
||||
|
@ -417,12 +417,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// Android with api less than 21 define sig* functions inline, so it is not
|
||||
// available for dynamic link. Implementing sigemptyset and sigaddset allow us
|
||||
// to support older Android version (independent of libc version).
|
||||
// The following implementations are based on https://git.io/vSkNf
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
extern {
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
|
||||
fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int;
|
||||
|
||||
#[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
|
||||
fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
unsafe fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int {
|
||||
libc::memset(set as *mut _, 0, mem::size_of::<libc::sigset_t>());
|
||||
return 0;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int {
|
||||
use slice;
|
||||
@ -450,7 +464,7 @@ mod tests {
|
||||
|
||||
let mut set: libc::sigset_t = mem::uninitialized();
|
||||
let mut old_set: libc::sigset_t = mem::uninitialized();
|
||||
t!(cvt(libc::sigemptyset(&mut set)));
|
||||
t!(cvt(sigemptyset(&mut set)));
|
||||
t!(cvt(sigaddset(&mut set, libc::SIGINT)));
|
||||
t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, &set, &mut old_set)));
|
||||
|
||||
|
@ -193,7 +193,16 @@ impl Command {
|
||||
// need to clean things up now to avoid confusing the program
|
||||
// we're about to run.
|
||||
let mut set: libc::sigset_t = mem::uninitialized();
|
||||
t!(cvt(libc::sigemptyset(&mut set)));
|
||||
if cfg!(target_os = "android") {
|
||||
// Implementing sigemptyset allow us to support older Android
|
||||
// versions. See the comment about Android and sig* functions in
|
||||
// process_common.rs
|
||||
libc::memset(&mut set as *mut _ as *mut _,
|
||||
0,
|
||||
mem::size_of::<libc::sigset_t>());
|
||||
} else {
|
||||
t!(cvt(libc::sigemptyset(&mut set)));
|
||||
}
|
||||
t!(cvt(libc::pthread_sigmask(libc::SIG_SETMASK, &set,
|
||||
ptr::null_mut())));
|
||||
let ret = sys::signal(libc::SIGPIPE, libc::SIG_DFL);
|
||||
|
@ -339,7 +339,7 @@ impl TcpListener {
|
||||
|
||||
// Bind our new socket
|
||||
let (addrp, len) = addr.into_inner();
|
||||
cvt(unsafe { c::bind(*sock.as_inner(), addrp, len) })?;
|
||||
cvt(unsafe { c::bind(*sock.as_inner(), addrp, len as _) })?;
|
||||
|
||||
// Start listening
|
||||
cvt(unsafe { c::listen(*sock.as_inner(), 128) })?;
|
||||
@ -430,7 +430,7 @@ impl UdpSocket {
|
||||
|
||||
let sock = Socket::new(addr, c::SOCK_DGRAM)?;
|
||||
let (addrp, len) = addr.into_inner();
|
||||
cvt(unsafe { c::bind(*sock.as_inner(), addrp, len) })?;
|
||||
cvt(unsafe { c::bind(*sock.as_inner(), addrp, len as _) })?;
|
||||
Ok(UdpSocket { inner: sock })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user