Commits

Romain Vernoux committed 5468b2a

Major new version with new package name

Comments (0)

Files changed (40)

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      package="jp.co.itpl.ocamlandroid"
-      android:versionCode="2"
-      android:versionName="0.9.1 beta">
+      package="fr.vernoux.ocaml"
+      android:versionCode="1"
+      android:versionName="1.0 Release">
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
     <application android:icon="@drawable/icon" 
     			 android:label="@string/app_name">
         <activity android:name=".MainActivity"
         	android:label="@string/menu_open">
         </activity>
     </application>
-    <uses-sdk android:minSdkVersion="3" />
+    <uses-sdk android:minSdkVersion="7" />
 
 </manifest> 
 LOCAL_MODULE    := ocamltop
 LOCAL_SRC_FILES := libocamltop.c start.c
 LOCAL_CFLAGS    := -std=c99 -I$(OCAMLANDROID_PREFIX)/lib/ocaml 
-LOCAL_LDLIBS := -llog jni/libcamlrun.a
+LOCAL_LDLIBS := -llog libcamlrun.a
 
-include $(BUILD_SHARED_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
+# EDIT BELOW
+OCAMLANDROID_PREFIX=C:/users/romain/caml/
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_MODULE    := ocamltop
+LOCAL_SRC_FILES := libocamltop.c start.c
+LOCAL_CFLAGS    := -std=c99 -I$(OCAMLANDROID_PREFIX)/lib/ocaml 
+LOCAL_LDLIBS := -llog jni/libcamlrun.a
+
+include $(BUILD_SHARED_LIBRARY)
+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: alloc.h 7064 2005-09-22 14:21:50Z xleroy $ */
+
+#ifndef CAML_ALLOC_H
+#define CAML_ALLOC_H
+
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "misc.h"
+#include "mlvalues.h"
+
+CAMLextern value caml_alloc (mlsize_t, tag_t);
+CAMLextern value caml_alloc_small (mlsize_t, tag_t);
+CAMLextern value caml_alloc_tuple (mlsize_t);
+CAMLextern value caml_alloc_string (mlsize_t);  /* size in bytes */
+CAMLextern value caml_copy_string (char const *);
+CAMLextern value caml_copy_string_array (char const **);
+CAMLextern value caml_copy_double (double);
+CAMLextern value caml_copy_int32 (int32);       /* defined in [ints.c] */
+CAMLextern value caml_copy_int64 (int64);       /* defined in [ints.c] */
+CAMLextern value caml_copy_nativeint (intnat);  /* defined in [ints.c] */
+CAMLextern value caml_alloc_array (value (*funct) (char const *),
+                                   char const ** array);
+
+typedef void (*final_fun)(value);
+CAMLextern value caml_alloc_final (mlsize_t, /*size in words*/
+                                   final_fun, /*finalization function*/
+                                   mlsize_t, /*resources consumed*/
+                                   mlsize_t  /*max resources*/);
+
+CAMLextern int caml_convert_flag_list (value, int *);
+
+#endif /* CAML_ALLOC_H */

jni/caml/bigarray.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Manuel Serrano and Xavier Leroy, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 2000 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../../LICENSE.  */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: bigarray.h 9153 2008-12-03 18:09:09Z doligez $ */
+
+#ifndef CAML_BIGARRAY_H
+#define CAML_BIGARRAY_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "config.h"
+#include "mlvalues.h"
+
+typedef signed char caml_ba_int8;
+typedef unsigned char caml_ba_uint8;
+#if SIZEOF_SHORT == 2
+typedef short caml_ba_int16;
+typedef unsigned short caml_ba_uint16;
+#else
+#error "No 16-bit integer type available"
+#endif
+
+#define CAML_BA_MAX_NUM_DIMS 16
+
+enum caml_ba_kind {
+  CAML_BA_FLOAT32,             /* Single-precision floats */
+  CAML_BA_FLOAT64,             /* Double-precision floats */
+  CAML_BA_SINT8,               /* Signed 8-bit integers */
+  CAML_BA_UINT8,               /* Unsigned 8-bit integers */
+  CAML_BA_SINT16,              /* Signed 16-bit integers */
+  CAML_BA_UINT16,              /* Unsigned 16-bit integers */
+  CAML_BA_INT32,               /* Signed 32-bit integers */
+  CAML_BA_INT64,               /* Signed 64-bit integers */
+  CAML_BA_CAML_INT,            /* Caml-style integers (signed 31 or 63 bits) */
+  CAML_BA_NATIVE_INT,       /* Platform-native long integers (32 or 64 bits) */
+  CAML_BA_COMPLEX32,           /* Single-precision complex */
+  CAML_BA_COMPLEX64,           /* Double-precision complex */
+  CAML_BA_KIND_MASK = 0xFF     /* Mask for kind in flags field */
+};
+
+enum caml_ba_layout {
+  CAML_BA_C_LAYOUT = 0,           /* Row major, indices start at 0 */
+  CAML_BA_FORTRAN_LAYOUT = 0x100, /* Column major, indices start at 1 */
+  CAML_BA_LAYOUT_MASK = 0x100  /* Mask for layout in flags field */
+};
+
+enum caml_ba_managed {
+  CAML_BA_EXTERNAL = 0,        /* Data is not allocated by Caml */
+  CAML_BA_MANAGED = 0x200,     /* Data is allocated by Caml */
+  CAML_BA_MAPPED_FILE = 0x400, /* Data is a memory mapped file */
+  CAML_BA_MANAGED_MASK = 0x600 /* Mask for "managed" bits in flags field */
+};
+
+struct caml_ba_proxy {
+  intnat refcount;              /* Reference count */
+  void * data;                  /* Pointer to base of actual data */
+  uintnat size;                 /* Size of data in bytes (if mapped file) */
+};
+
+struct caml_ba_array {
+  void * data;                /* Pointer to raw data */
+  intnat num_dims;            /* Number of dimensions */
+  intnat flags;  /* Kind of element array + memory layout + allocation status */
+  struct caml_ba_proxy * proxy; /* The proxy for sub-arrays, or NULL */
+  intnat dim[1] /*[num_dims]*/; /* Size in each dimension */
+};
+
+#define Caml_ba_array_val(v) ((struct caml_ba_array *) Data_custom_val(v))
+
+#define Caml_ba_data_val(v) (Caml_ba_array_val(v)->data)
+
+#if defined(IN_OCAML_BIGARRAY)
+#define CAMLBAextern CAMLexport
+#else
+#define CAMLBAextern CAMLextern
+#endif
+
+CAMLBAextern value
+    caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim);
+CAMLBAextern value caml_ba_alloc_dims(int flags, int num_dims, void * data,
+                                 ... /*dimensions, with type intnat */);
+CAMLBAextern uintnat caml_ba_byte_size(struct caml_ba_array * b);
+
+#endif

jni/caml/callback.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: callback.h 7596 2006-09-11 12:12:24Z doligez $ */
+
+/* Callbacks from C to Caml */
+
+#ifndef CAML_CALLBACK_H
+#define CAML_CALLBACK_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "mlvalues.h"
+
+CAMLextern value caml_callback (value closure, value arg);
+CAMLextern value caml_callback2 (value closure, value arg1, value arg2);
+CAMLextern value caml_callback3 (value closure, value arg1, value arg2,
+                                 value arg3);
+CAMLextern value caml_callbackN (value closure, int narg, value args[]);
+
+CAMLextern value caml_callback_exn (value closure, value arg);
+CAMLextern value caml_callback2_exn (value closure, value arg1, value arg2);
+CAMLextern value caml_callback3_exn (value closure,
+                                     value arg1, value arg2, value arg3);
+CAMLextern value caml_callbackN_exn (value closure, int narg, value args[]);
+
+#define Make_exception_result(v) ((v) | 2)
+#define Is_exception_result(v) (((v) & 3) == 2)
+#define Extract_exception(v) ((v) & ~3)
+
+CAMLextern value * caml_named_value (char const * name);
+
+CAMLextern void caml_main (char ** argv);
+CAMLextern void caml_startup (char ** argv);
+
+CAMLextern int caml_callback_depth;
+
+#endif

