summaryrefslogtreecommitdiffstats
path: root/asmrun/runtime.c
blob: b8061b46cab41c42196952f41f1bcbe9e93d876d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* A very simplified runtime system for the native code compiler */

#include <stdio.h>
#include <stdlib.h>
#include "mlvalues.h"

extern int caml_start_program();

value print_int(n)
     value n;
{
  printf("%d", n>>1);
  return 1;
}

value print_string(s)
     value s;
{
  printf("%s", (char *) s);
  return 1;
}

value print_char(c)
     value c;
{
  printf("%c", c>>1);
  return 1;
}

static struct {
  value header;
  char data[16];
} match_failure_id = {
  ((16 / sizeof(value)) << 11) + 0xFC,
  "Match_failure\0\0\2"
};

char * Match_failure = match_failure_id.data;

int main(argc, argv)
     int argc;
     char ** argv;
{
  init_heap();
  if (caml_start_program() != 0) {
    fprintf(stderr, "Uncaught exception\n");
    exit(2);
  }
  return 0;
}