use crate::mlvalues::{Intnat, Uintnat, Value};
use core::ffi::c_void;
pub type Data = *mut c_void;
#[repr(C)]
pub struct BigarrayProxy {
refcount: Intnat,
data: Data,
size: Uintnat,
}
#[repr(C)]
pub struct Bigarray {
pub data: Data,
pub num_dims: Intnat,
pub flags: Intnat,
pub proxy: *const BigarrayProxy,
pub dim: [Intnat; 0],
}
impl Bigarray {
pub fn is_fortran(&self) -> bool {
(self.flags & Layout::FORTRAN_LAYOUT as isize) != 0
}
}
#[allow(non_camel_case_types)]
pub enum Managed {
EXTERNAL = 0, MANAGED = 0x200, MAPPED_FILE = 0x400, MANAGED_MASK = 0x600, }
#[allow(non_camel_case_types)]
pub enum Kind {
FLOAT32 = 0x00, FLOAT64 = 0x01, SINT8 = 0x02, UINT8 = 0x03, SINT16 = 0x04, UINT16 = 0x05, INT32 = 0x06, INT64 = 0x07, CAML_INT = 0x08, NATIVE_INT = 0x09, COMPLEX32 = 0x0a, COMPLEX64 = 0x0b, CHAR = 0x0c, KIND_MASK = 0xFF, }
#[allow(non_camel_case_types)]
pub enum Layout {
C_LAYOUT = 0, FORTRAN_LAYOUT = 0x100, }
extern "C" {
pub fn malloc(size: usize) -> Data;
pub fn caml_ba_alloc(flags: i32, num_dims: i32, data: Data, dim: *const i32) -> Value;
pub fn caml_ba_alloc_dims(flags: i32, num_dims: i32, data: Data, ...) -> Value;
pub fn caml_ba_byte_size(b: *const Bigarray) -> u32;
}