jni/caml/compatibility.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*          Damien Doligez, projet Moscova, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 2003 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: compatibility.h 8953 2008-07-28 11:59:55Z doligez $ */
+
+/* definitions for compatibility with old identifiers */
+
+#ifndef CAML_COMPATIBILITY_H
+#define CAML_COMPATIBILITY_H
+
+#ifndef CAML_NAME_SPACE
+
+/*
+   #define --> CAMLextern  (defined with CAMLexport or CAMLprim)
+   (rien)  --> CAMLprim
+   g       --> global C identifier
+   x       --> special case
+
+   SP* signals the special cases:
+   - when the identifier was not simply prefixed with [caml_]
+   - when the [caml_] version was already used for something else, and
+     was renamed out of the way (watch out for [caml_alloc] and
+     [caml_array_bound_error] in *.s)
+*/
+
+/* a faire:
+   - ui_*   (reverifier que win32.c n'en depend pas)
+*/
+
+
+/* **** alloc.c */
+#define alloc caml_alloc /*SP*/
+#define alloc_small caml_alloc_small
+#define alloc_tuple caml_alloc_tuple
+#define alloc_string caml_alloc_string
+#define alloc_final caml_alloc_final
+#define copy_string caml_copy_string
+#define alloc_array caml_alloc_array
+#define copy_string_array caml_copy_string_array
+#define convert_flag_list caml_convert_flag_list
+
+/* **** array.c */
+
+/* **** backtrace.c */
+#define backtrace_active caml_backtrace_active
+#define backtrace_pos caml_backtrace_pos
+#define backtrace_buffer caml_backtrace_buffer
+#define backtrace_last_exn caml_backtrace_last_exn
+#define print_exception_backtrace caml_print_exception_backtrace
+
+/* **** callback.c */
+#define callback_depth caml_callback_depth
+#define callbackN_exn caml_callbackN_exn
+#define callback_exn caml_callback_exn
+#define callback2_exn caml_callback2_exn
+#define callback3_exn caml_callback3_exn
+#define callback caml_callback
+#define callback2 caml_callback2
+#define callback3 caml_callback3
+#define callbackN caml_callbackN
+
+/* **** compact.c */
+
+/* **** compare.c */
+#define compare_unordered caml_compare_unordered
+
+/* **** custom.c */
+#define alloc_custom caml_alloc_custom
+#define register_custom_operations caml_register_custom_operations
+
+/* **** debugger.c */
+
+/* **** dynlink.c */
+
+/* **** extern.c */
+#define output_val caml_output_val
+#define output_value_to_malloc caml_output_value_to_malloc
+#define output_value_to_block caml_output_value_to_block
+#define serialize_int_1 caml_serialize_int_1
+#define serialize_int_2 caml_serialize_int_2
+#define serialize_int_4 caml_serialize_int_4
+#define serialize_int_8 caml_serialize_int_8
+#define serialize_float_4 caml_serialize_float_4
+#define serialize_float_8 caml_serialize_float_8
+#define serialize_block_1 caml_serialize_block_1
+#define serialize_block_2 caml_serialize_block_2
+#define serialize_block_4 caml_serialize_block_4
+#define serialize_block_8 caml_serialize_block_8
+#define serialize_block_float_8 caml_serialize_block_float_8
+
+/* **** fail.c */
+#define external_raise caml_external_raise
+#define mlraise caml_raise /*SP*/
+#define raise_constant caml_raise_constant
+#define raise_with_arg caml_raise_with_arg
+#define raise_with_string caml_raise_with_string
+#define failwith caml_failwith
+#define invalid_argument caml_invalid_argument
+#define array_bound_error caml_array_bound_error /*SP*/
+#define raise_out_of_memory caml_raise_out_of_memory
+#define raise_stack_overflow caml_raise_stack_overflow
+#define raise_sys_error caml_raise_sys_error
+#define raise_end_of_file caml_raise_end_of_file
+#define raise_zero_divide caml_raise_zero_divide
+#define raise_not_found caml_raise_not_found
+#define raise_sys_blocked_io caml_raise_sys_blocked_io
+#define init_exceptions caml_init_exceptions
+/* **** asmrun/fail.c */
+/* **** asmrun/<arch>.s */
+
+/* **** finalise.c */
+
+/* **** fix_code.c */
+
+/* **** floats.c */
+/*#define Double_val caml_Double_val             done in mlvalues.h as needed */
+/*#define Store_double_val caml_Store_double_val done in mlvalues.h as needed */
+#define copy_double caml_copy_double
+
+/* **** freelist.c */
+
+/* **** gc_ctrl.c */
+
+/* **** globroots.c */
+#define register_global_root caml_register_global_root
+#define remove_global_root caml_remove_global_root
+
+/* **** hash.c */
+#define hash_variant caml_hash_variant
+
+/* **** instrtrace.c */
+
+/* **** intern.c */
+#define input_val caml_input_val
+#define input_val_from_string caml_input_val_from_string
+#define input_value_from_malloc caml_input_value_from_malloc
+#define input_value_from_block caml_input_value_from_block
+#define deserialize_uint_1 caml_deserialize_uint_1
+#define deserialize_sint_1 caml_deserialize_sint_1
+#define deserialize_uint_2 caml_deserialize_uint_2
+#define deserialize_sint_2 caml_deserialize_sint_2
+#define deserialize_uint_4 caml_deserialize_uint_4
+#define deserialize_sint_4 caml_deserialize_sint_4
+#define deserialize_uint_8 caml_deserialize_uint_8
+#define deserialize_sint_8 caml_deserialize_sint_8
+#define deserialize_float_4 caml_deserialize_float_4
+#define deserialize_float_8 caml_deserialize_float_8
+#define deserialize_block_1 caml_deserialize_block_1
+#define deserialize_block_2 caml_deserialize_block_2
+#define deserialize_block_4 caml_deserialize_block_4
+#define deserialize_block_8 caml_deserialize_block_8
+#define deserialize_block_float_8 caml_deserialize_block_float_8
+#define deserialize_error caml_deserialize_error
+
+/* **** interp.c */
+
+/* **** ints.c */
+#define int32_ops caml_int32_ops
+#define copy_int32 caml_copy_int32
+/*#define Int64_val caml_Int64_val   *** done in mlvalues.h as needed */
+#define int64_ops caml_int64_ops
+#define copy_int64 caml_copy_int64
+#define nativeint_ops caml_nativeint_ops
+#define copy_nativeint caml_copy_nativeint
+
+/* **** io.c */
+#define channel_mutex_free caml_channel_mutex_free
+#define channel_mutex_lock caml_channel_mutex_lock
+#define channel_mutex_unlock caml_channel_mutex_unlock
+#define channel_mutex_unlock_exn caml_channel_mutex_unlock_exn
+#define all_opened_channels caml_all_opened_channels
+#define open_descriptor_in caml_open_descriptor_in /*SP*/
+#define open_descriptor_out caml_open_descriptor_out /*SP*/
+#define close_channel caml_close_channel /*SP*/
+#define channel_size caml_channel_size /*SP*/
+#define channel_binary_mode caml_channel_binary_mode
+#define flush_partial caml_flush_partial /*SP*/
+#define flush caml_flush /*SP*/
+#define putword caml_putword
+#define putblock caml_putblock
+#define really_putblock caml_really_putblock
+#define seek_out caml_seek_out /*SP*/
+#define pos_out caml_pos_out /*SP*/
+#define do_read caml_do_read
+#define refill caml_refill
+#define getword caml_getword
+#define getblock caml_getblock
+#define really_getblock caml_really_getblock
+#define seek_in caml_seek_in /*SP*/
+#define pos_in caml_pos_in /*SP*/
+#define input_scan_line caml_input_scan_line /*SP*/
+#define finalize_channel caml_finalize_channel
+#define alloc_channel caml_alloc_channel
+/*#define Val_file_offset caml_Val_file_offset   *** done in io.h as needed */
+/*#define File_offset_val caml_File_offset_val   *** done in io.h as needed */
+
+/* **** lexing.c */
+
+/* **** main.c */
+/* *** no change */
+
+/* **** major_gc.c */
+#define heap_start caml_heap_start
+#define page_table caml_page_table
+
+/* **** md5.c */
+#define md5_string caml_md5_string
+#define md5_chan caml_md5_chan
+#define MD5Init caml_MD5Init
+#define MD5Update caml_MD5Update
+#define MD5Final caml_MD5Final
+#define MD5Transform caml_MD5Transform
+
+/* **** memory.c */
+#define alloc_shr caml_alloc_shr
+#define initialize caml_initialize
+#define modify caml_modify
+#define stat_alloc caml_stat_alloc
+#define stat_free caml_stat_free
+#define stat_resize caml_stat_resize
+
+/* **** meta.c */
+
+/* **** minor_gc.c */
+#define young_start caml_young_start
+#define young_end caml_young_end
+#define young_ptr caml_young_ptr
+#define young_limit caml_young_limit
+#define ref_table caml_ref_table
+#define minor_collection caml_minor_collection
+#define check_urgent_gc caml_check_urgent_gc
+
+/* **** misc.c */
+
+/* **** obj.c */
+
+/* **** parsing.c */
+
+/* **** prims.c */
+
+/* **** printexc.c */
+#define format_caml_exception caml_format_exception /*SP*/
+
+/* **** roots.c */
+#define local_roots caml_local_roots
+#define scan_roots_hook caml_scan_roots_hook
+#define do_local_roots caml_do_local_roots
+
+/* **** signals.c */
+#define pending_signals caml_pending_signals
+#define something_to_do caml_something_to_do
+#define enter_blocking_section_hook caml_enter_blocking_section_hook
+#define leave_blocking_section_hook caml_leave_blocking_section_hook
+#define try_leave_blocking_section_hook caml_try_leave_blocking_section_hook
+#define async_action_hook caml_async_action_hook
+#define enter_blocking_section caml_enter_blocking_section
+#define leave_blocking_section caml_leave_blocking_section
+#define convert_signal_number caml_convert_signal_number
+/* **** asmrun/signals.c */
+#define garbage_collection caml_garbage_collection
+
+/* **** stacks.c */
+#define stack_low caml_stack_low
+#define stack_high caml_stack_high
+#define stack_threshold caml_stack_threshold
+#define extern_sp caml_extern_sp
+#define trapsp caml_trapsp
+#define trap_barrier caml_trap_barrier
+
+/* **** startup.c */
+#define atom_table caml_atom_table
+/* **** asmrun/startup.c */
+#define static_data_start caml_static_data_start
+#define static_data_end caml_static_data_end
+
+/* **** str.c */
+#define string_length caml_string_length
+
+/* **** sys.c */
+#define sys_error caml_sys_error
+#define sys_exit caml_sys_exit
+
+/* **** terminfo.c */
+
+/* **** unix.c  &  win32.c */
+#define search_exe_in_path caml_search_exe_in_path
+
+/* **** weak.c */
+
+/* **** asmcomp/asmlink.ml */
+
+/* **** asmcomp/cmmgen.ml */
+
+/* **** asmcomp/asmlink.ml, asmcomp/cmmgen.ml, asmcomp/compilenv.ml */
+
+/* ************************************************************* */
+
+/* **** otherlibs/bigarray */
+#define int8 caml_ba_int8
+#define uint8 caml_ba_uint8
+#define int16 caml_ba_int16
+#define uint16 caml_ba_uint16
+#define MAX_NUM_DIMS CAML_BA_MAX_NUM_DIMS
+#define caml_bigarray_kind caml_ba_kind
+#define BIGARRAY_FLOAT32 CAML_BA_FLOAT32
+#define BIGARRAY_FLOAT64 CAML_BA_FLOAT64
+#define BIGARRAY_SINT8 CAML_BA_SINT8
+#define BIGARRAY_UINT8 CAML_BA_UINT8
+#define BIGARRAY_SINT16 CAML_BA_SINT16
+#define BIGARRAY_UINT16 CAML_BA_UINT16
+#define BIGARRAY_INT32 CAML_BA_INT32
+#define BIGARRAY_INT64 CAML_BA_INT64
+#define BIGARRAY_CAML_INT CAML_BA_CAML_INT
+#define BIGARRAY_NATIVE_INT CAML_BA_NATIVE_INT
+#define BIGARRAY_COMPLEX32 CAML_BA_COMPLEX32
+#define BIGARRAY_COMPLEX64 CAML_BA_COMPLEX64
+#define BIGARRAY_KIND_MASK CAML_BA_KIND_MASK
+#define caml_bigarray_layout caml_ba_layout
+#define BIGARRAY_C_LAYOUT CAML_BA_C_LAYOUT
+#define BIGARRAY_FORTRAN_LAYOUT CAML_BA_FORTRAN_LAYOUT
+#define BIGARRAY_LAYOUT_MASK CAML_BA_LAYOUT_MASK
+#define caml_bigarray_managed caml_ba_managed
+#define BIGARRAY_EXTERNAL CAML_BA_EXTERNAL
+#define BIGARRAY_MANAGED CAML_BA_MANAGED
+#define BIGARRAY_MAPPED_FILE CAML_BA_MAPPED_FILE
+#define BIGARRAY_MANAGED_MASK CAML_BA_MANAGED_MASK
+#define caml_bigarray_proxy caml_ba_proxy
+#define caml_bigarray caml_ba_array
+#define Bigarray_val Caml_ba_array_val
+#define Data_bigarray_val Caml_ba_data_val
+#define alloc_bigarray caml_ba_alloc
+#define alloc_bigarray_dims caml_ba_alloc_dims
+#define bigarray_map_file caml_ba_map_file
+#define bigarray_unmap_file caml_ba_unmap_file
+#define bigarray_element_size caml_ba_element_size
+#define bigarray_byte_size caml_ba_byte_size
+#define bigarray_deserialize caml_ba_deserialize
+#define MAX_BIGARRAY_MEMORY CAML_BA_MAX_MEMORY
+#define bigarray_create caml_ba_create
+#define bigarray_get_N caml_ba_get_N
+#define bigarray_get_1 caml_ba_get_1
+#define bigarray_get_2 caml_ba_get_2
+#define bigarray_get_3 caml_ba_get_3
+#define bigarray_get_generic caml_ba_get_generic
+#define bigarray_set_1 caml_ba_set_1
+#define bigarray_set_2 caml_ba_set_2
+#define bigarray_set_3 caml_ba_set_3
+#define bigarray_set_N caml_ba_set_N
+#define bigarray_set_generic caml_ba_set_generic
+#define bigarray_num_dims caml_ba_num_dims
+#define bigarray_dim caml_ba_dim
+#define bigarray_kind caml_ba_kind
+#define bigarray_layout caml_ba_layout
+#define bigarray_slice caml_ba_slice
+#define bigarray_sub caml_ba_sub
+#define bigarray_blit caml_ba_blit
+#define bigarray_fill caml_ba_fill
+#define bigarray_reshape caml_ba_reshape
+#define bigarray_init caml_ba_init
+
+#endif /* CAML_NAME_SPACE */
+#endif /* CAML_COMPATIBILITY_H */

