1 /* 2 * Caml bootstrap 3 * 4 * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008 5 */ 6 7 #include <stdio.h> 8 #include <errno.h> 9 10 #include <caml/mlvalues.h> 11 #include <caml/callback.h> 12 #include <unistd.h> 13 14 /* Ugly binary compatibility with Linux */ 15 FILE *_stderr asm("stderr"); 16 int *__errno_location; 17 /* Will probably break everything, probably need to fetch from glibc */ 18 void *__ctype_b_loc; 19 main(int argc,char * argv[],char * envp[])20int main(int argc, char *argv[], char *envp[]) 21 { 22 value *val; 23 24 /* Get current thread's value */ 25 _stderr = stderr; 26 __errno_location = &errno; 27 28 printf("starting caml\n"); 29 30 /* Wait before things might hang up */ 31 sleep(1); 32 33 caml_startup(argv); 34 val = caml_named_value("main"); 35 if (!val) { 36 printf("Couldn't find Caml main"); 37 return 1; 38 } 39 caml_callback(*val, Val_int(0)); 40 printf("callback returned\n"); 41 return 0; 42 } 43