Skip to content

Commit 45430a5

Browse files
authored
Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDenton
Replace libc::{type} with crate::ffi::{type} Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <[email protected]>
2 parents 36ef4f1 + c50d3e2 commit 45430a5

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

library/std/src/fs/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use crate::time::{Duration, Instant};
1212

1313
use rand::RngCore;
1414

15+
#[cfg(target_os = "macos")]
16+
use crate::ffi::{c_char, c_int};
1517
#[cfg(unix)]
1618
use crate::os::unix::fs::symlink as symlink_dir;
1719
#[cfg(unix)]
@@ -24,8 +26,6 @@ use crate::os::windows::fs::{symlink_dir, symlink_file};
2426
use crate::sys::fs::symlink_junction;
2527
#[cfg(target_os = "macos")]
2628
use crate::sys::weak::weak;
27-
#[cfg(target_os = "macos")]
28-
use libc::{c_char, c_int};
2929

3030
macro_rules! check {
3131
($e:expr) => {

library/std/src/personality/emcc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! On Emscripten Rust panics are wrapped in C++ exceptions, so we just forward
22
//! to `__gxx_personality_v0` which is provided by Emscripten.
33
4-
use libc::c_int;
4+
use crate::ffi::c_int;
55
use unwind as uw;
66

77
// This is required by the compiler to exist (e.g., it's a lang item), but it's

library/std/src/personality/gcc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
//! and the last personality routine transfers control to the catch block.
3838
3939
use super::dwarf::eh::{self, EHAction, EHContext};
40-
use libc::{c_int, uintptr_t};
40+
use crate::ffi::c_int;
41+
use libc::uintptr_t;
4142
use unwind as uw;
4243

4344
// Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister()

library/std/src/sys/windows/thread_parking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl Parker {
221221

222222
fn keyed_event_handle() -> c::HANDLE {
223223
const INVALID: c::HANDLE = ptr::invalid_mut(!0);
224-
static HANDLE: AtomicPtr<libc::c_void> = AtomicPtr::new(INVALID);
224+
static HANDLE: AtomicPtr<crate::ffi::c_void> = AtomicPtr::new(INVALID);
225225
match HANDLE.load(Relaxed) {
226226
INVALID => {
227227
let mut handle = c::INVALID_HANDLE_VALUE;

library/std/src/sys_common/net.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::sys::net::{cvt, cvt_gai, cvt_r, init, wrlen_t, Socket};
1414
use crate::sys_common::{AsInner, FromInner, IntoInner};
1515
use crate::time::Duration;
1616

17-
use libc::{c_int, c_void};
17+
use crate::ffi::{c_int, c_void};
1818

1919
cfg_if::cfg_if! {
2020
if #[cfg(any(
@@ -47,7 +47,7 @@ cfg_if::cfg_if! {
4747
target_os = "dragonfly", target_os = "freebsd",
4848
target_os = "openbsd", target_os = "netbsd",
4949
target_os = "solaris", target_os = "illumos"))] {
50-
use libc::c_uchar;
50+
use crate::ffi::c_uchar;
5151
type IpV4MultiCastType = c_uchar;
5252
} else {
5353
type IpV4MultiCastType = c_int;
@@ -127,8 +127,8 @@ fn to_ipv6mr_interface(value: u32) -> c_int {
127127
}
128128

129129
#[cfg(not(target_os = "android"))]
130-
fn to_ipv6mr_interface(value: u32) -> libc::c_uint {
131-
value as libc::c_uint
130+
fn to_ipv6mr_interface(value: u32) -> crate::ffi::c_uint {
131+
value as crate::ffi::c_uint
132132
}
133133

134134
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)