jni/caml/config.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: config.h 9153 2008-12-03 18:09:09Z doligez $ */
+
+#ifndef CAML_CONFIG_H
+#define CAML_CONFIG_H
+
+#ifndef __PIC__
+#  define ARCH_CODE32
+#endif
+#define ARCH_SIXTYFOUR
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 8
+#define SIZEOF_PTR 8
+#define SIZEOF_SHORT 2
+#define ARCH_INT64_TYPE long
+#define ARCH_UINT64_TYPE unsigned long
+#define ARCH_INT64_PRINTF_FORMAT "l"
+#undef ARCH_BIG_ENDIAN
+#undef ARCH_ALIGN_DOUBLE
+#undef ARCH_ALIGN_INT64
+#undef NONSTANDARD_DIV_MOD
+#define OCAML_OS_TYPE "Unix"
+#define OCAML_STDLIB_DIR "/usr/lib64/ocaml"
+#define POSIX_SIGNALS
+#define HAS_GETRUSAGE
+#define HAS_TIMES
+#define HAS_TERMCAP
+#define HAS_SOCKETS
+#define HAS_SOCKLEN_T
+#define HAS_INET_ATON
+#define HAS_IPV6
+#define HAS_UNISTD
+#define HAS_OFF_T
+#define HAS_DIRENT
+#define HAS_REWINDDIR
+#define HAS_LOCKF
+#define HAS_MKFIFO
+#define HAS_GETCWD
+#define HAS_GETWD
+#define HAS_GETPRIORITY
+#define HAS_UTIME
+#define HAS_UTIMES
+#define HAS_DUP2
+#define HAS_FCHMOD
+#define HAS_TRUNCATE
+#define HAS_SYS_SELECT_H
+#define HAS_SELECT
+#define HAS_SYMLINK
+#define HAS_WAITPID
+#define HAS_WAIT4
+#define HAS_GETGROUPS
+#define HAS_SETGROUPS
+#define HAS_INITGROUPS
+#define HAS_TERMIOS
+#define HAS_ASYNC_IO
+#define HAS_SETITIMER
+#define HAS_GETHOSTNAME
+#define HAS_UNAME
+#define HAS_GETTIMEOFDAY
+#define HAS_MKTIME
+#define HAS_SETSID
+#define HAS_PUTENV
+#define HAS_LOCALE
+#define SUPPORT_DYNAMIC_LINKING
+#define HAS_MMAP
+#define HAS_GETHOSTBYNAME_R 6
+#define HAS_GETHOSTBYADDR_R 8
+#define HAS_STACK_OVERFLOW_DETECTION
+#define HAS_SIGWAIT
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+
+/* Types for signed chars, 32-bit integers, 64-bit integers,
+   native integers (as wide as a pointer type) */
+
+typedef signed char schar;
+
+#if SIZEOF_PTR == SIZEOF_LONG
+/* Standard models: ILP32 or I32LP64 */
+typedef long intnat;
+typedef unsigned long uintnat;
+#define ARCH_INTNAT_PRINTF_FORMAT "l"
+#elif SIZEOF_PTR == SIZEOF_INT
+/* Hypothetical IP32L64 model */
+typedef int intnat;
+typedef unsigned int uintnat;
+#define ARCH_INTNAT_PRINTF_FORMAT ""
+#elif SIZEOF_PTR == 8 && defined(ARCH_INT64_TYPE)
+/* Win64 model: IL32LLP64 */
+typedef ARCH_INT64_TYPE intnat;
+typedef ARCH_UINT64_TYPE uintnat;
+#define ARCH_INTNAT_PRINTF_FORMAT ARCH_INT64_PRINTF_FORMAT
+#else
+#error "No integer type available to represent pointers"
+#endif
+
+#if SIZEOF_INT == 4
+typedef int int32;
+typedef unsigned int uint32;
+#define ARCH_INT32_PRINTF_FORMAT ""
+#elif SIZEOF_LONG == 4
+typedef long int32;
+typedef unsigned long uint32;
+#define ARCH_INT32_PRINTF_FORMAT "l"
+#elif SIZEOF_SHORT == 4
+typedef short int32;
+typedef unsigned short uint32;
+#define ARCH_INT32_PRINTF_FORMAT ""
+#else
+#error "No 32-bit integer type available"
+#endif
+
+#if defined(ARCH_INT64_TYPE)
+typedef ARCH_INT64_TYPE int64;
+typedef ARCH_UINT64_TYPE uint64;
+#else
+#  ifdef ARCH_BIG_ENDIAN
+typedef struct { uint32 h, l; } uint64, int64;
+#  else
+typedef struct { uint32 l, h; } uint64, int64;
+#  endif
+#endif
+
+/* Endianness of floats */
+
+/* ARCH_FLOAT_ENDIANNESS encodes the byte order of doubles as follows:
+   the value [0xabcdefgh] means that the least significant byte of the
+   float is at byte offset [a], the next lsb at [b], ..., and the
+   most significant byte at [h]. */
+
+#if defined(__arm__) && !defined(__ARM_EABI__)
+#define ARCH_FLOAT_ENDIANNESS 0x45670123
+#elif defined(ARCH_BIG_ENDIAN)
+#define ARCH_FLOAT_ENDIANNESS 0x76543210
+#else
+#define ARCH_FLOAT_ENDIANNESS 0x01234567
+#endif
+
+/* We use threaded code interpretation if the compiler provides labels
+   as first-class values (GCC 2.x). */
+
+#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(DEBUG) && !defined (SHRINKED_GNUC) && !defined(CAML_JIT)
+#define THREADED_CODE
+#endif
+
+
+/* Do not change this definition. */
+#define Page_size (1 << Page_log)
+
+/* Memory model parameters */
+
+/* The size of a page for memory management (in bytes) is [1 << Page_log].
+   It must be a multiple of [sizeof (value)] and >= 8 and <= 20. */
+#define Page_log 12             /* A page is 4 kilobytes. */
+
+/* Initial size of stack (bytes). */
+#define Stack_size (4096 * sizeof(value))
+
+/* Minimum free size of stack (bytes); below that, it is reallocated. */
+#define Stack_threshold (256 * sizeof(value))
+
+/* Default maximum size of the stack (words). */
+#define Max_stack_def (1024 * 1024)
+
+
+/* Maximum size of a block allocated in the young generation (words). */
+/* Must be > 4 */
+#define Max_young_wosize 256
+
+
+/* Minimum size of the minor zone (words).
+   This must be at least [Max_young_wosize + 1]. */
+#define Minor_heap_min 4096
+
+/* Maximum size of the minor zone (words).
+   Must be greater than or equal to [Minor_heap_min].
+*/
+#define Minor_heap_max (1 << 28)
+
+/* Default size of the minor zone. (words)  */
+#define Minor_heap_def 32768
+
+
+/* Minimum size increment when growing the heap (words).
+   Must be a multiple of [Page_size / sizeof (value)]. */
+#define Heap_chunk_min (2 * Page_size / sizeof (value))
+
+/* Default size increment when growing the heap. (words)
+   Must be a multiple of [Page_size / sizeof (value)].
+   (Approx 512 Kb for a 32-bit platform, 1 Mb for a 64-bit platform.) */
+#define Heap_chunk_def (31 * Page_size)
+
+/* Default initial size of the major heap (words);
+   same constraints as for Heap_chunk_def. */
+#define Init_heap_def (31 * Page_size)
+
+
+/* Default speed setting for the major GC.  The heap will grow until
+   the dead objects and the free list represent this percentage of the
+   total size of live objects. */
+#define Percent_free_def 80
+
+/* Default setting for the compacter: 500%
+   (i.e. trigger the compacter when 5/6 of the heap is free or garbage)
+   This can be set quite high because the overhead is over-estimated
+   when fragmentation occurs.
+ */
+#define Max_percent_free_def 500
+
+
+#endif /* CAML_CONFIG_H */

