search for: c_char

Displaying 20 results from an estimated 35 matches for "c_char".

Did you mean: x_char
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 Jun 27
0
[PATCH 7/9] Rust bindings: Complete actions
...diff --git a/generator/rust.ml b/generator/rust.ml index aa8b249ff..79e16dfc6 100644 --- a/generator/rust.ml +++ b/generator/rust.ml @@ -60,10 +60,11 @@ let generate_rust () = pr " use std::collections; +use std::convert; use std::ffi; use std::slice; use std::ptr; -use std::os::raw::c_char; +use std::os::raw::{c_char, c_int}; #[allow(non_camel_case_types)] @@ -74,6 +75,8 @@ extern \"C\" { fn guestfs_create() -> *mut guestfs_h; fn guestfs_create_flags(flags: i64) -> *mut guestfs_h; fn guestfs_close(g: *mut guestfs_h); + fn guestfs_last_error(g: *...
2019 Feb 08
0
[PATCH nbdkit] Add support for writing plugins in Rust.
...+ +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 { + return DISK.lock().unwrap().capacity() as int64_t; +} + +extern fn ramdisk_pread (_h: *mut c_void, buf: *mut c_char, count: uint32_t, + offset: uint64_t, _flags: uint32_t) -> c_int { + let offset = offset as usize; + let count = count as usize; + let disk = DISK.lock().unwrap(); + unsafe { + ptr::copy_nonoverlapping (&disk[offset], buf as *mut u8, count); + }...
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 Aug 16
0
[nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...it::ThreadModel::*; #[no_mangle] + extern fn myplugin_thread_model () -> ThreadModel { + Serialize_AllRequests + } + + //... more functions + pub extern fn plugin_init () -> *const Plugin { // Plugin name. let name = "myplugin\0" as *const str as *const [c_char] as *const c_char; - // Create a mutable plugin, setting the 5 required fields. + // Create a mutable plugin, setting the 4 required fields. let mut plugin = Plugin::new ( - Serialize_All_Requests, name, myplugin_open, myplugin_get_size, @@ -53,6 +58,7...
2019 Aug 16
1
Re: [nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...n fn myplugin_thread_model () -> ThreadModel { > + Serialize_AllRequests > + } > + > + //... more functions > + > pub extern fn plugin_init () -> *const Plugin { > // Plugin name. > let name = "myplugin\0" > as *const str as *const [c_char] as *const c_char; > > - // Create a mutable plugin, setting the 5 required fields. > + // Create a mutable plugin, setting the 4 required fields. > let mut plugin = Plugin::new ( > - Serialize_All_Requests, > name, > myplugin_open, >...
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 Jul 07
2
[libnbd PATCH] RFC: Add bindings for Rust language
...n -> pri (); pr "%s: i64,\n" n + | Mutable (Int n) -> pri (); pr "%s: *mut c_int,\n" n + | Mutable arg -> assert false + | Opaque n -> pri (); pr "%s: *mut c_void,\n" n + | Path n + | String n -> pri (); pr "%s: *const c_char,\n" n + | StringList n -> pri (); pr "%s: *mut *mut c_char,\n" n + | SockAddrAndLen (n, len) -> + pri (); pr "%s: *const libc::sockaddr,\n" n; + pri (); pr "%s: libc::socklen_t,\n" len + | UInt n -> pri (); pr "%s: 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 Jun 27
0
[PATCH 4/9] Rust bindings: Add generator of structs
...l @@ -29,13 +29,21 @@ open Structs open C open Events +let rec indent n = match n with + | x when x > 0 -> pr " "; indent (x - 1) + | _ -> () let generate_rust () = generate_header CStyle LGPLv2plus; pr " +use std::ffi; +use std::slice; +use std::os::raw::c_char; + + #[allow(non_camel_case_types)] -enum guestfs_h {} +enum guestfs_h {} // opaque struct #[link(name = \"guestfs\")] extern \"C\" { @@ -119,5 +127,80 @@ impl Handle { Ok(Handle { g }) } } +}\ + +pub struct UUID { + uuid: [u8; 32] +} + +impl...
2019 Jun 27
0
Re: [PATCH 08/11] Rust bindings: Fix memory management and format the file
...a/generator/rust.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...
2019 Jul 23
0
Re: [PATCH] Rust bindings: Add Rust bindings
...ck_list then + s ^ "_" + else + s + +let generate_rust () = + generate_header CStyle LGPLv2plus; + + pr " +use crate::base::*; +use crate::utils::*; +use crate::error::*; +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; + +extern \"C\" { + fn free(buf: *const c_void); +} +"; + + List.iter ( + fun { s_camel_name = name; s_name = c_name; s_cols = cols } -> + pr "\n"; + pr "pub struct %s {\n" name; + List.iter...
2019 Jul 23
2
Re: [PATCH] Rust bindings: Add Rust bindings
...et generate_rust () = > + generate_header CStyle LGPLv2plus; > + > + pr " > +use crate::base::*; > +use crate::utils::*; > +use crate::error::*; > +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; > + > +extern \"C\" { > + fn free(buf: *const c_void); > +} > +"; > + > + List.iter ( > + fun { s_camel_name = name; s_name = c_name; s_cols = cols } -> > + pr "\n"; > +...
2019 Jul 29
1
Re: [PATCH] Rust bindings: Add Rust bindings
...quot;_" + else + s + +let generate_rust () = + generate_header ~copywrites:copywrites CStyle LGPLv2plus; + + pr " +use crate::base::*; +use crate::utils::*; +use crate::error::*; +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; + +extern \"C\" { + fn free(buf: *const c_void); +} +"; + + List.iter ( + fun { s_camel_name = name; s_name = c_name; s_cols = cols } -> + pr "\n"; + pr "pub struct %s {\n" name; + List.iter...
2019 Jul 20
0
[PATCH] Rust bindings: Add Rust bindings
...ck_list then + s ^ "_" + else + s + +let generate_rust () = + generate_header CStyle LGPLv2plus; + + pr " +use crate::base::*; +use crate::utils::*; +use crate::error::*; +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; + +extern \"C\" { + fn free(buf: *const c_void); +} +"; + + List.iter ( + fun { s_camel_name = name; s_name = c_name; s_cols = cols } -> + pr "\n"; + pr "pub struct %s {\n" name; + List.iter...
2019 Jul 20
2
Re: [PATCH] Rust bindings: Add Rust bindings
...but only for this 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 > o...
2019 Jun 27
16
[PATCH 1/9] Rust bindings: Add Rust bindings
From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> --- Makefile.am | 4 ++++ configure.ac | 3 +++ generator/Makefile.am | 3 +++ generator/bindtests.ml | 3 +++ generator/bindtests.mli | 1 + generator/main.ml | 5 +++++ generator/rust.ml | 34 ++++++++++++++++++++++++++++++++++ generator/rust.mli | 19 +++++++++++++++++++
2019 Jul 02
16
[PATCH] Add Rust bindings
I fixed the patch I submitted before based on comments, and there are some commits which are merged or divided. So, I will re-send all the patches. Regards, Hiroyuki Katsura
2019 Jul 08
2
Re: [PATCH] Add Rust bindings
On Mon, Jul 08, 2019 at 10:04:57AM +0100, Richard W.M. Jones wrote: >On Mon, Jul 08, 2019 at 10:49:55AM +0200, Martin Kletzander wrote: >> On Mon, Jul 08, 2019 at 10:10:10AM +0200, Pino Toscano wrote: >> >On Saturday, 6 July 2019 13:03:24 CEST Martin Kletzander wrote: >> >>Just one thing, the Cargo.toml includes a version under which the crate would be >>
2019 Jul 26
4
Re: [PATCH] Rust bindings: Add Rust bindings
Hi Hiroyuki, sorry for the late reply. Most of the work is definitely nice! There are few notes below, although they are not big issues. I will check this patch once more on monday, especially the rust parts. Otherwise, I'd say that we are close to merging this :) On Tuesday, 23 July 2019 10:37:17 CEST Hiroyuki Katsura wrote: > From: Hiroyuki_Katsura