aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/main-caml.c
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2008-02-14 09:34:27 -0700
committerAlex Williamson <alex.williamson@hp.com>2008-02-14 09:34:27 -0700
commite38c4f55fe6ef6c393388ae181630ab3a92f77dd (patch)
tree24970faea32f21f96b9048f8a36c8e8d9dafe2b2 /extras/mini-os/main-caml.c
parent03c9b741df33f676c99c7885ca7f795190df37d5 (diff)
parentdf5b25e9af9248d8e00d0ef7e4ce3eec9eb44f97 (diff)
downloadxen-e38c4f55fe6ef6c393388ae181630ab3a92f77dd.tar.gz
xen-e38c4f55fe6ef6c393388ae181630ab3a92f77dd.tar.bz2
xen-e38c4f55fe6ef6c393388ae181630ab3a92f77dd.zip
merge with xen-unstable.hg
Diffstat (limited to 'extras/mini-os/main-caml.c')
-rw-r--r--extras/mini-os/main-caml.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/extras/mini-os/main-caml.c b/extras/mini-os/main-caml.c
new file mode 100644
index 0000000000..dd55aca38f
--- /dev/null
+++ b/extras/mini-os/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;
+}