search for: c_int

Displaying 20 results from an estimated 71 matches for "c_int".

Did you mean: u_int
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.
...RACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +// SUCH DAMAGE. + +extern crate nbdkit; + +#[macro_use] +extern crate lazy_static; + +use libc::*; +use std::ptr; +use std::os::raw::c_int; +use std::sync::Mutex; + +use nbdkit::*; +use nbdkit::ThreadModel::*; + +// The RAM disk. +lazy_static! { + static ref DISK: Mutex<Vec<u8>> = Mutex::new (vec![0; 100 * 1024 * 1024]); +} + +struct Handle { + // Box::new doesn't allocate anything unless we put some dummy + /...
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 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
0
[nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...examples/ramdisk.rs 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; -...
2019 Aug 16
1
Re: [nbdkit PATCH 2/2] rust: Add support for dynamic .thread_model
...; --- 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_cha...
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 07
2
[libnbd PATCH] RFC: Add bindings for Rust language
..."%s: usize,\n" len + | Callback (n, args) + | CallbackPersist (n, args) -> + pri (); pr "%s: Option<\n" n; + pri2 (); pr "unsafe extern \"C\" fn"; + print_rust_ffi_arg_list (indent + 2) args; + pr " -> c_int,\n"; + pri (); pr ">,\n" + | Flags n -> pri (); pr "%s: u32,\n" n + | Int n -> pri (); pr "%s: c_int,\n" n + | Int64 n -> pri (); pr "%s: i64,\n" n + | Mutable (Int n) -> pri (); pr "%s: *mut c_int,\n&q...
2019 Feb 01
2
Set the number of threads using openmp with .Fortran?
..."-fopenmp" LDFLAGS = "-fopenmp" *This is my Fortran module:* module hello_openmp use omp_lib implicit none contains subroutine hello(ncores) bind(C, name="hello_") use, intrinsic :: iso_c_binding, only : c_double, c_int integer(c_int), intent(in) :: ncores integer :: iam ! Specify number of threads to use: !$call omp_set_num_threads(ncores) !$omp parallel private(iam) iam=omp_get_thread_num() !$omp critical write(*,*) 'H...
2019 Jun 27
0
[PATCH 7/9] Rust bindings: Complete actions
...nerator/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: *mut guestfs_h) -> *const c_char;...
2019 Aug 16
0
[nbdkit PATCH 1/2] rust: Implement can_cache
...--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_void, +...
2019 Feb 02
1
Set the number of threads using openmp with .Fortran?
...le:* >> >> module hello_openmp >> use omp_lib >> implicit none >> contains >> >> subroutine hello(ncores) bind(C, name="hello_") >> use, intrinsic :: >> iso_c_binding, only : c_double, c_int >> integer(c_int), intent(in) :: ncores >> integer :: iam >> ! Specify number of threads to use: >> !$call omp_set_num_threads(ncores) >> !$omp parallel private(iam) >> iam=omp...
2015 Jul 27
2
R package with Fortran module on Windows? undefined reference to `__stack_chk_fail'
...umber(y_coord) if ((x_coord**2 + y_coord**2) <= 1.0d0) then score = score + 1 end if end do dartsscore = 4.0d0*score/darts end subroutine dboard subroutine pi(avepi, DARTS, ROUNDS) bind(C, name="pi_") use, intrinsic :: iso_c_binding, only : c_double, c_int real(c_double), intent(out) :: avepi integer(c_int), intent(in) :: DARTS, ROUNDS integer :: MASTER, rank, i, n integer, allocatable :: seed(:) double precision :: pi_est, homepi, pirecv, pis...
2019 Jun 25
3
[PATCH libnbd] generator: Add Mutable type to the generator.
...(Int n) -> + pr " PyObject *py_%s_dict = PyImport_GetModuleDict ();\n" n; + pr " PyObject *py_%s_mod = PyMapping_GetItemString (py_%s_dict, \"ctypes\");\n" n n; + pr " PyObject *py_%s = PyObject_CallMethod (py_%s_mod, \"c_int\", \"i\", *%s);\n" n n n | Opaque n -> pr " struct %s_%s_data *_data = %s;\n" name cb_name n | String n | UInt64 n -> () (* The following not yet implemented for callbacks XXX *) | ArrayAndLen _ | Bo...
2019 Jul 08
0
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...to happen in sync. 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...
2019 Feb 02
0
Set the number of threads using openmp with .Fortran?
...; > > *This is my Fortran module:* > > module hello_openmp > use omp_lib > implicit none > contains > > subroutine hello(ncores) bind(C, name="hello_") > use, intrinsic :: iso_c_binding, > only : c_double, c_int > integer(c_int), intent(in) :: ncores > integer :: iam > ! Specify number of threads to use: > !$call omp_set_num_threads(ncores) > !$omp parallel private(iam) > iam=omp_get_thread_num() >...
2019 Jul 08
2
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...so 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: >...
2019 Jul 08
1
Re: [libnbd PATCH] RFC: Add bindings for Rust language
...t;strings" (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. Tin...
2014 Mar 21
0
[PATCH RFC V2 4/4] tools: virtio: add a top-like utility for displaying vhost satistics
...nt32), + ('bp_type', ctypes.c_uint32), + ('bp_addr', ctypes.c_uint64), + ('bp_len', ctypes.c_uint64), + ] +def _perf_event_open(attr, pid, cpu, group_fd, flags): + return syscall(298, ctypes.pointer(attr), ctypes.c_int(pid), + ctypes.c_int(cpu), ctypes.c_int(group_fd), + ctypes.c_long(flags)) + +PERF_TYPE_HARDWARE = 0 +PERF_TYPE_SOFTWARE = 1 +PERF_TYPE_TRACEPOINT = 2 +PERF_TYPE_HW_CACHE = 3 +PERF_TYPE_RAW = 4 +...
2015 Jul 27
0
R package with Fortran module on Windows? undefined reference to `__stack_chk_fail'
...= 1.0d0) then > score = score + 1 > end if > end do > > dartsscore = 4.0d0*score/darts > > end subroutine dboard > > subroutine pi(avepi, DARTS, ROUNDS) bind(C, name="pi_") > use, intrinsic :: iso_c_binding, only : > c_double, c_int > real(c_double), intent(out) :: avepi > integer(c_int), intent(in) :: DARTS, ROUNDS > integer :: MASTER, rank, i, n > integer, allocatable :: seed(:) > double precision :: pi...