├── .gitignore
├── INSTALL
├── LICENSE-en
├── LICENSE-fr
├── Makefile
├── README
├── VERSION
├── configure
├── dist
├── distgen
├── ocamlcc-1.0.tar.bz2
└── ocamlcc-1.01.tar.bz2
├── man
└── ocamlcc.1
├── ocamlclean
└── ocamlclean-2.0.tar.bz2
├── runtime
├── LICENSE
├── ocamlcc-alloc.c
├── ocamlcc-apply-gen.c
├── ocamlcc-apply-none.c
├── ocamlcc-apply-x86x.c
├── ocamlcc-byterun-3.12
│ ├── alloc.c
│ ├── alloc.h
│ ├── array.c
│ ├── backtrace.c
│ ├── backtrace.h
│ ├── callback.c
│ ├── callback.h
│ ├── compact.c
│ ├── compact.h
│ ├── compare.c
│ ├── compare.h
│ ├── compatibility.h
│ ├── custom.c
│ ├── custom.h
│ ├── debugger.c
│ ├── debugger.h
│ ├── dynlink.c
│ ├── dynlink.h
│ ├── exec.h
│ ├── extern.c
│ ├── fail.c
│ ├── fail.h
│ ├── finalise.c
│ ├── finalise.h
│ ├── fix_code.c
│ ├── fix_code.h
│ ├── flexdll.c
│ ├── flexdll.h
│ ├── floats.c
│ ├── freelist.c
│ ├── freelist.h
│ ├── gc.h
│ ├── gc_ctrl.c
│ ├── gc_ctrl.h
│ ├── globroots.c
│ ├── globroots.h
│ ├── hash.c
│ ├── instruct.h
│ ├── int64_emul.h
│ ├── int64_format.h
│ ├── int64_native.h
│ ├── intern.c
│ ├── intext.h
│ ├── ints.c
│ ├── io.c
│ ├── io.h
│ ├── jumptbl.h
│ ├── lexing.c
│ ├── main.c
│ ├── major_gc.c
│ ├── major_gc.h
│ ├── md5.c
│ ├── md5.h
│ ├── memory.c
│ ├── memory.h
│ ├── minor_gc.c
│ ├── minor_gc.h
│ ├── misc.c
│ ├── misc.h
│ ├── mlvalues.h
│ ├── obj.c
│ ├── opnames.h
│ ├── osdeps.h
│ ├── parsing.c
│ ├── prims.c
│ ├── prims.h
│ ├── printexc.c
│ ├── printexc.h
│ ├── reverse.h
│ ├── roots.c
│ ├── roots.h
│ ├── signals.c
│ ├── signals.h
│ ├── signals_byt.c
│ ├── signals_machdep.h
│ ├── stacks.c
│ ├── stacks.h
│ ├── startup.c
│ ├── startup.h
│ ├── str.c
│ ├── sys.c
│ ├── sys.h
│ ├── terminfo.c
│ ├── ui.h
│ ├── unix.c
│ ├── version.h
│ ├── weak.c
│ ├── weak.h
│ └── win32.c
├── ocamlcc-byterun-4.00
│ ├── alloc.c
│ ├── alloc.h
│ ├── array.c
│ ├── backtrace.c
│ ├── backtrace.h
│ ├── callback.c
│ ├── callback.h
│ ├── compact.c
│ ├── compact.h
│ ├── compare.c
│ ├── compare.h
│ ├── compatibility.h
│ ├── custom.c
│ ├── custom.h
│ ├── debugger.c
│ ├── debugger.h
│ ├── dynlink.c
│ ├── dynlink.h
│ ├── exec.h
│ ├── extern.c
│ ├── fail.c
│ ├── fail.h
│ ├── finalise.c
│ ├── finalise.h
│ ├── fix_code.c
│ ├── fix_code.h
│ ├── flexdll.c
│ ├── floats.c
│ ├── freelist.c
│ ├── freelist.h
│ ├── gc.h
│ ├── gc_ctrl.c
│ ├── gc_ctrl.h
│ ├── globroots.c
│ ├── globroots.h
│ ├── hash.c
│ ├── hash.h
│ ├── instrtrace.c
│ ├── instrtrace.h
│ ├── instruct.h
│ ├── int64_emul.h
│ ├── int64_format.h
│ ├── int64_native.h
│ ├── intern.c
│ ├── intext.h
│ ├── ints.c
│ ├── io.c
│ ├── io.h
│ ├── jumptbl.h
│ ├── lexing.c
│ ├── main.c
│ ├── major_gc.c
│ ├── major_gc.h
│ ├── md5.c
│ ├── md5.h
│ ├── memory.c
│ ├── memory.h
│ ├── minor_gc.c
│ ├── minor_gc.h
│ ├── misc.c
│ ├── misc.h
│ ├── mlvalues.h
│ ├── obj.c
│ ├── osdeps.h
│ ├── parsing.c
│ ├── prims.c
│ ├── prims.h
│ ├── printexc.c
│ ├── printexc.h
│ ├── reverse.h
│ ├── roots.c
│ ├── roots.h
│ ├── signals.c
│ ├── signals.h
│ ├── signals_byt.c
│ ├── signals_machdep.h
│ ├── stacks.c
│ ├── stacks.h
│ ├── startup.c
│ ├── startup.h
│ ├── str.c
│ ├── sys.c
│ ├── sys.h
│ ├── terminfo.c
│ ├── ui.h
│ ├── unix.c
│ ├── version.h
│ ├── weak.c
│ ├── weak.h
│ └── win32.c
├── ocamlcc-byterun.h
├── ocamlcc-exceptions.c
├── ocamlcc-instrs.c
├── ocamlcc-main.c
├── ocamlcc-marshal.c
├── ocamlcc-otherlibs.h
├── ocamlcc-signals.c
├── ocamlcc-sp.c
├── ocamlcc-unimpl.c
├── ocamlcc-windows.c
└── ocamlcc.h
├── src
├── Makefile
├── codegen
│ ├── apply.ml
│ ├── codegen.ml
│ ├── macroc.mli
│ ├── mcgen.ml
│ ├── mcprinter.ml
│ └── tailcall.ml
├── frontend
│ ├── code.ml
│ ├── data.ml
│ ├── dbug.ml
│ ├── index.ml
│ ├── instr.ml
│ ├── loader.ml
│ └── prim.ml
├── ocamlcc.ml
├── optimizer
│ ├── body.ml
│ ├── cleanfuns.ml
│ ├── propag.ml
│ ├── remapstk.ml
│ └── xconst.ml
└── tools
│ ├── options.ml
│ ├── printer.ml
│ ├── stat.ml
│ ├── stk.ml
│ ├── tools.ml
│ └── types.mli
└── tests
├── Makefile
├── bigsrc_ml
├── extexn.ml
├── fact.ml
├── fibo.ml
├── flocon.ml
├── funs.ml
├── hw.ml
├── levenshtein.ml
├── loop.ml
├── marsh.ml
├── nucleic.ml
├── okb.ml
├── osolilet.ml
├── printfhw.ml
├── takc.ml
├── termtrap.ml
└── wscope.ml
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | etc/
3 | src/_build/
4 | src/config.ml
5 | dist/*.tar.bz2
6 | !dist/ocamlcc-1.0.tar.bz2
7 | !dist/ocamlcc-1.01.tar.bz2
8 | tests/a.out
9 | tests/*.byte
10 | tests/*.cmi
11 | tests/*.cmo
12 | tests/*.cmx
13 | tests/*.native
14 | tests/*.o
15 | tests/*.c
16 | tests/*-none
17 | tests/*-nxc
18 | tests/*-i386
19 | tests/*-i486
20 | tests/*-i586
21 | tests/*-i686
22 | tests/*-x86_64
23 | tests/*-try
24 | tests/*-clang
25 | tests/*-gsp
26 | tests/*-rsp
27 | tests/extexn
28 | tests/fact
29 | tests/fibo
30 | tests/funs
31 | tests/hw
32 | tests/levenshtein
33 | tests/loop
34 | tests/nucleic
35 | tests/okb
36 | tests/osolilet
37 | tests/printfhw
38 | tests/takc
39 | tests/termtrap
40 | tests/ocamlc
41 | tests/ocamlopt
42 | tests/flocon
43 | tests/wscope
44 | tests/marsh
45 | ocamlclean/*
46 | !ocamlclean/*.tar.bz2
47 | plus/
48 |
--------------------------------------------------------------------------------
/INSTALL:
--------------------------------------------------------------------------------
1 | Installing OCamlCC on a Unix machine
2 | ------------------------------------
3 |
4 | PREREQUISITES
5 |
6 | * The OCaml standard distribution
7 |
8 |
9 | INSTALLATION INSTRUCTIONS
10 |
11 | 1- Configure the system. From the top directory, do:
12 |
13 | ./configure
14 |
15 | This generates the configuration files "Makefile.conf", "config.ml"
16 | and "config.h" in the ./etc/ subdirectory.
17 |
18 | The "configure" script accepts the following options:
19 |
20 | -bindir
(default: /usr/local/bin)
21 | Directory where the binaries will be installed.
22 |
23 | -includedir (default: /usr/local/include)
24 | Directory where the C headers will be installed.
25 |
26 | -mandir (default: /usr/local/man/man1)
27 | Directory where the manual pages will be installed.
28 |
29 | -prefix (default: /usr/local)
30 | Set bindir, includedir and mandir to /bin, /include
31 | and /man/man1 respectively.
32 |
33 | Examples:
34 |
35 | Standard installation in /usr/{bin,include,man} instead of /usr/local:
36 | ./configure -prefix /usr
37 |
38 | Installation in /usr, man pages in section "l":
39 | ./configure -bindir /usr/bin -includedir /usr/include -mandir /usr/man/manl
40 |
41 |
42 | 2- From the top directory, do:
43 |
44 | make
45 |
46 | This builds ocamlcc in the local directory ./bin/.
47 |
48 |
49 | 3- You can now install OCamlCC. This will create the following command
50 | (in the binary directory selected during autoconfiguration):
51 |
52 | ocamlcc an Objective Caml to C code compiler
53 |
54 | From the top directory, become superuser and do:
55 |
56 | umask 022 # make sure to give read & execute permission to all
57 | make install
58 |
59 | 4- Installation is complete. Time to clean up. From the toplevel
60 | directory, do:
61 |
62 | make clean
63 |
64 |
65 | UNINSTALLATION INSTRUCTIONS
66 |
67 | 1- If configuration files (./etc/Makefile.conf, ./etc/config.ml,
68 | ./etc/config.h) have been lost, run again ./configure from the top
69 | directory with the same options as at step 1 of installation.
70 |
71 | 2- From the top directory, become superuser and do:
72 |
73 | make uninstall
74 |
--------------------------------------------------------------------------------
/LICENSE-en:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/LICENSE-en
--------------------------------------------------------------------------------
/LICENSE-fr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/LICENSE-fr
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | ###########################################################################
2 | ## ##
3 | ## OCamlCC ##
4 | ## ##
5 | ## Michel Mauny, Benoit Vaugon ##
6 | ## ENSTA ParisTech ##
7 | ## ##
8 | ## This file is distributed under the terms of the CeCILL license. ##
9 | ## See file LICENSE-en. ##
10 | ## ##
11 | ###########################################################################
12 |
13 | include etc/Makefile.conf
14 |
15 | all: config
16 | @make --no-print-directory -C src
17 | @if [ $(INSTALL_OCAMLCLEAN) = true ]; then \
18 | cd $(OCAMLCLEAN_DIRECTORY)/; \
19 | make --no-print-directory; \
20 | fi
21 |
22 | config:
23 | @if [ etc/Makefile.conf -ot VERSION -o \
24 | etc/Makefile.conf -ot configure ]; then \
25 | echo 'Configuration files are not up to date.' 1>&2; \
26 | echo 'Please run `./configure` (with right options).' 1>&2; \
27 | exit 1; \
28 | fi
29 |
30 | install: all
31 | mkdir -p "$(BINDIR)"
32 | mkdir -p "$(MAN1DIR)"
33 | mkdir -p "$(INCLUDEDIR)"
34 | cp bin/ocamlcc "$(BINDIR)/ocamlcc"
35 | gzip -c man/ocamlcc.1 > "$(MAN1DIR)/ocamlcc.1.gz"
36 | cp -R runtime/* "$(INCLUDEDIR)/"
37 | for d in runtime/ocamlcc-byterun-?.??; do \
38 | cp etc/config.h "$(INCLUDEDIR)/$${d:8:20}/config.h"; \
39 | done
40 | @if [ $(INSTALL_OCAMLCLEAN) = true ]; then \
41 | cd $(OCAMLCLEAN_DIRECTORY)/; \
42 | make --no-print-directory install; \
43 | fi
44 |
45 | uninstall:
46 | rm -f "$(BINDIR)/ocamlcc"
47 | rm -f "$(MAN1DIR)/ocamlcc.1.gz"
48 | rm -Rf "$(INCLUDEDIR)"
49 | @if [ $(INSTALL_OCAMLCLEAN) = true ]; then \
50 | cd $(OCAMLCLEAN_DIRECTORY)/; \
51 | make --no-print-directory uninstall; \
52 | fi
53 |
54 | etc/Makefile.conf:
55 | @echo "You must run ./configure before" 1>&2
56 | @exit 1
57 |
58 | tests: all
59 | @make --no-print-directory -C tests
60 |
61 | dist: clean
62 | dist/distgen
63 |
64 | clean:
65 | @make --no-print-directory -C src clean
66 | @make --no-print-directory -C tests clean
67 | @if [ $(INSTALL_OCAMLCLEAN) = true ]; then \
68 | cd $(OCAMLCLEAN_DIRECTORY)/; \
69 | make --no-print-directory clean; \
70 | fi
71 |
72 | .PHONY: all config install uninstall tests dist clean
73 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | ocamlcc
2 | =======
3 |
4 | OCaml bytecode to C compiler
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 1.01
2 |
--------------------------------------------------------------------------------
/dist/distgen:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 | ###########################################################################
3 | ## ##
4 | ## OCamlCC ##
5 | ## ##
6 | ## Michel Mauny, Benoit Vaugon ##
7 | ## ENSTA ParisTech ##
8 | ## ##
9 | ## This file is distributed under the terms of the CeCILL license. ##
10 | ## See file ../LICENSE-en. ##
11 | ## ##
12 | ###########################################################################
13 |
14 | cd $(dirname "$0")
15 |
16 | VERSION=$(cat ../VERSION)
17 | DEST=ocamlcc-"$VERSION"
18 |
19 | rm -Rf "$DEST"
20 |
21 | for d in "$DEST" "$DEST/bin" "$DEST/dist" "$DEST/etc" "$DEST/ocamlclean"; do
22 | mkdir "$d"
23 | done
24 |
25 | for d in \
26 | configure runtime INSTALL LICENSE-en LICENSE-fr Makefile man \
27 | src tests VERSION
28 | do
29 | cp -R ../"$d" "$DEST/"
30 | done
31 |
32 | cp ./distgen "$DEST/dist/"
33 |
34 | cp $(ls ../ocamlclean/ocamlclean-*.tar.bz2 -1 | sort -n | tail -n 1) \
35 | "$DEST/ocamlclean/"
36 |
37 | tar jcf "$DEST.tar.bz2" "$DEST"
38 |
39 | rm -Rf "$DEST"
40 |
41 | echo "** Distribution $DEST.tar.bz2 created successfully **"
42 |
--------------------------------------------------------------------------------
/dist/ocamlcc-1.0.tar.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/dist/ocamlcc-1.0.tar.bz2
--------------------------------------------------------------------------------
/dist/ocamlcc-1.01.tar.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/dist/ocamlcc-1.01.tar.bz2
--------------------------------------------------------------------------------
/man/ocamlcc.1:
--------------------------------------------------------------------------------
1 | .TH OCAMLCC 1
2 |
3 | .SH NAME
4 | ocamlcc \- OCaml bytecode to C code compiler
5 |
6 | .SH SYNOPSIS
7 | \fBocamlcc \fR[ \fIOPTIONS\fR ] [ \fIsrc.byte\fR ]
8 |
9 | .SH DESCRIPTION
10 |
11 | The \fBocamlcc\fR(1) command compiles an OCaml bytecode executable
12 | into C code, and sends the result to a C compiler.
13 |
14 | .SH OPTIONS
15 |
16 | The following command line options are recognized by \fBocamlcc(1)\fR.
17 |
18 | .TP
19 | \fB-c\fR
20 | Stop after the generation of C code.
21 |
22 | .TP
23 | \fB-k\fR
24 | Keep intermediate bytecode and C files.
25 |
26 | .TP
27 | \fB-o \fIoutfile\fR
28 | Specify the output file (default is a.out, or the bytecode source file
29 | with a .c extension).
30 |
31 | .TP
32 | \fB-cc\fR
33 | Specify which C compiler to use.
34 |
35 | .TP
36 | \fB-ccopts\fR
37 | Extra arguments for the C compiler (default is -O3 -Wall).
38 |
39 | .TP
40 | \fB-arch \fB( GEN | NONE | X86 | X86_64 )\fR
41 | Specify the target architecture. Default is \fBGEN\fR, in which case
42 | portable C code is generated.
43 |
44 | .TP
45 | \fB-signal \fB( E[fficient] | R[eactive] )\fR
46 | Generate code for signal handling to advantage efficiency (\fBE\fR) or
47 | reactiveness (\fBR\fR). Default is \fBE\fR.
48 |
49 | .TP
50 | \fB-exception \fB( S[etjmp] | T[ry-catch] )\fR
51 | Define exception mechanism: use setjmp/longjmp primitives (\fBS\fR) or
52 | C++ try-catch control structures (\fBT\fR). Default is \fBS\fR.
53 |
54 | .TP
55 | \fB-stack-pointer ( L[ocal] | G[lobal] | R[egister] )\fR
56 | Define stack pointer mode: use a local C variable (\fBL\fR), a global
57 | C variable (\fBG\fR) or a global C register (\fBR\fR). Default is \fBL\fR.
58 |
59 | .TP
60 | \fB-trace\ \fR
61 | Generate additional C code to trace execution.
62 |
63 | .TP
64 | \fB-no-main\fR
65 | Do not include the main function.
66 |
67 | .TP
68 | \fB-no-xconst\fR
69 | Disable xconst (OCaml stack constant extraction) optimisation.
70 |
71 | .TP
72 | \fB-include\fR
73 | Print include directory and exit.
74 |
75 | .TP
76 | \fB-stat\fR
77 | Print statistics.
78 |
79 | .TP
80 | \fB-verbose\fR
81 | Verbose mode.
82 |
83 | .TP
84 | \fB-version\fR
85 | Print version and exit.
86 |
87 | .TP
88 | \fB-v\fR
89 | Print version, include directory and OCaml runtime version, then exit.
90 |
91 | .SH SEE ALSO
92 | .BR \fBocamlclean\fR(1),\ \fBocamlc\fR(1),\ \fBocamlrun\fR(1),\ \fBocamlopt\fR(1)
93 |
--------------------------------------------------------------------------------
/ocamlclean/ocamlclean-2.0.tar.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/ocamlclean/ocamlclean-2.0.tar.bz2
--------------------------------------------------------------------------------
/runtime/ocamlcc-alloc.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #define Ocamlcc_alloc_small(result, wosize, tag, Before_gc, After_gc) { \
14 | CAMLassert ((wosize) >= 1); \
15 | CAMLassert ((tag_t) (tag) < 256); \
16 | CAMLassert ((wosize) <= Max_young_wosize); \
17 | caml_young_ptr -= Bhsize_wosize (wosize); \
18 | if (caml_young_ptr < caml_young_limit){ \
19 | caml_young_ptr += Bhsize_wosize (wosize); \
20 | Before_gc; \
21 | caml_minor_collection (); \
22 | After_gc; \
23 | caml_young_ptr -= Bhsize_wosize (wosize); \
24 | } \
25 | Hd_hp (caml_young_ptr) = Make_header ((wosize), (tag), Caml_black); \
26 | (result) = Val_hp (caml_young_ptr); \
27 | DEBUG_clear ((result), (wosize)); \
28 | }
29 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/alloc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: alloc.h 7064 2005-09-22 14:21:50Z xleroy $ */
15 |
16 | #ifndef CAML_ALLOC_H
17 | #define CAML_ALLOC_H
18 |
19 |
20 | #ifndef CAML_NAME_SPACE
21 | #include "compatibility.h"
22 | #endif
23 | #include "misc.h"
24 | #include "mlvalues.h"
25 |
26 | CAMLextern value caml_alloc (mlsize_t, tag_t);
27 | CAMLextern value caml_alloc_small (mlsize_t, tag_t);
28 | CAMLextern value caml_alloc_tuple (mlsize_t);
29 | CAMLextern value caml_alloc_string (mlsize_t); /* size in bytes */
30 | CAMLextern value caml_copy_string (char const *);
31 | CAMLextern value caml_copy_string_array (char const **);
32 | CAMLextern value caml_copy_double (double);
33 | CAMLextern value caml_copy_int32 (int32); /* defined in [ints.c] */
34 | CAMLextern value caml_copy_int64 (int64); /* defined in [ints.c] */
35 | CAMLextern value caml_copy_nativeint (intnat); /* defined in [ints.c] */
36 | CAMLextern value caml_alloc_array (value (*funct) (char const *),
37 | char const ** array);
38 |
39 | typedef void (*final_fun)(value);
40 | CAMLextern value caml_alloc_final (mlsize_t, /*size in words*/
41 | final_fun, /*finalization function*/
42 | mlsize_t, /*resources consumed*/
43 | mlsize_t /*max resources*/);
44 |
45 | CAMLextern int caml_convert_flag_list (value, int *);
46 |
47 | /* OCamlCC may call caml_obj_truncate when updating dummy blocks */
48 | CAMLextern value caml_obj_truncate (value, value);
49 |
50 | #endif /* CAML_ALLOC_H */
51 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/backtrace.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: backtrace.h 9540 2010-01-20 16:26:46Z doligez $ */
15 |
16 | #ifndef CAML_BACKTRACE_H
17 | #define CAML_BACKTRACE_H
18 |
19 | #include "mlvalues.h"
20 |
21 | CAMLextern int caml_backtrace_active;
22 | CAMLextern int caml_backtrace_pos;
23 | CAMLextern code_t * caml_backtrace_buffer;
24 | CAMLextern value caml_backtrace_last_exn;
25 | CAMLextern char * caml_cds_file;
26 |
27 | CAMLprim value caml_record_backtrace(value vflag);
28 | #ifndef NATIVE_CODE
29 | extern void caml_stash_backtrace(value exn, code_t pc, value * sp);
30 | #endif
31 | CAMLextern void caml_print_exception_backtrace(void);
32 |
33 | #endif /* CAML_BACKTRACE_H */
34 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/callback.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: callback.h 7596 2006-09-11 12:12:24Z doligez $ */
15 |
16 | /* Callbacks from C to Caml */
17 |
18 | #ifndef CAML_CALLBACK_H
19 | #define CAML_CALLBACK_H
20 |
21 | #ifndef CAML_NAME_SPACE
22 | #include "compatibility.h"
23 | #endif
24 | #include "mlvalues.h"
25 |
26 | CAMLextern value caml_callback (value closure, value arg);
27 | CAMLextern value caml_callback2 (value closure, value arg1, value arg2);
28 | CAMLextern value caml_callback3 (value closure, value arg1, value arg2,
29 | value arg3);
30 | CAMLextern value caml_callbackN (value closure, int narg, value args[]);
31 |
32 | CAMLextern value caml_callback_exn (value closure, value arg);
33 | CAMLextern value caml_callback2_exn (value closure, value arg1, value arg2);
34 | CAMLextern value caml_callback3_exn (value closure,
35 | value arg1, value arg2, value arg3);
36 | CAMLextern value caml_callbackN_exn (value closure, int narg, value args[]);
37 |
38 | #define Make_exception_result(v) ((v) | 2)
39 | #define Is_exception_result(v) (((v) & 3) == 2)
40 | #define Extract_exception(v) ((v) & ~3)
41 |
42 | CAMLextern value * caml_named_value (char const * name);
43 |
44 | CAMLextern void caml_main (char ** argv);
45 | CAMLextern void caml_startup (char ** argv);
46 |
47 | CAMLextern int caml_callback_depth;
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/compact.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: compact.h 6044 2003-12-31 14:20:40Z doligez $ */
15 |
16 | #ifndef CAML_COMPACT_H
17 | #define CAML_COMPACT_H
18 |
19 |
20 | #include "config.h"
21 | #include "misc.h"
22 |
23 | extern void caml_compact_heap (void);
24 | extern void caml_compact_heap_maybe (void);
25 |
26 |
27 | #endif /* CAML_COMPACT_H */
28 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/compare.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, Projet Moscova, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2003 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: compare.h 6044 2003-12-31 14:20:40Z doligez $ */
15 |
16 | #ifndef CAML_COMPARE_H
17 | #define CAML_COMPARE_H
18 |
19 | CAMLextern int caml_compare_unordered;
20 |
21 | #endif /* CAML_COMPARE_H */
22 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/custom.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Manuel Serrano and Xavier Leroy, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: custom.h 9547 2010-01-22 12:48:24Z doligez $ */
15 |
16 | #ifndef CAML_CUSTOM_H
17 | #define CAML_CUSTOM_H
18 |
19 |
20 | #ifndef CAML_NAME_SPACE
21 | #include "compatibility.h"
22 | #endif
23 | #include "mlvalues.h"
24 |
25 | struct custom_operations {
26 | const char *identifier;
27 | void (*finalize)(value v);
28 | int (*compare)(value v1, value v2);
29 | intnat (*hash)(value v);
30 | void (*serialize)(value v,
31 | /*out*/ uintnat * wsize_32 /*size in bytes*/,
32 | /*out*/ uintnat * wsize_64 /*size in bytes*/);
33 | uintnat (*deserialize)(void * dst);
34 | };
35 |
36 | #define custom_finalize_default NULL
37 | #define custom_compare_default NULL
38 | #define custom_hash_default NULL
39 | #define custom_serialize_default NULL
40 | #define custom_deserialize_default NULL
41 |
42 | #define Custom_ops_val(v) (*((struct custom_operations **) (v)))
43 |
44 | CAMLextern value caml_alloc_custom(struct custom_operations * ops,
45 | uintnat size, /*size in bytes*/
46 | mlsize_t mem, /*resources consumed*/
47 | mlsize_t max /*max resources*/);
48 |
49 | CAMLextern void caml_register_custom_operations(struct custom_operations * ops);
50 |
51 | CAMLextern int caml_compare_unordered;
52 | /* Used by custom comparison to report unordered NaN-like cases. */
53 |
54 | /* */
55 | extern struct custom_operations * caml_find_custom_operations(char * ident);
56 | extern struct custom_operations *
57 | caml_final_custom_operations(void (*fn)(value));
58 |
59 | extern void caml_init_custom_operations(void);
60 | /* */
61 |
62 | #endif /* CAML_CUSTOM_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/dynlink.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: dynlink.h 6130 2004-02-22 15:07:51Z xleroy $ */
15 |
16 | /* Dynamic loading of C primitives. */
17 |
18 | #ifndef CAML_DYNLINK_H
19 | #define CAML_DYNLINK_H
20 |
21 | #include "misc.h"
22 |
23 | /* Build the table of primitives, given a search path, a list
24 | of shared libraries, and a list of primitive names
25 | (all three 0-separated in char arrays).
26 | Abort the runtime system on error. */
27 | extern void caml_build_primitive_table(char * lib_path,
28 | char * libs,
29 | char * req_prims);
30 |
31 | /* The search path for shared libraries */
32 | extern struct ext_table caml_shared_libs_path;
33 |
34 | /* Build the table of primitives as a copy of the builtin primitive table.
35 | Used for executables generated by ocamlc -output-obj. */
36 | extern void caml_build_primitive_table_builtin(void);
37 |
38 | #endif /* CAML_DYNLINK_H */
39 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/exec.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: exec.h 6359 2004-06-01 12:36:34Z xleroy $ */
15 |
16 | /* exec.h : format of executable bytecode files */
17 |
18 | #ifndef CAML_EXEC_H
19 | #define CAML_EXEC_H
20 |
21 | /* Executable bytecode files are composed of a number of sections,
22 | identified by 4-character names. A table of contents at the
23 | end of the file lists the section names along with their sizes,
24 | in the order in which they appear in the file:
25 |
26 | offset 0 ---> initial junk
27 | data for section 1
28 | data for section 2
29 | ...
30 | data for section N
31 | table of contents:
32 | descriptor for section 1
33 | ...
34 | descriptor for section N
35 | trailer
36 | end of file --->
37 | */
38 |
39 | /* Structure of t.o.c. entries
40 | Numerical quantities are 32-bit unsigned integers, big endian */
41 |
42 | struct section_descriptor {
43 | char name[4]; /* Section name */
44 | uint32 len; /* Length of data in bytes */
45 | };
46 |
47 | /* Structure of the trailer. */
48 |
49 | struct exec_trailer {
50 | uint32 num_sections; /* Number of sections */
51 | char magic[12]; /* The magic number */
52 | struct section_descriptor * section; /* Not part of file */
53 | };
54 |
55 | #define TRAILER_SIZE (4+12)
56 |
57 | /* Magic number for this release */
58 |
59 | #define EXEC_MAGIC "Caml1999X008"
60 |
61 |
62 | #endif /* CAML_EXEC_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/fail.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: fail.h 9030 2008-09-18 11:23:28Z xleroy $ */
15 |
16 | #ifndef CAML_FAIL_H
17 | #define CAML_FAIL_H
18 |
19 | /* */
20 | #include
21 | /* */
22 |
23 | #ifndef CAML_NAME_SPACE
24 | #include "compatibility.h"
25 | #endif
26 | #include "misc.h"
27 | #include "mlvalues.h"
28 |
29 | /* */
30 | #define OUT_OF_MEMORY_EXN 0 /* "Out_of_memory" */
31 | #define SYS_ERROR_EXN 1 /* "Sys_error" */
32 | #define FAILURE_EXN 2 /* "Failure" */
33 | #define INVALID_EXN 3 /* "Invalid_argument" */
34 | #define END_OF_FILE_EXN 4 /* "End_of_file" */
35 | #define ZERO_DIVIDE_EXN 5 /* "Division_by_zero" */
36 | #define NOT_FOUND_EXN 6 /* "Not_found" */
37 | #define MATCH_FAILURE_EXN 7 /* "Match_failure" */
38 | #define STACK_OVERFLOW_EXN 8 /* "Stack_overflow" */
39 | #define SYS_BLOCKED_IO 9 /* "Sys_blocked_io" */
40 | #define ASSERT_FAILURE_EXN 10 /* "Assert_failure" */
41 | #define UNDEFINED_RECURSIVE_MODULE_EXN 11 /* "Undefined_recursive_module" */
42 |
43 | #ifdef POSIX_SIGNALS
44 | struct longjmp_buffer {
45 | sigjmp_buf buf;
46 | };
47 | #else
48 | struct longjmp_buffer {
49 | jmp_buf buf;
50 | };
51 | #define sigsetjmp(buf,save) setjmp(buf)
52 | #define siglongjmp(buf,val) longjmp(buf,val)
53 | #endif
54 |
55 | CAMLextern struct longjmp_buffer * caml_external_raise;
56 | extern value caml_exn_bucket;
57 |
58 | /* */
59 |
60 | CAMLextern void caml_raise (value bucket) Noreturn;
61 | CAMLextern void caml_raise_constant (value tag) Noreturn;
62 | CAMLextern void caml_raise_with_arg (value tag, value arg) Noreturn;
63 | CAMLextern void caml_raise_with_args (value tag, int nargs, value arg[]) Noreturn;
64 | CAMLextern void caml_raise_with_string (value tag, char const * msg) Noreturn;
65 | CAMLextern void caml_failwith (char const *) Noreturn;
66 | CAMLextern void caml_invalid_argument (char const *) Noreturn;
67 | CAMLextern void caml_raise_out_of_memory (void) Noreturn;
68 | CAMLextern void caml_raise_stack_overflow (void) Noreturn;
69 | CAMLextern void caml_raise_sys_error (value) Noreturn;
70 | CAMLextern void caml_raise_end_of_file (void) Noreturn;
71 | CAMLextern void caml_raise_zero_divide (void) Noreturn;
72 | CAMLextern void caml_raise_not_found (void) Noreturn;
73 | CAMLextern void caml_init_exceptions (void);
74 | CAMLextern void caml_array_bound_error (void) Noreturn;
75 | CAMLextern void caml_raise_sys_blocked_io (void) Noreturn;
76 |
77 | #endif /* CAML_FAIL_H */
78 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/finalise.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Moscova, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: finalise.h 6047 2004-01-02 19:23:29Z doligez $ */
15 |
16 | #ifndef CAML_FINALISE_H
17 | #define CAML_FINALISE_H
18 |
19 | #include "roots.h"
20 |
21 | void caml_final_update (void);
22 | void caml_final_do_calls (void);
23 | void caml_final_do_strong_roots (scanning_action f);
24 | void caml_final_do_weak_roots (scanning_action f);
25 | void caml_final_do_young_roots (scanning_action f);
26 | void caml_final_empty_young (void);
27 | value caml_final_register (value f, value v);
28 |
29 | #endif /* CAML_FINALISE_H */
30 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/fix_code.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: fix_code.h 6047 2004-01-02 19:23:29Z doligez $ */
15 |
16 | /* Handling of blocks of bytecode (endianness switch, threading). */
17 |
18 | #ifndef CAML_FIX_CODE_H
19 | #define CAML_FIX_CODE_H
20 |
21 |
22 | #include "config.h"
23 | #include "misc.h"
24 | #include "mlvalues.h"
25 |
26 | extern code_t caml_start_code;
27 | extern asize_t caml_code_size;
28 | extern unsigned char * caml_saved_code;
29 | extern unsigned char caml_code_md5[16];
30 |
31 | void caml_load_code (int fd, asize_t len);
32 | void caml_fixup_endianness (code_t code, asize_t len);
33 | void caml_set_instruction (code_t pos, opcode_t instr);
34 | int caml_is_instruction (opcode_t instr1, opcode_t instr2);
35 |
36 | #ifdef THREADED_CODE
37 | extern char ** caml_instr_table;
38 | extern char * caml_instr_base;
39 | void caml_thread_code (code_t code, asize_t len);
40 | #endif
41 |
42 | #endif /* CAML_FIX_CODE_H */
43 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/flexdll.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************
2 | FlexDLL
3 | Alain Frisch
4 |
5 | Copyright 2007 Institut National de Recherche en Informatique et
6 | en Automatique.
7 |
8 | ******************************************************************/
9 |
10 | /* Header for the runtime support library */
11 |
12 | #ifndef FLEXDLL_H
13 | #define FLEXDLL_H
14 |
15 | #define FLEXDLL_RTLD_GLOBAL 0x0001
16 | #define FLEXDLL_RTLD_LOCAL 0x0000
17 | #define FLEXDLL_RTLD_NOEXEC 0x0002
18 |
19 | #ifdef __cplusplus
20 | extern "C"
21 | {
22 | #endif
23 |
24 | void *flexdll_dlopen(const char *, int);
25 | void *flexdll_dlsym(void *, const char *);
26 | void flexdll_dlclose(void *);
27 | char *flexdll_dlerror(void);
28 |
29 | void flexdll_dump_exports(void *);
30 | void flexdll_dump_relocations(void *);
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/freelist.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: freelist.h 9153 2008-12-03 18:09:09Z doligez $ */
15 |
16 | /* Free lists of heap blocks. */
17 |
18 | #ifndef CAML_FREELIST_H
19 | #define CAML_FREELIST_H
20 |
21 |
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 |
25 | extern asize_t caml_fl_cur_size; /* size in words */
26 |
27 | char *caml_fl_allocate (mlsize_t);
28 | void caml_fl_init_merge (void);
29 | void caml_fl_reset (void);
30 | char *caml_fl_merge_block (char *);
31 | void caml_fl_add_blocks (char *);
32 | void caml_make_free_blocks (value *, mlsize_t, int);
33 | void caml_set_allocation_policy (uintnat);
34 |
35 |
36 | #endif /* CAML_FREELIST_H */
37 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: gc.h 6557 2004-07-19 13:20:06Z xleroy $ */
15 |
16 | #ifndef CAML_GC_H
17 | #define CAML_GC_H
18 |
19 |
20 | #include "mlvalues.h"
21 |
22 | #define Caml_white (0 << 8)
23 | #define Caml_gray (1 << 8)
24 | #define Caml_blue (2 << 8)
25 | #define Caml_black (3 << 8)
26 |
27 | #define Color_hd(hd) ((color_t) ((hd) & Caml_black))
28 | #define Color_hp(hp) (Color_hd (Hd_hp (hp)))
29 | #define Color_val(val) (Color_hd (Hd_val (val)))
30 |
31 | #define Is_white_hd(hd) (Color_hd (hd) == Caml_white)
32 | #define Is_gray_hd(hd) (Color_hd (hd) == Caml_gray)
33 | #define Is_blue_hd(hd) (Color_hd (hd) == Caml_blue)
34 | #define Is_black_hd(hd) (Color_hd (hd) == Caml_black)
35 |
36 | #define Whitehd_hd(hd) (((hd) & ~Caml_black)/*| Caml_white*/)
37 | #define Grayhd_hd(hd) (((hd) & ~Caml_black) | Caml_gray)
38 | #define Blackhd_hd(hd) (((hd)/*& ~Caml_black*/)| Caml_black)
39 | #define Bluehd_hd(hd) (((hd) & ~Caml_black) | Caml_blue)
40 |
41 | /* This depends on the layout of the header. See [mlvalues.h]. */
42 | #define Make_header(wosize, tag, color) \
43 | (/*Assert ((wosize) <= Max_wosize),*/ \
44 | ((header_t) (((header_t) (wosize) << 10) \
45 | + (color) \
46 | + (tag_t) (tag))) \
47 | )
48 |
49 | #define Is_white_val(val) (Color_val(val) == Caml_white)
50 | #define Is_gray_val(val) (Color_val(val) == Caml_gray)
51 | #define Is_blue_val(val) (Color_val(val) == Caml_blue)
52 | #define Is_black_val(val) (Color_val(val) == Caml_black)
53 |
54 | /* For extern.c */
55 | #define Colornum_hd(hd) ((color_t) (((hd) >> 8) & 3))
56 | #define Coloredhd_hd(hd,colnum) (((hd) & ~Caml_black) | ((colnum) << 8))
57 |
58 | #endif /* CAML_GC_H */
59 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/gc_ctrl.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: gc_ctrl.h 7064 2005-09-22 14:21:50Z xleroy $ */
15 |
16 | #ifndef CAML_GC_CTRL_H
17 | #define CAML_GC_CTRL_H
18 |
19 | #include "misc.h"
20 |
21 | extern double
22 | caml_stat_minor_words,
23 | caml_stat_promoted_words,
24 | caml_stat_major_words;
25 |
26 | extern intnat
27 | caml_stat_minor_collections,
28 | caml_stat_major_collections,
29 | caml_stat_heap_size,
30 | caml_stat_top_heap_size,
31 | caml_stat_compactions,
32 | caml_stat_heap_chunks;
33 |
34 | void caml_init_gc (uintnat, uintnat, uintnat,
35 | uintnat, uintnat);
36 |
37 |
38 | #ifdef DEBUG
39 | void caml_heap_check (void);
40 | #endif
41 |
42 | #endif /* CAML_GC_CTRL_H */
43 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/globroots.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: globroots.h 8828 2008-03-10 19:56:39Z xleroy $ */
15 |
16 | /* Registration of global memory roots */
17 |
18 | #ifndef CAML_GLOBROOTS_H
19 | #define CAML_GLOBROOTS_H
20 |
21 | #include "mlvalues.h"
22 | #include "roots.h"
23 |
24 | void caml_scan_global_roots(scanning_action f);
25 | void caml_scan_global_young_roots(scanning_action f);
26 |
27 | #endif /* CAML_GLOBROOTS_H */
28 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/instruct.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: instruct.h 9547 2010-01-22 12:48:24Z doligez $ */
15 |
16 | /* The instruction set. */
17 |
18 | #ifndef CAML_INSTRUCT_H
19 | #define CAML_INSTRUCT_H
20 |
21 | /* OCamlCC: rename ATOM -> ATOM_ (collision windef.h) */
22 |
23 | enum instructions {
24 | ACC0, ACC1, ACC2, ACC3, ACC4, ACC5, ACC6, ACC7,
25 | ACC, PUSH,
26 | PUSHACC0, PUSHACC1, PUSHACC2, PUSHACC3,
27 | PUSHACC4, PUSHACC5, PUSHACC6, PUSHACC7,
28 | PUSHACC, POP, ASSIGN,
29 | ENVACC1, ENVACC2, ENVACC3, ENVACC4, ENVACC,
30 | PUSHENVACC1, PUSHENVACC2, PUSHENVACC3, PUSHENVACC4, PUSHENVACC,
31 | PUSH_RETADDR, APPLY, APPLY1, APPLY2, APPLY3,
32 | APPTERM, APPTERM1, APPTERM2, APPTERM3,
33 | RETURN, RESTART, GRAB,
34 | CLOSURE, CLOSUREREC,
35 | OFFSETCLOSUREM2, OFFSETCLOSURE0, OFFSETCLOSURE2, OFFSETCLOSURE,
36 | PUSHOFFSETCLOSUREM2, PUSHOFFSETCLOSURE0,
37 | PUSHOFFSETCLOSURE2, PUSHOFFSETCLOSURE,
38 | GETGLOBAL, PUSHGETGLOBAL, GETGLOBALFIELD, PUSHGETGLOBALFIELD, SETGLOBAL,
39 | ATOM0, ATOM_, PUSHATOM0, PUSHATOM,
40 | MAKEBLOCK, MAKEBLOCK1, MAKEBLOCK2, MAKEBLOCK3, MAKEFLOATBLOCK,
41 | GETFIELD0, GETFIELD1, GETFIELD2, GETFIELD3, GETFIELD, GETFLOATFIELD,
42 | SETFIELD0, SETFIELD1, SETFIELD2, SETFIELD3, SETFIELD, SETFLOATFIELD,
43 | VECTLENGTH, GETVECTITEM, SETVECTITEM,
44 | GETSTRINGCHAR, SETSTRINGCHAR,
45 | BRANCH, BRANCHIF, BRANCHIFNOT, SWITCH, BOOLNOT,
46 | PUSHTRAP, POPTRAP, RAISE, CHECK_SIGNALS,
47 | C_CALL1, C_CALL2, C_CALL3, C_CALL4, C_CALL5, C_CALLN,
48 | CONST0, CONST1, CONST2, CONST3, CONSTINT,
49 | PUSHCONST0, PUSHCONST1, PUSHCONST2, PUSHCONST3, PUSHCONSTINT,
50 | NEGINT, ADDINT, SUBINT, MULINT, DIVINT, MODINT,
51 | ANDINT, ORINT, XORINT, LSLINT, LSRINT, ASRINT,
52 | EQ, NEQ, LTINT, LEINT, GTINT, GEINT,
53 | OFFSETINT, OFFSETREF, ISINT,
54 | GETMETHOD,
55 | BEQ, BNEQ, BLTINT, BLEINT, BGTINT, BGEINT,
56 | ULTINT, UGEINT,
57 | BULTINT, BUGEINT,
58 | GETPUBMET, GETDYNMET,
59 | STOP,
60 | EVENT, BREAK
61 | };
62 |
63 | #endif /* CAML_INSTRUCT_H */
64 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/int64_format.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2002 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: int64_format.h 9547 2010-01-22 12:48:24Z doligez $ */
15 |
16 | /* printf-like formatting of 64-bit integers, in case the C library
17 | printf() function does not support them. */
18 |
19 | #ifndef CAML_INT64_FORMAT_H
20 | #define CAML_INT64_FORMAT_H
21 |
22 | static void I64_format(char * buffer, char * fmt, int64 x)
23 | {
24 | static char conv_lower[] = "0123456789abcdef";
25 | static char conv_upper[] = "0123456789ABCDEF";
26 | char rawbuffer[24];
27 | char justify, signstyle, filler, alternate, signedconv;
28 | int base, width, sign, i, rawlen;
29 | char * cvtbl;
30 | char * p, * r;
31 | int64 wbase, digit;
32 |
33 | /* Parsing of format */
34 | justify = '+';
35 | signstyle = '-';
36 | filler = ' ';
37 | alternate = 0;
38 | base = 0;
39 | signedconv = 0;
40 | width = 0;
41 | cvtbl = conv_lower;
42 | for (p = fmt; *p != 0; p++) {
43 | switch (*p) {
44 | case '-':
45 | justify = '-'; break;
46 | case '+': case ' ':
47 | signstyle = *p; break;
48 | case '0':
49 | filler = '0'; break;
50 | case '#':
51 | alternate = 1; break;
52 | case '1': case '2': case '3': case '4': case '5':
53 | case '6': case '7': case '8': case '9':
54 | width = atoi(p);
55 | while (*p >= '0' && *p <= '9') p++;
56 | break;
57 | case 'd': case 'i':
58 | signedconv = 1; /* fallthrough */
59 | case 'u':
60 | base = 10; break;
61 | case 'x':
62 | base = 16; break;
63 | case 'X':
64 | base = 16; cvtbl = conv_upper; break;
65 | case 'o':
66 | base = 8; break;
67 | }
68 | }
69 | if (base == 0) { buffer[0] = 0; return; }
70 | /* Do the conversion */
71 | sign = 1;
72 | if (signedconv && I64_is_negative(x)) { sign = -1; x = I64_neg(x); }
73 | r = rawbuffer + sizeof(rawbuffer);
74 | wbase = I64_of_int32(base);
75 | do {
76 | I64_udivmod(x, wbase, &x, &digit);
77 | *--r = cvtbl[I64_to_int32(digit)];
78 | } while (! I64_is_zero(x));
79 | rawlen = rawbuffer + sizeof(rawbuffer) - r;
80 | /* Adjust rawlen to reflect additional chars (sign, etc) */
81 | if (signedconv && (sign < 0 || signstyle != '-')) rawlen++;
82 | if (alternate) {
83 | if (base == 8) rawlen += 1;
84 | if (base == 16) rawlen += 2;
85 | }
86 | /* Do the formatting */
87 | p = buffer;
88 | if (justify == '+' && filler == ' ') {
89 | for (i = rawlen; i < width; i++) *p++ = ' ';
90 | }
91 | if (signedconv) {
92 | if (sign < 0) *p++ = '-';
93 | else if (signstyle != '-') *p++ = signstyle;
94 | }
95 | if (alternate && base == 8) *p++ = '0';
96 | if (alternate && base == 16) { *p++ = '0'; *p++ = 'x'; }
97 | if (justify == '+' && filler == '0') {
98 | for (i = rawlen; i < width; i++) *p++ = '0';
99 | }
100 | while (r < rawbuffer + sizeof(rawbuffer)) *p++ = *r++;
101 | if (justify == '-') {
102 | for (i = rawlen; i < width; i++) *p++ = ' ';
103 | }
104 | *p = 0;
105 | }
106 |
107 | #endif /* CAML_INT64_FORMAT_H */
108 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/int64_native.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2002 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: int64_native.h 9270 2009-05-20 11:52:42Z doligez $ */
15 |
16 | /* Wrapper macros around native 64-bit integer arithmetic,
17 | so that it has the same interface as the software emulation
18 | provided in int64_emul.h */
19 |
20 | #ifndef CAML_INT64_NATIVE_H
21 | #define CAML_INT64_NATIVE_H
22 |
23 | #define I64_literal(hi,lo) ((int64)(hi) << 32 | (lo))
24 | #define I64_compare(x,y) (((x) > (y)) - ((x) < (y)))
25 | #define I64_ult(x,y) ((uint64)(x) < (uint64)(y))
26 | #define I64_neg(x) (-(x))
27 | #define I64_add(x,y) ((x) + (y))
28 | #define I64_sub(x,y) ((x) - (y))
29 | #define I64_mul(x,y) ((x) * (y))
30 | #define I64_is_zero(x) ((x) == 0)
31 | #define I64_is_negative(x) ((x) < 0)
32 | #define I64_is_min_int(x) ((x) == ((int64)1 << 63))
33 | #define I64_is_minus_one(x) ((x) == -1)
34 |
35 | #define I64_div(x,y) ((x) / (y))
36 | #define I64_mod(x,y) ((x) % (y))
37 | #define I64_udivmod(x,y,quo,rem) \
38 | (*(rem) = (uint64)(x) % (uint64)(y), \
39 | *(quo) = (uint64)(x) / (uint64)(y))
40 | #define I64_and(x,y) ((x) & (y))
41 | #define I64_or(x,y) ((x) | (y))
42 | #define I64_xor(x,y) ((x) ^ (y))
43 | #define I64_lsl(x,y) ((x) << (y))
44 | #define I64_asr(x,y) ((x) >> (y))
45 | #define I64_lsr(x,y) ((uint64)(x) >> (y))
46 | #define I64_to_intnat(x) ((intnat) (x))
47 | #define I64_of_intnat(x) ((intnat) (x))
48 | #define I64_to_int32(x) ((int32) (x))
49 | #define I64_of_int32(x) ((int64) (x))
50 | #define I64_to_double(x) ((double)(x))
51 | #define I64_of_double(x) ((int64)(x))
52 |
53 | #endif /* CAML_INT64_NATIVE_H */
54 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/jumptbl.h:
--------------------------------------------------------------------------------
1 | &&lbl_ACC0, &&lbl_ACC1, &&lbl_ACC2, &&lbl_ACC3, &&lbl_ACC4, &&lbl_ACC5, &&lbl_ACC6, &&lbl_ACC7,
2 | &&lbl_ACC, &&lbl_PUSH,
3 | &&lbl_PUSHACC0, &&lbl_PUSHACC1, &&lbl_PUSHACC2, &&lbl_PUSHACC3,
4 | &&lbl_PUSHACC4, &&lbl_PUSHACC5, &&lbl_PUSHACC6, &&lbl_PUSHACC7,
5 | &&lbl_PUSHACC, &&lbl_POP, &&lbl_ASSIGN,
6 | &&lbl_ENVACC1, &&lbl_ENVACC2, &&lbl_ENVACC3, &&lbl_ENVACC4, &&lbl_ENVACC,
7 | &&lbl_PUSHENVACC1, &&lbl_PUSHENVACC2, &&lbl_PUSHENVACC3, &&lbl_PUSHENVACC4, &&lbl_PUSHENVACC,
8 | &&lbl_PUSH_RETADDR, &&lbl_APPLY, &&lbl_APPLY1, &&lbl_APPLY2, &&lbl_APPLY3,
9 | &&lbl_APPTERM, &&lbl_APPTERM1, &&lbl_APPTERM2, &&lbl_APPTERM3,
10 | &&lbl_RETURN, &&lbl_RESTART, &&lbl_GRAB,
11 | &&lbl_CLOSURE, &&lbl_CLOSUREREC,
12 | &&lbl_OFFSETCLOSUREM2, &&lbl_OFFSETCLOSURE0, &&lbl_OFFSETCLOSURE2, &&lbl_OFFSETCLOSURE,
13 | &&lbl_PUSHOFFSETCLOSUREM2, &&lbl_PUSHOFFSETCLOSURE0,
14 | &&lbl_PUSHOFFSETCLOSURE2, &&lbl_PUSHOFFSETCLOSURE,
15 | &&lbl_GETGLOBAL, &&lbl_PUSHGETGLOBAL, &&lbl_GETGLOBALFIELD, &&lbl_PUSHGETGLOBALFIELD, &&lbl_SETGLOBAL,
16 | &&lbl_ATOM0, &&lbl_ATOM, &&lbl_PUSHATOM0, &&lbl_PUSHATOM,
17 | &&lbl_MAKEBLOCK, &&lbl_MAKEBLOCK1, &&lbl_MAKEBLOCK2, &&lbl_MAKEBLOCK3, &&lbl_MAKEFLOATBLOCK,
18 | &&lbl_GETFIELD0, &&lbl_GETFIELD1, &&lbl_GETFIELD2, &&lbl_GETFIELD3, &&lbl_GETFIELD, &&lbl_GETFLOATFIELD,
19 | &&lbl_SETFIELD0, &&lbl_SETFIELD1, &&lbl_SETFIELD2, &&lbl_SETFIELD3, &&lbl_SETFIELD, &&lbl_SETFLOATFIELD,
20 | &&lbl_VECTLENGTH, &&lbl_GETVECTITEM, &&lbl_SETVECTITEM,
21 | &&lbl_GETSTRINGCHAR, &&lbl_SETSTRINGCHAR,
22 | &&lbl_BRANCH, &&lbl_BRANCHIF, &&lbl_BRANCHIFNOT, &&lbl_SWITCH, &&lbl_BOOLNOT,
23 | &&lbl_PUSHTRAP, &&lbl_POPTRAP, &&lbl_RAISE, &&lbl_CHECK_SIGNALS,
24 | &&lbl_C_CALL1, &&lbl_C_CALL2, &&lbl_C_CALL3, &&lbl_C_CALL4, &&lbl_C_CALL5, &&lbl_C_CALLN,
25 | &&lbl_CONST0, &&lbl_CONST1, &&lbl_CONST2, &&lbl_CONST3, &&lbl_CONSTINT,
26 | &&lbl_PUSHCONST0, &&lbl_PUSHCONST1, &&lbl_PUSHCONST2, &&lbl_PUSHCONST3, &&lbl_PUSHCONSTINT,
27 | &&lbl_NEGINT, &&lbl_ADDINT, &&lbl_SUBINT, &&lbl_MULINT, &&lbl_DIVINT, &&lbl_MODINT,
28 | &&lbl_ANDINT, &&lbl_ORINT, &&lbl_XORINT, &&lbl_LSLINT, &&lbl_LSRINT, &&lbl_ASRINT,
29 | &&lbl_EQ, &&lbl_NEQ, &&lbl_LTINT, &&lbl_LEINT, &&lbl_GTINT, &&lbl_GEINT,
30 | &&lbl_OFFSETINT, &&lbl_OFFSETREF, &&lbl_ISINT,
31 | &&lbl_GETMETHOD,
32 | &&lbl_BEQ, &&lbl_BNEQ, &&lbl_BLTINT, &&lbl_BLEINT, &&lbl_BGTINT, &&lbl_BGEINT,
33 | &&lbl_ULTINT, &&lbl_UGEINT,
34 | &&lbl_BULTINT, &&lbl_BUGEINT,
35 | &&lbl_GETPUBMET, &&lbl_GETDYNMET,
36 | &&lbl_STOP,
37 | &&lbl_EVENT, &&lbl_BREAK
38 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/main.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: main.c 8822 2008-02-29 12:56:15Z doligez $ */
15 |
16 | /* Main entry point (can be overridden by a user-provided main()
17 | function that calls caml_main() later). */
18 |
19 | #include "misc.h"
20 | #include "mlvalues.h"
21 | #include "sys.h"
22 |
23 | CAMLextern void caml_main (char **);
24 |
25 | #ifdef _WIN32
26 | CAMLextern void caml_expand_command_line (int *, char ***);
27 | #endif
28 |
29 | #ifndef OCAMLCC_NO_MAIN /* OCamlCC */
30 | int main(int argc, char **argv)
31 | {
32 | #ifdef DEBUG
33 | {
34 | #if 0 /* OCamlCC: clean */
35 | char *ocp;
36 | char *cp;
37 | int i;
38 | #endif
39 |
40 | caml_gc_message (-1, "### OCaml runtime: debug mode ###\n", 0);
41 | #if 0
42 | caml_gc_message (-1, "### command line:", 0);
43 | for (i = 0; i < argc; i++){
44 | caml_gc_message (-1, " %s", argv[i]);
45 | }
46 | caml_gc_message (-1, "\n", 0);
47 | ocp = getenv ("OCAMLRUNPARAM");
48 | caml_gc_message (-1, "### OCAMLRUNPARAM=%s\n", ocp == NULL ? "" : ocp);
49 | cp = getenv ("CAMLRUNPARAM");
50 | caml_gc_message (-1, "### CAMLRUNPARAM=%s\n", cp == NULL ? "" : cp);
51 | caml_gc_message (-1, "### working dir: %s\n", getcwd (NULL, 0));
52 | #endif
53 | }
54 | #endif
55 | #ifdef _WIN32
56 | /* Expand wildcards and diversions in command line */
57 | caml_expand_command_line(&argc, &argv);
58 | #endif
59 | caml_main(argv);
60 | caml_sys_exit(Val_int(0));
61 | return 0; /* not reached */
62 | }
63 | #endif
64 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/major_gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: major_gc.h 8766 2008-01-11 11:55:36Z doligez $ */
15 |
16 | #ifndef CAML_MAJOR_GC_H
17 | #define CAML_MAJOR_GC_H
18 |
19 |
20 | #include "freelist.h"
21 | #include "misc.h"
22 |
23 | typedef struct {
24 | void *block; /* address of the malloced block this chunk live in */
25 | asize_t alloc; /* in bytes, used for compaction */
26 | asize_t size; /* in bytes */
27 | char *next;
28 | } heap_chunk_head;
29 |
30 | #define Chunk_size(c) (((heap_chunk_head *) (c)) [-1]).size
31 | #define Chunk_alloc(c) (((heap_chunk_head *) (c)) [-1]).alloc
32 | #define Chunk_next(c) (((heap_chunk_head *) (c)) [-1]).next
33 | #define Chunk_block(c) (((heap_chunk_head *) (c)) [-1]).block
34 |
35 | extern int caml_gc_phase;
36 | extern int caml_gc_subphase;
37 | extern uintnat caml_allocated_words;
38 | extern double caml_extra_heap_resources;
39 | extern uintnat caml_dependent_size, caml_dependent_allocated;
40 | extern uintnat caml_fl_size_at_phase_change;
41 |
42 | #define Phase_mark 0
43 | #define Phase_sweep 1
44 | #define Phase_idle 2
45 | #define Subphase_main 10
46 | #define Subphase_weak1 11
47 | #define Subphase_weak2 12
48 | #define Subphase_final 13
49 |
50 | CAMLextern char *caml_heap_start;
51 | extern uintnat total_heap_size;
52 | extern char *caml_gc_sweep_hp;
53 |
54 | void caml_init_major_heap (asize_t); /* size in bytes */
55 | asize_t caml_round_heap_chunk_size (asize_t); /* size in bytes */
56 | void caml_darken (value, value *);
57 | intnat caml_major_collection_slice (long);
58 | void major_collection (void);
59 | void caml_finish_major_cycle (void);
60 |
61 |
62 | #endif /* CAML_MAJOR_GC_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/md5.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1999 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: md5.h 9547 2010-01-22 12:48:24Z doligez $ */
15 |
16 | /* MD5 message digest */
17 |
18 | #ifndef CAML_MD5_H
19 | #define CAML_MD5_H
20 |
21 |
22 | #include "mlvalues.h"
23 | #include "io.h"
24 |
25 | CAMLextern value caml_md5_string (value str, value ofs, value len);
26 | CAMLextern value caml_md5_chan (value vchan, value len);
27 |
28 | struct MD5Context {
29 | uint32 buf[4];
30 | uint32 bits[2];
31 | unsigned char in[64];
32 | };
33 |
34 | CAMLextern void caml_MD5Init (struct MD5Context *context);
35 | CAMLextern void caml_MD5Update (struct MD5Context *context, unsigned char *buf,
36 | uintnat len);
37 | CAMLextern void caml_MD5Final (unsigned char *digest, struct MD5Context *ctx);
38 | CAMLextern void caml_MD5Transform (uint32 *buf, uint32 *in);
39 |
40 |
41 | #endif /* CAML_MD5_H */
42 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/minor_gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: minor_gc.h 8211 2007-05-04 14:05:13Z doligez $ */
15 |
16 | #ifndef CAML_MINOR_GC_H
17 | #define CAML_MINOR_GC_H
18 |
19 |
20 | #include "misc.h"
21 |
22 | CAMLextern char *caml_young_start, *caml_young_ptr;
23 | CAMLextern char *caml_young_end, *caml_young_limit;
24 | extern asize_t caml_minor_heap_size;
25 | extern int caml_in_minor_collection;
26 |
27 | struct caml_ref_table {
28 | value **base;
29 | value **end;
30 | value **threshold;
31 | value **ptr;
32 | value **limit;
33 | asize_t size;
34 | asize_t reserve;
35 | };
36 | CAMLextern struct caml_ref_table caml_ref_table, caml_weak_ref_table;
37 |
38 | #define Is_young(val) \
39 | (Assert (Is_block (val)), \
40 | (addr)(val) < (addr)caml_young_end && (addr)(val) > (addr)caml_young_start)
41 |
42 | extern void caml_set_minor_heap_size (asize_t);
43 | extern void caml_empty_minor_heap (void);
44 | CAMLextern void caml_minor_collection (void);
45 | CAMLextern void garbage_collection (void); /* def in asmrun/signals.c */
46 | extern void caml_realloc_ref_table (struct caml_ref_table *);
47 | extern void caml_alloc_table (struct caml_ref_table *, asize_t, asize_t);
48 | extern void caml_oldify_one (value, value *);
49 | extern void caml_oldify_mopup (void);
50 |
51 | #define Oldify(p) do{ \
52 | value __oldify__v__ = *p; \
53 | if (Is_block (__oldify__v__) && Is_young (__oldify__v__)){ \
54 | caml_oldify_one (__oldify__v__, (p)); \
55 | } \
56 | }while(0)
57 |
58 | #endif /* CAML_MINOR_GC_H */
59 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/opnames.h:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | char * names_of_instructions [] = {
6 | "ACC0", "ACC1", "ACC2", "ACC3", "ACC4", "ACC5", "ACC6", "ACC7",
7 | "ACC", "PUSH",
8 | "PUSHACC0", "PUSHACC1", "PUSHACC2", "PUSHACC3",
9 | "PUSHACC4", "PUSHACC5", "PUSHACC6", "PUSHACC7",
10 | "PUSHACC", "POP", "ASSIGN",
11 | "ENVACC1", "ENVACC2", "ENVACC3", "ENVACC4", "ENVACC",
12 | "PUSHENVACC1", "PUSHENVACC2", "PUSHENVACC3", "PUSHENVACC4", "PUSHENVACC",
13 | "PUSH_RETADDR", "APPLY", "APPLY1", "APPLY2", "APPLY3",
14 | "APPTERM", "APPTERM1", "APPTERM2", "APPTERM3",
15 | "RETURN", "RESTART", "GRAB",
16 | "CLOSURE", "CLOSUREREC",
17 | "OFFSETCLOSUREM2", "OFFSETCLOSURE0", "OFFSETCLOSURE2", "OFFSETCLOSURE",
18 | "PUSHOFFSETCLOSUREM2", "PUSHOFFSETCLOSURE0",
19 | "PUSHOFFSETCLOSURE2", "PUSHOFFSETCLOSURE",
20 | "GETGLOBAL", "PUSHGETGLOBAL", "GETGLOBALFIELD", "PUSHGETGLOBALFIELD", "SETGLOBAL",
21 | "ATOM0", "ATOM", "PUSHATOM0", "PUSHATOM",
22 | "MAKEBLOCK", "MAKEBLOCK1", "MAKEBLOCK2", "MAKEBLOCK3", "MAKEFLOATBLOCK",
23 | "GETFIELD0", "GETFIELD1", "GETFIELD2", "GETFIELD3", "GETFIELD", "GETFLOATFIELD",
24 | "SETFIELD0", "SETFIELD1", "SETFIELD2", "SETFIELD3", "SETFIELD", "SETFLOATFIELD",
25 | "VECTLENGTH", "GETVECTITEM", "SETVECTITEM",
26 | "GETSTRINGCHAR", "SETSTRINGCHAR",
27 | "BRANCH", "BRANCHIF", "BRANCHIFNOT", "SWITCH", "BOOLNOT",
28 | "PUSHTRAP", "POPTRAP", "RAISE", "CHECK_SIGNALS",
29 | "C_CALL1", "C_CALL2", "C_CALL3", "C_CALL4", "C_CALL5", "C_CALLN",
30 | "CONST0", "CONST1", "CONST2", "CONST3", "CONSTINT",
31 | "PUSHCONST0", "PUSHCONST1", "PUSHCONST2", "PUSHCONST3", "PUSHCONSTINT",
32 | "NEGINT", "ADDINT", "SUBINT", "MULINT", "DIVINT", "MODINT",
33 | "ANDINT", "ORINT", "XORINT", "LSLINT", "LSRINT", "ASRINT",
34 | "EQ", "NEQ", "LTINT", "LEINT", "GTINT", "GEINT",
35 | "OFFSETINT", "OFFSETREF", "ISINT",
36 | "GETMETHOD",
37 | "BEQ", "BNEQ", "BLTINT", "BLEINT", "BGTINT", "BGEINT",
38 | "ULTINT", "UGEINT",
39 | "BULTINT", "BUGEINT",
40 | "GETPUBMET", "GETDYNMET",
41 | "STOP",
42 | "EVENT", "BREAK"
43 | };
44 |
45 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/osdeps.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: osdeps.h 9547 2010-01-22 12:48:24Z doligez $ */
15 |
16 | /* Operating system - specific stuff */
17 |
18 | #ifndef CAML_OSDEPS_H
19 | #define CAML_OSDEPS_H
20 |
21 | #include "misc.h"
22 |
23 | /* Decompose the given path into a list of directories, and add them
24 | to the given table. Return the block to be freed later. */
25 | extern char * caml_decompose_path(struct ext_table * tbl, char * path);
26 |
27 | /* Search the given file in the given list of directories.
28 | If not found, return a copy of [name]. Result is allocated with
29 | [caml_stat_alloc]. */
30 | extern char * caml_search_in_path(struct ext_table * path, const char * name);
31 |
32 | /* Same, but search an executable name in the system path for executables. */
33 | CAMLextern char * caml_search_exe_in_path(const char * name);
34 |
35 | /* Same, but search a shared library in the given path. */
36 | extern char * caml_search_dll_in_path(struct ext_table * path, char * name);
37 |
38 | /* Open a shared library and return a handle on it.
39 | If [for_execution] is true, perform full symbol resolution and
40 | execute initialization code so that functions from the shared library
41 | can be called. If [for_execution] is false, functions from this
42 | shared library will not be called, but just checked for presence,
43 | so symbol resolution can be skipped.
44 | If [global] is true, symbols from the shared library can be used
45 | to resolve for other libraries to be opened later on.
46 | Return [NULL] on error. */
47 | extern void * caml_dlopen(char * libname, int for_execution, int global);
48 |
49 | /* Close a shared library handle */
50 | extern void caml_dlclose(void * handle);
51 |
52 | /* Look up the given symbol in the given shared library.
53 | Return [NULL] if not found, or symbol value if found. */
54 | extern void * caml_dlsym(void * handle, char * name);
55 |
56 | extern void * caml_globalsym(char * name);
57 |
58 | /* Return an error message describing the most recent dynlink failure. */
59 | extern char * caml_dlerror(void);
60 |
61 | /* Add to [contents] the (short) names of the files contained in
62 | the directory named [dirname]. No entries are added for [.] and [..].
63 | Return 0 on success, -1 on error; set errno in the case of error. */
64 | extern int caml_read_directory(char * dirname, struct ext_table * contents);
65 |
66 | #ifdef __linux__
67 | /* Recover executable name from /proc/self/exe if possible */
68 | extern int caml_executable_name(char * name, int name_len);
69 | #endif
70 |
71 | #endif /* CAML_OSDEPS_H */
72 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/prims.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: prims.h 6130 2004-02-22 15:07:51Z xleroy $ */
15 |
16 | /* Interface with C primitives. */
17 |
18 | #ifndef CAML_PRIMS_H
19 | #define CAML_PRIMS_H
20 |
21 | typedef value (*c_primitive)();
22 |
23 | extern c_primitive caml_builtin_cprim[];
24 | /* OCamlCC: add const modifier */
25 | extern const char * caml_names_of_builtin_cprim[];
26 |
27 | extern struct ext_table caml_prim_table;
28 | #ifdef DEBUG
29 | extern struct ext_table caml_prim_name_table;
30 | #endif
31 |
32 | #define Primitive(n) ((c_primitive)(caml_prim_table.contents[n]))
33 |
34 | extern char * caml_section_table;
35 | extern asize_t caml_section_table_size;
36 |
37 | #endif /* CAML_PRIMS_H */
38 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/printexc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: printexc.h 6045 2004-01-01 16:42:43Z doligez $ */
15 |
16 | #ifndef CAML_PRINTEXC_H
17 | #define CAML_PRINTEXC_H
18 |
19 |
20 | #include "misc.h"
21 | #include "mlvalues.h"
22 |
23 | CAMLextern char * caml_format_exception (value);
24 | void caml_fatal_uncaught_exception (value) Noreturn;
25 |
26 |
27 | #endif /* CAML_PRINTEXC_H */
28 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/roots.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: roots.h 7064 2005-09-22 14:21:50Z xleroy $ */
15 |
16 | #ifndef CAML_ROOTS_H
17 | #define CAML_ROOTS_H
18 |
19 | #include "misc.h"
20 | #include "memory.h"
21 |
22 | typedef void (*scanning_action) (value, value *);
23 |
24 | void caml_oldify_local_roots (void);
25 | void caml_darken_all_roots (void);
26 | void caml_do_roots (scanning_action);
27 | #ifndef NATIVE_CODE
28 | CAMLextern void caml_do_local_roots (scanning_action, value *, value *,
29 | struct caml__roots_block *);
30 | #else
31 | CAMLextern void caml_do_local_roots(scanning_action f, char * bottom_of_stack,
32 | uintnat last_retaddr, value * gc_regs,
33 | struct caml__roots_block * local_roots);
34 | #endif
35 |
36 | CAMLextern void (*caml_scan_roots_hook) (scanning_action);
37 |
38 | #endif /* CAML_ROOTS_H */
39 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/signals.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals.h 7904 2007-02-23 09:29:45Z xleroy $ */
15 |
16 | #ifndef CAML_SIGNALS_H
17 | #define CAML_SIGNALS_H
18 |
19 | #ifndef CAML_NAME_SPACE
20 | #include "compatibility.h"
21 | #endif
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 |
25 | /* */
26 | CAMLextern intnat volatile caml_signals_are_pending;
27 | CAMLextern intnat volatile caml_pending_signals[];
28 | CAMLextern int volatile caml_something_to_do;
29 | extern int volatile caml_force_major_slice;
30 | /* */
31 |
32 | CAMLextern void caml_enter_blocking_section (void);
33 | CAMLextern void caml_leave_blocking_section (void);
34 |
35 | /* */
36 | void caml_urge_major_slice (void);
37 | CAMLextern int caml_convert_signal_number (int);
38 | CAMLextern int caml_rev_convert_signal_number (int);
39 | void caml_execute_signal(int signal_number, int in_signal_handler);
40 | void caml_record_signal(int signal_number);
41 | void caml_process_pending_signals(void);
42 | void caml_process_event(void);
43 | int caml_set_signal_action(int signo, int action);
44 |
45 | CAMLextern void (*caml_enter_blocking_section_hook)(void);
46 | CAMLextern void (*caml_leave_blocking_section_hook)(void);
47 | CAMLextern int (*caml_try_leave_blocking_section_hook)(void);
48 | CAMLextern void (* volatile caml_async_action_hook)(void);
49 | /* */
50 |
51 | #endif /* CAML_SIGNALS_H */
52 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/signals_byt.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2007 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals_byt.c 7904 2007-02-23 09:29:45Z xleroy $ */
15 |
16 | /* Signal handling, code specific to the bytecode interpreter */
17 |
18 | #include
19 | #include "config.h"
20 | #include "memory.h"
21 | #include "osdeps.h"
22 | #include "signals.h"
23 | #include "signals_machdep.h"
24 |
25 | #ifdef __MINGW32__ /* OCamlCC */
26 | #undef POSIX_SIGNALS
27 | #endif
28 |
29 | #ifndef NSIG
30 | #define NSIG 64
31 | #endif
32 |
33 | #ifdef _WIN32
34 | #ifndef __MINGW32__ /* OCamlCC */
35 | typedef void (*sighandler)(int sig);
36 | #endif
37 | extern sighandler caml_win32_signal(int sig, sighandler action);
38 | #define signal(sig,act) caml_win32_signal(sig,act)
39 | #endif
40 |
41 | CAMLexport int volatile caml_something_to_do = 0;
42 | CAMLexport void (* volatile caml_async_action_hook)(void) = NULL;
43 |
44 | void caml_process_event(void)
45 | {
46 | void (*async_action)(void);
47 |
48 | if (caml_force_major_slice) caml_minor_collection ();
49 | /* FIXME should be [caml_check_urgent_gc] */
50 | caml_process_pending_signals();
51 | async_action = caml_async_action_hook;
52 | if (async_action != NULL) {
53 | caml_async_action_hook = NULL;
54 | (*async_action)();
55 | }
56 | }
57 |
58 | static void handle_signal(int signal_number)
59 | {
60 | #if !defined(POSIX_SIGNALS) && !defined(BSD_SIGNALS)
61 | signal(signal_number, handle_signal);
62 | #endif
63 | if (signal_number < 0 || signal_number >= NSIG) return;
64 | if (caml_try_leave_blocking_section_hook()) {
65 | caml_execute_signal(signal_number, 1);
66 | caml_enter_blocking_section_hook();
67 | }else{
68 | caml_record_signal(signal_number);
69 | }
70 | }
71 |
72 | int caml_set_signal_action(int signo, int action)
73 | {
74 | void (*act)(int signo), (*oldact)(int signo);
75 | #ifdef POSIX_SIGNALS
76 | struct sigaction sigact, oldsigact;
77 | #endif
78 |
79 | switch (action) {
80 | case 0: act = SIG_DFL; break;
81 | case 1: act = SIG_IGN; break;
82 | default: act = handle_signal; break;
83 | }
84 |
85 | #ifdef POSIX_SIGNALS
86 | sigact.sa_handler = act;
87 | sigemptyset(&sigact.sa_mask);
88 | sigact.sa_flags = 0;
89 | if (sigaction(signo, &sigact, &oldsigact) == -1) return -1;
90 | oldact = oldsigact.sa_handler;
91 | #else
92 | oldact = signal(signo, act);
93 | if (oldact == SIG_ERR) return -1;
94 | #endif
95 | if (oldact == handle_signal)
96 | return 2;
97 | else if (oldact == SIG_IGN)
98 | return 1;
99 | else
100 | return 0;
101 | }
102 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/signals_machdep.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals_machdep.h 7905 2007-02-23 09:43:14Z xleroy $ */
15 |
16 | /* Processor-specific operation: atomic "read and clear" */
17 |
18 | #ifndef CAML_SIGNALS_MACHDEP_H
19 | #define CAML_SIGNALS_MACHDEP_H
20 |
21 | #if defined(__GNUC__) && defined(__i386__)
22 |
23 | #define Read_and_clear(dst,src) \
24 | asm("xorl %0, %0; xchgl %0, %1" \
25 | : "=r" (dst), "=m" (src) \
26 | : "m" (src))
27 |
28 | #elif defined(__GNUC__) && defined(__x86_64__)
29 |
30 | #define Read_and_clear(dst,src) \
31 | asm("xorq %0, %0; xchgq %0, %1" \
32 | : "=r" (dst), "=m" (src) \
33 | : "m" (src))
34 |
35 | #elif defined(__GNUC__) && defined(__ppc__)
36 |
37 | #define Read_and_clear(dst,src) \
38 | asm("0: lwarx %0, 0, %1\n\t" \
39 | "stwcx. %2, 0, %1\n\t" \
40 | "bne- 0b" \
41 | : "=&r" (dst) \
42 | : "r" (&(src)), "r" (0) \
43 | : "cr0", "memory")
44 |
45 | #elif defined(__GNUC__) && defined(__ppc64__)
46 |
47 | #define Read_and_clear(dst,src) \
48 | asm("0: ldarx %0, 0, %1\n\t" \
49 | "stdcx. %2, 0, %1\n\t" \
50 | "bne- 0b" \
51 | : "=&r" (dst) \
52 | : "r" (&(src)), "r" (0) \
53 | : "cr0", "memory")
54 |
55 | #else
56 |
57 | /* Default, non-atomic implementation */
58 | #define Read_and_clear(dst,src) ((dst) = (src), (src) = 0)
59 |
60 | #endif
61 |
62 | #endif /* CAML_SIGNALS_MACHDEP_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/stacks.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: stacks.h 10315 2010-04-27 07:55:08Z xleroy $ */
15 |
16 | /* structure of the stacks */
17 |
18 | #ifndef CAML_STACKS_H
19 | #define CAML_STACKS_H
20 |
21 |
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 | #include "memory.h"
25 |
26 | CAMLextern value * caml_stack_low;
27 | CAMLextern value * caml_stack_high;
28 | CAMLextern value * caml_stack_threshold;
29 | CAMLextern value * caml_extern_sp;
30 | CAMLextern value * caml_trapsp;
31 | CAMLextern value * caml_trap_barrier;
32 |
33 | #define Trap_pc(tp) (((code_t *)(tp))[0])
34 | #define Trap_link(tp) (((value **)(tp))[1])
35 |
36 | void caml_init_stack (uintnat init_max_size);
37 | void caml_realloc_stack (asize_t required_size);
38 | void caml_change_max_stack_size (uintnat new_max_size);
39 | uintnat caml_stack_usage (void);
40 |
41 | CAMLextern uintnat (*caml_stack_usage_hook)(void);
42 |
43 | #endif /* CAML_STACKS_H */
44 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/startup.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: startup.h 6130 2004-02-22 15:07:51Z xleroy $ */
15 |
16 | #ifndef CAML_STARTUP_H
17 | #define CAML_STARTUP_H
18 |
19 | #include "mlvalues.h"
20 | #include "exec.h"
21 |
22 | CAMLextern void caml_main(char **argv);
23 |
24 | CAMLextern void caml_startup_code(
25 | code_t code, asize_t code_size,
26 | char *data, asize_t data_size,
27 | char *section_table, asize_t section_table_size,
28 | char **argv);
29 |
30 | enum { FILE_NOT_FOUND = -1, BAD_BYTECODE = -2 };
31 |
32 | extern int caml_attempt_open(const char **name, struct exec_trailer *trail,
33 | int do_open_script);
34 | extern void caml_read_section_descriptors(int fd, struct exec_trailer *trail);
35 | extern int32 caml_seek_optional_section(int fd, struct exec_trailer *trail,
36 | const char *name);
37 | extern int32 caml_seek_section(int fd, struct exec_trailer *trail,
38 | const char *name);
39 |
40 |
41 | #endif /* CAML_STARTUP_H */
42 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/sys.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: sys.h 7919 2007-02-25 12:38:36Z xleroy $ */
15 |
16 | #ifndef CAML_SYS_H
17 | #define CAML_SYS_H
18 |
19 | #include "misc.h"
20 |
21 | #define NO_ARG Val_int(0)
22 |
23 | CAMLextern void caml_sys_error (value);
24 | CAMLextern void caml_sys_io_error (value);
25 | extern void caml_sys_init (const char * exe_name, char ** argv);
26 | CAMLextern value caml_sys_exit (value);
27 |
28 | extern const char * caml_exe_name;
29 |
30 | #endif /* CAML_SYS_H */
31 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/ui.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: ui.h 6021 2003-12-15 18:10:51Z doligez $ */
15 |
16 | /* Function declarations for non-Unix user interfaces */
17 |
18 | #ifndef CAML_UI_H
19 | #define CAML_UI_H
20 |
21 | #include "config.h"
22 |
23 | void ui_exit (int return_code);
24 | int ui_read (int file_desc, char *buf, unsigned int length);
25 | int ui_write (int file_desc, char *buf, unsigned int length);
26 | void ui_print_stderr (char *format, void *arg);
27 |
28 | #endif /* CAML_UI_H */
29 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/version.h:
--------------------------------------------------------------------------------
1 | #define OCAML_VERSION "3.12"
2 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-3.12/weak.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* Objective Caml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1997 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: weak.h 6045 2004-01-01 16:42:43Z doligez $ */
15 |
16 | /* Operations on weak arrays */
17 |
18 | #ifndef CAML_WEAK_H
19 | #define CAML_WEAK_H
20 |
21 | #include "mlvalues.h"
22 |
23 | extern value caml_weak_list_head;
24 | extern value caml_weak_none;
25 |
26 | #endif /* CAML_WEAK_H */
27 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/alloc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: alloc.h 12000 2012-01-07 20:55:28Z lefessan $ */
15 |
16 | #ifndef CAML_ALLOC_H
17 | #define CAML_ALLOC_H
18 |
19 |
20 | #ifndef CAML_NAME_SPACE
21 | #include "compatibility.h"
22 | #endif
23 | #include "misc.h"
24 | #include "mlvalues.h"
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | CAMLextern value caml_alloc (mlsize_t, tag_t);
31 | CAMLextern value caml_alloc_small (mlsize_t, tag_t);
32 | CAMLextern value caml_alloc_tuple (mlsize_t);
33 | CAMLextern value caml_alloc_string (mlsize_t); /* size in bytes */
34 | CAMLextern value caml_copy_string (char const *);
35 | CAMLextern value caml_copy_string_array (char const **);
36 | CAMLextern value caml_copy_double (double);
37 | CAMLextern value caml_copy_int32 (int32); /* defined in [ints.c] */
38 | CAMLextern value caml_copy_int64 (int64); /* defined in [ints.c] */
39 | CAMLextern value caml_copy_nativeint (intnat); /* defined in [ints.c] */
40 | CAMLextern value caml_alloc_array (value (*funct) (char const *),
41 | char const ** array);
42 |
43 | typedef void (*final_fun)(value);
44 | CAMLextern value caml_alloc_final (mlsize_t, /*size in words*/
45 | final_fun, /*finalization function*/
46 | mlsize_t, /*resources consumed*/
47 | mlsize_t /*max resources*/);
48 |
49 | CAMLextern int caml_convert_flag_list (value, int *);
50 |
51 | /* OCamlCC may call caml_obj_truncate when updating dummy blocks */
52 | CAMLextern value caml_obj_truncate (value, value);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif /* CAML_ALLOC_H */
59 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/backtrace.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: backtrace.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_BACKTRACE_H
17 | #define CAML_BACKTRACE_H
18 |
19 | #include "mlvalues.h"
20 |
21 | CAMLextern int caml_backtrace_active;
22 | CAMLextern int caml_backtrace_pos;
23 | CAMLextern code_t * caml_backtrace_buffer;
24 | CAMLextern value caml_backtrace_last_exn;
25 | CAMLextern char * caml_cds_file;
26 |
27 | CAMLprim value caml_record_backtrace(value vflag);
28 | #ifndef NATIVE_CODE
29 | extern void caml_stash_backtrace(value exn, code_t pc, value * sp);
30 | #endif
31 | CAMLextern void caml_print_exception_backtrace(void);
32 |
33 | #endif /* CAML_BACKTRACE_H */
34 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/callback.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: callback.h 12149 2012-02-10 16:15:24Z doligez $ */
15 |
16 | /* Callbacks from C to OCaml */
17 |
18 | #ifndef CAML_CALLBACK_H
19 | #define CAML_CALLBACK_H
20 |
21 | #ifndef CAML_NAME_SPACE
22 | #include "compatibility.h"
23 | #endif
24 | #include "mlvalues.h"
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | CAMLextern value caml_callback (value closure, value arg);
31 | CAMLextern value caml_callback2 (value closure, value arg1, value arg2);
32 | CAMLextern value caml_callback3 (value closure, value arg1, value arg2,
33 | value arg3);
34 | CAMLextern value caml_callbackN (value closure, int narg, value args[]);
35 |
36 | CAMLextern value caml_callback_exn (value closure, value arg);
37 | CAMLextern value caml_callback2_exn (value closure, value arg1, value arg2);
38 | CAMLextern value caml_callback3_exn (value closure,
39 | value arg1, value arg2, value arg3);
40 | CAMLextern value caml_callbackN_exn (value closure, int narg, value args[]);
41 |
42 | #define Make_exception_result(v) ((v) | 2)
43 | #define Is_exception_result(v) (((v) & 3) == 2)
44 | #define Extract_exception(v) ((v) & ~3)
45 |
46 | CAMLextern value * caml_named_value (char const * name);
47 |
48 | CAMLextern void caml_main (char ** argv);
49 | CAMLextern void caml_startup (char ** argv);
50 |
51 | CAMLextern int caml_callback_depth;
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/compact.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: compact.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_COMPACT_H
17 | #define CAML_COMPACT_H
18 |
19 |
20 | #include "config.h"
21 | #include "misc.h"
22 |
23 | extern void caml_compact_heap (void);
24 | extern void caml_compact_heap_maybe (void);
25 |
26 |
27 | #endif /* CAML_COMPACT_H */
28 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/compare.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, Projet Moscova, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2003 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: compare.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_COMPARE_H
17 | #define CAML_COMPARE_H
18 |
19 | CAMLextern int caml_compare_unordered;
20 |
21 | #endif /* CAML_COMPARE_H */
22 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/custom.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Manuel Serrano and Xavier Leroy, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: custom.h 12000 2012-01-07 20:55:28Z lefessan $ */
15 |
16 | #ifndef CAML_CUSTOM_H
17 | #define CAML_CUSTOM_H
18 |
19 |
20 | #ifndef CAML_NAME_SPACE
21 | #include "compatibility.h"
22 | #endif
23 | #include "mlvalues.h"
24 |
25 | struct custom_operations {
26 | /* OCamlCC: fix g++ warning */
27 | const char *identifier;
28 | void (*finalize)(value v);
29 | int (*compare)(value v1, value v2);
30 | intnat (*hash)(value v);
31 | void (*serialize)(value v,
32 | /*out*/ uintnat * wsize_32 /*size in bytes*/,
33 | /*out*/ uintnat * wsize_64 /*size in bytes*/);
34 | uintnat (*deserialize)(void * dst);
35 | int (*compare_ext)(value v1, value v2);
36 | };
37 |
38 | #define custom_finalize_default NULL
39 | #define custom_compare_default NULL
40 | #define custom_hash_default NULL
41 | #define custom_serialize_default NULL
42 | #define custom_deserialize_default NULL
43 | #define custom_compare_ext_default NULL
44 |
45 | #define Custom_ops_val(v) (*((struct custom_operations **) (v)))
46 |
47 | #ifdef __cplusplus
48 | extern "C" {
49 | #endif
50 |
51 |
52 | CAMLextern value caml_alloc_custom(struct custom_operations * ops,
53 | uintnat size, /*size in bytes*/
54 | mlsize_t mem, /*resources consumed*/
55 | mlsize_t max /*max resources*/);
56 |
57 | CAMLextern void caml_register_custom_operations(struct custom_operations * ops);
58 |
59 | CAMLextern int caml_compare_unordered;
60 | /* Used by custom comparison to report unordered NaN-like cases. */
61 |
62 | /* */
63 | extern struct custom_operations * caml_find_custom_operations(char * ident);
64 | extern struct custom_operations *
65 | caml_final_custom_operations(void (*fn)(value));
66 |
67 | extern void caml_init_custom_operations(void);
68 | /* */
69 |
70 | #ifdef __cplusplus
71 | }
72 | #endif
73 |
74 | #endif /* CAML_CUSTOM_H */
75 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/dynlink.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: dynlink.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Dynamic loading of C primitives. */
17 |
18 | #ifndef CAML_DYNLINK_H
19 | #define CAML_DYNLINK_H
20 |
21 | #include "misc.h"
22 |
23 | /* Build the table of primitives, given a search path, a list
24 | of shared libraries, and a list of primitive names
25 | (all three 0-separated in char arrays).
26 | Abort the runtime system on error. */
27 | extern void caml_build_primitive_table(char * lib_path,
28 | char * libs,
29 | char * req_prims);
30 |
31 | /* The search path for shared libraries */
32 | extern struct ext_table caml_shared_libs_path;
33 |
34 | /* Build the table of primitives as a copy of the builtin primitive table.
35 | Used for executables generated by ocamlc -output-obj. */
36 | extern void caml_build_primitive_table_builtin(void);
37 |
38 | #endif /* CAML_DYNLINK_H */
39 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/exec.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: exec.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* exec.h : format of executable bytecode files */
17 |
18 | #ifndef CAML_EXEC_H
19 | #define CAML_EXEC_H
20 |
21 | /* Executable bytecode files are composed of a number of sections,
22 | identified by 4-character names. A table of contents at the
23 | end of the file lists the section names along with their sizes,
24 | in the order in which they appear in the file:
25 |
26 | offset 0 ---> initial junk
27 | data for section 1
28 | data for section 2
29 | ...
30 | data for section N
31 | table of contents:
32 | descriptor for section 1
33 | ...
34 | descriptor for section N
35 | trailer
36 | end of file --->
37 | */
38 |
39 | /* Structure of t.o.c. entries
40 | Numerical quantities are 32-bit unsigned integers, big endian */
41 |
42 | struct section_descriptor {
43 | char name[4]; /* Section name */
44 | uint32 len; /* Length of data in bytes */
45 | };
46 |
47 | /* Structure of the trailer. */
48 |
49 | struct exec_trailer {
50 | uint32 num_sections; /* Number of sections */
51 | char magic[12]; /* The magic number */
52 | struct section_descriptor * section; /* Not part of file */
53 | };
54 |
55 | #define TRAILER_SIZE (4+12)
56 |
57 | /* Magic number for this release */
58 |
59 | #define EXEC_MAGIC "Caml1999X008"
60 |
61 |
62 | #endif /* CAML_EXEC_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/fail.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: fail.h 12000 2012-01-07 20:55:28Z lefessan $ */
15 |
16 | #ifndef CAML_FAIL_H
17 | #define CAML_FAIL_H
18 |
19 | /* */
20 | #include
21 | /* */
22 |
23 | #ifndef CAML_NAME_SPACE
24 | #include "compatibility.h"
25 | #endif
26 | #include "misc.h"
27 | #include "mlvalues.h"
28 |
29 | /* */
30 | #define OUT_OF_MEMORY_EXN 0 /* "Out_of_memory" */
31 | #define SYS_ERROR_EXN 1 /* "Sys_error" */
32 | #define FAILURE_EXN 2 /* "Failure" */
33 | #define INVALID_EXN 3 /* "Invalid_argument" */
34 | #define END_OF_FILE_EXN 4 /* "End_of_file" */
35 | #define ZERO_DIVIDE_EXN 5 /* "Division_by_zero" */
36 | #define NOT_FOUND_EXN 6 /* "Not_found" */
37 | #define MATCH_FAILURE_EXN 7 /* "Match_failure" */
38 | #define STACK_OVERFLOW_EXN 8 /* "Stack_overflow" */
39 | #define SYS_BLOCKED_IO 9 /* "Sys_blocked_io" */
40 | #define ASSERT_FAILURE_EXN 10 /* "Assert_failure" */
41 | #define UNDEFINED_RECURSIVE_MODULE_EXN 11 /* "Undefined_recursive_module" */
42 |
43 | #ifdef POSIX_SIGNALS
44 | struct longjmp_buffer {
45 | sigjmp_buf buf;
46 | };
47 | #else
48 | struct longjmp_buffer {
49 | jmp_buf buf;
50 | };
51 | #define sigsetjmp(buf,save) setjmp(buf)
52 | #define siglongjmp(buf,val) longjmp(buf,val)
53 | #endif
54 |
55 | CAMLextern struct longjmp_buffer * caml_external_raise;
56 | extern value caml_exn_bucket;
57 | int caml_is_special_exception(value exn);
58 |
59 | /* */
60 |
61 | #ifdef __cplusplus
62 | extern "C" {
63 | #endif
64 |
65 | CAMLextern void caml_raise (value bucket) Noreturn;
66 | CAMLextern void caml_raise_constant (value tag) Noreturn;
67 | CAMLextern void caml_raise_with_arg (value tag, value arg) Noreturn;
68 | CAMLextern void caml_raise_with_args (value tag, int nargs, value arg[]) Noreturn;
69 | CAMLextern void caml_raise_with_string (value tag, char const * msg) Noreturn;
70 | CAMLextern void caml_failwith (char const *) Noreturn;
71 | CAMLextern void caml_invalid_argument (char const *) Noreturn;
72 | CAMLextern void caml_raise_out_of_memory (void) Noreturn;
73 | CAMLextern void caml_raise_stack_overflow (void) Noreturn;
74 | CAMLextern void caml_raise_sys_error (value) Noreturn;
75 | CAMLextern void caml_raise_end_of_file (void) Noreturn;
76 | CAMLextern void caml_raise_zero_divide (void) Noreturn;
77 | CAMLextern void caml_raise_not_found (void) Noreturn;
78 | CAMLextern void caml_init_exceptions (void);
79 | CAMLextern void caml_array_bound_error (void) Noreturn;
80 | CAMLextern void caml_raise_sys_blocked_io (void) Noreturn;
81 |
82 | #ifdef __cplusplus
83 | }
84 | #endif
85 |
86 | #endif /* CAML_FAIL_H */
87 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/finalise.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Moscova, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2000 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: finalise.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_FINALISE_H
17 | #define CAML_FINALISE_H
18 |
19 | #include "roots.h"
20 |
21 | void caml_final_update (void);
22 | void caml_final_do_calls (void);
23 | void caml_final_do_strong_roots (scanning_action f);
24 | void caml_final_do_weak_roots (scanning_action f);
25 | void caml_final_do_young_roots (scanning_action f);
26 | void caml_final_empty_young (void);
27 | value caml_final_register (value f, value v);
28 |
29 | #endif /* CAML_FINALISE_H */
30 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/fix_code.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: fix_code.h 12715 2012-07-16 10:37:03Z frisch $ */
15 |
16 | /* Handling of blocks of bytecode (endianness switch, threading). */
17 |
18 | #ifndef CAML_FIX_CODE_H
19 | #define CAML_FIX_CODE_H
20 |
21 |
22 | #include "config.h"
23 | #include "misc.h"
24 | #include "mlvalues.h"
25 |
26 | extern code_t caml_start_code;
27 | extern asize_t caml_code_size;
28 | extern unsigned char * caml_saved_code;
29 |
30 | void caml_init_code_fragments();
31 | void caml_load_code (int fd, asize_t len);
32 | void caml_fixup_endianness (code_t code, asize_t len);
33 | void caml_set_instruction (code_t pos, opcode_t instr);
34 | int caml_is_instruction (opcode_t instr1, opcode_t instr2);
35 |
36 | #ifdef THREADED_CODE
37 | extern char ** caml_instr_table;
38 | extern char * caml_instr_base;
39 | void caml_thread_code (code_t code, asize_t len);
40 | #endif
41 |
42 | #endif /* CAML_FIX_CODE_H */
43 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/freelist.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: freelist.h 12910 2012-09-10 09:52:09Z doligez $ */
15 |
16 | /* Free lists of heap blocks. */
17 |
18 | #ifndef CAML_FREELIST_H
19 | #define CAML_FREELIST_H
20 |
21 |
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 |
25 | extern asize_t caml_fl_cur_size; /* size in words */
26 |
27 | char *caml_fl_allocate (mlsize_t);
28 | void caml_fl_init_merge (void);
29 | void caml_fl_reset (void);
30 | char *caml_fl_merge_block (char *);
31 | void caml_fl_add_blocks (char *);
32 | void caml_make_free_blocks (value *, mlsize_t, int, int);
33 | void caml_set_allocation_policy (uintnat);
34 |
35 |
36 | #endif /* CAML_FREELIST_H */
37 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: gc.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_GC_H
17 | #define CAML_GC_H
18 |
19 |
20 | #include "mlvalues.h"
21 |
22 | #define Caml_white (0 << 8)
23 | #define Caml_gray (1 << 8)
24 | #define Caml_blue (2 << 8)
25 | #define Caml_black (3 << 8)
26 |
27 | #define Color_hd(hd) ((color_t) ((hd) & Caml_black))
28 | #define Color_hp(hp) (Color_hd (Hd_hp (hp)))
29 | #define Color_val(val) (Color_hd (Hd_val (val)))
30 |
31 | #define Is_white_hd(hd) (Color_hd (hd) == Caml_white)
32 | #define Is_gray_hd(hd) (Color_hd (hd) == Caml_gray)
33 | #define Is_blue_hd(hd) (Color_hd (hd) == Caml_blue)
34 | #define Is_black_hd(hd) (Color_hd (hd) == Caml_black)
35 |
36 | #define Whitehd_hd(hd) (((hd) & ~Caml_black)/*| Caml_white*/)
37 | #define Grayhd_hd(hd) (((hd) & ~Caml_black) | Caml_gray)
38 | #define Blackhd_hd(hd) (((hd)/*& ~Caml_black*/)| Caml_black)
39 | #define Bluehd_hd(hd) (((hd) & ~Caml_black) | Caml_blue)
40 |
41 | /* This depends on the layout of the header. See [mlvalues.h]. */
42 | #define Make_header(wosize, tag, color) \
43 | (/*Assert ((wosize) <= Max_wosize),*/ \
44 | ((header_t) (((header_t) (wosize) << 10) \
45 | + (color) \
46 | + (tag_t) (tag))) \
47 | )
48 |
49 | #define Is_white_val(val) (Color_val(val) == Caml_white)
50 | #define Is_gray_val(val) (Color_val(val) == Caml_gray)
51 | #define Is_blue_val(val) (Color_val(val) == Caml_blue)
52 | #define Is_black_val(val) (Color_val(val) == Caml_black)
53 |
54 | /* For extern.c */
55 | #define Colornum_hd(hd) ((color_t) (((hd) >> 8) & 3))
56 | #define Coloredhd_hd(hd,colnum) (((hd) & ~Caml_black) | ((colnum) << 8))
57 |
58 | #endif /* CAML_GC_H */
59 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/gc_ctrl.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: gc_ctrl.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_GC_CTRL_H
17 | #define CAML_GC_CTRL_H
18 |
19 | #include "misc.h"
20 |
21 | extern double
22 | caml_stat_minor_words,
23 | caml_stat_promoted_words,
24 | caml_stat_major_words;
25 |
26 | extern intnat
27 | caml_stat_minor_collections,
28 | caml_stat_major_collections,
29 | caml_stat_heap_size,
30 | caml_stat_top_heap_size,
31 | caml_stat_compactions,
32 | caml_stat_heap_chunks;
33 |
34 | void caml_init_gc (uintnat, uintnat, uintnat,
35 | uintnat, uintnat);
36 |
37 |
38 | #ifdef DEBUG
39 | void caml_heap_check (void);
40 | #endif
41 |
42 | #endif /* CAML_GC_CTRL_H */
43 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/globroots.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: globroots.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Registration of global memory roots */
17 |
18 | #ifndef CAML_GLOBROOTS_H
19 | #define CAML_GLOBROOTS_H
20 |
21 | #include "mlvalues.h"
22 | #include "roots.h"
23 |
24 | void caml_scan_global_roots(scanning_action f);
25 | void caml_scan_global_young_roots(scanning_action f);
26 |
27 | #endif /* CAML_GLOBROOTS_H */
28 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/hash.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Gallium, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2011 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id$ */
15 |
16 | /* Auxiliary functions for custom hash functions */
17 |
18 | #ifndef CAML_HASH_H
19 | #define CAML_HASH_H
20 |
21 | #include "mlvalues.h"
22 |
23 | CAMLextern uint32 caml_hash_mix_uint32(uint32 h, uint32 d);
24 | CAMLextern uint32 caml_hash_mix_intnat(uint32 h, intnat d);
25 | CAMLextern uint32 caml_hash_mix_int64(uint32 h, int64 d);
26 | CAMLextern uint32 caml_hash_mix_double(uint32 h, double d);
27 | CAMLextern uint32 caml_hash_mix_float(uint32 h, float d);
28 | CAMLextern uint32 caml_hash_mix_string(uint32 h, value s);
29 |
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/instrtrace.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: instrtrace.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Trace the instructions executed */
17 |
18 | #ifndef _instrtrace_
19 | #define _instrtrace_
20 |
21 |
22 | #include "mlvalues.h"
23 | #include "misc.h"
24 |
25 | extern int caml_trace_flag;
26 | extern intnat caml_icount;
27 | void caml_stop_here (void);
28 | void caml_disasm_instr (code_t pc);
29 | void caml_trace_value_file (value v, code_t prog, int proglen, FILE * f);
30 | void caml_trace_accu_sp_file(value accu, value * sp, code_t prog, int proglen, FILE * f);
31 | #endif
32 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/instruct.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: instruct.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* The instruction set. */
17 |
18 | #ifndef CAML_INSTRUCT_H
19 | #define CAML_INSTRUCT_H
20 |
21 | /* OCamlCC: rename ATOM -> ATOM_ (collision windef.h) */
22 |
23 | enum instructions {
24 | ACC0, ACC1, ACC2, ACC3, ACC4, ACC5, ACC6, ACC7,
25 | ACC, PUSH,
26 | PUSHACC0, PUSHACC1, PUSHACC2, PUSHACC3,
27 | PUSHACC4, PUSHACC5, PUSHACC6, PUSHACC7,
28 | PUSHACC, POP, ASSIGN,
29 | ENVACC1, ENVACC2, ENVACC3, ENVACC4, ENVACC,
30 | PUSHENVACC1, PUSHENVACC2, PUSHENVACC3, PUSHENVACC4, PUSHENVACC,
31 | PUSH_RETADDR, APPLY, APPLY1, APPLY2, APPLY3,
32 | APPTERM, APPTERM1, APPTERM2, APPTERM3,
33 | RETURN, RESTART, GRAB,
34 | CLOSURE, CLOSUREREC,
35 | OFFSETCLOSUREM2, OFFSETCLOSURE0, OFFSETCLOSURE2, OFFSETCLOSURE,
36 | PUSHOFFSETCLOSUREM2, PUSHOFFSETCLOSURE0,
37 | PUSHOFFSETCLOSURE2, PUSHOFFSETCLOSURE,
38 | GETGLOBAL, PUSHGETGLOBAL, GETGLOBALFIELD, PUSHGETGLOBALFIELD, SETGLOBAL,
39 | ATOM0, ATOM_, PUSHATOM0, PUSHATOM,
40 | MAKEBLOCK, MAKEBLOCK1, MAKEBLOCK2, MAKEBLOCK3, MAKEFLOATBLOCK,
41 | GETFIELD0, GETFIELD1, GETFIELD2, GETFIELD3, GETFIELD, GETFLOATFIELD,
42 | SETFIELD0, SETFIELD1, SETFIELD2, SETFIELD3, SETFIELD, SETFLOATFIELD,
43 | VECTLENGTH, GETVECTITEM, SETVECTITEM,
44 | GETSTRINGCHAR, SETSTRINGCHAR,
45 | BRANCH, BRANCHIF, BRANCHIFNOT, SWITCH, BOOLNOT,
46 | PUSHTRAP, POPTRAP, RAISE, CHECK_SIGNALS,
47 | C_CALL1, C_CALL2, C_CALL3, C_CALL4, C_CALL5, C_CALLN,
48 | CONST0, CONST1, CONST2, CONST3, CONSTINT,
49 | PUSHCONST0, PUSHCONST1, PUSHCONST2, PUSHCONST3, PUSHCONSTINT,
50 | NEGINT, ADDINT, SUBINT, MULINT, DIVINT, MODINT,
51 | ANDINT, ORINT, XORINT, LSLINT, LSRINT, ASRINT,
52 | EQ, NEQ, LTINT, LEINT, GTINT, GEINT,
53 | OFFSETINT, OFFSETREF, ISINT,
54 | GETMETHOD,
55 | BEQ, BNEQ, BLTINT, BLEINT, BGTINT, BGEINT,
56 | ULTINT, UGEINT,
57 | BULTINT, BUGEINT,
58 | GETPUBMET, GETDYNMET,
59 | STOP,
60 | EVENT, BREAK
61 | };
62 |
63 | #endif /* CAML_INSTRUCT_H */
64 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/int64_native.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2002 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: int64_native.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Wrapper macros around native 64-bit integer arithmetic,
17 | so that it has the same interface as the software emulation
18 | provided in int64_emul.h */
19 |
20 | #ifndef CAML_INT64_NATIVE_H
21 | #define CAML_INT64_NATIVE_H
22 |
23 | #define I64_literal(hi,lo) ((int64)(hi) << 32 | (lo))
24 | #define I64_split(x,hi,lo) (hi = (uint32)((x)>>32), lo = (uint32)(x))
25 | #define I64_compare(x,y) (((x) > (y)) - ((x) < (y)))
26 | #define I64_ult(x,y) ((uint64)(x) < (uint64)(y))
27 | #define I64_neg(x) (-(x))
28 | #define I64_add(x,y) ((x) + (y))
29 | #define I64_sub(x,y) ((x) - (y))
30 | #define I64_mul(x,y) ((x) * (y))
31 | #define I64_is_zero(x) ((x) == 0)
32 | #define I64_is_negative(x) ((x) < 0)
33 | #define I64_is_min_int(x) ((x) == ((int64)1 << 63))
34 | #define I64_is_minus_one(x) ((x) == -1)
35 |
36 | #define I64_div(x,y) ((x) / (y))
37 | #define I64_mod(x,y) ((x) % (y))
38 | #define I64_udivmod(x,y,quo,rem) \
39 | (*(rem) = (uint64)(x) % (uint64)(y), \
40 | *(quo) = (uint64)(x) / (uint64)(y))
41 | #define I64_and(x,y) ((x) & (y))
42 | #define I64_or(x,y) ((x) | (y))
43 | #define I64_xor(x,y) ((x) ^ (y))
44 | #define I64_lsl(x,y) ((x) << (y))
45 | #define I64_asr(x,y) ((x) >> (y))
46 | #define I64_lsr(x,y) ((uint64)(x) >> (y))
47 | #define I64_to_intnat(x) ((intnat) (x))
48 | #define I64_of_intnat(x) ((intnat) (x))
49 | #define I64_to_int32(x) ((int32) (x))
50 | #define I64_of_int32(x) ((int64) (x))
51 | #define I64_to_double(x) ((double)(x))
52 | #define I64_of_double(x) ((int64)(x))
53 |
54 | #endif /* CAML_INT64_NATIVE_H */
55 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/jumptbl.h:
--------------------------------------------------------------------------------
1 | &&lbl_ACC0, &&lbl_ACC1, &&lbl_ACC2, &&lbl_ACC3, &&lbl_ACC4, &&lbl_ACC5, &&lbl_ACC6, &&lbl_ACC7,
2 | &&lbl_ACC, &&lbl_PUSH,
3 | &&lbl_PUSHACC0, &&lbl_PUSHACC1, &&lbl_PUSHACC2, &&lbl_PUSHACC3,
4 | &&lbl_PUSHACC4, &&lbl_PUSHACC5, &&lbl_PUSHACC6, &&lbl_PUSHACC7,
5 | &&lbl_PUSHACC, &&lbl_POP, &&lbl_ASSIGN,
6 | &&lbl_ENVACC1, &&lbl_ENVACC2, &&lbl_ENVACC3, &&lbl_ENVACC4, &&lbl_ENVACC,
7 | &&lbl_PUSHENVACC1, &&lbl_PUSHENVACC2, &&lbl_PUSHENVACC3, &&lbl_PUSHENVACC4, &&lbl_PUSHENVACC,
8 | &&lbl_PUSH_RETADDR, &&lbl_APPLY, &&lbl_APPLY1, &&lbl_APPLY2, &&lbl_APPLY3,
9 | &&lbl_APPTERM, &&lbl_APPTERM1, &&lbl_APPTERM2, &&lbl_APPTERM3,
10 | &&lbl_RETURN, &&lbl_RESTART, &&lbl_GRAB,
11 | &&lbl_CLOSURE, &&lbl_CLOSUREREC,
12 | &&lbl_OFFSETCLOSUREM2, &&lbl_OFFSETCLOSURE0, &&lbl_OFFSETCLOSURE2, &&lbl_OFFSETCLOSURE,
13 | &&lbl_PUSHOFFSETCLOSUREM2, &&lbl_PUSHOFFSETCLOSURE0,
14 | &&lbl_PUSHOFFSETCLOSURE2, &&lbl_PUSHOFFSETCLOSURE,
15 | &&lbl_GETGLOBAL, &&lbl_PUSHGETGLOBAL, &&lbl_GETGLOBALFIELD, &&lbl_PUSHGETGLOBALFIELD, &&lbl_SETGLOBAL,
16 | &&lbl_ATOM0, &&lbl_ATOM, &&lbl_PUSHATOM0, &&lbl_PUSHATOM,
17 | &&lbl_MAKEBLOCK, &&lbl_MAKEBLOCK1, &&lbl_MAKEBLOCK2, &&lbl_MAKEBLOCK3, &&lbl_MAKEFLOATBLOCK,
18 | &&lbl_GETFIELD0, &&lbl_GETFIELD1, &&lbl_GETFIELD2, &&lbl_GETFIELD3, &&lbl_GETFIELD, &&lbl_GETFLOATFIELD,
19 | &&lbl_SETFIELD0, &&lbl_SETFIELD1, &&lbl_SETFIELD2, &&lbl_SETFIELD3, &&lbl_SETFIELD, &&lbl_SETFLOATFIELD,
20 | &&lbl_VECTLENGTH, &&lbl_GETVECTITEM, &&lbl_SETVECTITEM,
21 | &&lbl_GETSTRINGCHAR, &&lbl_SETSTRINGCHAR,
22 | &&lbl_BRANCH, &&lbl_BRANCHIF, &&lbl_BRANCHIFNOT, &&lbl_SWITCH, &&lbl_BOOLNOT,
23 | &&lbl_PUSHTRAP, &&lbl_POPTRAP, &&lbl_RAISE, &&lbl_CHECK_SIGNALS,
24 | &&lbl_C_CALL1, &&lbl_C_CALL2, &&lbl_C_CALL3, &&lbl_C_CALL4, &&lbl_C_CALL5, &&lbl_C_CALLN,
25 | &&lbl_CONST0, &&lbl_CONST1, &&lbl_CONST2, &&lbl_CONST3, &&lbl_CONSTINT,
26 | &&lbl_PUSHCONST0, &&lbl_PUSHCONST1, &&lbl_PUSHCONST2, &&lbl_PUSHCONST3, &&lbl_PUSHCONSTINT,
27 | &&lbl_NEGINT, &&lbl_ADDINT, &&lbl_SUBINT, &&lbl_MULINT, &&lbl_DIVINT, &&lbl_MODINT,
28 | &&lbl_ANDINT, &&lbl_ORINT, &&lbl_XORINT, &&lbl_LSLINT, &&lbl_LSRINT, &&lbl_ASRINT,
29 | &&lbl_EQ, &&lbl_NEQ, &&lbl_LTINT, &&lbl_LEINT, &&lbl_GTINT, &&lbl_GEINT,
30 | &&lbl_OFFSETINT, &&lbl_OFFSETREF, &&lbl_ISINT,
31 | &&lbl_GETMETHOD,
32 | &&lbl_BEQ, &&lbl_BNEQ, &&lbl_BLTINT, &&lbl_BLEINT, &&lbl_BGTINT, &&lbl_BGEINT,
33 | &&lbl_ULTINT, &&lbl_UGEINT,
34 | &&lbl_BULTINT, &&lbl_BUGEINT,
35 | &&lbl_GETPUBMET, &&lbl_GETDYNMET,
36 | &&lbl_STOP,
37 | &&lbl_EVENT, &&lbl_BREAK
38 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/main.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: main.c 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Main entry point (can be overridden by a user-provided main()
17 | function that calls caml_main() later). */
18 |
19 | #include "misc.h"
20 | #include "mlvalues.h"
21 | #include "sys.h"
22 |
23 | CAMLextern void caml_main (char **);
24 |
25 | #ifdef _WIN32
26 | CAMLextern void caml_expand_command_line (int *, char ***);
27 | #endif
28 |
29 | #ifndef OCAMLCC_NO_MAIN /* OCamlCC */
30 | int main(int argc, char **argv)
31 | {
32 | #ifdef DEBUG
33 | {
34 | #if 0 /* OCamlCC: clean */
35 | char *ocp;
36 | char *cp;
37 | int i;
38 | #endif
39 |
40 | caml_gc_message (-1, "### OCaml runtime: debug mode ###\n", 0);
41 | #if 0
42 | caml_gc_message (-1, "### command line:", 0);
43 | for (i = 0; i < argc; i++){
44 | caml_gc_message (-1, " %s", argv[i]);
45 | }
46 | caml_gc_message (-1, "\n", 0);
47 | ocp = getenv ("OCAMLRUNPARAM");
48 | caml_gc_message (-1, "### OCAMLRUNPARAM=%s\n", ocp == NULL ? "" : ocp);
49 | cp = getenv ("CAMLRUNPARAM");
50 | caml_gc_message (-1, "### CAMLRUNPARAM=%s\n", cp == NULL ? "" : cp);
51 | caml_gc_message (-1, "### working dir: %s\n", getcwd (NULL, 0));
52 | #endif
53 | }
54 | #endif
55 | #ifdef _WIN32
56 | /* Expand wildcards and diversions in command line */
57 | caml_expand_command_line(&argc, &argv);
58 | #endif
59 | caml_main(argv);
60 | caml_sys_exit(Val_int(0));
61 | return 0; /* not reached */
62 | }
63 | #endif
64 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/major_gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: major_gc.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_MAJOR_GC_H
17 | #define CAML_MAJOR_GC_H
18 |
19 |
20 | #include "freelist.h"
21 | #include "misc.h"
22 |
23 | typedef struct {
24 | void *block; /* address of the malloced block this chunk live in */
25 | asize_t alloc; /* in bytes, used for compaction */
26 | asize_t size; /* in bytes */
27 | char *next;
28 | } heap_chunk_head;
29 |
30 | #define Chunk_size(c) (((heap_chunk_head *) (c)) [-1]).size
31 | #define Chunk_alloc(c) (((heap_chunk_head *) (c)) [-1]).alloc
32 | #define Chunk_next(c) (((heap_chunk_head *) (c)) [-1]).next
33 | #define Chunk_block(c) (((heap_chunk_head *) (c)) [-1]).block
34 |
35 | extern int caml_gc_phase;
36 | extern int caml_gc_subphase;
37 | extern uintnat caml_allocated_words;
38 | extern double caml_extra_heap_resources;
39 | extern uintnat caml_dependent_size, caml_dependent_allocated;
40 | extern uintnat caml_fl_size_at_phase_change;
41 |
42 | #define Phase_mark 0
43 | #define Phase_sweep 1
44 | #define Phase_idle 2
45 | #define Subphase_main 10
46 | #define Subphase_weak1 11
47 | #define Subphase_weak2 12
48 | #define Subphase_final 13
49 |
50 | CAMLextern char *caml_heap_start;
51 | extern uintnat total_heap_size;
52 | extern char *caml_gc_sweep_hp;
53 |
54 | void caml_init_major_heap (asize_t); /* size in bytes */
55 | asize_t caml_round_heap_chunk_size (asize_t); /* size in bytes */
56 | void caml_darken (value, value *);
57 | intnat caml_major_collection_slice (intnat);
58 | void major_collection (void);
59 | void caml_finish_major_cycle (void);
60 |
61 |
62 | #endif /* CAML_MAJOR_GC_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/md5.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1999 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: md5.h 12800 2012-07-30 18:59:07Z doligez $ */
15 |
16 | /* MD5 message digest */
17 |
18 | #ifndef CAML_MD5_H
19 | #define CAML_MD5_H
20 |
21 |
22 | #include "mlvalues.h"
23 | #include "io.h"
24 |
25 | CAMLextern value caml_md5_string (value str, value ofs, value len);
26 | CAMLextern value caml_md5_chan (value vchan, value len);
27 | CAMLextern void caml_md5_block(unsigned char digest[16],
28 | void * data, uintnat len);
29 |
30 | struct MD5Context {
31 | uint32 buf[4];
32 | uint32 bits[2];
33 | unsigned char in[64];
34 | };
35 |
36 | CAMLextern void caml_MD5Init (struct MD5Context *context);
37 | CAMLextern void caml_MD5Update (struct MD5Context *context, unsigned char *buf,
38 | uintnat len);
39 | CAMLextern void caml_MD5Final (unsigned char *digest, struct MD5Context *ctx);
40 | CAMLextern void caml_MD5Transform (uint32 *buf, uint32 *in);
41 |
42 |
43 | #endif /* CAML_MD5_H */
44 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/minor_gc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: minor_gc.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_MINOR_GC_H
17 | #define CAML_MINOR_GC_H
18 |
19 |
20 | #include "misc.h"
21 |
22 | CAMLextern char *caml_young_start, *caml_young_ptr;
23 | CAMLextern char *caml_young_end, *caml_young_limit;
24 | extern asize_t caml_minor_heap_size;
25 | extern int caml_in_minor_collection;
26 |
27 | struct caml_ref_table {
28 | value **base;
29 | value **end;
30 | value **threshold;
31 | value **ptr;
32 | value **limit;
33 | asize_t size;
34 | asize_t reserve;
35 | };
36 | CAMLextern struct caml_ref_table caml_ref_table, caml_weak_ref_table;
37 |
38 | #define Is_young(val) \
39 | (Assert (Is_block (val)), \
40 | (addr)(val) < (addr)caml_young_end && (addr)(val) > (addr)caml_young_start)
41 |
42 | extern void caml_set_minor_heap_size (asize_t);
43 | extern void caml_empty_minor_heap (void);
44 | CAMLextern void caml_minor_collection (void);
45 | CAMLextern void garbage_collection (void); /* def in asmrun/signals.c */
46 | extern void caml_realloc_ref_table (struct caml_ref_table *);
47 | extern void caml_alloc_table (struct caml_ref_table *, asize_t, asize_t);
48 | extern void caml_oldify_one (value, value *);
49 | extern void caml_oldify_mopup (void);
50 |
51 | #define Oldify(p) do{ \
52 | value __oldify__v__ = *p; \
53 | if (Is_block (__oldify__v__) && Is_young (__oldify__v__)){ \
54 | caml_oldify_one (__oldify__v__, (p)); \
55 | } \
56 | }while(0)
57 |
58 | #endif /* CAML_MINOR_GC_H */
59 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/osdeps.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: osdeps.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Operating system - specific stuff */
17 |
18 | #ifndef CAML_OSDEPS_H
19 | #define CAML_OSDEPS_H
20 |
21 | #include "misc.h"
22 |
23 | /* Decompose the given path into a list of directories, and add them
24 | to the given table. Return the block to be freed later. */
25 | extern char * caml_decompose_path(struct ext_table * tbl, char * path);
26 |
27 | /* Search the given file in the given list of directories.
28 | If not found, return a copy of [name]. Result is allocated with
29 | [caml_stat_alloc]. */
30 | extern char * caml_search_in_path(struct ext_table * path, char * name);
31 |
32 | /* Same, but search an executable name in the system path for executables. */
33 | CAMLextern char * caml_search_exe_in_path(char * name);
34 |
35 | /* Same, but search a shared library in the given path. */
36 | extern char * caml_search_dll_in_path(struct ext_table * path, char * name);
37 |
38 | /* Open a shared library and return a handle on it.
39 | If [for_execution] is true, perform full symbol resolution and
40 | execute initialization code so that functions from the shared library
41 | can be called. If [for_execution] is false, functions from this
42 | shared library will not be called, but just checked for presence,
43 | so symbol resolution can be skipped.
44 | If [global] is true, symbols from the shared library can be used
45 | to resolve for other libraries to be opened later on.
46 | Return [NULL] on error. */
47 | extern void * caml_dlopen(char * libname, int for_execution, int global);
48 |
49 | /* Close a shared library handle */
50 | extern void caml_dlclose(void * handle);
51 |
52 | /* Look up the given symbol in the given shared library.
53 | Return [NULL] if not found, or symbol value if found. */
54 | extern void * caml_dlsym(void * handle, char * name);
55 |
56 | extern void * caml_globalsym(char * name);
57 |
58 | /* Return an error message describing the most recent dynlink failure. */
59 | extern char * caml_dlerror(void);
60 |
61 | /* Add to [contents] the (short) names of the files contained in
62 | the directory named [dirname]. No entries are added for [.] and [..].
63 | Return 0 on success, -1 on error; set errno in the case of error. */
64 | extern int caml_read_directory(char * dirname, struct ext_table * contents);
65 |
66 | #ifdef __linux__
67 | /* Recover executable name from /proc/self/exe if possible */
68 | extern int caml_executable_name(char * name, int name_len);
69 | #endif
70 |
71 | #endif /* CAML_OSDEPS_H */
72 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/prims.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: prims.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Interface with C primitives. */
17 |
18 | #ifndef CAML_PRIMS_H
19 | #define CAML_PRIMS_H
20 |
21 | typedef value (*c_primitive)();
22 |
23 | extern c_primitive caml_builtin_cprim[];
24 | /* OCamlCC: add const modifier */
25 | extern const char * caml_names_of_builtin_cprim[];
26 |
27 | extern struct ext_table caml_prim_table;
28 | #ifdef DEBUG
29 | extern struct ext_table caml_prim_name_table;
30 | #endif
31 |
32 | #define Primitive(n) ((c_primitive)(caml_prim_table.contents[n]))
33 |
34 | extern char * caml_section_table;
35 | extern asize_t caml_section_table_size;
36 |
37 | #endif /* CAML_PRIMS_H */
38 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/printexc.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: printexc.h 12000 2012-01-07 20:55:28Z lefessan $ */
15 |
16 | #ifndef CAML_PRINTEXC_H
17 | #define CAML_PRINTEXC_H
18 |
19 |
20 | #include "misc.h"
21 | #include "mlvalues.h"
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 |
28 | CAMLextern char * caml_format_exception (value);
29 | void caml_fatal_uncaught_exception (value) Noreturn;
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 |
35 | #endif /* CAML_PRINTEXC_H */
36 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/roots.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: roots.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_ROOTS_H
17 | #define CAML_ROOTS_H
18 |
19 | #include "misc.h"
20 | #include "memory.h"
21 |
22 | typedef void (*scanning_action) (value, value *);
23 |
24 | void caml_oldify_local_roots (void);
25 | void caml_darken_all_roots (void);
26 | void caml_do_roots (scanning_action);
27 | #ifndef NATIVE_CODE
28 | CAMLextern void caml_do_local_roots (scanning_action, value *, value *,
29 | struct caml__roots_block *);
30 | #else
31 | CAMLextern void caml_do_local_roots(scanning_action f, char * bottom_of_stack,
32 | uintnat last_retaddr, value * gc_regs,
33 | struct caml__roots_block * local_roots);
34 | #endif
35 |
36 | CAMLextern void (*caml_scan_roots_hook) (scanning_action);
37 |
38 | #endif /* CAML_ROOTS_H */
39 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/signals.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals.h 12000 2012-01-07 20:55:28Z lefessan $ */
15 |
16 | #ifndef CAML_SIGNALS_H
17 | #define CAML_SIGNALS_H
18 |
19 | #ifndef CAML_NAME_SPACE
20 | #include "compatibility.h"
21 | #endif
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* */
30 | CAMLextern intnat volatile caml_signals_are_pending;
31 | CAMLextern intnat volatile caml_pending_signals[];
32 | CAMLextern int volatile caml_something_to_do;
33 | extern int volatile caml_force_major_slice;
34 | /* */
35 |
36 | CAMLextern void caml_enter_blocking_section (void);
37 | CAMLextern void caml_leave_blocking_section (void);
38 |
39 | /* */
40 | void caml_urge_major_slice (void);
41 | CAMLextern int caml_convert_signal_number (int);
42 | CAMLextern int caml_rev_convert_signal_number (int);
43 | void caml_execute_signal(int signal_number, int in_signal_handler);
44 | void caml_record_signal(int signal_number);
45 | void caml_process_pending_signals(void);
46 | void caml_process_event(void);
47 | int caml_set_signal_action(int signo, int action);
48 |
49 | CAMLextern void (*caml_enter_blocking_section_hook)(void);
50 | CAMLextern void (*caml_leave_blocking_section_hook)(void);
51 | CAMLextern int (*caml_try_leave_blocking_section_hook)(void);
52 | CAMLextern void (* volatile caml_async_action_hook)(void);
53 | /* */
54 |
55 | #ifdef __cplusplus
56 | }
57 | #endif
58 |
59 | #endif /* CAML_SIGNALS_H */
60 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/signals_byt.c:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2007 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals_byt.c 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Signal handling, code specific to the bytecode interpreter */
17 |
18 | #include
19 | #include "config.h"
20 | #include "memory.h"
21 | #include "osdeps.h"
22 | #include "signals.h"
23 | #include "signals_machdep.h"
24 |
25 | #ifdef __MINGW32__ /* OCamlCC */
26 | #undef POSIX_SIGNALS
27 | #endif
28 |
29 | #ifndef NSIG
30 | #define NSIG 64
31 | #endif
32 |
33 | #ifdef _WIN32
34 | #ifndef __MINGW32__ /* OCamlCC */
35 | typedef void (*sighandler)(int sig);
36 | #endif
37 | extern sighandler caml_win32_signal(int sig, sighandler action);
38 | #define signal(sig,act) caml_win32_signal(sig,act)
39 | #endif
40 |
41 | CAMLexport int volatile caml_something_to_do = 0;
42 | CAMLexport void (* volatile caml_async_action_hook)(void) = NULL;
43 |
44 | void caml_process_event(void)
45 | {
46 | void (*async_action)(void);
47 |
48 | if (caml_force_major_slice) caml_minor_collection ();
49 | /* FIXME should be [caml_check_urgent_gc] */
50 | caml_process_pending_signals();
51 | async_action = caml_async_action_hook;
52 | if (async_action != NULL) {
53 | caml_async_action_hook = NULL;
54 | (*async_action)();
55 | }
56 | }
57 |
58 | static void handle_signal(int signal_number)
59 | {
60 | #if !defined(POSIX_SIGNALS) && !defined(BSD_SIGNALS)
61 | signal(signal_number, handle_signal);
62 | #endif
63 | if (signal_number < 0 || signal_number >= NSIG) return;
64 | if (caml_try_leave_blocking_section_hook()) {
65 | caml_execute_signal(signal_number, 1);
66 | caml_enter_blocking_section_hook();
67 | }else{
68 | caml_record_signal(signal_number);
69 | }
70 | }
71 |
72 | int caml_set_signal_action(int signo, int action)
73 | {
74 | void (*act)(int signo), (*oldact)(int signo);
75 | #ifdef POSIX_SIGNALS
76 | struct sigaction sigact, oldsigact;
77 | #endif
78 |
79 | switch (action) {
80 | case 0: act = SIG_DFL; break;
81 | case 1: act = SIG_IGN; break;
82 | default: act = handle_signal; break;
83 | }
84 |
85 | #ifdef POSIX_SIGNALS
86 | sigact.sa_handler = act;
87 | sigemptyset(&sigact.sa_mask);
88 | sigact.sa_flags = 0;
89 | if (sigaction(signo, &sigact, &oldsigact) == -1) return -1;
90 | oldact = oldsigact.sa_handler;
91 | #else
92 | oldact = signal(signo, act);
93 | if (oldact == SIG_ERR) return -1;
94 | #endif
95 | if (oldact == handle_signal)
96 | return 2;
97 | else if (oldact == SIG_IGN)
98 | return 1;
99 | else
100 | return 0;
101 | }
102 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/signals_machdep.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: signals_machdep.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Processor-specific operation: atomic "read and clear" */
17 |
18 | #ifndef CAML_SIGNALS_MACHDEP_H
19 | #define CAML_SIGNALS_MACHDEP_H
20 |
21 | #if defined(__GNUC__) && defined(__i386__)
22 |
23 | #define Read_and_clear(dst,src) \
24 | asm("xorl %0, %0; xchgl %0, %1" \
25 | : "=r" (dst), "=m" (src) \
26 | : "m" (src))
27 |
28 | #elif defined(__GNUC__) && defined(__x86_64__)
29 |
30 | #define Read_and_clear(dst,src) \
31 | asm("xorq %0, %0; xchgq %0, %1" \
32 | : "=r" (dst), "=m" (src) \
33 | : "m" (src))
34 |
35 | #elif defined(__GNUC__) && defined(__ppc__)
36 |
37 | #define Read_and_clear(dst,src) \
38 | asm("0: lwarx %0, 0, %1\n\t" \
39 | "stwcx. %2, 0, %1\n\t" \
40 | "bne- 0b" \
41 | : "=&r" (dst) \
42 | : "r" (&(src)), "r" (0) \
43 | : "cr0", "memory")
44 |
45 | #elif defined(__GNUC__) && defined(__ppc64__)
46 |
47 | #define Read_and_clear(dst,src) \
48 | asm("0: ldarx %0, 0, %1\n\t" \
49 | "stdcx. %2, 0, %1\n\t" \
50 | "bne- 0b" \
51 | : "=&r" (dst) \
52 | : "r" (&(src)), "r" (0) \
53 | : "cr0", "memory")
54 |
55 | #else
56 |
57 | /* Default, non-atomic implementation */
58 | #define Read_and_clear(dst,src) ((dst) = (src), (src) = 0)
59 |
60 | #endif
61 |
62 | #endif /* CAML_SIGNALS_MACHDEP_H */
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/stacks.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: stacks.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* structure of the stacks */
17 |
18 | #ifndef CAML_STACKS_H
19 | #define CAML_STACKS_H
20 |
21 |
22 | #include "misc.h"
23 | #include "mlvalues.h"
24 | #include "memory.h"
25 |
26 | CAMLextern value * caml_stack_low;
27 | CAMLextern value * caml_stack_high;
28 | CAMLextern value * caml_stack_threshold;
29 | CAMLextern value * caml_extern_sp;
30 | CAMLextern value * caml_trapsp;
31 | CAMLextern value * caml_trap_barrier;
32 |
33 | #define Trap_pc(tp) (((code_t *)(tp))[0])
34 | #define Trap_link(tp) (((value **)(tp))[1])
35 |
36 | void caml_init_stack (uintnat init_max_size);
37 | void caml_realloc_stack (asize_t required_size);
38 | void caml_change_max_stack_size (uintnat new_max_size);
39 | uintnat caml_stack_usage (void);
40 |
41 | CAMLextern uintnat (*caml_stack_usage_hook)(void);
42 |
43 | #endif /* CAML_STACKS_H */
44 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/startup.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 2001 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: startup.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_STARTUP_H
17 | #define CAML_STARTUP_H
18 |
19 | #include "mlvalues.h"
20 | #include "exec.h"
21 |
22 | CAMLextern void caml_main(char **argv);
23 |
24 | CAMLextern void caml_startup_code(
25 | code_t code, asize_t code_size,
26 | char *data, asize_t data_size,
27 | char *section_table, asize_t section_table_size,
28 | char **argv);
29 |
30 | enum { FILE_NOT_FOUND = -1, BAD_BYTECODE = -2 };
31 |
32 | extern int caml_attempt_open(char **name, struct exec_trailer *trail,
33 | int do_open_script);
34 | extern void caml_read_section_descriptors(int fd, struct exec_trailer *trail);
35 | /* OCamlCC: fix g++ warning */
36 | extern int32 caml_seek_optional_section(int fd, struct exec_trailer *trail,
37 | const char *name);
38 | extern int32 caml_seek_section(int fd, struct exec_trailer *trail, char *name);
39 |
40 |
41 | #endif /* CAML_STARTUP_H */
42 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/sys.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: sys.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | #ifndef CAML_SYS_H
17 | #define CAML_SYS_H
18 |
19 | #include "misc.h"
20 |
21 | #define NO_ARG Val_int(0)
22 |
23 | CAMLextern void caml_sys_error (value);
24 | CAMLextern void caml_sys_io_error (value);
25 | extern void caml_sys_init (char * exe_name, char ** argv);
26 | CAMLextern value caml_sys_exit (value);
27 |
28 | extern char * caml_exe_name;
29 |
30 | #endif /* CAML_SYS_H */
31 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/ui.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1996 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: ui.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Function declarations for non-Unix user interfaces */
17 |
18 | #ifndef CAML_UI_H
19 | #define CAML_UI_H
20 |
21 | #include "config.h"
22 |
23 | void ui_exit (int return_code);
24 | int ui_read (int file_desc, char *buf, unsigned int length);
25 | int ui_write (int file_desc, char *buf, unsigned int length);
26 | void ui_print_stderr (char *format, void *arg);
27 |
28 | #endif /* CAML_UI_H */
29 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/version.h:
--------------------------------------------------------------------------------
1 | #define OCAML_VERSION "4.00.1"
2 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun-4.00/weak.h:
--------------------------------------------------------------------------------
1 | /***********************************************************************/
2 | /* */
3 | /* OCaml */
4 | /* */
5 | /* Damien Doligez, projet Para, INRIA Rocquencourt */
6 | /* */
7 | /* Copyright 1997 Institut National de Recherche en Informatique et */
8 | /* en Automatique. All rights reserved. This file is distributed */
9 | /* under the terms of the GNU Library General Public License, with */
10 | /* the special exception on linking described in file ../LICENSE. */
11 | /* */
12 | /***********************************************************************/
13 |
14 | /* $Id: weak.h 11156 2011-07-27 14:17:02Z doligez $ */
15 |
16 | /* Operations on weak arrays */
17 |
18 | #ifndef CAML_WEAK_H
19 | #define CAML_WEAK_H
20 |
21 | #include "mlvalues.h"
22 |
23 | extern value caml_weak_list_head;
24 | extern value caml_weak_none;
25 |
26 | #endif /* CAML_WEAK_H */
27 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-byterun.h:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #ifndef OCAMLCC_BYTERUN_H
14 | #define OCAMLCC_BYTERUN_H
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #ifndef __MINGW32__
54 | #include
55 | #else
56 | #include
57 | #endif
58 | #include
59 | #include
60 | #include
61 | #include
62 | #include
63 |
64 | #ifdef OCAMLCC_RUNTIME_VERSION_4_00
65 | #include
66 | #endif
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-main.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 |
19 | static void ocamlcc_bytecode_main(void);
20 |
21 | value ocamlcc_main() {
22 | CAMLparam0();
23 | CAMLlocal1(result);
24 | DeclareLocalSp();
25 | ocamlcc_exception_init();
26 | ocamlcc_codeptrs_init();
27 | ocamlcc_pushtrap(result = Make_exception_result(caml_exn_bucket),
28 | catch_label, 0_main_0);
29 | ocamlcc_bytecode_main();
30 | ocamlcc_poptrap(0);
31 | OffsetSp(0);
32 | result = Val_unit;
33 | goto end;
34 | ocamlcc_catch(catch_label, result = Make_exception_result(exn));
35 | OffsetSp(0);
36 | end:
37 | CAMLreturn(result);
38 | }
39 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-marshal.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | extern const int ocamlcc_fun_nb;
18 | extern const void *ocamlcc_fun_ptrs[];
19 |
20 | void caml_init_code_fragments();
21 |
22 | void ocamlcc_codeptrs_init(void) {
23 | int i;
24 | code_t caml_end_code = caml_start_code = (code_t) ocamlcc_fun_ptrs[0];
25 | for (i = 1 ; i < ocamlcc_fun_nb ; i ++) {
26 | if ((code_t) ocamlcc_fun_ptrs[i] < caml_start_code)
27 | caml_start_code = (code_t) ocamlcc_fun_ptrs[i];
28 | else if ((code_t) ocamlcc_fun_ptrs[i] > caml_end_code)
29 | caml_end_code = (code_t) ocamlcc_fun_ptrs[i];
30 | }
31 | caml_code_size = caml_end_code - caml_start_code + sizeof(char *);
32 | #ifdef OCAMLCC_RUNTIME_VERSION_4_00
33 | {
34 | struct code_fragment * cf;
35 | /* Register the code in the table of code fragments */
36 | cf = (struct code_fragment *)
37 | caml_stat_alloc(sizeof(struct code_fragment));
38 | cf->code_start = (char *) caml_start_code;
39 | cf->code_end = (char *) caml_start_code + caml_code_size;
40 | memcpy(cf->digest, OCAMLCC_MD5, 16);
41 | cf->digest_computed = 1;
42 | caml_ext_table_init(&caml_code_fragments_table, 8);
43 | caml_ext_table_add(&caml_code_fragments_table, cf);
44 | }
45 | #endif
46 | #ifdef OCAMLCC_RUNTIME_VERSION_3_12
47 | memcpy(caml_code_md5, OCAMLCC_MD5, 16);
48 | #endif
49 | }
50 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-signals.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #ifdef OCAMLCC_SIGNAL_REACTIVE
14 |
15 | #define ocamlcc_check_something_to_do(frame_sz) { \
16 | if (caml_something_to_do) { \
17 | long ocamlcc_save_sp_offset; \
18 | SaveSp(ocamlcc_save_sp_offset); \
19 | sp[-frame_sz - 1] = sp[-frame_sz - 2] = sp[-frame_sz - 3] = \
20 | sp[-frame_sz - 4] = sp[-frame_sz - 5] = \
21 | sp[-frame_sz - 6] = Val_unit; \
22 | OffsetSp(-frame_sz - 6); \
23 | do { \
24 | caml_something_to_do = 0; \
25 | caml_process_event(); \
26 | } while (caml_something_to_do); \
27 | ResetSp(-frame_sz - 6); \
28 | RestoreSp(ocamlcc_save_sp_offset); \
29 | } \
30 | }
31 |
32 | #define ocamlcc_saved_check_something_to_do(to_save, frame_sz) { \
33 | if (caml_something_to_do) { \
34 | long ocamlcc_save_sp_offset; \
35 | SaveSp(ocamlcc_save_sp_offset); \
36 | sp[-frame_sz - 1] = sp[-frame_sz - 2] = sp[-frame_sz - 3] = \
37 | sp[-frame_sz - 4] = sp[-frame_sz - 5] = Val_unit; \
38 | sp[-frame_sz - 6] = to_save; \
39 | OffsetSp(-frame_sz - 6); \
40 | do { \
41 | caml_something_to_do = 0; \
42 | caml_process_event(); \
43 | } while (caml_something_to_do); \
44 | ResetSp(-frame_sz - 6); \
45 | RestoreSp(ocamlcc_save_sp_offset); \
46 | to_save = sp[-frame_sz - 6]; \
47 | } \
48 | }
49 |
50 | #else
51 |
52 | #define ocamlcc_check_something_to_do(frame_sz)
53 | #define ocamlcc_saved_check_something_to_do(to_save, frame_sz)
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-unimpl.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #include
14 | #include
15 |
16 | void ocamlcc_dynlink_error(void) Noreturn;
17 | void ocamlcc_dynlink_error(void) {
18 | caml_failwith("OCamlCC: dynlink not implemented");
19 | }
20 |
21 | CAMLprim value caml_reify_bytecode(value prog, value len) {
22 | ocamlcc_dynlink_error();
23 | }
24 | CAMLprim value caml_get_current_environment(value unit) {
25 | ocamlcc_dynlink_error();
26 | }
27 | CAMLprim value caml_invoke_traced_function(value codeptr, value env,
28 | value arg) {
29 | ocamlcc_dynlink_error();
30 | }
31 | CAMLprim value caml_get_global_data(value unit) {
32 | ocamlcc_dynlink_error();
33 | }
34 | CAMLprim value caml_get_section_table(value unit) {
35 | ocamlcc_dynlink_error();
36 | }
37 | CAMLprim value caml_realloc_global(value size) {
38 | ocamlcc_dynlink_error();
39 | }
40 | CAMLprim value caml_register_code_fragment(value prog, value len,
41 | value digest) {
42 | ocamlcc_dynlink_error();
43 | }
44 |
--------------------------------------------------------------------------------
/runtime/ocamlcc-windows.c:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #ifdef __MINGW32__
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #define sigjmp_buf jmp_buf
23 | #define sigsetjmp(buf,save) setjmp(buf)
24 | #define siglongjmp(env,val) longjmp(env,val)
25 |
26 | #define SIG_BLOCK 0
27 | #define SIG_SETMASK 2
28 | int sigemptyset(sigset_t *set){
29 | printf("Error: sigemptyset not implemented\n");
30 | exit(1);
31 | }
32 | int sigaddset(sigset_t *set, int signum){
33 | printf("Error: sigaddset not implemented\n");
34 | exit(1);
35 | }
36 | int sigdelset(sigset_t *set, int signum){
37 | printf("Error: sigdelset not implemented\n");
38 | exit(1);
39 | }
40 | int sigprocmask(int how, sigset_t *set, sigset_t *oldset){
41 | printf("Error: sigprocmask not implemented\n");
42 | exit(1);
43 | }
44 |
45 | int tputs(char *str, int affcnt, int (*putc)(int)){
46 | printf("Error: tputs not implemented\n");
47 | exit(1);
48 | }
49 | int tgetent(char *bp, char *name){
50 | printf("Error: tgetent not implemented\n");
51 | exit(1);
52 | }
53 | int tgetnum (char * id){
54 | printf("Error: tgetnum not implemented\n");
55 | exit(1);
56 | }
57 | char *tgetstr(char *id, char **area){
58 | printf("Error: tgetstr not implemented\n");
59 | exit(1);
60 | }
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/runtime/ocamlcc.h:
--------------------------------------------------------------------------------
1 | /*************************************************************************/
2 | /* */
3 | /* OCamlCC */
4 | /* */
5 | /* Michel Mauny, Benoit Vaugon */
6 | /* ENSTA ParisTech */
7 | /* */
8 | /* This file is distributed under the terms of the CeCILL license. */
9 | /* See file ../LICENSE-en. */
10 | /* */
11 | /*************************************************************************/
12 |
13 | #ifndef OCAMLCC_H
14 | #define OCAMLCC_H
15 |
16 | #ifdef __cplusplus
17 | extern "C" {
18 | #endif
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include "ocamlcc-sp.c"
25 | #include "ocamlcc-signals.c"
26 | #include "ocamlcc-exceptions.c"
27 | #include "ocamlcc-windows.c"
28 | #include "ocamlcc-unimpl.c"
29 | #include "ocamlcc-instrs.c"
30 | #include "ocamlcc-alloc.c"
31 | #include "ocamlcc-apply-gen.c"
32 | #include "ocamlcc-apply-none.c"
33 | #include "ocamlcc-apply-x86x.c"
34 | #include "ocamlcc-marshal.c"
35 | #include "ocamlcc-main.c"
36 | #include "ocamlcc-byterun.h"
37 | #include "ocamlcc-otherlibs.h"
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | ###########################################################################
2 | ## ##
3 | ## OCamlCC ##
4 | ## ##
5 | ## Michel Mauny, Benoit Vaugon ##
6 | ## ENSTA ParisTech ##
7 | ## ##
8 | ## This file is distributed under the terms of the CeCILL license. ##
9 | ## See file ../LICENSE-en. ##
10 | ## ##
11 | ###########################################################################
12 |
13 | include ../etc/Makefile.conf
14 |
15 | TARG = ../bin/ocamlcc
16 | SRCS = $(wildcard *.ml *.mli */*.ml */*.mli)
17 | DIRS = tools,frontend,optimizer,codegen
18 |
19 | all: $(TARG)
20 |
21 | $(TARG): _build/ocamlcc.native
22 | cp $< $@
23 |
24 | _build/ocamlcc.native: $(SRCS) config.ml
25 | @$(OCAMLBUILD) -Is $(DIRS) -cflag -g -lflag -g -libs unix \
26 | ocamlcc.native
27 |
28 | config.ml: ../etc/config.ml
29 | cp $< $@
30 |
31 | clean:
32 | @$(OCAMLBUILD) -clean
33 | @rm -f $(TARG) config.ml
34 |
35 | .PHONY: all clean
36 |
--------------------------------------------------------------------------------
/src/codegen/codegen.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | open Types;;
14 | open Macroc;;
15 |
16 | let gen_code cfile macroc md5 =
17 | Options.verb_start "+ Generating %S..." cfile;
18 | let oc = open_out cfile in
19 | Printf.fprintf oc "#define OCAMLCC_MD5 \"";
20 | for i = 0 to 15 do Printf.fprintf oc "\\x%c%c" md5.[2*i] md5.[2*i+1] done;
21 | Printf.fprintf oc "\"\n";
22 | if !Options.no_main then Printf.fprintf oc "#define OCAMLCC_NO_MAIN\n";
23 | Printf.fprintf oc "#define OCAMLCC_GLOBAL_DATA_LENGTH %d\n"
24 | (String.length macroc.mc_data);
25 | Printf.fprintf oc "#define OCAMLCC_MAXIMUM_ARITY %d\n" macroc.mc_max_arity;
26 | Printf.fprintf oc "#define OCAMLCC_ARCH_%a\n" Printer.print_arch
27 | !Options.arch;
28 | Printf.fprintf oc "#define OCAMLCC_SIGNAL_%a\n" Printer.print_sigconf
29 | !Options.sigconf;
30 | Printf.fprintf oc "#define OCAMLCC_EXCEPTION_%a\n" Printer.print_except
31 | !Options.except;
32 | Printf.fprintf oc "#define OCAMLCC_SP_%a\n" Printer.print_spmode
33 | !Options.sp_mode;
34 | Printf.fprintf oc "#define OCAMLCC_RUNTIME_VERSION_%s\n"
35 | (let s = String.copy !Options.runtime_version in s.[1] <- '_'; s);
36 | Printf.fprintf oc "\n";
37 | Printf.fprintf oc "#if !defined(__GNUC__)\n";
38 | Printf.fprintf oc
39 | " #error - Incompatible code: compiler should be GNU C compatible\n";
40 | Printf.fprintf oc "#endif\n";
41 | begin match !Options.arch with
42 | | Gen_arch | None_arch -> ()
43 | | X86 ->
44 | Printf.fprintf oc
45 | "#if (!defined(__i386__) && !defined(__i486__) \\\n \
46 | && !defined(__i585__) && !defined(__i686__))\n";
47 | Printf.fprintf oc
48 | " #error - Incompatible code: architecture should be x86\n";
49 | Printf.fprintf oc "#endif\n\n";
50 | | X86_64 ->
51 | Printf.fprintf oc
52 | "#if !defined(__x86_64__)\n";
53 | Printf.fprintf oc
54 | " #error - Incompatible code: architecture should be x86-64\n";
55 | Printf.fprintf oc "#endif\n";
56 | end;
57 | Printf.fprintf oc "\n";
58 | Printf.fprintf oc "#include \n\n";
59 | Mcprinter.print_macroc oc macroc;
60 | close_out oc;
61 | Options.verb_stop ();
62 | ;;
63 |
--------------------------------------------------------------------------------
/src/frontend/data.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | open Types
14 |
15 | let dump ic index =
16 | let (offset, length) =
17 | try Index.find_section index Data
18 | with Not_found ->
19 | failwith "invalid bytecode executable file (DATA section not found)"
20 | in
21 | let buf = String.create length in
22 | seek_in ic offset;
23 | really_input ic buf 0 length;
24 | buf
25 | ;;
26 |
27 | let export oc data =
28 | let len = String.length data in
29 | let rec f i =
30 | if i mod 8 = 0 then Printf.fprintf oc "\n ";
31 | if i < len then (
32 | Printf.fprintf oc " 0x%02x," (int_of_char data.[i]);
33 | f (succ i);
34 | ) else (
35 | Printf.fprintf oc " 0x00\n";
36 | )
37 | in
38 | Printf.fprintf oc "unsigned char ocamlcc_global_data[] = {";
39 | f 0;
40 | Printf.fprintf oc "};\n";
41 | ;;
42 |
--------------------------------------------------------------------------------
/src/frontend/dbug.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | open Types
14 | open Tools
15 |
16 | let parse ic index =
17 | try
18 | let rec read_events n acc =
19 | if n = 0 then acc else
20 | let orig = input_binary_int ic in
21 | let evl = (input_value ic : debug_event list) in
22 | let add acc ev =
23 | if ev.ev_loc.loc_ghost then acc
24 | else IMap.add ((orig + ev.ev_pos) / 4) ev.ev_loc acc
25 | in
26 | read_events (n - 1) (List.fold_left add acc evl)
27 | in
28 | let (offset, length) = Index.find_section index Dbug in
29 | if length = 0 then raise Not_found;
30 | seek_in ic offset;
31 | let event_nb = input_binary_int ic in
32 | let events = read_events event_nb IMap.empty in
33 | events
34 | with Not_found -> IMap.empty
35 | ;;
36 |
--------------------------------------------------------------------------------
/src/frontend/index.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | open Types
14 |
15 | let parse ic =
16 | let magic_str = "Caml1999X008" in
17 | let magic_size = String.length magic_str in
18 | let file_length = in_channel_length ic in
19 | let buf_magic = String.create magic_size in
20 | let buf4 = String.create 4 in
21 | let read_int offset =
22 | seek_in ic offset;
23 | input_binary_int ic
24 | in
25 | let read_name offset =
26 | seek_in ic offset;
27 | really_input ic buf4 0 4;
28 | match buf4 with
29 | | "CODE" -> Code
30 | | "DLPT" -> Dlpt
31 | | "DLLS" -> Dlls
32 | | "PRIM" -> Prim
33 | | "DATA" -> Data
34 | | "SYMB" -> Symb
35 | | "CRCS" -> Crcs
36 | | "DBUG" -> Dbug
37 | | _ ->
38 | failwith (Printf.sprintf
39 | "invalid bytecode executable file (unknown section name: `%s')"
40 | buf4)
41 | in
42 | seek_in ic (file_length - magic_size);
43 | really_input ic buf_magic 0 magic_size;
44 | if buf_magic <> magic_str then
45 | failwith "invalid bytecode executable file (unknown magic string)";
46 | let size = read_int (file_length - magic_size - 4) in
47 | let rec f ind next_offset rem =
48 | if ind <> -1 then
49 | let descr_offset = file_length - magic_size - 4 - (size - ind) lsl 3 in
50 | let name = read_name descr_offset in
51 | let length = read_int (descr_offset + 4) in
52 | let new_offset = next_offset - length in
53 | f (ind - 1) new_offset ((name, new_offset, length) :: rem)
54 | else
55 | rem
56 | in
57 | f (size - 1) (file_length - magic_size - 4 - size lsl 3) []
58 | ;;
59 |
60 | let find_section index name =
61 | let (_, offset, length) = List.find (fun (n, _, _) -> name = n) index in
62 | (offset, length)
63 | ;;
64 |
--------------------------------------------------------------------------------
/src/frontend/loader.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let load input_file =
14 | Options.verb_start "+ Loading %S" input_file;
15 | let ic = open_in_bin input_file in
16 | Options.message ".";
17 | let index = Index.parse ic in
18 | Options.message ".";
19 | let prims = Prim.parse ic index in
20 | Options.message ".";
21 | let data = Data.dump ic index in
22 | Options.message ".";
23 | let code = Code.parse ic index in
24 | Options.message ".";
25 | let dbug = Dbug.parse ic index in
26 | close_in ic;
27 | Options.verb_stop();
28 | (prims, data, code, dbug)
29 | ;;
30 |
--------------------------------------------------------------------------------
/src/optimizer/cleanfuns.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | open Types;;
14 | open Tools;;
15 |
16 | let search_funs performed tosearch states read_set body =
17 | let len = Array.length body in
18 | let add ptr s =
19 | let index = ptr.pointed.index in
20 | if ISet.mem index performed then s else ISet.add index s
21 | in
22 | let rec f ind s =
23 | if ind = len then s else
24 | match body.(ind).bc with
25 | | StaticApply (_, ptr) | StaticAppterm (_, _, ptr) ->
26 | f (ind + 1) (add ptr s)
27 | | Closure (_, ptr) ->
28 | begin match states.(ind + 1) with
29 | | Some { accu = accu ; stack = _ } when ISet.mem accu read_set ->
30 | f (ind + 1) (add ptr s)
31 | | Some _ | None ->
32 | f (ind + 1) s
33 | end
34 | | Closurerec (fun_nb, _, ptr, ptrs) ->
35 | begin match states.(ind + 1) with
36 | | Some { accu = accu ; stack = stack } ->
37 | let rec g i =
38 | if i = fun_nb - 1 then false
39 | else if ISet.mem (Stk.acc i stack) read_set then true
40 | else g (i + 1)
41 | in
42 | let used =
43 | ISet.mem accu read_set ||
44 | ISet.mem (Stk.acc (fun_nb - 1) stack) read_set || g 0
45 | in
46 | if used then f (ind + 1) (Array.fold_right add ptrs (add ptr s))
47 | else f (ind + 1) s
48 | | None ->
49 | f (ind + 1) s
50 | end
51 | | _ ->
52 | f (ind + 1) s
53 | in
54 | f 0 tosearch
55 | ;;
56 |
57 | let clean_functions funs ids_infos fun_infos tc_set =
58 | Options.verb_start "+ Cleaning functions.";
59 | let rec search performed tosearch =
60 | if ISet.is_empty tosearch then performed else
61 | let id = ISet.choose tosearch in
62 | let new_performed = ISet.add id performed in
63 | let new_tosearch = ISet.remove id tosearch in
64 | let body = (IMap.find id funs).body in
65 | let ids_info = IMap.find id ids_infos in
66 | let new_tosearch2 =
67 | search_funs new_performed new_tosearch ids_info.states ids_info.read_set
68 | body
69 | in
70 | search new_performed new_tosearch2
71 | in
72 | let used = search ISet.empty (ISet.singleton 0) in
73 | let filter id _ = ISet.mem id used in
74 | Options.message ".";
75 | let new_funs = IMap.filter filter funs in
76 | Options.message ".";
77 | let new_ids_infos = IMap.filter filter ids_infos in
78 | Options.message ".";
79 | let new_fun_infos = IMap.filter filter fun_infos in
80 | Options.message ".";
81 | let new_tc_set = ISet.inter tc_set used in
82 | Options.verb_stop ();
83 | (new_funs, new_ids_infos, new_fun_infos, new_tc_set)
84 | ;;
85 |
--------------------------------------------------------------------------------
/src/tools/stk.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | type 'a t = { size : int ; list : 'a list }
14 |
15 | let empty = { size = 0 ; list = [] }
16 |
17 | let push x { size = size ; list = list } =
18 | { size = size + 1 ; list = x :: list }
19 |
20 | let pop n { size = size ; list = list } =
21 | if n > size || n < 0 then
22 | invalid_arg (Printf.sprintf "Stk.pop %d { size = %d }" n size);
23 | let rec f i list = if i = n then list else f (i + 1) (List.tl list) in
24 | { size = size - n ; list = f 0 list }
25 |
26 | let acc n { size = size ; list = list } =
27 | if n >= size || n < 0 then invalid_arg "Stk.acc";
28 | List.nth list n
29 |
30 | let assign n x { size = size ; list = list } =
31 | if n >= size || n < 0 then invalid_arg "Stk.assign";
32 | let rec f i list =
33 | if i = 0 then x :: List.tl list else
34 | match list with
35 | | [] -> assert false
36 | | hd :: tl -> hd :: f (i - 1) tl
37 | in
38 | { size = size ; list = f n list }
39 |
40 | let size stack = stack.size
41 |
42 | let push_list l stack =
43 | let rec f cnt l acc =
44 | match l with
45 | | [] -> { size = cnt ; list = acc }
46 | | hd :: tl -> f (cnt + 1) tl (hd :: acc)
47 | in
48 | f stack.size l stack.list
49 |
50 | let iter f stack =
51 | List.iter f stack.list
52 |
53 | let iteri f stack =
54 | let rec loop i l =
55 | match l with
56 | | [] -> ()
57 | | x :: rest -> f i x; loop (i + 1) rest
58 | in
59 | loop 0 stack.list
60 |
61 | let iter2 f stack stack' =
62 | if stack.size <> stack'.size then invalid_arg "Stk.iter2";
63 | List.iter2 f stack.list stack'.list
64 |
65 | let map f stack =
66 | { size = stack.size ; list = List.map f stack.list }
67 |
68 | let map2 f stack stack' =
69 | if stack.size <> stack'.size then invalid_arg "Stk.map2";
70 | { size = stack.size ; list = List.map2 f stack.list stack'.list }
71 |
72 | let fold_left f init stack =
73 | List.fold_left f init stack.list
74 |
75 | let fold_right f stack init =
76 | List.fold_right f stack.list init
77 |
78 | let fold_left2 f init stack stack' =
79 | if stack.size <> stack'.size then invalid_arg "Stk.fold_left2";
80 | List.fold_left2 f init stack.list stack'.list
81 |
82 | let print pp oc stack =
83 | let rec f i l =
84 | match l with
85 | | [] -> ()
86 | | hd :: tl -> Printf.fprintf oc "%d: %a\n" i pp hd; f (i + 1) tl
87 | in
88 | f 0 stack.list
89 |
--------------------------------------------------------------------------------
/src/tools/tools.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let noinline = "__attribute__((noinline))";;
14 |
15 | (***)
16 |
17 | module Id = struct
18 | type t = int
19 | let counter = ref 0
20 | let create () = let n = !counter in counter := n + 1; n
21 | end;;
22 |
23 | (***)
24 |
25 | module Int = struct
26 | type t = int
27 | let compare (x : int) (y : int) = compare x y
28 | end;;
29 |
30 | module ISet = Set.Make (Int);;
31 | module IMap = Map.Make (Int);;
32 | module SMap = Map.Make (String);;
33 |
--------------------------------------------------------------------------------
/tests/bigsrc_ml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bvaugon/ocamlcc/14f6fe96ad8cae1365276a52114be59284a55d90/tests/bigsrc_ml
--------------------------------------------------------------------------------
/tests/extexn.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let rec f n =
14 | if n > 0 then
15 | try
16 | f (n - 1);
17 | if n mod 2 = 0 then Sys.remove "/tmp/abc.ocamlcc.tmp"
18 | else raise Exit;
19 | print_endline "coucou";
20 | with exn ->
21 | f (n - 1);
22 | print_endline "exception";
23 | in
24 | f 8;
25 | ;;
26 |
--------------------------------------------------------------------------------
/tests/fact.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let usage () =
14 | Printf.eprintf "Usage: %s \n" Sys.argv.(0);
15 | exit 1;
16 | ;;
17 |
18 | if Array.length Sys.argv <> 3 then usage ();;
19 | let n = try int_of_string Sys.argv.(1) with _ -> usage ();;
20 | let p = try int_of_string Sys.argv.(2) with _ -> usage ();;
21 |
22 | let rec fact n = if n = 0 then 1 else n * fact (n - 1) in
23 | for i = 2 to p do ignore (fact n) done;
24 | Printf.printf "%d\n" (fact n);
25 | ;;
26 |
--------------------------------------------------------------------------------
/tests/fibo.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let usage () =
14 | Printf.eprintf "Usage: %s \n" Sys.argv.(0);
15 | exit 1;
16 | ;;
17 |
18 | if Array.length Sys.argv <> 2 then usage ();;
19 | let n = try int_of_string Sys.argv.(1) with _ -> usage ();;
20 |
21 | let rec fibo x = if x < 2 then 1 else fibo (x - 1) + fibo (x - 2) in
22 | Printf.printf "%d\n" (fibo n);
23 | ;;
24 |
--------------------------------------------------------------------------------
/tests/flocon.ml:
--------------------------------------------------------------------------------
1 | open Graphics;;
2 |
3 | let perim n =
4 | let rec f r = function
5 | | k when k = n -> r
6 | | k -> f (r*.4./.3.) (k+1)
7 | in
8 | f 3. 0
9 | ;;
10 |
11 | let aire n =
12 | let rec f r l t = function
13 | | k when k = n -> r
14 | | k -> f (r +. (float_of_int t)*.l*.l*.sqrt(3.)/.4.) (l/.3.) (t*4) (k+1)
15 | in
16 | f (sqrt(3.)/.4.) (1./.3.) 3 0
17 | ;;
18 |
19 | let rec trace nb xm ym xn yn =
20 | if nb <> 0 then
21 | let xa = float_of_int (2*xm + xn) /. 3. in
22 | let xc = float_of_int (xm + 2*xn) /. 3. in
23 | let ya = float_of_int (2*ym + yn) /. 3. in
24 | let yc = float_of_int (ym + 2*yn) /. 3. in
25 | let xb = xa +. (xc -. xa -. sqrt 3. *. (yc -. ya)) /. 2. in
26 | let yb = ya +. (yc -. ya +. sqrt 3. *. (xc -. xa)) /. 2. in
27 | trace (nb - 1) xm ym (int_of_float xa) (int_of_float ya);
28 | trace (nb - 1) (int_of_float xa) (int_of_float ya) (int_of_float xb)
29 | (int_of_float yb);
30 | trace (nb - 1) (int_of_float xb) (int_of_float yb) (int_of_float xc)
31 | (int_of_float yc);
32 | trace (nb - 1) (int_of_float xc) (int_of_float yc) xn yn
33 | else
34 | moveto xm ym ; lineto xn yn
35 | ;;
36 |
37 | let xmax = 600;;
38 | let ymax = 600;;
39 |
40 | open_graph (" " ^ (string_of_int xmax) ^ "x" ^ (string_of_int ymax));;
41 | set_color blue;;
42 |
43 | let yv = ymax / 8 in
44 | let xv = xmax / 2 in
45 | let yu = yv + int_of_float (0.5196 *. float_of_int ymax) in
46 | let xu = xv - int_of_float (3. *. float_of_int xmax /. 10.) in
47 | let yw = yu in
48 | let xw = xv + int_of_float (3. *. float_of_int xmax /. 10.) in
49 | let rec loop = function
50 | | 10 -> loop 0;
51 | | k ->
52 | clear_graph ();
53 | moveto 20 20 ; draw_string ("N = " ^ (string_of_int (k+1)));
54 | moveto 200 20 ; draw_string ("P = " ^ (string_of_float (perim k)));
55 | moveto 400 20 ; draw_string ("A = " ^ (string_of_float (aire k)));
56 | trace k xv yv xu yu;
57 | trace k xu yu xw yw;
58 | trace k xw yw xv yv;
59 | (* synchronize ();*)
60 | let t = Unix.time () in
61 | while Unix.time () < t +. 2. do
62 | Unix.sleep 1
63 | done;
64 | draw_circle (xmax/2) (ymax/2-18) 208;
65 | let t = Unix.time () in
66 | while Unix.time () < t +. 2. do
67 | Unix.sleep 1
68 | done;
69 | loop (k + 1)
70 | in
71 | (* auto_synchronize false;*)
72 | loop 0;
73 |
--------------------------------------------------------------------------------
/tests/funs.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let f s1 s2 =
14 | print_string s1;
15 | print_char ' ';
16 | print_endline s2;
17 | in
18 | f "Hello" "world";
19 | let g = f "Bye" in
20 | g "bye";
21 | ;;
22 |
23 | (***)
24 |
25 | let f s1 =
26 | print_string s1;
27 | print_char ':';
28 | fun s2 -> print_endline (s1 ^ " " ^ s2);
29 | in
30 | f "Cot" "cot";;
31 |
32 | (***)
33 |
34 | let f s1 s2 =
35 | print_string (s1 ^ "-" ^ s2);
36 | print_char ':';
37 | fun s3 -> print_endline (s1 ^ s2 ^ s3);
38 | in
39 | let g = f "Bla" in
40 | g "lab" "alb"
41 | ;;
42 |
--------------------------------------------------------------------------------
/tests/hw.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | print_endline "Hello world";;
14 |
--------------------------------------------------------------------------------
/tests/levenshtein.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let min3 a b c = min a (min b c);;
14 |
15 | let levenshtein m n =
16 | let d1 = Array.init (String.length n) (fun i -> i) in
17 | let d0 = Array.make (String.length n) 0 in
18 | for i = 1 to String.length m - 1 do
19 | d0.(0) <- i;
20 | let ui = int_of_char m.[i] in
21 | for j = 1 to String.length n - 1 do
22 | d0.(j) <- 1 + min3 d1.(j) d0.(j-1)
23 | (d1.(j-1) + if ui = int_of_char n.[j] then -1 else 0);
24 | done;
25 | Array.blit d0 0 d1 0 (String.length n);
26 | done;
27 | d0.(String.length n - 1)
28 | ;;
29 |
30 | let str = String.create 1500 in
31 | for i = 0 to 299 do
32 | str.[i] <- char_of_int (int_of_char 'a' + Random.int 26);
33 | done;
34 | for i = 1 to 10 do
35 | print_char '*'; flush stdout;
36 | ignore (levenshtein str ("foo" ^ str));
37 | done;
38 | print_newline ();
39 | ;;
40 |
--------------------------------------------------------------------------------
/tests/loop.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | for i = 0 to 123456789 do () done
14 |
--------------------------------------------------------------------------------
/tests/marsh.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let f x = x + 42;;
14 |
15 | let s = Marshal.to_string f [ Marshal.Closures ];;
16 |
17 | let g : int -> int = Marshal.from_string s 0;;
18 |
19 | Printf.printf "%d\n" (g 42);;
20 |
--------------------------------------------------------------------------------
/tests/printfhw.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | Printf.printf "Hello world\n";;
14 |
--------------------------------------------------------------------------------
/tests/takc.ml:
--------------------------------------------------------------------------------
1 | (***********************************************************************)
2 | (* *)
3 | (* Objective Caml *)
4 | (* *)
5 | (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 | (* *)
7 | (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 | (* en Automatique. All rights reserved. This file is distributed *)
9 | (* under the terms of the Q Public License version 1.0. *)
10 | (* *)
11 | (***********************************************************************)
12 |
13 | (* $Id: taku.ml 10713 2010-10-08 11:53:19Z doligez $ *)
14 |
15 | let rec tak x y z =
16 | if x > y then tak (tak (x-1) y z) (tak (y-1) z x) (tak (z-1) x y)
17 | else z
18 |
19 | let rec repeat n =
20 | if n <= 0 then 0 else tak 18 12 6 + repeat(n-1)
21 |
22 | let _ = print_int (repeat 2000); print_newline(); exit 0
23 |
--------------------------------------------------------------------------------
/tests/termtrap.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let rec f n =
14 | (try ignore (int_of_string "42") with Failure _ -> print_endline "hohoho");
15 | if n = 0 then 1 else f (n - 1)
16 | in
17 | print_int (f 100000000);
18 | print_newline ();
19 | ;;
20 |
--------------------------------------------------------------------------------
/tests/wscope.ml:
--------------------------------------------------------------------------------
1 | (*************************************************************************)
2 | (* *)
3 | (* OCamlCC *)
4 | (* *)
5 | (* Michel Mauny, Benoit Vaugon *)
6 | (* ENSTA ParisTech *)
7 | (* *)
8 | (* This file is distributed under the terms of the CeCILL license. *)
9 | (* See file ../LICENSE-en. *)
10 | (* *)
11 | (*************************************************************************)
12 |
13 | let f x y = x ^ y;;
14 | let g = f "toto";;
15 |
16 | try ignore (int_of_string "jim")
17 | with Failure msg -> print_endline (g "jij");;
18 |
--------------------------------------------------------------------------------