jni/caml/custom.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Manuel Serrano and Xavier Leroy, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 2000 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: custom.h 9547 2010-01-22 12:48:24Z doligez $ */
+
+#ifndef CAML_CUSTOM_H
+#define CAML_CUSTOM_H
+
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "mlvalues.h"
+
+struct custom_operations {
+  char *identifier;
+  void (*finalize)(value v);
+  int (*compare)(value v1, value v2);
+  intnat (*hash)(value v);
+  void (*serialize)(value v,
+                    /*out*/ uintnat * wsize_32 /*size in bytes*/,
+                    /*out*/ uintnat * wsize_64 /*size in bytes*/);
+  uintnat (*deserialize)(void * dst);
+};
+
+#define custom_finalize_default NULL
+#define custom_compare_default NULL
+#define custom_hash_default NULL
+#define custom_serialize_default NULL
+#define custom_deserialize_default NULL
+
+#define Custom_ops_val(v) (*((struct custom_operations **) (v)))
+
+CAMLextern value caml_alloc_custom(struct custom_operations * ops,
+                                   uintnat size, /*size in bytes*/
+                                   mlsize_t mem, /*resources consumed*/
+                                   mlsize_t max  /*max resources*/);
+
+CAMLextern void caml_register_custom_operations(struct custom_operations * ops);
+
+CAMLextern int caml_compare_unordered;
+  /* Used by custom comparison to report unordered NaN-like cases. */
+
+
+#endif /* CAML_CUSTOM_H */
+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: fail.h 9030 2008-09-18 11:23:28Z xleroy $ */
+
+#ifndef CAML_FAIL_H
+#define CAML_FAIL_H
+
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "misc.h"
+#include "mlvalues.h"
+
+
+CAMLextern void caml_raise (value bucket) Noreturn;
+CAMLextern void caml_raise_constant (value tag) Noreturn;
+CAMLextern void caml_raise_with_arg (value tag, value arg) Noreturn;
+CAMLextern void caml_raise_with_args (value tag, int nargs, value arg[]) Noreturn;
+CAMLextern void caml_raise_with_string (value tag, char const * msg) Noreturn;
+CAMLextern void caml_failwith (char const *) Noreturn;
+CAMLextern void caml_invalid_argument (char const *) Noreturn;
+CAMLextern void caml_raise_out_of_memory (void) Noreturn;
+CAMLextern void caml_raise_stack_overflow (void) Noreturn;
+CAMLextern void caml_raise_sys_error (value) Noreturn;
+CAMLextern void caml_raise_end_of_file (void) Noreturn;
+CAMLextern void caml_raise_zero_divide (void) Noreturn;
+CAMLextern void caml_raise_not_found (void) Noreturn;
+CAMLextern void caml_init_exceptions (void);
+CAMLextern void caml_array_bound_error (void) Noreturn;
+CAMLextern void caml_raise_sys_blocked_io (void) Noreturn;
+
+#endif /* CAML_FAIL_H */

jni/caml/intext.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: intext.h 7064 2005-09-22 14:21:50Z xleroy $ */
+
+/* Structured input/output */
+
+#ifndef CAML_INTEXT_H
+#define CAML_INTEXT_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "misc.h"
+#include "mlvalues.h"
+
+
+CAMLextern void caml_output_value_to_malloc(value v, value flags,
+                                            /*out*/ char ** buf,
+                                            /*out*/ intnat * len);
+  /* Output [v] with flags [flags] to a memory buffer allocated with
+     malloc.  On return, [*buf] points to the buffer and [*len]
+     contains the number of bytes in buffer. */
+CAMLextern intnat caml_output_value_to_block(value v, value flags,
+                                             char * data, intnat len);
+  /* Output [v] with flags [flags] to a user-provided memory buffer.
+     [data] points to the start of this buffer, and [len] is its size
+     in bytes.  Return the number of bytes actually written in buffer.
+     Raise [Failure] if buffer is too short. */
+
+
+CAMLextern value caml_input_val_from_string (value str, intnat ofs);
+  /* Read a structured value from the Caml string [str], starting
+     at offset [ofs]. */
+CAMLextern value caml_input_value_from_malloc(char * data, intnat ofs);
+  /* Read a structured value from a malloced buffer.  [data] points
+     to the beginning of the buffer, and [ofs] is the offset of the
+     beginning of the externed data in this buffer.  The buffer is
+     deallocated with [free] on return, or if an exception is raised. */
+CAMLextern value caml_input_value_from_block(char * data, intnat len);
+  /* Read a structured value from a user-provided buffer.  [data] points
+     to the beginning of the externed data in this buffer,
+     and [len] is the length in bytes of valid data in this buffer.
+     The buffer is never deallocated by this routine. */
+
+/* Functions for writing user-defined marshallers */
+
+CAMLextern void caml_serialize_int_1(int i);
+CAMLextern void caml_serialize_int_2(int i);
+CAMLextern void caml_serialize_int_4(int32 i);
+CAMLextern void caml_serialize_int_8(int64 i);
+CAMLextern void caml_serialize_float_4(float f);
+CAMLextern void caml_serialize_float_8(double f);
+CAMLextern void caml_serialize_block_1(void * data, intnat len);
+CAMLextern void caml_serialize_block_2(void * data, intnat len);
+CAMLextern void caml_serialize_block_4(void * data, intnat len);
+CAMLextern void caml_serialize_block_8(void * data, intnat len);
+CAMLextern void caml_serialize_block_float_8(void * data, intnat len);
+
+CAMLextern int caml_deserialize_uint_1(void);
+CAMLextern int caml_deserialize_sint_1(void);
+CAMLextern int caml_deserialize_uint_2(void);
+CAMLextern int caml_deserialize_sint_2(void);
+CAMLextern uint32 caml_deserialize_uint_4(void);
+CAMLextern int32 caml_deserialize_sint_4(void);
+CAMLextern uint64 caml_deserialize_uint_8(void);
+CAMLextern int64 caml_deserialize_sint_8(void);
+CAMLextern float caml_deserialize_float_4(void);
+CAMLextern double caml_deserialize_float_8(void);
+CAMLextern void caml_deserialize_block_1(void * data, intnat len);
+CAMLextern void caml_deserialize_block_2(void * data, intnat len);
+CAMLextern void caml_deserialize_block_4(void * data, intnat len);
+CAMLextern void caml_deserialize_block_8(void * data, intnat len);
+CAMLextern void caml_deserialize_block_float_8(void * data, intnat len);
+CAMLextern void caml_deserialize_error(char * msg);
+
+
+#endif /* CAML_INTEXT_H */

