Skip to content

Commit

Permalink
Rollup merge of rust-lang#105524 - Ayush1325:libc-free, r=ChrisDenton
Browse files Browse the repository at this point in the history
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 <ayushsingh1325@gmail.com>
  • Loading branch information
matthiaskrgr committed Jan 28, 2023
2 parents 36ef4f1 + c50d3e2 commit 45430a5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crate::time::{Duration, Instant};

use rand::RngCore;

#[cfg(target_os = "macos")]
use crate::ffi::{c_char, c_int};
#[cfg(unix)]
use crate::os::unix::fs::symlink as symlink_dir;
#[cfg(unix)]
Expand All @@ -24,8 +26,6 @@ use crate::os::windows::fs::{symlink_dir, symlink_file};
use crate::sys::fs::symlink_junction;
#[cfg(target_os = "macos")]
use crate::sys::weak::weak;
#[cfg(target_os = "macos")]
use libc::{c_char, c_int};

macro_rules! check {
($e:expr) => {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/personality/emcc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! On Emscripten Rust panics are wrapped in C++ exceptions, so we just forward
//! to `__gxx_personality_v0` which is provided by Emscripten.

use libc::c_int;
use crate::ffi::c_int;
use unwind as uw;

// This is required by the compiler to exist (e.g., it's a lang item), but it's
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/personality/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
//! and the last personality routine transfers control to the catch block.

use super::dwarf::eh::{self, EHAction, EHContext};
use libc::{c_int, uintptr_t};
use crate::ffi::c_int;
use libc::uintptr_t;
use unwind as uw;

// Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister()
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/thread_parking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Parker {

fn keyed_event_handle() -> c::HANDLE {
const INVALID: c::HANDLE = ptr::invalid_mut(!0);
static HANDLE: AtomicPtr<libc::c_void> = AtomicPtr::new(INVALID);
static HANDLE: AtomicPtr<crate::ffi::c_void> = AtomicPtr::new(INVALID);
match HANDLE.load(Relaxed) {
INVALID => {
let mut handle = c::INVALID_HANDLE_VALUE;
Expand Down
8 changes: 4 additions & 4 deletions library/std/src/sys_common/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::sys::net::{cvt, cvt_gai, cvt_r, init, wrlen_t, Socket};
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::time::Duration;

use libc::{c_int, c_void};
use crate::ffi::{c_int, c_void};

cfg_if::cfg_if! {
if #[cfg(any(
Expand Down Expand Up @@ -47,7 +47,7 @@ cfg_if::cfg_if! {
target_os = "dragonfly", target_os = "freebsd",
target_os = "openbsd", target_os = "netbsd",
target_os = "solaris", target_os = "illumos"))] {
use libc::c_uchar;
use crate::ffi::c_uchar;
type IpV4MultiCastType = c_uchar;
} else {
type IpV4MultiCastType = c_int;
Expand Down Expand Up @@ -127,8 +127,8 @@ fn to_ipv6mr_interface(value: u32) -> c_int {
}

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

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 45430a5

Please sign in to comment.