ocaml_sys/
alloc.rs

1//! External definitions for allocating values in the OCaml runtime
2
3use crate::{
4    mlvalues::{Size, Value},
5    tag::Tag,
6    Char,
7};
8
9extern "C" {
10    pub fn caml_alloc(size: Size, tag: Tag) -> Value;
11    pub fn caml_alloc_small(size: Size, tag: Tag) -> Value;
12    pub fn caml_alloc_tuple(size: Size) -> Value;
13    pub fn caml_alloc_string(size: Size) -> Value; // size in bytes
14    pub fn caml_alloc_initialized_string(size: Size, string: *const Char) -> Value;
15    pub fn caml_copy_string(string: *const Char) -> Value;
16    pub fn caml_copy_string_array(arr: *const *const Char) -> Value;
17    pub fn caml_is_double_array(v: Value) -> i32;
18    pub fn caml_copy_double(double: f64) -> Value;
19    pub fn caml_copy_int32(int: i32) -> Value; // defined in [ints.c]
20    pub fn caml_copy_int64(int: i64) -> Value; // defined in [ints.c]
21    pub fn caml_copy_nativeint(int: isize) -> Value; // defined in [ints.c]
22    pub fn caml_alloc_float_array(size: Size) -> Value;
23    pub fn caml_alloc_array(
24        value: unsafe extern "C" fn(*const Char) -> Value,
25        array: *const *const Char,
26    ) -> Value;
27
28    pub fn caml_alloc_final(
29        size: Size,
30        final_fn: extern "C" fn(Value),
31        consumed: Size,
32        max: Size,
33    ) -> Value;
34}