search for: c_void

Displaying 20 results from an estimated 37 matches for "c_void".

2019 Jun 11
3
[nbdkit PATCH 0/2] Few rust plugin fixups/nitpicks
There are few more things that could be cleaned up related to the coding style and other things, like explicitly specifying the abi style after "extern" (i.e. `extern "C" fn` instead of `extern fn`), but since those are configurable in rustfmt config, I'm not sure whether the config needs to be added or complying with the defaults should be the priority. But this was just
2019 Feb 08
0
[PATCH nbdkit] Add support for writing plugins in Rust.
...; 100 * 1024 * 1024]); +} + +struct Handle { + // Box::new doesn't allocate anything unless we put some dummy + // fields here. In a real implementation you would put per-handle + // data here as required. + _not_used: i32, +} + +extern fn ramdisk_open (_readonly: c_int) -> *mut c_void { + let h = Handle {_not_used: 0}; + let h = Box::new(h); + return Box::into_raw(h) as *mut c_void; +} + +extern fn ramdisk_close (h: *mut c_void) { + let h = unsafe { Box::from_raw(h as *mut Handle) }; + drop (h); +} + +extern fn ramdisk_get_size (_h: *mut c_void) -> int64_t { +...
2019 Feb 08
3
[PATCH nbdkit] Add support for writing plugins in Rust.
This adds very rough support for writing nbdkit plugins in Rust. This is not very idiomatic -- essentially we're handling the direct C calls from nbdkit in Rust. We have to use ‘unsafe’ in a few places because there's no way to tell the Rust code that nbdkit satisfies guarantees (eg. around thread safety, always returning leaked pointers back to the close function, always doing bounds
2019 Aug 16
7
[nbdkit PATCH 0/2] rust: Implement some missing v2 callbacks
Similar to what I just did for OCaml (this IS an API break, requiring recompilation of any existing Rust plugin), and done because I want to add fast_zero support to both languages as part of my upcoming fast zero series. Figuring out how to get extents working was hard enough that I punted that, still. Eric Blake (2): rust: Implement can_cache rust: Add support for dynamic .thread_model
2019 Jul 30
0
Re: [PATCH] Rust bindings: Implement Event features
...ic >+ * License along with this library; if not, write to the Free Software >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >+ */ >+ >+use crate::base; >+use crate::error; >+use crate::guestfs; >+use std::ffi; >+use std::os::raw::{c_char, c_void}; >+use std::slice; >+use std::sync; >+ >+type GuestfsEventCallback = extern "C" fn( >+ *const base::guestfs_h, >+ *const c_void, >+ u64, >+ i32, >+ i32, >+ *const i8, >+ usize, >+ *const u64, >+ usize, >+); >+ >+#...
2019 Aug 16
0
[nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...s index 9d0af0ee..e9462fca 100644 --- a/plugins/rust/examples/ramdisk.rs +++ b/plugins/rust/examples/ramdisk.rs @@ -53,6 +53,10 @@ struct Handle { _not_used: i32, } +extern fn ramdisk_thread_model () -> ThreadModel { + Parallel +} + extern fn ramdisk_open (_readonly: c_int) -> *mut c_void { let h = Handle {_not_used: 0}; let h = Box::new(h); @@ -98,9 +102,8 @@ pub extern fn plugin_init () -> *const Plugin { // https://github.com/rust-lang/rfcs/issues/400 let name = "ramdisk\0" as *const str as *const [c_char] as *const c_char; - // Create a mutab...
2019 Aug 16
1
Re: [nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...st/examples/ramdisk.rs > +++ b/plugins/rust/examples/ramdisk.rs > @@ -53,6 +53,10 @@ struct Handle { > _not_used: i32, > } > > +extern fn ramdisk_thread_model () -> ThreadModel { > + Parallel > +} > + > extern fn ramdisk_open (_readonly: c_int) -> *mut c_void { > let h = Handle {_not_used: 0}; > let h = Box::new(h); > @@ -98,9 +102,8 @@ pub extern fn plugin_init () -> *const Plugin { > // https://github.com/rust-lang/rfcs/issues/400 > let name = "ramdisk\0" as *const str as *const [c_char] as *const c_char...
2019 Jul 07
2
[libnbd PATCH] RFC: Add bindings for Rust language
...i (); pr "%s: *mut u32,\n" n; + pri (); pr "%s: usize,\n" len + | ArrayAndLen _ -> assert false + | Bool n -> pri (); pr "%s: bool,\n" n + | BytesIn (n, len) + | BytesPersistIn (n, len) -> + pri (); pr "%s: *const c_void,\n" n; + pri (); pr "%s: usize,\n" len + | BytesOut (n, len) + | BytesPersistOut (n, len) -> + pri (); pr "%s: *mut c_void,\n" n; + pri (); pr "%s: usize,\n" len + | Callback (n, args) + | CallbackPersist (n, a...
2019 Jul 30
4
[PATCH] Rust bindings: Implement Event features
...copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +use crate::base; +use crate::error; +use crate::guestfs; +use std::ffi; +use std::os::raw::{c_char, c_void}; +use std::slice; +use std::sync; + +type GuestfsEventCallback = extern "C" fn( + *const base::guestfs_h, + *const c_void, + u64, + i32, + i32, + *const i8, + usize, + *const u64, + usize, +); + +#[link(name = "guestfs")] +extern "C" { +...
2019 Aug 31
1
[PATCH libnbd] Add bindings for Rust language
Still not working, but I took the latest patch and: - rebased it against libnbd 1.0 - fixed it so it handles new args and cbargs The generator now runs without warnings. This patch doesn't handle optargs at all. In C these are converted to non-optional parameter. Rust doesn't (AFAIK) have optional or labelled arguments unfortunately. Rich.
2019 Jul 30
1
Re: [PATCH] Rust bindings: Implement Event features
...f not, write to the Free Software > >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > >+ */ > >+ > >+use crate::base; > >+use crate::error; > >+use crate::guestfs; > >+use std::ffi; > >+use std::os::raw::{c_char, c_void}; > >+use std::slice; > >+use std::sync; > >+ > >+type GuestfsEventCallback = extern "C" fn( > >+ *const base::guestfs_h, > >+ *const c_void, > >+ u64, > >+ i32, > >+ i32, > >+ *const i8, > >+ usize, &g...
2019 Aug 05
2
[PATCH 2/2] Rust bindings: Implement callback handlers
...y of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +use crate::base; +use crate::error; +use crate::guestfs; +use crate::utils; +use std::os::raw::{c_char, c_void}; +use std::slice; + +type GuestfsEventCallback = extern "C" fn( + *const base::guestfs_h, + *const c_void, + u64, + i32, + i32, + *const i8, + usize, + *const u64, + usize, +); + +#[link(name = "guestfs")] +extern "C" { + fn guestfs_set_e...
2019 Aug 16
0
[nbdkit PATCH 1/2] rust: Implement can_cache
...(1)>, diff --git a/plugins/rust/src/lib.rs b/plugins/rust/src/lib.rs index a3dbf43e..25af2fe6 100644 --- a/plugins/rust/src/lib.rs +++ b/plugins/rust/src/lib.rs @@ -93,6 +93,15 @@ pub struct Plugin { pub magic_config_key: *const c_char, pub can_multi_conn: Option<extern fn (h: *mut c_void) -> c_int>, + + // Slots for extents functions, which needs more integration. + _can_extents: Option<extern fn ()>, + _extents: Option<extern fn ()>, + + pub can_cache: Option<extern fn (h: *mut c_void) -> c_int>, + pub cache: Option<extern fn (h: *mut c...
2019 Jun 27
0
Re: [PATCH 08/11] Rust bindings: Fix memory management and format the file
...t.ml b/generator/rust.ml index 79e16dfc6..ee65b1073 100644 --- a/generator/rust.ml +++ b/generator/rust.ml @@ -61,14 +61,16 @@ let generate_rust () = pr " use std::collections; use std::convert; +use std::convert::TryFrom; use std::ffi; -use std::slice; +use std::os::raw::{c_char, c_int, c_void}; use std::ptr; -use std::os::raw::{c_char, c_int}; +use std::slice; +use std::str; #[allow(non_camel_case_types)] -enum guestfs_h {} // opaque struct +enum guestfs_h {} // opaque struct #[link(name = \"guestfs\")] extern \"C\" { @@ -79,6 +81,11 @@ extern \"C\"...
2019 Jul 08
0
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...nc. I also didn't understand what this means. It's a matter of personal preference but you can use multi-line string constants in OCaml which can be unlimited in length, so this: > + pr "#[allow(unused_imports)]\n"; > + pr "use std::os::raw::{c_char, c_int, c_uint, c_void};\n"; > + pr "use std::os::unix::io::RawFd;\n"; > + pr "use std::ffi::CStr;\n"; > + pr "use libnbd_sys::*;\n"; > + pr "use libc;\n"; > + pr "\n"; (etc) can be written as: pr "\ #[allow(unused_imports)] use std::os::...
2019 Aug 05
3
Re: [PATCH] Rust bindings: Implement Event features
I fixed based on comments. I'll send these two patches to this mailing list. - Fix Handle -> Handle<'a> - Add events Regards, Hiroyuki 2019年8月1日(木) 0:01 Pino Toscano <ptoscano@redhat.com>: > Hi Hiroyuki, > > On Tuesday, 30 July 2019 07:51:37 CEST Hiroyuki Katsura wrote: > > This patch includes: > > > > - Event callback handlers > > -
2019 Jul 08
2
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...nderstand what this means. > >It's a matter of personal preference but you can use multi-line string >constants in OCaml which can be unlimited in length, so this: > >> + pr "#[allow(unused_imports)]\n"; >> + pr "use std::os::raw::{c_char, c_int, c_uint, c_void};\n"; >> + pr "use std::os::unix::io::RawFd;\n"; >> + pr "use std::ffi::CStr;\n"; >> + pr "use libnbd_sys::*;\n"; >> + pr "use libc;\n"; >> + pr "\n"; >(etc) > >can be written as: > > pr "...
2019 Jul 08
1
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...(above) and "substrings" means in >this context. Do you mean actual string constants? > No, I mean the strings printed by the generator, e.g. the one from your example on how to use a multiline one: pr "\ #[allow(unused_imports)] use std::os::raw::{c_char, c_int, c_uint, c_void}; use std::os::unix::io::RawFd; [...] "; >Rich. > >-- >Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones >Read my programming and virtualization blog: http://rwmj.wordpress.com >virt-top is 'top' for virtual machines. Tiny program with m...
2019 Jun 27
4
Re: [PATCH 9/9] Rust bindings: Complete bindings
Patch 9 is a kind of dumping ground of all kinds of stuff. It may be better to spend some time with git rebase -i trying to work this into more coherent patches. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live
2019 Jul 20
2
Re: [PATCH] Rust bindings: Add Rust bindings
...his particular crate. That way you can share > things > between modules without exposing it to consumers of this crate > > >+use std::collections; > >+use std::convert; > >+use std::convert::TryFrom; > >+use std::ffi; > >+use std::os::raw::{c_char, c_int, c_void}; > >+use std::ptr; > >+use std::slice; > >+use std::str; > >+ > >+#[allow(non_camel_case_types)] > >+enum guestfs_h {} // opaque struct > >+ > > You should not use empty enums for ffi opaque structs as they can be > optimized > out. Also #[rep...