diff options
Diffstat (limited to 'stubdom/caml')
-rw-r--r-- | stubdom/caml/Makefile | 10 | ||||
-rw-r--r-- | stubdom/caml/main-caml.c | 42 |
2 files changed, 51 insertions, 1 deletions
diff --git a/stubdom/caml/Makefile b/stubdom/caml/Makefile index 69595a8f99..8642240cef 100644 --- a/stubdom/caml/Makefile +++ b/stubdom/caml/Makefile @@ -2,12 +2,20 @@ XEN_ROOT = ../.. include $(XEN_ROOT)/Config.mk +CAMLLIB = $(shell ocamlc -where) +DEF_CPPFLAGS += -I$(CAMLLIB) + OCAMLFIND=ocamlfind OCAMLOPT=ocamlopt OBJS := hello.cmx LIBS := +all: main-c.o main-caml.o caml.o + +main-c.c: + ln -sf $(XEN_ROOT)/extras/mini-os/main.c $@ + %.cmx: %.ml $(OCAMLFIND) $(OCAMLOPT) -c $< -o $@ @@ -15,4 +23,4 @@ caml.o: $(OBJS) $(OCAMLFIND) $(OCAMLOPT) $(LIBS) $^ -output-obj -o $@ clean: - rm -f *.o *.cmx *.cmi + rm -f *.a *.o *.cmx *.cmi diff --git a/stubdom/caml/main-caml.c b/stubdom/caml/main-caml.c new file mode 100644 index 0000000000..dd55aca38f --- /dev/null +++ b/stubdom/caml/main-caml.c @@ -0,0 +1,42 @@ +/* + * Caml bootstrap + * + * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008 + */ + +#include <stdio.h> +#include <errno.h> + +#include <caml/mlvalues.h> +#include <caml/callback.h> +#include <unistd.h> + +/* Ugly binary compatibility with Linux */ +FILE *_stderr asm("stderr"); +int *__errno_location; +/* Will probably break everything, probably need to fetch from glibc */ +void *__ctype_b_loc; + +int main(int argc, char *argv[], char *envp[]) +{ + value *val; + + /* Get current thread's value */ + _stderr = stderr; + __errno_location = &errno; + + printf("starting caml\n"); + + /* Wait before things might hang up */ + sleep(1); + + caml_startup(argv); + val = caml_named_value("main"); + if (!val) { + printf("Couldn't find Caml main"); + return 1; + } + caml_callback(*val, Val_int(0)); + printf("callback returned\n"); + return 0; +} |