1
Fork 0

Replace libc::c_int with core::ffi::c_int

And remove the libc crate when it isn't needed
This commit is contained in:
Chris Denton 2024-03-09 02:03:22 +00:00
parent f3c6608861
commit b1f1039d8b
No known key found for this signature in database
GPG key ID: 713472F2F45627DE
14 changed files with 35 additions and 15 deletions

View file

@ -431,6 +431,9 @@ extern crate test;
#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
#[macro_use]
extern crate alloc as alloc_crate;
// Many compiler tests depend on libc being pulled in by std
// so include it here even if it's unused.
#[doc(masked)]
#[allow(unused_extern_crates)]
extern crate libc;

View file

@ -11,7 +11,7 @@ use crate::{fmt, io, mem, ptr};
#[cfg(not(unix))]
#[allow(non_camel_case_types)]
mod libc {
pub use libc::c_int;
pub use core::ffi::c_int;
pub type socklen_t = u32;
pub struct sockaddr;
#[derive(Clone)]

View file

@ -20,7 +20,7 @@ use crate::sys::net::Socket;
))]
#[allow(non_camel_case_types)]
mod libc {
pub use libc::c_int;
pub use core::ffi::c_int;
pub struct ucred;
pub struct cmsghdr;
pub struct sockcred2;

View file

@ -34,7 +34,7 @@ use libc::MSG_NOSIGNAL;
target_os = "haiku",
target_os = "nto",
)))]
const MSG_NOSIGNAL: libc::c_int = 0x0;
const MSG_NOSIGNAL: core::ffi::c_int = 0x0;
/// A Unix datagram socket.
///
@ -317,7 +317,7 @@ impl UnixDatagram {
fn recv_from_flags(
&self,
buf: &mut [u8],
flags: libc::c_int,
flags: core::ffi::c_int,
) -> io::Result<(usize, SocketAddr)> {
let mut count = 0;
let addr = SocketAddr::new(|addr, len| unsafe {

View file

@ -79,14 +79,14 @@ impl UnixListener {
target_os = "espidf",
target_os = "horizon"
))]
const backlog: libc::c_int = 128;
const backlog: core::ffi::c_int = 128;
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
target_os = "openbsd",
target_os = "macos"
))]
const backlog: libc::c_int = -1;
const backlog: core::ffi::c_int = -1;
#[cfg(not(any(
target_os = "windows",
target_os = "redox",
@ -138,9 +138,9 @@ impl UnixListener {
unsafe {
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
#[cfg(target_os = "linux")]
const backlog: libc::c_int = -1;
const backlog: core::ffi::c_int = -1;
#[cfg(not(target_os = "linux"))]
const backlog: libc::c_int = 128;
const backlog: core::ffi::c_int = 128;
cvt(libc::bind(
inner.as_raw_fd(),
core::ptr::addr_of!(socket_addr.addr) as *const _,