[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/14] rust: replace std::ffi::c_char with libc::c_char
From: |
Paolo Bonzini |
Subject: |
[PATCH 11/14] rust: replace std::ffi::c_char with libc::c_char |
Date: |
Mon, 1 Jul 2024 16:58:43 +0200 |
Allow working with Rust versions prior to 1.64.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu/src/bindings/mod.rs | 3 ++-
qemu/src/util/foreign.rs | 7 +++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/qemu/src/bindings/mod.rs b/qemu/src/bindings/mod.rs
index a49447b..0ad3828 100644
--- a/qemu/src/bindings/mod.rs
+++ b/qemu/src/bindings/mod.rs
@@ -1,4 +1,5 @@
-use std::ffi::{c_char, c_void};
+use libc::c_char;
+use std::ffi::c_void;
#[repr(C)]
pub struct Object {
diff --git a/qemu/src/util/foreign.rs b/qemu/src/util/foreign.rs
index 0b8b708..464400a 100644
--- a/qemu/src/util/foreign.rs
+++ b/qemu/src/util/foreign.rs
@@ -4,8 +4,11 @@
/// Traits to map between C structs and native Rust types.
/// Similar to glib-rs but a bit simpler and possibly more
/// idiomatic.
+
+use libc::c_char;
+
use std::borrow::Cow;
-use std::ffi::{c_char, c_void, CStr, CString};
+use std::ffi::{c_void, CStr, CString};
use std::fmt;
use std::fmt::Debug;
use std::mem;
@@ -166,7 +169,7 @@ pub trait FromForeign: CloneToForeign + Sized {
/// # use qemu::FromForeign;
/// let p = c"Hello, world!".as_ptr();
/// let s = unsafe {
- /// String::cloned_from_foreign(p as *const std::ffi::c_char)
+ /// String::cloned_from_foreign(p as *const libc::c_char)
/// };
/// assert_eq!(s, "Hello, world!");
/// ```
--
2.45.2
- Re: [PATCH 03/14] rust: define traits and pointer wrappers to convert from/to C representations, (continued)
- [PATCH 07/14] rust: define wrappers for methods of the QOM Object class, Paolo Bonzini, 2024/07/01
- [PATCH 08/14] rust: define wrappers for methods of the QOM Device class, Paolo Bonzini, 2024/07/01
- [PATCH 06/14] rust: define wrappers for basic QOM concepts, Paolo Bonzini, 2024/07/01
- [PATCH 09/14] rust: add idiomatic bindings to define Object subclasses, Paolo Bonzini, 2024/07/01
- [PATCH 10/14] rust: add idiomatic bindings to define Device subclasses, Paolo Bonzini, 2024/07/01
- [PATCH 12/14] rust: replace c"" literals with cstr crate, Paolo Bonzini, 2024/07/01
- [PATCH 14/14] rust: use version of toml_edit that does not require new Rust, Paolo Bonzini, 2024/07/01
- [PATCH 13/14] rust: introduce alternative to offset_of!, Paolo Bonzini, 2024/07/01
- [PATCH 11/14] rust: replace std::ffi::c_char with libc::c_char,
Paolo Bonzini <=
- Re: [PATCH 00/14] rust: example of bindings code for Rust in QEMU, Pierrick Bouvier, 2024/07/04