qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]