jni/caml/memory.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*             Damien Doligez, projet Para, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: memory.h 9153 2008-12-03 18:09:09Z doligez $ */
+
+/* Allocation macros and functions */
+
+#ifndef CAML_MEMORY_H
+#define CAML_MEMORY_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "config.h"
+#include "misc.h"
+#include "mlvalues.h"
+
+CAMLextern value caml_alloc_shr (mlsize_t, tag_t);
+CAMLextern void caml_adjust_gc_speed (mlsize_t, mlsize_t);
+CAMLextern void caml_alloc_dependent_memory (mlsize_t);
+CAMLextern void caml_free_dependent_memory (mlsize_t);
+CAMLextern void caml_modify (value *, value);
+CAMLextern void caml_initialize (value *, value);
+CAMLextern value caml_check_urgent_gc (value);
+CAMLextern void * caml_stat_alloc (asize_t);              /* Size in bytes. */
+CAMLextern void caml_stat_free (void *);
+CAMLextern void * caml_stat_resize (void *, asize_t);     /* Size in bytes. */
+char *caml_alloc_for_heap (asize_t request);   /* Size in bytes. */
+void caml_free_for_heap (char *mem);
+int caml_add_to_heap (char *mem);
+color_t caml_allocation_color (void *hp);
+
+/* void caml_shrink_heap (char *);        Only used in compact.c */
+
+
+struct caml__roots_block {
+  struct caml__roots_block *next;
+  intnat ntables;
+  intnat nitems;
+  value *tables [5];
+};
+
+CAMLextern struct caml__roots_block *caml_local_roots;  /* defined in roots.c */
+
+/* The following macros are used to declare C local variables and
+   function parameters of type [value].
+
+   The function body must start with one of the [CAMLparam] macros.
+   If the function has no parameter of type [value], use [CAMLparam0].
+   If the function has 1 to 5 [value] parameters, use the corresponding
+   [CAMLparam] with the parameters as arguments.
+   If the function has more than 5 [value] parameters, use [CAMLparam5]
+   for the first 5 parameters, and one or more calls to the [CAMLxparam]
+   macros for the others.
+   If the function takes an array of [value]s as argument, use
+   [CAMLparamN] to declare it (or [CAMLxparamN] if you already have a
+   call to [CAMLparam] for some other arguments).
+
+   If you need local variables of type [value], declare them with one
+   or more calls to the [CAMLlocal] macros at the beginning of the
+   function. Use [CAMLlocalN] (at the beginning of the function) to
+   declare an array of [value]s.
+
+   Your function may raise an exception or return a [value] with the
+   [CAMLreturn] macro.  Its argument is simply the [value] returned by
+   your function.  Do NOT directly return a [value] with the [return]
+   keyword.  If your function returns void, use [CAMLreturn0].
+
+   All the identifiers beginning with "caml__" are reserved by Caml.
+   Do not use them for anything (local or global variables, struct or
+   union tags, macros, etc.)
+*/
+
+#define CAMLparam0() \
+  struct caml__roots_block *caml__frame = caml_local_roots
+
+#define CAMLparam1(x) \
+  CAMLparam0 (); \
+  CAMLxparam1 (x)
+
+#define CAMLparam2(x, y) \
+  CAMLparam0 (); \
+  CAMLxparam2 (x, y)
+
+#define CAMLparam3(x, y, z) \
+  CAMLparam0 (); \
+  CAMLxparam3 (x, y, z)
+
+#define CAMLparam4(x, y, z, t) \
+  CAMLparam0 (); \
+  CAMLxparam4 (x, y, z, t)
+
+#define CAMLparam5(x, y, z, t, u) \
+  CAMLparam0 (); \
+  CAMLxparam5 (x, y, z, t, u)
+
+#define CAMLparamN(x, size) \
+  CAMLparam0 (); \
+  CAMLxparamN (x, (size))
+
+
+#if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
+  #define CAMLunused __attribute__ ((unused))
+#else
+  #define CAMLunused
+#endif
+
+#define CAMLxparam1(x) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = 1), \
+    (caml__roots_##x.ntables = 1), \
+    (caml__roots_##x.tables [0] = &x), \
+    0)
+
+#define CAMLxparam2(x, y) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = 1), \
+    (caml__roots_##x.ntables = 2), \
+    (caml__roots_##x.tables [0] = &x), \
+    (caml__roots_##x.tables [1] = &y), \
+    0)
+
+#define CAMLxparam3(x, y, z) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = 1), \
+    (caml__roots_##x.ntables = 3), \
+    (caml__roots_##x.tables [0] = &x), \
+    (caml__roots_##x.tables [1] = &y), \
+    (caml__roots_##x.tables [2] = &z), \
+    0)
+
+#define CAMLxparam4(x, y, z, t) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = 1), \
+    (caml__roots_##x.ntables = 4), \
+    (caml__roots_##x.tables [0] = &x), \
+    (caml__roots_##x.tables [1] = &y), \
+    (caml__roots_##x.tables [2] = &z), \
+    (caml__roots_##x.tables [3] = &t), \
+    0)
+
+#define CAMLxparam5(x, y, z, t, u) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = 1), \
+    (caml__roots_##x.ntables = 5), \
+    (caml__roots_##x.tables [0] = &x), \
+    (caml__roots_##x.tables [1] = &y), \
+    (caml__roots_##x.tables [2] = &z), \
+    (caml__roots_##x.tables [3] = &t), \
+    (caml__roots_##x.tables [4] = &u), \
+    0)
+
+#define CAMLxparamN(x, size) \
+  struct caml__roots_block caml__roots_##x; \
+  CAMLunused int caml__dummy_##x = ( \
+    (caml__roots_##x.next = caml_local_roots), \
+    (caml_local_roots = &caml__roots_##x), \
+    (caml__roots_##x.nitems = (size)), \
+    (caml__roots_##x.ntables = 1), \
+    (caml__roots_##x.tables[0] = &(x[0])), \
+    0)
+
+#define CAMLlocal1(x) \
+  value x = 0; \
+  CAMLxparam1 (x)
+
+#define CAMLlocal2(x, y) \
+  value x = 0, y = 0; \
+  CAMLxparam2 (x, y)
+
+#define CAMLlocal3(x, y, z) \
+  value x = 0, y = 0, z = 0; \
+  CAMLxparam3 (x, y, z)
+
+#define CAMLlocal4(x, y, z, t) \
+  value x = 0, y = 0, z = 0, t = 0; \
+  CAMLxparam4 (x, y, z, t)
+
+#define CAMLlocal5(x, y, z, t, u) \
+  value x = 0, y = 0, z = 0, t = 0, u = 0; \
+  CAMLxparam5 (x, y, z, t, u)
+
+#define CAMLlocalN(x, size) \
+  value x [(size)] = { 0, /* 0, 0, ... */ }; \
+  CAMLxparamN (x, (size))
+
+
+#define CAMLreturn0 do{ \
+  caml_local_roots = caml__frame; \
+  return; \
+}while (0)
+
+#define CAMLreturnT(type, result) do{ \
+  type caml__temp_result = (result); \
+  caml_local_roots = caml__frame; \
+  return (caml__temp_result); \
+}while(0)
+
+#define CAMLreturn(result) CAMLreturnT(value, result)
+
+#define CAMLnoreturn ((void) caml__frame)
+
+
+/* convenience macro */
+#define Store_field(block, offset, val) do{ \
+  mlsize_t caml__temp_offset = (offset); \
+  value caml__temp_val = (val); \
+  caml_modify (&Field ((block), caml__temp_offset), caml__temp_val); \
+}while(0)
+
+/*
+   NOTE: [Begin_roots] and [End_roots] are superseded by [CAMLparam]*,
+   [CAMLxparam]*, [CAMLlocal]*, [CAMLreturn].
+
+   [Begin_roots] and [End_roots] are used for C variables that are GC roots.
+   It must contain all values in C local variables and function parameters
+   at the time the minor GC is called.
+   Usage:
+   After initialising your local variables to legal Caml values, but before
+   calling allocation functions, insert [Begin_roots_n(v1, ... vn)], where
+   v1 ... vn are your variables of type [value] that you want to be updated
+   across allocations.
+   At the end, insert [End_roots()].
+
+   Note that [Begin_roots] opens a new block, and [End_roots] closes it.
+   Thus they must occur in matching pairs at the same brace nesting level.
+
+   You can use [Val_unit] as a dummy initial value for your variables.
+*/
+
+#define Begin_root Begin_roots1
+
+#define Begin_roots1(r0) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = 1; \
+  caml__roots_block.ntables = 1; \
+  caml__roots_block.tables[0] = &(r0);
+
+#define Begin_roots2(r0, r1) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = 1; \
+  caml__roots_block.ntables = 2; \
+  caml__roots_block.tables[0] = &(r0); \
+  caml__roots_block.tables[1] = &(r1);
+
+#define Begin_roots3(r0, r1, r2) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = 1; \
+  caml__roots_block.ntables = 3; \
+  caml__roots_block.tables[0] = &(r0); \
+  caml__roots_block.tables[1] = &(r1); \
+  caml__roots_block.tables[2] = &(r2);
+
+#define Begin_roots4(r0, r1, r2, r3) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = 1; \
+  caml__roots_block.ntables = 4; \
+  caml__roots_block.tables[0] = &(r0); \
+  caml__roots_block.tables[1] = &(r1); \
+  caml__roots_block.tables[2] = &(r2); \
+  caml__roots_block.tables[3] = &(r3);
+
+#define Begin_roots5(r0, r1, r2, r3, r4) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = 1; \
+  caml__roots_block.ntables = 5; \
+  caml__roots_block.tables[0] = &(r0); \
+  caml__roots_block.tables[1] = &(r1); \
+  caml__roots_block.tables[2] = &(r2); \
+  caml__roots_block.tables[3] = &(r3); \
+  caml__roots_block.tables[4] = &(r4);
+
+#define Begin_roots_block(table, size) { \
+  struct caml__roots_block caml__roots_block; \
+  caml__roots_block.next = caml_local_roots; \
+  caml_local_roots = &caml__roots_block; \
+  caml__roots_block.nitems = (size); \
+  caml__roots_block.ntables = 1; \
+  caml__roots_block.tables[0] = (table);
+
+#define End_roots() caml_local_roots = caml__roots_block.next; }
+
+
+/* [caml_register_global_root] registers a global C variable as a memory root
+   for the duration of the program, or until [caml_remove_global_root] is
+   called. */
+
+CAMLextern void caml_register_global_root (value *);
+
+/* [caml_remove_global_root] removes a memory root registered on a global C
+   variable with [caml_register_global_root]. */
+
+CAMLextern void caml_remove_global_root (value *);
+
+/* [caml_register_generational_global_root] registers a global C
+   variable as a memory root for the duration of the program, or until
+   [caml_remove_generational_global_root] is called.
+   The program guarantees that the value contained in this variable
+   will not be assigned directly.  If the program needs to change
+   the value of this variable, it must do so by calling
+   [caml_modify_generational_global_root].  The [value *] pointer
+   passed to [caml_register_generational_global_root] must contain
+   a valid Caml value before the call.
+   In return for these constraints, scanning of memory roots during
+   minor collection is made more efficient. */
+
+CAMLextern void caml_register_generational_global_root (value *);
+
+/* [caml_remove_generational_global_root] removes a memory root
+   registered on a global C variable with
+   [caml_register_generational_global_root]. */
+
+CAMLextern void caml_remove_generational_global_root (value *);
+
+/* [caml_modify_generational_global_root(r, newval)]
+   modifies the value contained in [r], storing [newval] inside.
+   In other words, the assignment [*r = newval] is performed,
+   but in a way that is compatible with the optimized scanning of
+   generational global roots.  [r] must be a global memory root
+   previously registered with [caml_register_generational_global_root]. */
+
+CAMLextern void caml_modify_generational_global_root(value *r, value newval);
+
+#endif /* CAML_MEMORY_H */
+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: misc.h 8822 2008-02-29 12:56:15Z doligez $ */
+
+/* Miscellaneous macros and variables. */
+
+#ifndef CAML_MISC_H
+#define CAML_MISC_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "config.h"
+
+/* Standard definitions */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+/* Basic types and constants */
+
+typedef size_t asize_t;
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+
+#ifdef __GNUC__
+  /* Works only in GCC 2.5 and later */
+  #define Noreturn __attribute__ ((noreturn))
+#else
+  #define Noreturn
+#endif
+
+/* Export control (to mark primitives and to handle Windows DLL) */
+
+#define CAMLexport
+#define CAMLprim
+#define CAMLextern extern
+
+/* Assertions */
+
+
+#endif /* CAML_MISC_H */

jni/caml/mlvalues.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: mlvalues.h 8970 2008-08-01 14:10:36Z xleroy $ */
+
+#ifndef CAML_MLVALUES_H
+#define CAML_MLVALUES_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "config.h"
+#include "misc.h"
+
+/* Definitions
+
+  word: Four bytes on 32 and 16 bit architectures,
+        eight bytes on 64 bit architectures.
+  long: A C integer having the same number of bytes as a word.
+  val: The ML representation of something.  A long or a block or a pointer
+       outside the heap.  If it is a block, it is the (encoded) address
+       of an object.  If it is a long, it is encoded as well.
+  block: Something allocated.  It always has a header and some
+          fields or some number of bytes (a multiple of the word size).
+  field: A word-sized val which is part of a block.
+  bp: Pointer to the first byte of a block.  (a char *)
+  op: Pointer to the first field of a block.  (a value *)
+  hp: Pointer to the header of a block.  (a char *)
+  int32: Four bytes on all architectures.
+  int64: Eight bytes on all architectures.
+
+  Remark: A block size is always a multiple of the word size, and at least
+          one word plus the header.
+
+  bosize: Size (in bytes) of the "bytes" part.
+  wosize: Size (in words) of the "fields" part.
+  bhsize: Size (in bytes) of the block with its header.
+  whsize: Size (in words) of the block with its header.
+
+  hd: A header.
+  tag: The value of the tag field of the header.
+  color: The value of the color field of the header.
+         This is for use only by the GC.
+*/
+
+typedef intnat value;
+typedef uintnat header_t;
+typedef uintnat mlsize_t;
+typedef unsigned int tag_t;             /* Actually, an unsigned char */
+typedef uintnat color_t;
+typedef uintnat mark_t;
+
+/* Longs vs blocks. */
+#define Is_long(x)   (((x) & 1) != 0)
+#define Is_block(x)  (((x) & 1) == 0)
+
+/* Conversion macro names are always of the form  "to_from". */
+/* Example: Val_long as in "Val from long" or "Val of long". */
+#define Val_long(x)     (((intnat)(x) << 1) + 1)
+#define Long_val(x)     ((x) >> 1)
+#define Max_long (((intnat)1 << (8 * sizeof(value) - 2)) - 1)
+#define Min_long (-((intnat)1 << (8 * sizeof(value) - 2)))
+#define Val_int(x) Val_long(x)
+#define Int_val(x) ((int) Long_val(x))
+#define Unsigned_long_val(x) ((uintnat)(x) >> 1)
+#define Unsigned_int_val(x)  ((int) Unsigned_long_val(x))
+
+/* Structure of the header:
+
+For 16-bit and 32-bit architectures:
+     +--------+-------+-----+
+     | wosize | color | tag |
+     +--------+-------+-----+
+bits  31    10 9     8 7   0
+
+For 64-bit architectures:
+
+     +--------+-------+-----+
+     | wosize | color | tag |
+     +--------+-------+-----+
+bits  63    10 9     8 7   0
+
+*/
+
+#define Tag_hd(hd) ((tag_t) ((hd) & 0xFF))
+#define Wosize_hd(hd) ((mlsize_t) ((hd) >> 10))
+
+#define Hd_val(val) (((header_t *) (val)) [-1])        /* Also an l-value. */
+#define Hd_op(op) (Hd_val (op))                        /* Also an l-value. */
+#define Hd_bp(bp) (Hd_val (bp))                        /* Also an l-value. */
+#define Hd_hp(hp) (* ((header_t *) (hp)))              /* Also an l-value. */
+#define Hp_val(val) ((char *) (((header_t *) (val)) - 1))
+#define Hp_op(op) (Hp_val (op))
+#define Hp_bp(bp) (Hp_val (bp))
+#define Val_op(op) ((value) (op))
+#define Val_hp(hp) ((value) (((header_t *) (hp)) + 1))
+#define Op_hp(hp) ((value *) Val_hp (hp))
+#define Bp_hp(hp) ((char *) Val_hp (hp))
+
+#define Num_tags (1 << 8)
+#ifdef ARCH_SIXTYFOUR
+#define Max_wosize (((intnat)1 << 54) - 1)
+#else
+#define Max_wosize ((1 << 22) - 1)
+#endif
+
+#define Wosize_val(val) (Wosize_hd (Hd_val (val)))
+#define Wosize_op(op) (Wosize_val (op))
+#define Wosize_bp(bp) (Wosize_val (bp))
+#define Wosize_hp(hp) (Wosize_hd (Hd_hp (hp)))
+#define Whsize_wosize(sz) ((sz) + 1)
+#define Wosize_whsize(sz) ((sz) - 1)
+#define Wosize_bhsize(sz) ((sz) / sizeof (value) - 1)
+#define Bsize_wsize(sz) ((sz) * sizeof (value))
+#define Wsize_bsize(sz) ((sz) / sizeof (value))
+#define Bhsize_wosize(sz) (Bsize_wsize (Whsize_wosize (sz)))
+#define Bhsize_bosize(sz) ((sz) + sizeof (header_t))
+#define Bosize_val(val) (Bsize_wsize (Wosize_val (val)))
+#define Bosize_op(op) (Bosize_val (Val_op (op)))
+#define Bosize_bp(bp) (Bosize_val (Val_bp (bp)))
+#define Bosize_hd(hd) (Bsize_wsize (Wosize_hd (hd)))
+#define Whsize_hp(hp) (Whsize_wosize (Wosize_hp (hp)))
+#define Whsize_val(val) (Whsize_hp (Hp_val (val)))
+#define Whsize_bp(bp) (Whsize_val (Val_bp (bp)))
+#define Whsize_hd(hd) (Whsize_wosize (Wosize_hd (hd)))
+#define Bhsize_hp(hp) (Bsize_wsize (Whsize_hp (hp)))
+#define Bhsize_hd(hd) (Bsize_wsize (Whsize_hd (hd)))
+
+#ifdef ARCH_BIG_ENDIAN
+#define Tag_val(val) (((unsigned char *) (val)) [-1])
+                                                 /* Also an l-value. */
+#define Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(value)-1])
+                                                 /* Also an l-value. */
+#else
+#define Tag_val(val) (((unsigned char *) (val)) [-sizeof(value)])
+                                                 /* Also an l-value. */
+#define Tag_hp(hp) (((unsigned char *) (hp)) [0])
+                                                 /* Also an l-value. */
+#endif
+
+/* The lowest tag for blocks containing no value. */
+#define No_scan_tag 251
+
+
+/* 1- If tag < No_scan_tag : a tuple of fields.  */
+
+/* Pointer to the first field. */
+#define Op_val(x) ((value *) (x))
+/* Fields are numbered from 0. */
+#define Field(x, i) (((value *)(x)) [i])           /* Also an l-value. */
+
+typedef int32 opcode_t;
+typedef opcode_t * code_t;
+
+/* NOTE: [Forward_tag] and [Infix_tag] must be just under
+   [No_scan_tag], with [Infix_tag] the lower one.
+   See [caml_oldify_one] in minor_gc.c for more details.
+
+   NOTE: Update stdlib/obj.ml whenever you change the tags.
+ */
+
+/* Forward_tag: forwarding pointer that the GC may silently shortcut.
+   See stdlib/lazy.ml. */
+#define Forward_tag 250
+#define Forward_val(v) Field(v, 0)
+
+/* If tag == Infix_tag : an infix header inside a closure */
+/* Infix_tag must be odd so that the infix header is scanned as an integer */
+/* Infix_tag must be 1 modulo 4 and infix headers can only occur in blocks
+   with tag Closure_tag (see compact.c). */
+
+#define Infix_tag 249
+#define Infix_offset_hd(hd) (Bosize_hd(hd))
+#define Infix_offset_val(v) Infix_offset_hd(Hd_val(v))
+
+/* Another special case: objects */
+#define Object_tag 248
+#define Class_val(val) Field((val), 0)
+#define Oid_val(val) Long_val(Field((val), 1))
+CAMLextern value caml_get_public_method (value obj, value tag);
+/* Called as:
+   caml_callback(caml_get_public_method(obj, caml_hash_variant(name)), obj) */
+/* caml_get_public_method returns 0 if tag not in the table.
+   Note however that tags being hashed, same tag does not necessarily mean
+   same method name. */
+
+/* Special case of tuples of fields: closures */
+#define Closure_tag 247
+#define Code_val(val) (((code_t *) (val)) [0])     /* Also an l-value. */
+
+/* This tag is used (with Forward_tag) to implement lazy values.
+   See major_gc.c and stdlib/lazy.ml. */
+#define Lazy_tag 246
+
+/* Another special case: variants */
+CAMLextern value caml_hash_variant(char const * tag);
+
+/* 2- If tag >= No_scan_tag : a sequence of bytes. */
+
+/* Pointer to the first byte */
+#define Bp_val(v) ((char *) (v))
+#define Val_bp(p) ((value) (p))
+/* Bytes are numbered from 0. */
+#define Byte(x, i) (((char *) (x)) [i])            /* Also an l-value. */
+#define Byte_u(x, i) (((unsigned char *) (x)) [i]) /* Also an l-value. */
+
+/* Abstract things.  Their contents is not traced by the GC; therefore they
+   must not contain any [value].
+*/
+#define Abstract_tag 251
+
+/* Strings. */
+#define String_tag 252
+#define String_val(x) ((char *) Bp_val(x))
+CAMLextern mlsize_t caml_string_length (value);   /* size in bytes */
+
+/* Floating-point numbers. */
+#define Double_tag 253
+#define Double_wosize ((sizeof(double) / sizeof(value)))
+#ifndef ARCH_ALIGN_DOUBLE
+#define Double_val(v) (* (double *)(v))
+#define Store_double_val(v,d) (* (double *)(v) = (d))
+#else
+CAMLextern double caml_Double_val (value);
+CAMLextern void caml_Store_double_val (value,double);
+#define Double_val(v) caml_Double_val(v)
+#define Store_double_val(v,d) caml_Store_double_val(v,d)
+#endif
+
+/* Arrays of floating-point numbers. */
+#define Double_array_tag 254
+#define Double_field(v,i) Double_val((value)((double *)(v) + (i)))
+#define Store_double_field(v,i,d) do{ \
+  mlsize_t caml__temp_i = (i); \
+  double caml__temp_d = (d); \
+  Store_double_val((value)((double *) (v) + caml__temp_i), caml__temp_d); \
+}while(0)
+
+/* Custom blocks.  They contain a pointer to a "method suite"
+   of functions (for finalization, comparison, hashing, etc)
+   followed by raw data.  The contents of custom blocks is not traced by
+   the GC; therefore, they must not contain any [value].
+   See [custom.h] for operations on method suites. */
+#define Custom_tag 255
+#define Data_custom_val(v) ((void *) &Field((v), 1))
+struct custom_operations;       /* defined in [custom.h] */
+
+/* Int32.t, Int64.t and Nativeint.t are represented as custom blocks. */
+
+#define Int32_val(v) (*((int32 *) Data_custom_val(v)))
+#define Nativeint_val(v) (*((intnat *) Data_custom_val(v)))
+#ifndef ARCH_ALIGN_INT64
+#define Int64_val(v) (*((int64 *) Data_custom_val(v)))
+#else
+CAMLextern int64 caml_Int64_val(value v);
+#define Int64_val(v) caml_Int64_val(v)
+#endif
+
+/* 3- Atoms are 0-tuples.  They are statically allocated once and for all. */
+
+CAMLextern header_t caml_atom_table[];
+#define Atom(tag) (Val_hp (&(caml_atom_table [(tag)])))
+
+/* Booleans are integers 0 or 1 */
+
+#define Val_bool(x) Val_int((x) != 0)
+#define Bool_val(x) Int_val(x)
+#define Val_false Val_int(0)
+#define Val_true Val_int(1)
+#define Val_not(x) (Val_false + Val_true - (x))
+
+/* The unit value is 0 (tagged) */
+
+#define Val_unit Val_int(0)
+
+/* List constructors */
+#define Val_emptylist Val_int(0)
+#define Tag_cons 0
+
+/* The table of global identifiers */
+
+extern value caml_global_data;
+
+
+#endif /* CAML_MLVALUES_H */

jni/caml/printexc.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 2001 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: printexc.h 6045 2004-01-01 16:42:43Z doligez $ */
+
+#ifndef CAML_PRINTEXC_H
+#define CAML_PRINTEXC_H
+
+
+#include "misc.h"
+#include "mlvalues.h"
+
+CAMLextern char * caml_format_exception (value);
+void caml_fatal_uncaught_exception (value) Noreturn;
+
+
+#endif /* CAML_PRINTEXC_H */

jni/caml/signals.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: signals.h 7904 2007-02-23 09:29:45Z xleroy $ */
+
+#ifndef CAML_SIGNALS_H
+#define CAML_SIGNALS_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "misc.h"
+#include "mlvalues.h"
+
+
+CAMLextern void caml_enter_blocking_section (void);
+CAMLextern void caml_leave_blocking_section (void);
+
+
+#endif /* CAML_SIGNALS_H */

jni/caml/socketaddr.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../../LICENSE.  */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: socketaddr.h 6824 2005-03-24 17:20:54Z doligez $ */
+
+#include <misc.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+union sock_addr_union {
+  struct sockaddr s_gen;
+  struct sockaddr_un s_unix;
+  struct sockaddr_in s_inet;
+#ifdef HAS_IPV6
+  struct sockaddr_in6 s_inet6;
+#endif
+};
+
+#ifdef HAS_SOCKLEN_T
+typedef socklen_t socklen_param_type;
+#else
+typedef int socklen_param_type;
+#endif
+
+extern void get_sockaddr (value mladdr,
+                          union sock_addr_union * addr /*out*/,
+                          socklen_param_type * addr_len /*out*/);
+CAMLexport value alloc_sockaddr (union sock_addr_union * addr /*in*/,
+                      socklen_param_type addr_len, int close_on_error);
+CAMLexport value alloc_inet_addr (struct in_addr * inaddr);
+#define GET_INET_ADDR(v) (*((struct in_addr *) (v)))
+
+#ifdef HAS_IPV6
+CAMLexport value alloc_inet6_addr (struct in6_addr * inaddr);
+#define GET_INET6_ADDR(v) (*((struct in6_addr *) (v)))
+#endif

jni/caml/threads.h

+/***********************************************************************/
+/*                                                                     */
+/*                             Objective Caml                          */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1995 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../../LICENSE.  */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: posix.c 9270 2009-05-20 11:52:42Z doligez $ */
+
+#ifndef CAML_THREADS_H
+#define CAML_THREADS_H
+
+CAMLextern void caml_enter_blocking_section (void);
+CAMLextern void caml_leave_blocking_section (void);
+#define caml_acquire_runtime_system caml_leave_blocking_section
+#define caml_release_runtime_system caml_enter_blocking_section
+
+/* Manage the master lock around the Caml run-time system.
+   Only one thread at a time can execute Caml compiled code or
+   Caml run-time system functions.
+
+   When Caml calls a C function, the current thread holds the master
+   lock.  The C function can release it by calling
+   [caml_release_runtime_system].  Then, another thread can execute Caml
+   code.  However, the calling thread must not access any Caml data,
+   nor call any runtime system function, nor call back into Caml.
+
+   Before returning to its Caml caller, or accessing Caml data,
+   or call runtime system functions, the current thread must
+   re-acquire the master lock by calling [caml_acquire_runtime_system].
+
+   Symmetrically, if a C function (not called from Caml) wishes to
+   call back into Caml code, it should invoke [caml_acquire_runtime_system]
+   first, then do the callback, then invoke [caml_release_runtime_system].
+
+   For historical reasons, alternate names can be used:
+     [caml_enter_blocking_section]  instead of  [caml_release_runtime_system]
+     [caml_leave_blocking_section]  instead of  [caml_acquire_runtime_system]
+   Intuition: a ``blocking section'' is a piece of C code that does not
+   use the runtime system (typically, a blocking I/O operation).
+*/
+
+CAMLextern int caml_c_thread_register(void);
+CAMLextern int caml_c_thread_unregister(void);
+
+/* If a thread is created by C code (instead of by Caml itself),
+   it must be registered with the Caml runtime system before
+   being able to call back into Caml code or use other runtime system
+   functions.  Just call [caml_c_thread_register] once.
+   Before the thread finishes, it must call [caml_c_thread_unregister].
+   Both functions return 1 on success, 0 on error.
+*/
+
+#endif /* CAML_THREADS_H */

jni/caml/unixsupport.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../../LICENSE.  */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: unixsupport.h 7045 2005-09-06 12:38:32Z doligez $ */
+
+#ifdef HAS_UNISTD
+#include <unistd.h>
+#endif
+
+#define Nothing ((value) 0)
+
+extern value unix_error_of_code (int errcode);
+extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
+extern void uerror (char * cmdname, value arg) Noreturn;
+
+#define UNIX_BUFFER_SIZE 16384
+
+#define DIR_Val(v) *((DIR **) &Field(v, 0))

jni/caml/values.h

+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../LICENSE.     */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: mlvalues.h 8970 2008-08-01 14:10:36Z xleroy $ */
+
+#ifndef CAML_MLVALUES_H
+#define CAML_MLVALUES_H
+
+#ifndef CAML_NAME_SPACE
+#include "compatibility.h"
+#endif
+#include "config.h"
+#include "misc.h"
+
+/* Definitions
+
+  word: Four bytes on 32 and 16 bit architectures,
+        eight bytes on 64 bit architectures.
+  long: A C integer having the same number of bytes as a word.
+  val: The ML representation of something.  A long or a block or a pointer
+       outside the heap.  If it is a block, it is the (encoded) address
+       of an object.  If it is a long, it is encoded as well.
+  block: Something allocated.  It always has a header and some
+          fields or some number of bytes (a multiple of the word size).
+  field: A word-sized val which is part of a block.
+  bp: Pointer to the first byte of a block.  (a char *)
+  op: Pointer to the first field of a block.  (a value *)
+  hp: Pointer to the header of a block.  (a char *)
+  int32: Four bytes on all architectures.
+  int64: Eight bytes on all architectures.
+
+  Remark: A block size is always a multiple of the word size, and at least
+          one word plus the header.
+
+  bosize: Size (in bytes) of the "bytes" part.
+  wosize: Size (in words) of the "fields" part.
+  bhsize: Size (in bytes) of the block with its header.
+  whsize: Size (in words) of the block with its header.
+
+  hd: A header.
+  tag: The value of the tag field of the header.
+  color: The value of the color field of the header.
+         This is for use only by the GC.
+*/
+
+typedef intnat value;
+typedef uintnat header_t;
+typedef uintnat mlsize_t;
+typedef unsigned int tag_t;             /* Actually, an unsigned char */
+typedef uintnat color_t;
+typedef uintnat mark_t;
+
+/* Longs vs blocks. */
+#define Is_long(x)   (((x) & 1) != 0)
+#define Is_block(x)  (((x) & 1) == 0)
+
+/* Conversion macro names are always of the form  "to_from". */
+/* Example: Val_long as in "Val from long" or "Val of long". */
+#define Val_long(x)     (((intnat)(x) << 1) + 1)
+#define Long_val(x)     ((x) >> 1)
+#define Max_long (((intnat)1 << (8 * sizeof(value) - 2)) - 1)
+#define Min_long (-((intnat)1 << (8 * sizeof(value) - 2)))
+#define Val_int(x) Val_long(x)
+#define Int_val(x) ((int) Long_val(x))
+#define Unsigned_long_val(x) ((uintnat)(x) >> 1)
+#define Unsigned_int_val(x)  ((int) Unsigned_long_val(x))
+
+/* Structure of the header:
+
+For 16-bit and 32-bit architectures:
+     +--------+-------+-----+
+     | wosize | color | tag |
+     +--------+-------+-----+
+bits  31    10 9     8 7   0
+
+For 64-bit architectures:
+
+     +--------+-------+-----+
+     | wosize | color | tag |
+     +--------+-------+-----+
+bits  63    10 9     8 7   0
+
+*/
+
+#define Tag_hd(hd) ((tag_t) ((hd) & 0xFF))
+#define Wosize_hd(hd) ((mlsize_t) ((hd) >> 10))
+
+#define Hd_val(val) (((header_t *) (val)) [-1])        /* Also an l-value. */
+#define Hd_op(op) (Hd_val (op))                        /* Also an l-value. */
+#define Hd_bp(bp) (Hd_val (bp))                        /* Also an l-value. */
+#define Hd_hp(hp) (* ((header_t *) (hp)))              /* Also an l-value. */
+#define Hp_val(val) ((char *) (((header_t *) (val)) - 1))
+#define Hp_op(op) (Hp_val (op))
+#define Hp_bp(bp) (Hp_val (bp))
+#define Val_op(op) ((value) (op))
+#define Val_hp(hp) ((value) (((header_t *) (hp)) + 1))
+#define Op_hp(hp) ((value *) Val_hp (hp))
+#define Bp_hp(hp) ((char *) Val_hp (hp))
+
+#define Num_tags (1 << 8)
+#ifdef ARCH_SIXTYFOUR
+#define Max_wosize (((intnat)1 << 54) - 1)
+#else
+#define Max_wosize ((1 << 22) - 1)
+#endif
+
+#define Wosize_val(val) (Wosize_hd (Hd_val (val)))
+#define Wosize_op(op) (Wosize_val (op))
+#define Wosize_bp(bp) (Wosize_val (bp))
+#define Wosize_hp(hp) (Wosize_hd (Hd_hp (hp)))
+#define Whsize_wosize(sz) ((sz) + 1)
+#define Wosize_whsize(sz) ((sz) - 1)
+#define Wosize_bhsize(sz) ((sz) / sizeof (value) - 1)
+#define Bsize_wsize(sz) ((sz) * sizeof (value))
+#define Wsize_bsize(sz) ((sz) / sizeof (value))
+#define Bhsize_wosize(sz) (Bsize_wsize (Whsize_wosize (sz)))
+#define Bhsize_bosize(sz) ((sz) + sizeof (header_t))
+#define Bosize_val(val) (Bsize_wsize (Wosize_val (val)))
+#define Bosize_op(op) (Bosize_val (Val_op (op)))
+#define Bosize_bp(bp) (Bosize_val (Val_bp (bp)))
+#define Bosize_hd(hd) (Bsize_wsize (Wosize_hd (hd)))