systemd-ml/lib/systemd_stubs.c

31 lines
641 B
C
Raw Normal View History

2024-09-24 08:23:56 +00:00
#include <malloc.h>
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/custom.h>
#include <caml/unixsupport.h>
/**
* Wrapper for caml_unix_code_of_unix_error that returns a real OCaml int value
*/
CAMLprim value ocaml_systemd_unix_code_of_unix_error(value code) {
CAMLparam1(code);
CAMLlocal1(result);
int raw_code = caml_unix_code_of_unix_error(code);
result = Val_int(raw_code);
CAMLreturn(result);
}
CAMLprim value ocaml_systemd_memory_trim(value unit) {
CAMLparam1(unit);
#ifdef OCAML_SYSTEMD_USE_MALLOC_TRIM
malloc_trim(0);
#endif
CAMLreturn(Val_unit);
}