ocaml/test/Moretest/cmstub.c

18 lines
406 B
C

#include <string.h>
#include <mlvalues.h>
#include <callback.h>
/* Functions callable directly from C */
int fib(int n)
{
value * fib_closure = caml_named_value("fib");
return Int_val(callback(*fib_closure, Val_int(n)));
}
char * format_result(int n)
{
value * format_result_closure = caml_named_value("format_result");
return strdup(String_val(callback(*format_result_closure, Val_int(n))));
}