1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* Automatique. Distributed only by permission. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-07-10 02:48:27 -07:00
|
|
|
/* Start-up code */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "gc.h"
|
|
|
|
#include "gc_ctrl.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "mlvalues.h"
|
|
|
|
#include "sys.h"
|
|
|
|
|
1996-02-20 02:59:35 -08:00
|
|
|
header_t atom_table[256];
|
|
|
|
char * static_data_start, * static_data_end;
|
1995-07-10 02:48:27 -07:00
|
|
|
|
|
|
|
static void init_atoms()
|
|
|
|
{
|
|
|
|
int i;
|
1996-02-20 02:59:35 -08:00
|
|
|
extern struct { char * begin; char * end; } caml_data_segments[];
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) atom_table[i] = Make_header(0, i, White);
|
|
|
|
static_data_start = caml_data_segments[0].begin;
|
|
|
|
static_data_end = caml_data_segments[0].end;
|
|
|
|
for (i = 1; caml_data_segments[i].begin != 0; i++) {
|
|
|
|
if (caml_data_segments[i].begin < static_data_start)
|
|
|
|
static_data_start = caml_data_segments[i].begin;
|
|
|
|
if (caml_data_segments[i].end > static_data_end)
|
|
|
|
static_data_end = caml_data_segments[i].end;
|
|
|
|
}
|
1995-07-10 02:48:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
extern value caml_start_program P((void));
|
|
|
|
|
1996-10-07 06:20:04 -07:00
|
|
|
void caml_main(argc, argv)
|
1995-07-10 02:48:27 -07:00
|
|
|
int argc;
|
|
|
|
char * argv[];
|
|
|
|
{
|
|
|
|
int verbose_init = 0, percent_free_init = Percent_free_def;
|
|
|
|
long minor_heap_init = Minor_heap_def, heap_chunk_init = Heap_chunk_def;
|
|
|
|
char * opt;
|
|
|
|
value retcode;
|
|
|
|
|
1995-10-16 09:59:18 -07:00
|
|
|
init_ieee_floats();
|
1995-07-10 02:48:27 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
verbose_init = 1;
|
|
|
|
#endif
|
|
|
|
/* Runtime options. The option letter is the first letter of the
|
|
|
|
last word of the ML name of the option (see [lib/gc.mli]). */
|
|
|
|
opt = getenv ("CAMLRUNPARAM");
|
|
|
|
if (opt != NULL){
|
|
|
|
while (*opt != '\0'){
|
|
|
|
switch (*opt++){
|
|
|
|
case 's': sscanf (opt, "=%ld", &minor_heap_init); break;
|
|
|
|
case 'i': sscanf (opt, "=%ld", &heap_chunk_init); break;
|
|
|
|
case 'o': sscanf (opt, "=%d", &percent_free_init); break;
|
|
|
|
case 'v': sscanf (opt, "=%d", &verbose_init); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
init_gc (minor_heap_init, heap_chunk_init, percent_free_init, verbose_init);
|
|
|
|
init_atoms();
|
1995-12-21 03:01:45 -08:00
|
|
|
init_signals();
|
1995-07-10 02:48:27 -07:00
|
|
|
sys_init(argv);
|
|
|
|
retcode = caml_start_program();
|
1996-10-07 06:20:04 -07:00
|
|
|
if (retcode != 0) {
|
1995-07-10 02:48:27 -07:00
|
|
|
fatal_error_arg("Fatal error: uncaught exception %s.\n",
|
|
|
|
String_val(Field(Field(retcode, 0), 0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|