From 399cbcd3e14ce6c2a62cba1e7cea32369d9ea735 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 3 Oct 2022 23:10:08 +0200 Subject: [PATCH 1/3] Replace cty with core::ffi As the types re-exported from there are aliases to the native types (i8 etc) and not newtypes, they can compatibly be replaced with their now-stdlib definitions. --- Cargo.toml | 2 +- build.rs | 2 +- src/bindgen.rs | 2 +- src/inline.rs | 2 +- src/libc.rs | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 27e446a..60bc806 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "riot-sys" version = "0.7.9" authors = ["Christian Amsüss "] edition = "2018" +rust-version = "1.64" description = "Rust FFI wrappers for the RIOT operating system" documentation = "https://rustdoc.etonomy.org/riot_sys/" @@ -14,7 +15,6 @@ license = "LGPL-2.1" links = "riot-sys" [dependencies] -cty = "^0.2" c2rust-asm-casts = "0.2" # Relevant for some boards like the wemos-zero c2rust-bitfields = { version = "0.3", features = ["no_std"] } diff --git a/build.rs b/build.rs index a98531c..7926d47 100644 --- a/build.rs +++ b/build.rs @@ -179,7 +179,7 @@ fn main() { .header("riot-bindgen.h") .clang_args(&cflags) .use_core() - .ctypes_prefix("libc") + .ctypes_prefix("core::ffi") .impl_debug(true) // Structs listed here are Packed and thus need impl_debug, but also contain non-Copy // members. diff --git a/src/bindgen.rs b/src/bindgen.rs index 8f5a22c..54303d0 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -3,6 +3,6 @@ //! These are kept in a separate module (rather than including the bindings right in the lib.rs) //! because bindgen is a bit sensitive to some of its assignments being defined differently -use crate::libc; +use core::ffi as libc; include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/src/inline.rs b/src/inline.rs index 60d0b02..771a28e 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -87,7 +87,7 @@ macro_rules! llvm_asm { }}; } -use cty as libc; +use core::ffi as libc; use c2rust_bitfields::*; diff --git a/src/libc.rs b/src/libc.rs index eec0254..5a3a303 100644 --- a/src/libc.rs +++ b/src/libc.rs @@ -5,7 +5,7 @@ #![allow(non_camel_case_types)] -pub use cty::{ +pub use core::ffi::{ c_char, c_double, c_float, @@ -22,5 +22,4 @@ pub use cty::{ // Not even loading size_t and ssize_t as they don't fit with bindgen's mapping anyway }; -// Used to be a dedicated type, pub-used to avoid breaking the API pub use core::ffi::c_void; From 2296601b047be74872a7e5b4620546780e28c189 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 3 Oct 2022 23:11:39 +0200 Subject: [PATCH 2/3] Update edition Now that a recent change made 1.64 mandatory, this can just as well be done now. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 60bc806..545f513 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "riot-sys" version = "0.7.9" authors = ["Christian Amsüss "] -edition = "2018" +edition = "2021" rust-version = "1.64" description = "Rust FFI wrappers for the RIOT operating system" From b52bdc25b745e531a33b07cfd19d7235f9f9603b Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 3 Oct 2022 23:15:14 +0200 Subject: [PATCH 3/3] libc: Deprecate re-export in favor of core::ffi --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 657a469..7131ce3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,6 +89,7 @@ #![allow(non_snake_case)] #![cfg_attr(feature = "keep-extern-types", feature(extern_types))] +#[deprecated(note = "Use core::ffi types directly")] pub mod libc; mod intrinsics_replacements;