Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee

Remove libc

We don't use much libc on Windows and it seemed silly to keep if for the sake of [two well documented constants](https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170).
This commit is contained in:
bors 2023-10-06 03:39:22 +00:00
commit fd80c02c16
7 changed files with 18 additions and 13 deletions

View File

@ -46,6 +46,10 @@
pub use LINGER as linger; pub use LINGER as linger;
pub use TIMEVAL as timeval; pub use TIMEVAL as timeval;
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170
pub const EXIT_SUCCESS: u32 = 0;
pub const EXIT_FAILURE: u32 = 1;
pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr: ptr::null_mut() }; pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr: ptr::null_mut() };
pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { Ptr: ptr::null_mut() }; pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { Ptr: ptr::null_mut() };
pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() }; pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() };

View File

@ -1,6 +1,6 @@
#![cfg(not(test))] #![cfg(not(test))]
use libc::{c_double, c_float, c_int}; use core::ffi::{c_double, c_float, c_int};
extern "C" { extern "C" {
pub fn acos(n: c_double) -> c_double; pub fn acos(n: c_double) -> c_double;
@ -33,7 +33,7 @@
#[cfg(not(all(target_env = "msvc", target_arch = "x86")))] #[cfg(not(all(target_env = "msvc", target_arch = "x86")))]
mod shims { mod shims {
use libc::c_float; use core::ffi::c_float;
extern "C" { extern "C" {
pub fn acosf(n: c_float) -> c_float; pub fn acosf(n: c_float) -> c_float;
@ -52,7 +52,7 @@ mod shims {
// back to f32. While not precisely correct should be "correct enough" for now. // back to f32. While not precisely correct should be "correct enough" for now.
#[cfg(all(target_env = "msvc", target_arch = "x86"))] #[cfg(all(target_env = "msvc", target_arch = "x86"))]
mod shims { mod shims {
use libc::c_float; use core::ffi::c_float;
#[inline] #[inline]
pub unsafe fn acosf(n: c_float) -> c_float { pub unsafe fn acosf(n: c_float) -> c_float {

View File

@ -16,6 +16,8 @@
use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::thread; use crate::thread;
use core::ffi::c_void;
use super::path::maybe_verbatim; use super::path::maybe_verbatim;
use super::to_u16s; use super::to_u16s;
@ -371,7 +373,7 @@ pub fn file_attr(&self) -> io::Result<FileAttr> {
cvt(c::GetFileInformationByHandleEx( cvt(c::GetFileInformationByHandleEx(
self.handle.as_raw_handle(), self.handle.as_raw_handle(),
c::FileBasicInfo, c::FileBasicInfo,
&mut info as *mut _ as *mut libc::c_void, &mut info as *mut _ as *mut c_void,
size as c::DWORD, size as c::DWORD,
))?; ))?;
let mut attr = FileAttr { let mut attr = FileAttr {
@ -399,7 +401,7 @@ pub fn file_attr(&self) -> io::Result<FileAttr> {
cvt(c::GetFileInformationByHandleEx( cvt(c::GetFileInformationByHandleEx(
self.handle.as_raw_handle(), self.handle.as_raw_handle(),
c::FileStandardInfo, c::FileStandardInfo,
&mut info as *mut _ as *mut libc::c_void, &mut info as *mut _ as *mut c_void,
size as c::DWORD, size as c::DWORD,
))?; ))?;
attr.file_size = info.AllocationSize as u64; attr.file_size = info.AllocationSize as u64;
@ -624,7 +626,7 @@ fn basic_info(&self) -> io::Result<c::FILE_BASIC_INFO> {
cvt(c::GetFileInformationByHandleEx( cvt(c::GetFileInformationByHandleEx(
self.handle.as_raw_handle(), self.handle.as_raw_handle(),
c::FileBasicInfo, c::FileBasicInfo,
&mut info as *mut _ as *mut libc::c_void, &mut info as *mut _ as *mut c_void,
size as c::DWORD, size as c::DWORD,
))?; ))?;
Ok(info) Ok(info)

View File

@ -3,7 +3,7 @@
use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle}; use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle};
use crate::slice; use crate::slice;
use crate::sys::c; use crate::sys::c;
use libc; use core::ffi::c_void;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
@ -136,7 +136,7 @@ struct FILE_NAME_INFO {
let res = c::GetFileInformationByHandleEx( let res = c::GetFileInformationByHandleEx(
handle, handle,
c::FileNameInfo, c::FileNameInfo,
&mut name_info as *mut _ as *mut libc::c_void, &mut name_info as *mut _ as *mut c_void,
size_of::<FILE_NAME_INFO>() as u32, size_of::<FILE_NAME_INFO>() as u32,
); );
if res == 0 { if res == 0 {

View File

@ -15,7 +15,7 @@
use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::time::Duration; use crate::time::Duration;
use libc::{c_int, c_long, c_ulong, c_ushort}; use core::ffi::{c_int, c_long, c_ulong, c_ushort};
pub type wrlen_t = i32; pub type wrlen_t = i32;

View File

@ -19,8 +19,7 @@
use crate::ptr; use crate::ptr;
use crate::sync::Mutex; use crate::sync::Mutex;
use crate::sys::args::{self, Arg}; use crate::sys::args::{self, Arg};
use crate::sys::c; use crate::sys::c::{self, NonZeroDWORD, EXIT_FAILURE, EXIT_SUCCESS};
use crate::sys::c::NonZeroDWORD;
use crate::sys::cvt; use crate::sys::cvt;
use crate::sys::fs::{File, OpenOptions}; use crate::sys::fs::{File, OpenOptions};
use crate::sys::handle::Handle; use crate::sys::handle::Handle;
@ -30,7 +29,7 @@
use crate::sys_common::process::{CommandEnv, CommandEnvs}; use crate::sys_common::process::{CommandEnv, CommandEnvs};
use crate::sys_common::IntoInner; use crate::sys_common::IntoInner;
use libc::{c_void, EXIT_FAILURE, EXIT_SUCCESS}; use core::ffi::c_void;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Command // Command

View File

@ -10,7 +10,7 @@
use crate::sys_common::FromInner; use crate::sys_common::FromInner;
use crate::time::Duration; use crate::time::Duration;
use libc::c_void; use core::ffi::c_void;
use super::to_u16s; use super::to_u16s;