From 2cec9f1b38f2ce5efdbc1118f7883b66b35796da Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Sat, 7 Sep 2024 21:07:32 +0200 Subject: [PATCH] ffi: Use std::ffi types instead of libc These aliases were added in rust 1.64. --- src/analysis/ffi_type.rs | 26 +++++++++++++------------- src/codegen/sys/statics.rs | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/analysis/ffi_type.rs b/src/analysis/ffi_type.rs index 3583ff28a..60926257a 100644 --- a/src/analysis/ffi_type.rs +++ b/src/analysis/ffi_type.rs @@ -72,7 +72,7 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result { Type::Basic(fund) => { use crate::library::Basic::*; let inner = match fund { - None => "libc::c_void", + None => "std::ffi::c_void", Boolean => return Ok(use_glib_if_needed(env, "ffi::gboolean").into()), Int8 => "i8", UInt8 => "u8", @@ -82,18 +82,18 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result { UInt32 => "u32", Int64 => "i64", UInt64 => "u64", - Char => "libc::c_char", - UChar => "libc::c_uchar", - Short => "libc::c_short", - UShort => "libc::c_ushort", - Int => "libc::c_int", - UInt => "libc::c_uint", - Long => "libc::c_long", - ULong => "libc::c_ulong", + Char => "std::ffi::c_char", + UChar => "std::ffi::c_uchar", + Short => "std::ffi::c_short", + UShort => "std::ffi::c_ushort", + Int => "std::ffi::c_int", + UInt => "std::ffi::c_uint", + Long => "std::ffi::c_long", + ULong => "std::ffi::c_ulong", Size => "libc::size_t", SSize => "libc::ssize_t", - Float => "libc::c_float", - Double => "libc::c_double", + Float => "std::ffi::c_float", + Double => "std::ffi::c_double", TimeT => "libc::time_t", OffT => "libc::off_t", DevT => "libc::dev_t", @@ -102,8 +102,8 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result { SockLenT => "libc::socklen_t", UidT => "libc::uid_t", UniChar => "u32", - Utf8 => "libc::c_char", - Filename => "libc::c_char", + Utf8 => "std::ffi::c_char", + Filename => "std::ffi::c_char", Type => return Ok(use_glib_if_needed(env, "ffi::GType").into()), IntPtr => "libc::intptr_t", UIntPtr => "libc::uintptr_t", diff --git a/src/codegen/sys/statics.rs b/src/codegen/sys/statics.rs index 94c637246..b8b7a3d2b 100644 --- a/src/codegen/sys/statics.rs +++ b/src/codegen/sys/statics.rs @@ -18,9 +18,9 @@ pub fn after_extern_crates(w: &mut dyn Write) -> Result<()> { let v = vec![ "", "#[allow(unused_imports)]", - "use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,", - " c_short, c_ushort, c_long, c_ulong,", - " c_void, size_t, ssize_t, time_t, off_t, intptr_t, uintptr_t, FILE};", + "use std::ffi::{c_int, c_char, c_uchar, c_float, c_uint, c_double,", + " c_short, c_ushort, c_long, c_ulong, c_void};", + "use libc::{size_t, ssize_t, time_t, off_t, intptr_t, uintptr_t, FILE};", "#[cfg(unix)]", "#[allow(unused_imports)]", "use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};",