summaryrefslogtreecommitdiff
path: root/byterun
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2004-01-02 19:23:29 +0000
committerDamien Doligez <damien.doligez-inria.fr>2004-01-02 19:23:29 +0000
commit0c7aecb88dc696f66f49f3bed54a037361a26b8d (patch)
tree32bde8a45b8881d3d121fd39cc1270980f596096 /byterun
parent7ba8c1ca1d044232ed6d81d04a8c46800cf15097 (diff)
downloadocaml-0c7aecb88dc696f66f49f3bed54a037361a26b8d.tar.gz
depollution suite (et fin?) (PR#1914 et PR#1956)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6047 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun')
-rw-r--r--byterun/alloc.h2
-rw-r--r--byterun/array.c8
-rw-r--r--byterun/backtrace.c14
-rw-r--r--byterun/callback.c4
-rw-r--r--byterun/compact.c35
-rw-r--r--byterun/compatibility.h128
-rw-r--r--byterun/debugger.c20
-rw-r--r--byterun/extern.c4
-rw-r--r--byterun/fail.c4
-rw-r--r--byterun/fail.h2
-rw-r--r--byterun/finalise.c14
-rw-r--r--byterun/finalise.h14
-rw-r--r--byterun/fix_code.c46
-rw-r--r--byterun/fix_code.h22
-rw-r--r--byterun/floats.c148
-rw-r--r--byterun/freelist.c78
-rw-r--r--byterun/freelist.h16
-rw-r--r--byterun/gc_ctrl.c89
-rw-r--r--byterun/gc_ctrl.h24
-rw-r--r--byterun/globroots.c4
-rw-r--r--byterun/hash.c5
-rw-r--r--byterun/instrtrace.c12
-rw-r--r--byterun/instrtrace.h8
-rw-r--r--byterun/intern.c12
-rw-r--r--byterun/interp.c14
-rw-r--r--byterun/intext.h6
-rw-r--r--byterun/ints.c10
-rw-r--r--byterun/major_gc.c57
-rw-r--r--byterun/memory.c26
-rw-r--r--byterun/memory.h12
-rw-r--r--byterun/meta.c4
-rw-r--r--byterun/minor_gc.c10
-rw-r--r--byterun/mlvalues.h15
-rw-r--r--byterun/obj.c4
-rw-r--r--byterun/roots.c4
-rw-r--r--byterun/signals.c2
-rw-r--r--byterun/startup.c28
-rw-r--r--byterun/str.c4
-rw-r--r--byterun/sys.c4
39 files changed, 513 insertions, 400 deletions
diff --git a/byterun/alloc.h b/byterun/alloc.h
index 203ff091aa..1cf70c2247 100644
--- a/byterun/alloc.h
+++ b/byterun/alloc.h
@@ -29,7 +29,7 @@ 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 copy_double (double);
+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 (long); /* defined in [ints.c] */
diff --git a/byterun/array.c b/byterun/array.c
index 29847c3b5d..c13c0fed72 100644
--- a/byterun/array.c
+++ b/byterun/array.c
@@ -26,7 +26,7 @@
CAMLprim value caml_array_get_addr(value array, value index)
{
long idx = Long_val(index);
- if (idx < 0 || idx >= Wosize_val(array)) array_bound_error();
+ if (idx < 0 || idx >= Wosize_val(array)) caml_array_bound_error();
return Field(array, idx);
}
@@ -37,7 +37,7 @@ CAMLprim value caml_array_get_float(value array, value index)
value res;
if (idx < 0 || idx >= Wosize_val(array) / Double_wosize)
- array_bound_error();
+ caml_array_bound_error();
d = Double_field(array, idx);
#define Setup_for_gc
#define Restore_after_gc
@@ -59,7 +59,7 @@ CAMLprim value caml_array_get(value array, value index)
CAMLprim value caml_array_set_addr(value array, value index, value newval)
{
long idx = Long_val(index);
- if (idx < 0 || idx >= Wosize_val(array)) array_bound_error();
+ if (idx < 0 || idx >= Wosize_val(array)) caml_array_bound_error();
Modify(&Field(array, idx), newval);
return Val_unit;
}
@@ -68,7 +68,7 @@ CAMLprim value caml_array_set_float(value array, value index, value newval)
{
long idx = Long_val(index);
if (idx < 0 || idx >= Wosize_val(array) / Double_wosize)
- array_bound_error();
+ caml_array_bound_error();
Store_double_field(array, idx, Double_val(newval));
return Val_unit;
}
diff --git a/byterun/backtrace.c b/byterun/backtrace.c
index dd60f993cb..52b51ce286 100644
--- a/byterun/backtrace.c
+++ b/byterun/backtrace.c
@@ -59,7 +59,7 @@ enum {
void caml_init_backtrace(void)
{
caml_backtrace_active = 1;
- register_global_root(&caml_backtrace_last_exn);
+ caml_register_global_root(&caml_backtrace_last_exn);
/* Note: lazy initialization of caml_backtrace_buffer in caml_stash_backtrace
to simplify the interface with the thread libraries */
}
@@ -69,7 +69,7 @@ void caml_init_backtrace(void)
void caml_stash_backtrace(value exn, code_t pc, value * sp)
{
- code_t end_code = (code_t) ((char *) start_code + code_size);
+ code_t end_code = (code_t) ((char *) caml_start_code + caml_code_size);
if (pc != NULL) pc = pc - 1;
if (exn != caml_backtrace_last_exn) {
caml_backtrace_pos = 0;
@@ -80,12 +80,12 @@ void caml_stash_backtrace(value exn, code_t pc, value * sp)
if (caml_backtrace_buffer == NULL) return;
}
if (caml_backtrace_pos >= BACKTRACE_BUFFER_SIZE) return;
- if (pc >= start_code && pc < end_code){
+ if (pc >= caml_start_code && pc < end_code){
caml_backtrace_buffer[caml_backtrace_pos++] = pc;
}
for (/*nothing*/; sp < caml_trapsp; sp++) {
code_t p = (code_t) *sp;
- if (p >= start_code && p < end_code) {
+ if (p >= caml_start_code && p < end_code) {
if (caml_backtrace_pos >= BACKTRACE_BUFFER_SIZE) break;
caml_backtrace_buffer[caml_backtrace_pos++] = p;
}
@@ -144,8 +144,8 @@ static value event_for_location(value events, code_t pc)
mlsize_t i;
value pos, l, ev, ev_pos;
- Assert(pc >= start_code && pc < start_code + code_size);
- pos = Val_long((char *) pc - (char *) start_code);
+ Assert(pc >= caml_start_code && pc < caml_start_code + caml_code_size);
+ pos = Val_long((char *) pc - (char *) caml_start_code);
for (i = 0; i < Wosize_val(events); i++) {
for (l = Field(events, i); l != Val_int(0); l = Field(l, 1)) {
ev = Field(l, 0);
@@ -167,7 +167,7 @@ static void print_location(value events, int index)
value ev;
ev = event_for_location(events, pc);
- if (is_instruction(*pc, RAISE)) {
+ if (caml_is_instruction(*pc, RAISE)) {
/* Ignore compiler-inserted raise */
if (ev == Val_false) return;
/* Initial raise if index == 0, re-raise otherwise */
diff --git a/byterun/callback.c b/byterun/callback.c
index 6e1d8efbb7..84e0c41160 100644
--- a/byterun/callback.c
+++ b/byterun/callback.c
@@ -40,7 +40,7 @@ static int callback_code_threaded = 0;
static void thread_callback(void)
{
- thread_code(callback_code, sizeof(callback_code));
+ caml_thread_code(callback_code, sizeof(callback_code));
callback_code_threaded = 1;
}
@@ -196,7 +196,7 @@ CAMLprim value caml_register_named_value(value vname, value val)
nv->val = val;
nv->next = named_value_table[h];
named_value_table[h] = nv;
- register_global_root(&nv->val);
+ caml_register_global_root(&nv->val);
return Val_unit;
}
diff --git a/byterun/compact.c b/byterun/compact.c
index a72db880d4..b0b39b6015 100644
--- a/byterun/compact.c
+++ b/byterun/compact.c
@@ -42,7 +42,7 @@ extern void caml_shrink_heap (char *); /* memory.c */
XXX Should be fixed:
XXX The above assumes that all roots are aligned on a 4-byte boundary,
XXX which is not always guaranteed by C.
- XXX (see [register_global_roots] and [caml_init_exceptions])
+ XXX (see [caml_register_global_roots] and [caml_init_exceptions])
XXX Should be able to fix it to only assume 2-byte alignment.
*/
#define Make_ehd(s,t,c) (((s) << 10) | (t) << 2 | (c))
@@ -151,7 +151,7 @@ void caml_compact_heap (void)
caml_gc_message (0x10, "Compacting heap...\n", 0);
#ifdef DEBUG
- heap_check ();
+ caml_heap_check ();
#endif
/* First pass: encode all noninfix headers. */
@@ -187,7 +187,7 @@ void caml_compact_heap (void)
data structures to find its roots. Fortunately, it doesn't need
the headers (see above). */
caml_do_roots (invert_root);
- final_do_weak_roots (invert_root);
+ caml_final_do_weak_roots (invert_root);
ch = caml_heap_start;
while (ch != NULL){
@@ -380,16 +380,16 @@ void caml_compact_heap (void)
/* Rebuild the free list. */
{
ch = caml_heap_start;
- fl_reset ();
+ caml_fl_reset ();
while (ch != NULL){
if (Chunk_size (ch) > Chunk_alloc (ch)){
- make_free_blocks ((value *) (ch + Chunk_alloc (ch)),
- Wsize_bsize (Chunk_size (ch) - Chunk_alloc (ch)), 1);
+ caml_make_free_blocks ((value *) (ch + Chunk_alloc (ch)),
+ Wsize_bsize (Chunk_size(ch)-Chunk_alloc(ch)), 1);
}
ch = Chunk_next (ch);
}
}
- ++ stat_compactions;
+ ++ caml_stat_compactions;
caml_gc_message (0x10, "done.\n", 0);
}
@@ -398,24 +398,25 @@ unsigned long caml_percent_max; /* used in gc_ctrl.c */
void caml_compact_heap_maybe (void)
{
/* Estimated free words in the heap:
- FW = fl_size_at_change + 3 * (fl_cur_size - fl_size_at_change)
- FW = 3 * fl_cur_size - 2 * fl_size_at_change
- Estimated live words: LW = stat_heap_size - FW
+ FW = fl_size_at_change + 3 * (caml_fl_cur_size
+ - caml_fl_size_at_phase_change)
+ FW = 3 * caml_fl_cur_size - 2 * caml_fl_size_at_phase_change
+ Estimated live words: LW = caml_stat_heap_size - FW
Estimated free percentage: FP = 100 * FW / LW
We compact the heap if FP > caml_percent_max
*/
float fw, fp;
Assert (caml_gc_phase == Phase_idle);
if (caml_percent_max >= 1000000) return;
- if (stat_major_collections < 5 || stat_heap_chunks < 5) return;
+ if (caml_stat_major_collections < 5 || caml_stat_heap_chunks < 5) return;
- fw = 3.0 * fl_cur_size - 2.0 * caml_fl_size_at_phase_change;
- if (fw < 0) fw = fl_cur_size;
+ fw = 3.0 * caml_fl_cur_size - 2.0 * caml_fl_size_at_phase_change;
+ if (fw < 0) fw = caml_fl_cur_size;
- if (fw >= Wsize_bsize (stat_heap_size)){
+ if (fw >= Wsize_bsize (caml_stat_heap_size)){
fp = 1000000.0;
}else{
- fp = 100.0 * fw / (Wsize_bsize (stat_heap_size) - fw);
+ fp = 100.0 * fw / (Wsize_bsize (caml_stat_heap_size) - fw);
if (fp > 1000000.0) fp = 1000000.0;
}
caml_gc_message (0x200, "FL size at phase change = %lu\n",
@@ -426,8 +427,8 @@ void caml_compact_heap_maybe (void)
caml_finish_major_cycle ();
/* We just did a complete GC, so we can measure the overhead exactly. */
- fw = fl_cur_size;
- fp = 100.0 * fw / (Wsize_bsize (stat_heap_size) - fw);
+ fw = caml_fl_cur_size;
+ fp = 100.0 * fw / (Wsize_bsize (caml_stat_heap_size) - fw);
caml_gc_message (0x200, "Measured overhead: %lu%%\n", (unsigned long) fp);
caml_compact_heap ();
diff --git a/byterun/compatibility.h b/byterun/compatibility.h
index 82f14303ef..1ff7743ab3 100644
--- a/byterun/compatibility.h
+++ b/byterun/compatibility.h
@@ -26,6 +26,11 @@
g --> ident global C
*/
+/* FIXME a faire:
+ system__frametable dans <arch>.s
+ supprimer lazy_is_forward dans obj.c
+*/
+
/* **** alloc.c */
#define alloc caml_alloc
#define alloc_small caml_alloc_small
@@ -144,7 +149,7 @@
#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 FIXME */
+#define array_bound_error caml_array_bound_error
#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
@@ -154,30 +159,122 @@
#define raise_sys_blocked_io caml_raise_sys_blocked_io
#define init_exceptions caml_init_exceptions
/* **** asmrun/fail.c */
-/* g Out_of_memory -> caml_Out_of_memory FIXME a faire */
-/* g Sys_error -> caml_Sys_error FIXME a faire */
-/* g Failure -> caml_Failure FIXME a faire */
-/* g Invalid_argument -> caml_Invalid_argument FIXME a faire */
-/* g End_of_file -> caml_End_of_file FIXME a faire */
-/* g Division_by_zero -> caml_Division_by_zero FIXME a faire */
-/* g Not_found -> caml_Not_found FIXME a faire */
-/* g Match_failure -> caml_Match_failure FIXME a faire */
-/* g Sys_blocked_io -> caml_Sys_blocked_io FIXME a faire */
-/* g Stack_overflow -> caml_Stack_overflow FIXME a faire */
-/* g bucket_Out_of_memory -> caml_bucket_Out_of_memory FIXME pkoi extern? */
-/* g bucket_Stack_overflow -> caml_bucket_Stack_overflow FIXME idem */
/* g raise_caml_exception -> caml_raise_exception */
/* **** asmrun/<arch>.s */
/* g caml_array_bound_error -> caml_ml_array_bound_error */
/* **** finalise.c */
+/* g final_update -> caml_final_update */
+/* g final_do_calls -> caml_final_do_calls */
+/* g final_do_strong_roots -> caml_final_do_strong_roots */
+/* g final_do_weak_roots -> caml_final_do_weak_roots */
+/* g final_do_young_roots -> caml_final_do_young_roots */
+/* g final_empty_young -> caml_final_empty_young */
+/* final_register -> caml_final_register */
+
/* **** fix_code.c */
+/* g start_code -> caml_start_code */
+/* g code_size -> caml_code_size */
+/* g saved_code -> caml_saved_code */
+/* g code_md5 -> caml_code_md5 */
+/* g load_code -> caml_load_code */
+/* g fixup_endianness -> caml_fixup_endianness */
+/* g instr_table -> caml_instr_table */
+/* g instr_base -> caml_instr_base */
+/* g thread_code -> caml_thread_code */
+/* g set_instruction -> caml_set_instruction */
+/* g is_instruction -> caml_is_instruction */
+
/* **** floats.c */
+/*#define Double_val caml_Double_val done as needed in mlvalues.h */
+/*#define Store_double_val caml_Store_double_val done as needed in mlvalues.h */
+#define copy_double caml_copy_double
+/* format_float -> caml_format_float */
+/* float_of_string -> caml_float_of_string */
+/* int_of_float -> caml_int_of_float */
+/* float_of_int -> caml_float_of_int */
+/* neg_float -> caml_neg_float */
+/* abs_float -> caml_abs_float */
+/* add_float -> caml_add_float */
+/* sub_float -> caml_sub_float */
+/* mul_float -> caml_mul_float */
+/* div_float -> caml_div_float */
+/* exp_float -> caml_exp_float */
+/* floor_float -> caml_floor_float */
+/* fmod_float -> caml_fmod_float */
+/* frexp_float -> caml_frexp_float */
+/* ldexp_float -> caml_ldexp_float */
+/* log_float -> caml_log_float */
+/* log10_float -> caml_log10_float */
+/* modf_float -> caml_modf_float */
+/* sqrt_float -> caml_sqrt_float */
+/* power_float -> caml_power_float */
+/* sin_float -> caml_sin_float */
+/* sinh_float -> caml_sinh_float */
+/* cos_float -> caml_cos_float */
+/* cosh_float -> caml_cosh_float */
+/* tan_float -> caml_tan_float */
+/* tanh_float -> caml_tanh_float */
+/* asin_float -> caml_asin_float */
+/* acos_float -> caml_acos_float */
+/* atan_float -> caml_atan_float */
+/* atan2_float -> caml_atan2_float */
+/* ceil_float -> caml_ceil_float */
+/* eq_float -> caml_eq_float */
+/* neq_float -> caml_neq_float */
+/* le_float -> caml_le_float */
+/* lt_float -> caml_lt_float */
+/* ge_float -> caml_ge_float */
+/* gt_float -> caml_gt_float */
+/* float_compare -> caml_float_compare */
+/* classify_float -> caml_classify_float */
+/* init_ieee_float -> caml_init_ieee_float */
+
/* **** freelist.c */
+/* g fl_merge -> caml_fl_merge */
+/* g fl_cur_size -> caml_fl_cur_size */
+/* fl_check *** devient static */
+/* g fl_allocate -> caml_fl_allocate */
+/* g fl_init_merge -> caml_fl_init_merge */
+/* g fl_reset -> caml_fl_reset */
+/* g fl_merge_block -> caml_fl_merge_block */
+/* g fl_add_block -> caml_fl_add_block */
+/* g make_free_blocks -> caml_make_free_blocks */
+
/* **** gc_ctrl.c */
+/* g stat_minor_words -> caml_stat_minor_words */
+/* g stat_promoted_words -> caml_stat_promoted_words */
+/* g stat_major-words -> caml_stat_major_words */
+/* g stat_minor_collections -> caml_stat_minor_collections */
+/* g stat_major_collections -> caml_stat_major_collections */
+/* g stat_heap_size -> caml_stat_heap_size */
+/* g stat_top_heap_size -> caml_stat_top_heap_size */
+/* g stat_compactions -> caml_stat_compactions */
+/* g stat_heap_chunks -> caml_stat_heap_chunks */
+/* g heap_check -> caml_heap_check */
+/* gc_stat -> caml_gc_stat */
+/* gc_counters -> caml_gc_counters */
+/* gc_get -> caml_gc_get */
+/* gc_set -> caml_gc_set */
+/* gc_minor -> caml_gc_minor */
+/* gc_major -> caml_gc_major */
+/* gc_full_major -> caml_gc_full_major */
+/* gc_major_slice -> caml_gc_major_slice */
+/* gc_compaction -> caml_gc_compaction */
+
/* **** globroots.c */
+#define register_global_root caml_register_global_root /* FIXME extern/export */
+#define remove_global_root caml_remove_global_root /* FIXME extern sans export*/
+
/* **** hash.c */
+/* hash_univ_param -> caml_hash_univ_param */
+#define hash_variant caml_hash_variant */
+
/* **** instrtrace.c */
+/* g icount -> caml_icount */
+/* g stop_here -> caml_stop_here */
+/* g trace_flag -> caml_trace_flag */
+/* g disasm_instr -> caml_disasm_instr */
/* **** intern.c */
/* g input_val -> caml_input_val */
@@ -504,6 +601,11 @@
/* g read_section_descriptors -> caml_read_section_descriptors */
/* g seek_optional_section -> caml_seek_optional_section */
/* g seek_section -> caml_seek_section */
+/* **** asmrun/startup.c */
+/* g static_data_start -> caml_static_data_start */
+/* g static_data_end -> caml_static_data_end */
+/* g code_area_start -> caml_code_area_start */
+/* g code_area_end -> caml_code_area_end */
/* **** str.c */
#define string_length caml_string_length
diff --git a/byterun/debugger.c b/byterun/debugger.c
index 007078a7b2..41ab845441 100644
--- a/byterun/debugger.c
+++ b/byterun/debugger.c
@@ -202,7 +202,7 @@ void caml_debugger(enum event_kind event)
caml_putword(dbg_out, caml_event_count);
if (event == EVENT_COUNT || event == BREAKPOINT) {
caml_putword(dbg_out, caml_stack_high - frame);
- caml_putword(dbg_out, (Pc(frame) - start_code) * sizeof(opcode_t));
+ caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
} else {
/* No PC and no stack frame associated with other events */
caml_putword(dbg_out, 0);
@@ -218,21 +218,21 @@ void caml_debugger(enum event_kind event)
case REQ_SET_EVENT:
pos = caml_getword(dbg_in);
Assert (pos >= 0);
- Assert (pos < code_size);
- set_instruction(start_code + pos / sizeof(opcode_t), EVENT);
+ Assert (pos < caml_code_size);
+ caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), EVENT);
break;
case REQ_SET_BREAKPOINT:
pos = caml_getword(dbg_in);
Assert (pos >= 0);
- Assert (pos < code_size);
- set_instruction(start_code + pos / sizeof(opcode_t), BREAK);
+ Assert (pos < caml_code_size);
+ caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), BREAK);
break;
case REQ_RESET_INSTR:
pos = caml_getword(dbg_in);
Assert (pos >= 0);
- Assert (pos < code_size);
+ Assert (pos < caml_code_size);
pos = pos / sizeof(opcode_t);
- set_instruction(start_code + pos, saved_code[pos]);
+ caml_set_instruction(caml_start_code + pos, caml_saved_code[pos]);
break;
case REQ_CHECKPOINT:
i = fork();
@@ -259,7 +259,7 @@ void caml_debugger(enum event_kind event)
case REQ_GET_FRAME:
caml_putword(dbg_out, caml_stack_high - frame);
if (frame < caml_stack_high){
- caml_putword(dbg_out, (Pc(frame) - start_code) * sizeof(opcode_t));
+ caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
}else{
caml_putword (dbg_out, 0);
}
@@ -276,7 +276,7 @@ void caml_debugger(enum event_kind event)
} else {
frame += Extra_args(frame) + i + 3;
caml_putword(dbg_out, caml_stack_high - frame);
- caml_putword(dbg_out, (Pc(frame) - start_code) * sizeof(opcode_t));
+ caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t));
}
caml_flush(dbg_out);
break;
@@ -328,7 +328,7 @@ void caml_debugger(enum event_kind event)
break;
case REQ_GET_CLOSURE_CODE:
val = getval(dbg_in);
- caml_putword(dbg_out, (Code_val(val) - start_code) * sizeof(opcode_t));
+ caml_putword(dbg_out, (Code_val(val)-caml_start_code) * sizeof(opcode_t));
caml_flush(dbg_out);
break;
}
diff --git a/byterun/extern.c b/byterun/extern.c
index 434412b3d2..2faeb9e853 100644
--- a/byterun/extern.c
+++ b/byterun/extern.c
@@ -376,10 +376,10 @@ static void extern_rec(value v)
}
return;
}
- if ((char *) v >= code_area_start && (char *) v < code_area_end) {
+ if ((char *) v >= caml_code_area_start && (char *) v < caml_code_area_end) {
if (!extern_closures)
extern_invalid_argument("output_value: functional value");
- writecode32(CODE_CODEPOINTER, (char *) v - code_area_start);
+ writecode32(CODE_CODEPOINTER, (char *) v - caml_code_area_start);
writeblock((char *) caml_code_checksum(), 16);
return;
}
diff --git a/byterun/fail.c b/byterun/fail.c
index 67d53e9d03..a814b27f74 100644
--- a/byterun/fail.c
+++ b/byterun/fail.c
@@ -81,7 +81,7 @@ CAMLexport void caml_invalid_argument (char *msg)
caml_raise_with_string(Field(caml_global_data, INVALID_EXN), msg);
}
-CAMLexport void array_bound_error(void)
+CAMLexport void caml_array_bound_error(void)
{
caml_invalid_argument("index out of bounds");
}
@@ -139,5 +139,5 @@ void caml_init_exceptions(void)
{
out_of_memory_bucket.hdr = Make_header(1, 0, Caml_white);
out_of_memory_bucket.exn = Field(caml_global_data, OUT_OF_MEMORY_EXN);
- register_global_root(&out_of_memory_bucket.exn);
+ caml_register_global_root(&out_of_memory_bucket.exn);
}
diff --git a/byterun/fail.h b/byterun/fail.h
index 5317b33046..47df947c51 100644
--- a/byterun/fail.h
+++ b/byterun/fail.h
@@ -70,7 +70,7 @@ 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 array_bound_error (void) Noreturn;
+CAMLextern void caml_array_bound_error (void) Noreturn;
CAMLextern void caml_raise_sys_blocked_io (void) Noreturn;
#endif /* CAML_FAIL_H */
diff --git a/byterun/finalise.c b/byterun/finalise.c
index ee8e5aea58..6b955d9c59 100644
--- a/byterun/finalise.c
+++ b/byterun/finalise.c
@@ -38,7 +38,7 @@ static unsigned long old = 0, young = 0, active = 0, size = 0;
finalising set.
The recent set is empty.
*/
-void final_update (void)
+void caml_final_update (void)
{
unsigned long i;
unsigned long oldactive = active;
@@ -78,7 +78,7 @@ void final_update (void)
/* Call the finalisation functions for the finalising set.
Note that this function must be reentrant.
*/
-void final_do_calls (void)
+void caml_final_do_calls (void)
{
struct final f;
@@ -102,7 +102,7 @@ void final_do_calls (void)
This is called by the major GC and the compactor
through [caml_darken_all_roots].
*/
-void final_do_strong_roots (scanning_action f)
+void caml_final_do_strong_roots (scanning_action f)
{
unsigned long i;
@@ -120,7 +120,7 @@ void final_do_strong_roots (scanning_action f)
The recent set is empty.
This is called directly by the compactor.
*/
-void final_do_weak_roots (scanning_action f)
+void caml_final_do_weak_roots (scanning_action f)
{
unsigned long i;
@@ -131,7 +131,7 @@ void final_do_weak_roots (scanning_action f)
/* Call [*f] on the closures and values of the recent set.
This is called by the minor GC through [caml_oldify_local_roots].
*/
-void final_do_young_roots (scanning_action f)
+void caml_final_do_young_roots (scanning_action f)
{
unsigned long i;
@@ -146,13 +146,13 @@ void final_do_young_roots (scanning_action f)
This is called at the end of each minor collection.
The minor heap must be empty when this is called.
*/
-void final_empty_young (void)
+void caml_final_empty_young (void)
{
old = young;
}
/* Put (f,v) in the recent set. */
-CAMLprim value final_register (value f, value v)
+CAMLprim value caml_final_register (value f, value v)
{
if (!(Is_block (v) && (Is_in_heap (v) || Is_young (v)))){
caml_invalid_argument ("Gc.finalise");
diff --git a/byterun/finalise.h b/byterun/finalise.h
index ca9cc29514..ec656f4f48 100644
--- a/byterun/finalise.h
+++ b/byterun/finalise.h
@@ -18,12 +18,12 @@
#include "roots.h"
-void final_update (void);
-void final_do_calls (void);
-void final_do_strong_roots (scanning_action f);
-void final_do_weak_roots (scanning_action f);
-void final_do_young_roots (scanning_action f);
-void final_empty_young (void);
-value final_register (value f, value v);
+void caml_final_update (void);
+void caml_final_do_calls (void);
+void caml_final_do_strong_roots (scanning_action f);
+void caml_final_do_weak_roots (scanning_action f);
+void caml_final_do_young_roots (scanning_action f);
+void caml_final_empty_young (void);
+value caml_final_register (value f, value v);
#endif /* CAML_FINALISE_H */
diff --git a/byterun/fix_code.c b/byterun/fix_code.c
index 19c54c7f13..470ae825e1 100644
--- a/byterun/fix_code.c
+++ b/byterun/fix_code.c
@@ -30,38 +30,38 @@
#include "mlvalues.h"
#include "reverse.h"
-code_t start_code;
-asize_t code_size;
-unsigned char * saved_code;
-unsigned char code_md5[16];
+code_t caml_start_code;
+asize_t caml_code_size;
+unsigned char * caml_saved_code;
+unsigned char caml_code_md5[16];
/* Read the main bytecode block from a file */
-void load_code(int fd, asize_t len)
+void caml_load_code(int fd, asize_t len)
{
int i;
struct MD5Context ctx;
- code_size = len;
- start_code = (code_t) caml_stat_alloc(code_size);
- if (read(fd, (char *) start_code, code_size) != code_size)
+ caml_code_size = len;
+ caml_start_code = (code_t) caml_stat_alloc(caml_code_size);
+ if (read(fd, (char *) caml_start_code, caml_code_size) != caml_code_size)
caml_fatal_error("Fatal error: truncated bytecode file.\n");
caml_MD5Init(&ctx);
- caml_MD5Update(&ctx, (unsigned char *) start_code, code_size);
- caml_MD5Final(code_md5, &ctx);
+ caml_MD5Update(&ctx, (unsigned char *) caml_start_code, caml_code_size);
+ caml_MD5Final(caml_code_md5, &ctx);
#ifdef ARCH_BIG_ENDIAN
- fixup_endianness(start_code, code_size);
+ caml_fixup_endianness(caml_start_code, caml_code_size);
#endif
if (caml_debugger_in_use) {
len /= sizeof(opcode_t);
- saved_code = (unsigned char *) caml_stat_alloc(len);
- for (i = 0; i < len; i++) saved_code[i] = start_code[i];
+ caml_saved_code = (unsigned char *) caml_stat_alloc(len);
+ for (i = 0; i < len; i++) caml_saved_code[i] = caml_start_code[i];
}
#ifdef THREADED_CODE
/* Better to thread now than at the beginning of [caml_interprete],
since the debugger interface needs to perform SET_EVENT requests
on the code. */
- thread_code(start_code, code_size);
+ caml_thread_code(caml_start_code, caml_code_size);
#endif
}
@@ -69,7 +69,7 @@ void load_code(int fd, asize_t len)
#ifdef ARCH_BIG_ENDIAN
-void fixup_endianness(code_t code, asize_t len)
+void caml_fixup_endianness(code_t code, asize_t len)
{
code_t p;
len /= sizeof(opcode_t);
@@ -84,10 +84,10 @@ void fixup_endianness(code_t code, asize_t len)
#ifdef THREADED_CODE
-char ** instr_table;
-char * instr_base;
+char ** caml_instr_table;
+char * caml_instr_base;
-void thread_code (code_t code, asize_t len)
+void caml_thread_code (code_t code, asize_t len)
{
code_t p;
int l [STOP + 1];
@@ -124,7 +124,7 @@ void thread_code (code_t code, asize_t len)
*/
instr = STOP;
}
- *p++ = (opcode_t)(instr_table[instr] - instr_base);
+ *p++ = (opcode_t)(caml_instr_table[instr] - caml_instr_base);
if (instr == SWITCH) {
uint32 sizes = *p++;
uint32 const_size = sizes & 0xFFFF;
@@ -143,19 +143,19 @@ void thread_code (code_t code, asize_t len)
#endif /* THREADED_CODE */
-void set_instruction(code_t pos, opcode_t instr)
+void caml_set_instruction(code_t pos, opcode_t instr)
{
#ifdef THREADED_CODE
- *pos = (opcode_t)(instr_table[instr] - instr_base);
+ *pos = (opcode_t)(caml_instr_table[instr] - caml_instr_base);
#else
*pos = instr;
#endif
}
-int is_instruction(opcode_t instr1, opcode_t instr2)
+int caml_is_instruction(opcode_t instr1, opcode_t instr2)
{
#ifdef THREADED_CODE
- return instr1 == (opcode_t)(instr_table[instr2] - instr_base);
+ return instr1 == (opcode_t)(caml_instr_table[instr2] - caml_instr_base);
#else
return instr1 == instr2;
#endif
diff --git a/byterun/fix_code.h b/byterun/fix_code.h
index 0caab959ac..f6e9e3b773 100644
--- a/byterun/fix_code.h
+++ b/byterun/fix_code.h
@@ -23,20 +23,20 @@
#include "misc.h"
#include "mlvalues.h"
-extern code_t start_code;
-extern asize_t code_size;
-extern unsigned char * saved_code;
-extern unsigned char code_md5[16];
+extern code_t caml_start_code;
+extern asize_t caml_code_size;
+extern unsigned char * caml_saved_code;
+extern unsigned char caml_code_md5[16];
-void load_code (int fd, asize_t len);
-void fixup_endianness (code_t code, asize_t len);
-void set_instruction (code_t pos, opcode_t instr);
-int is_instruction (opcode_t instr1, opcode_t instr2);
+void caml_load_code (int fd, asize_t len);
+void caml_fixup_endianness (code_t code, asize_t len);
+void caml_set_instruction (code_t pos, opcode_t instr);
+int caml_is_instruction (opcode_t instr1, opcode_t instr2);
#ifdef THREADED_CODE
-extern char ** instr_table;
-extern char * instr_base;
-void thread_code (code_t code, asize_t len);
+extern char ** caml_instr_table;
+extern char * caml_instr_base;
+void caml_thread_code (code_t code, asize_t len);
#endif
#endif /* CAML_FIX_CODE_H */
diff --git a/byterun/floats.c b/byterun/floats.c
index a81f83e1dc..00270e4cbc 100644
--- a/byterun/floats.c
+++ b/byterun/floats.c
@@ -30,7 +30,7 @@
#ifdef ARCH_ALIGN_DOUBLE
-CAMLexport double Double_val(value val)
+CAMLexport double caml_Double_val(value val)
{
union { value v[2]; double d; } buffer;
@@ -40,7 +40,7 @@ CAMLexport double Double_val(value val)
return buffer.d;
}
-CAMLexport void Store_double_val(value val, double dbl)
+CAMLexport void caml_Store_double_val(value val, double dbl)
{
union { value v[2]; double d; } buffer;
@@ -52,7 +52,7 @@ CAMLexport void Store_double_val(value val, double dbl)
#endif
-CAMLexport value copy_double(double d)
+CAMLexport value caml_copy_double(double d)
{
value res;
@@ -65,7 +65,7 @@ CAMLexport value copy_double(double d)
return res;
}
-CAMLprim value format_float(value fmt, value arg)
+CAMLprim value caml_format_float(value fmt, value arg)
{
#define MAX_DIGITS 350
/* Max number of decimal digits in a "natural" (not artificially padded)
@@ -106,7 +106,7 @@ CAMLprim value format_float(value fmt, value arg)
return res;
}
-CAMLprim value float_of_string(value vs)
+CAMLprim value caml_float_of_string(value vs)
{
char parse_buffer[64];
char * buf, * src, * dst, * end;
@@ -126,93 +126,93 @@ CAMLprim value float_of_string(value vs)
d = strtod((const char *) buf, &end);
if (buf != parse_buffer) caml_stat_free(buf);
if (end != dst) caml_failwith("float_of_string");
- return copy_double(d);
+ return caml_copy_double(d);
}
-CAMLprim value int_of_float(value f)
+CAMLprim value caml_int_of_float(value f)
{
return Val_long((long) Double_val(f));
}
-CAMLprim value float_of_int(value n)
+CAMLprim value caml_float_of_int(value n)
{
- return copy_double((double) Long_val(n));
+ return caml_copy_double((double) Long_val(n));
}
-CAMLprim value neg_float(value f)
+CAMLprim value caml_neg_float(value f)
{
- return copy_double(- Double_val(f));
+ return caml_copy_double(- Double_val(f));
}
-CAMLprim value abs_float(value f)
+CAMLprim value caml_abs_float(value f)
{
- return copy_double(fabs(Double_val(f)));
+ return caml_copy_double(fabs(Double_val(f)));
}
-CAMLprim value add_float(value f, value g)
+CAMLprim value caml_add_float(value f, value g)
{
- return copy_double(Double_val(f) + Double_val(g));
+ return caml_copy_double(Double_val(f) + Double_val(g));
}
-CAMLprim value sub_float(value f, value g)
+CAMLprim value caml_sub_float(value f, value g)
{
- return copy_double(Double_val(f) - Double_val(g));
+ return caml_copy_double(Double_val(f) - Double_val(g));
}
-CAMLprim value mul_float(value f, value g)
+CAMLprim value caml_mul_float(value f, value g)
{
- return copy_double(Double_val(f) * Double_val(g));
+ return caml_copy_double(Double_val(f) * Double_val(g));
}
-CAMLprim value div_float(value f, value g)
+CAMLprim value caml_div_float(value f, value g)
{
- return copy_double(Double_val(f) / Double_val(g));
+ return caml_copy_double(Double_val(f) / Double_val(g));
}
-CAMLprim value exp_float(value f)
+CAMLprim value caml_exp_float(value f)
{
- return copy_double(exp(Double_val(f)));
+ return caml_copy_double(exp(Double_val(f)));
}
-CAMLprim value floor_float(value f)
+CAMLprim value caml_floor_float(value f)
{
- return copy_double(floor(Double_val(f)));
+ return caml_copy_double(floor(Double_val(f)));
}
-CAMLprim value fmod_float(value f1, value f2)
+CAMLprim value caml_fmod_float(value f1, value f2)
{
- return copy_double(fmod(Double_val(f1), Double_val(f2)));
+ return caml_copy_double(fmod(Double_val(f1), Double_val(f2)));
}
-CAMLprim value frexp_float(value f)
+CAMLprim value caml_frexp_float(value f)
{
CAMLparam1 (f);
CAMLlocal2 (res, mantissa);
int exponent;
- mantissa = copy_double(frexp (Double_val(f), &exponent));
+ mantissa = caml_copy_double(frexp (Double_val(f), &exponent));
res = caml_alloc_tuple(2);
Field(res, 0) = mantissa;
Field(res, 1) = Val_int(exponent);
CAMLreturn (res);
}
-CAMLprim value ldexp_float(value f, value i)
+CAMLprim value caml_ldexp_float(value f, value i)
{
- return copy_double(ldexp(Double_val(f), Int_val(i)));
+ return caml_copy_double(ldexp(Double_val(f), Int_val(i)));
}
-CAMLprim value log_float(value f)
+CAMLprim value caml_log_float(value f)
{
- return copy_double(log(Double_val(f)));
+ return caml_copy_double(log(Double_val(f)));
}
-CAMLprim value log10_float(value f)
+CAMLprim value caml_log10_float(value f)
{
- return copy_double(log10(Double_val(f)));
+ return caml_copy_double(log10(Double_val(f)));
}
-CAMLprim value modf_float(value f)
+CAMLprim value caml_modf_float(value f)
{
#if __SC__
_float_eval frem; /* Problem with Apple's <math.h> */
@@ -222,110 +222,110 @@ CAMLprim value modf_float(value f)
CAMLparam1 (f);
CAMLlocal3 (res, quo, rem);
- quo = copy_double(modf (Double_val(f), &frem));
- rem = copy_double(frem);
+ quo = caml_copy_double(modf (Double_val(f), &frem));
+ rem = caml_copy_double(frem);
res = caml_alloc_tuple(2);
Field(res, 0) = quo;
Field(res, 1) = rem;
CAMLreturn (res);
}
-CAMLprim value sqrt_float(value f)
+CAMLprim value caml_sqrt_float(value f)
{
- return copy_double(sqrt(Double_val(f)));
+ return caml_copy_double(sqrt(Double_val(f)));
}
-CAMLprim value power_float(value f, value g)
+CAMLprim value caml_power_float(value f, value g)
{
- return copy_double(pow(Double_val(f), Double_val(g)));
+ return caml_copy_double(pow(Double_val(f), Double_val(g)));
}
-CAMLprim value sin_float(value f)
+CAMLprim value caml_sin_float(value f)
{
- return copy_double(sin(Double_val(f)));
+ return caml_copy_double(sin(Double_val(f)));
}
-CAMLprim value sinh_float(value f)
+CAMLprim value caml_sinh_float(value f)
{
- return copy_double(sinh(Double_val(f)));
+ return caml_copy_double(sinh(Double_val(f)));
}
-CAMLprim value cos_float(value f)
+CAMLprim value caml_cos_float(value f)
{
- return copy_double(cos(Double_val(f)));
+ return caml_copy_double(cos(Double_val(f)));
}
-CAMLprim value cosh_float(value f)
+CAMLprim value caml_cosh_float(value f)
{
- return copy_double(cosh(Double_val(f)));
+ return caml_copy_double(cosh(Double_val(f)));
}
-CAMLprim value tan_float(value f)
+CAMLprim value caml_tan_float(value f)
{
- return copy_double(tan(Double_val(f)));
+ return caml_copy_double(tan(Double_val(f)));
}
-CAMLprim value tanh_float(value f)
+CAMLprim value caml_tanh_float(value f)
{
- return copy_double(tanh(Double_val(f)));
+ return caml_copy_double(tanh(Double_val(f)));
}
-CAMLprim value asin_float(value f)
+CAMLprim value caml_asin_float(value f)
{
- return copy_double(asin(Double_val(f)));
+ return caml_copy_double(asin(Double_val(f)));
}
-CAMLprim value acos_float(value f)
+CAMLprim value caml_acos_float(value f)
{
- return copy_double(acos(Double_val(f)));
+ return caml_copy_double(acos(Double_val(f)));
}
-CAMLprim value atan_float(value f)
+CAMLprim value caml_atan_float(value f)
{
- return copy_double(atan(Double_val(f)));
+ return caml_copy_double(atan(Double_val(f)));
}
-CAMLprim value atan2_float(value f, value g)
+CAMLprim value caml_atan2_float(value f, value g)
{
- return copy_double(atan2(Double_val(f), Double_val(g)));
+ return caml_copy_double(atan2(Double_val(f), Double_val(g)));
}
-CAMLprim value ceil_float(value f)
+CAMLprim value caml_ceil_float(value f)
{
- return copy_double(ceil(Double_val(f)));
+ return caml_copy_double(ceil(Double_val(f)));
}
-CAMLprim value eq_float(value f, value g)
+CAMLprim value caml_eq_float(value f, value g)
{
return Val_bool(Double_val(f) == Double_val(g));
}
-CAMLprim value neq_float(value f, value g)
+CAMLprim value caml_neq_float(value f, value g)
{
return Val_bool(Double_val(f) != Double_val(g));
}
-CAMLprim value le_float(value f, value g)
+CAMLprim value caml_le_float(value f, value g)
{
return Val_bool(Double_val(f) <= Double_val(g));
}
-CAMLprim value lt_float(value f, value g)
+CAMLprim value caml_lt_float(value f, value g)
{
return Val_bool(Double_val(f) < Double_val(g));
}
-CAMLprim value ge_float(value f, value g)
+CAMLprim value caml_ge_float(value f, value g)
{
return Val_bool(Double_val(f) >= Double_val(g));
}
-CAMLprim value gt_float(value f, value g)
+CAMLprim value caml_gt_float(value f, value g)
{
return Val_bool(Double_val(f) > Double_val(g));
}
-CAMLprim value float_compare(value vf, value vg)
+CAMLprim value caml_float_compare(value vf, value vg)
{
double f = Double_val(vf);
double g = Double_val(vg);
@@ -341,7 +341,7 @@ CAMLprim value float_compare(value vf, value vg)
enum { FP_normal, FP_subnormal, FP_zero, FP_infinite, FP_nan };
-CAMLprim value classify_float(value vd)
+CAMLprim value caml_classify_float(value vd)
{
/* Cygwin 1.3 has problems with fpclassify (PR#1293), so don't use it */
#if defined(fpclassify) && !defined(__CYGWIN32__) && !defined(__MINGW32__)
@@ -383,7 +383,7 @@ CAMLprim value classify_float(value vd)
#endif
}
-/* The init_ieee_float function should initialize floating-point hardware
+/* The [caml_init_ieee_float] function should initialize floating-point hardware
so that it behaves as much as possible like the IEEE standard.
In particular, return special numbers like Infinity and NaN instead
of signalling exceptions. Currently, everyone is in IEEE mode
@@ -396,7 +396,7 @@ CAMLprim value classify_float(value vd)
#endif
#endif
-void init_ieee_floats(void)
+void caml_init_ieee_floats(void)
{
#if defined(__FreeBSD__) && (__FreeBSD_version < 400017)
fpsetmask(0);
diff --git a/byterun/freelist.c b/byterun/freelist.c
index d359db5913..00b095e960 100644
--- a/byterun/freelist.c
+++ b/byterun/freelist.c
@@ -23,7 +23,7 @@
/* The free-list is kept sorted by increasing addresses.
This makes the merging of adjacent free blocks possible.
- (See [fl_merge_block].)
+ (See [caml_fl_merge_block].)
*/
typedef struct {
@@ -42,16 +42,16 @@ static struct {
#define Fl_head ((char *) (&(sentinel.first_bp)))
static char *fl_prev = Fl_head; /* Current allocation pointer. */
static char *fl_last = NULL; /* Last block in the list. Only valid
- just after fl_allocate returned NULL. */
-char *fl_merge = Fl_head; /* Current insertion pointer. Managed
+ just after [caml_fl_allocate] returns NULL. */
+char *caml_fl_merge = Fl_head; /* Current insertion pointer. Managed
jointly with [sweep_slice]. */
-asize_t fl_cur_size = 0; /* Number of words in the free list,
+asize_t caml_fl_cur_size = 0; /* Number of words in the free list,
including headers but not fragments. */
#define Next(b) (((block *) (b))->next_bp)
#ifdef DEBUG
-void fl_check (void)
+static void fl_check (void)
{
char *cur, *prev;
int prev_found = 0, merge_found = 0;
@@ -63,17 +63,17 @@ void fl_check (void)
size_found += Whsize_bp (cur);
Assert (Is_in_heap (cur));
if (cur == fl_prev) prev_found = 1;
- if (cur == fl_merge) merge_found = 1;
+ if (cur == caml_fl_merge) merge_found = 1;
prev = cur;
cur = Next (prev);
}
Assert (prev_found || fl_prev == Fl_head);
- Assert (merge_found || fl_merge == Fl_head);
- Assert (size_found == fl_cur_size);
+ Assert (merge_found || caml_fl_merge == Fl_head);
+ Assert (size_found == caml_fl_cur_size);
}
#endif
-/* [allocate_block] is called by [fl_allocate]. Given a suitable free
+/* [allocate_block] is called by [caml_fl_allocate]. Given a suitable free
block and the desired size, it allocates a new block from the free
block. There are three cases:
0. The free block has the desired size. Detach the block from the
@@ -92,30 +92,30 @@ static char *allocate_block (mlsize_t wh_sz, char *prev, char *cur)
header_t h = Hd_bp (cur);
Assert (Whsize_hd (h) >= wh_sz);
if (Wosize_hd (h) < wh_sz + 1){ /* Cases 0 and 1. */
- fl_cur_size -= Whsize_hd (h);
+ caml_fl_cur_size -= Whsize_hd (h);
Next (prev) = Next (cur);
Assert (Is_in_heap (Next (prev)) || Next (prev) == NULL);
- if (fl_merge == cur) fl_merge = prev;
+ if (caml_fl_merge == cur) caml_fl_merge = prev;
#ifdef DEBUG
fl_last = NULL;
#endif
/* In case 1, the following creates the empty block correctly.
In case 0, it gives an invalid header to the block. The function
- calling [fl_allocate] will overwrite it. */
+ calling [caml_fl_allocate] will overwrite it. */
Hd_op (cur) = Make_header (0, 0, Caml_white);
}else{ /* Case 2. */
- fl_cur_size -= wh_sz;
+ caml_fl_cur_size -= wh_sz;
Hd_op (cur) = Make_header (Wosize_hd (h) - wh_sz, 0, Caml_blue);
}
fl_prev = prev;
return cur + Bosize_hd (h) - Bsize_wsize (wh_sz);
}
-/* [fl_allocate] does not set the header of the newly allocated block.
+/* [caml_fl_allocate] does not set the header of the newly allocated block.
The calling function must do it before any GC function gets called.
- [fl_allocate] returns a head pointer.
+ [caml_fl_allocate] returns a head pointer.
*/
-char *fl_allocate (mlsize_t wo_sz)
+char *caml_fl_allocate (mlsize_t wo_sz)
{
char *cur, *prev;
Assert (sizeof (char *) == sizeof (value));
@@ -148,33 +148,33 @@ char *fl_allocate (mlsize_t wo_sz)
static char *last_fragment;
-void fl_init_merge (void)
+void caml_fl_init_merge (void)
{
last_fragment = NULL;
- fl_merge = Fl_head;
+ caml_fl_merge = Fl_head;
#ifdef DEBUG
fl_check ();
#endif
}
/* This is called by caml_compact_heap. */
-void fl_reset (void)
+void caml_fl_reset (void)
{
Next (Fl_head) = 0;
fl_prev = Fl_head;
- fl_cur_size = 0;
- fl_init_merge ();
+ caml_fl_cur_size = 0;
+ caml_fl_init_merge ();
}
-/* [fl_merge_block] returns the head pointer of the next block after [bp],
+/* [caml_fl_merge_block] returns the head pointer of the next block after [bp],
because merging blocks may change the size of [bp]. */
-char *fl_merge_block (char *bp)
+char *caml_fl_merge_block (char *bp)
{
char *prev, *cur, *adj;
header_t hd = Hd_bp (bp);
mlsize_t prev_wosz;
- fl_cur_size += Whsize_hd (hd);
+ caml_fl_cur_size += Whsize_hd (hd);
#ifdef DEBUG
{
@@ -184,7 +184,7 @@ char *fl_merge_block (char *bp)
}
}
#endif
- prev = fl_merge;
+ prev = caml_fl_merge;
cur = Next (prev);
/* The sweep code makes sure that this is the right place to insert
this block: */
@@ -198,7 +198,7 @@ char *fl_merge_block (char *bp)
hd = Make_header (bp_whsz, 0, Caml_white);
bp = last_fragment;
Hd_bp (bp) = hd;
- fl_cur_size += Whsize_wosize (0);
+ caml_fl_cur_size += Whsize_wosize (0);
}
}
@@ -232,29 +232,29 @@ char *fl_merge_block (char *bp)
#ifdef DEBUG
Hd_bp (bp) = Debug_free_major;
#endif
- Assert (fl_merge == prev);
+ Assert (caml_fl_merge == prev);
}else if (Wosize_hd (hd) != 0){
Hd_bp (bp) = Bluehd_hd (hd);
Next (bp) = cur;
Next (prev) = bp;
- fl_merge = bp;
+ caml_fl_merge = bp;
}else{
/* This is a fragment. Leave it in white but remember it for eventual
merging with the next block. */
last_fragment = bp;
- fl_cur_size -= Whsize_wosize (0);
+ caml_fl_cur_size -= Whsize_wosize (0);
}
return adj;
}
/* This is a heap extension. We have to insert it in the right place
in the free-list.
- [fl_add_block] can only be called just after a call to [fl_allocate]
- that returned NULL.
+ [caml_fl_add_block] can only be called right after a call to
+ [caml_fl_allocate] that returned NULL.
Most of the heap extensions are expected to be at the end of the
free list. (This depends on the implementation of [malloc].)
*/
-void fl_add_block (char *bp)
+void caml_fl_add_block (char *bp)
{
Assert (fl_last != NULL);
Assert (Next (fl_last) == NULL);
@@ -267,7 +267,7 @@ void fl_add_block (char *bp)
}
#endif
- fl_cur_size += Whsize_bp (bp);
+ caml_fl_cur_size += Whsize_bp (bp);
if (bp > fl_last){
Next (fl_last) = bp;
@@ -284,10 +284,10 @@ void fl_add_block (char *bp)
Assert (cur > bp || cur == NULL);
Next (bp) = cur;
Next (prev) = bp;
- /* When inserting a block between fl_merge and caml_gc_sweep_hp, we must
- advance fl_merge to the new block, so that fl_merge is always the
- last free-list block before caml_gc_sweep_hp. */
- if (prev == fl_merge && bp <= caml_gc_sweep_hp) fl_merge = bp;
+ /* When inserting a block between [caml_fl_merge] and [caml_gc_sweep_hp],
+ we must advance [caml_fl_merge] to the new block, so that [caml_fl_merge]
+ is always the last free-list block before [caml_gc_sweep_hp]. */
+ if (prev == caml_fl_merge && bp <= caml_gc_sweep_hp) caml_fl_merge = bp;
}
}
@@ -298,7 +298,7 @@ void fl_add_block (char *bp)
size: size of the block (in words)
do_merge: 1 -> do merge; 0 -> do not merge
*/
-void make_free_blocks (value *p, mlsize_t size, int do_merge)
+void caml_make_free_blocks (value *p, mlsize_t size, int do_merge)
{
mlsize_t sz;
@@ -309,7 +309,7 @@ void make_free_blocks (value *p, mlsize_t size, int do_merge)
sz = size;
}
*(header_t *)p = Make_header (Wosize_whsize (sz), 0, Caml_white);
- if (do_merge) fl_merge_block (Bp_hp (p));
+ if (do_merge) caml_fl_merge_block (Bp_hp (p));
size -= sz;
p += sz;
}
diff --git a/byterun/freelist.h b/byterun/freelist.h
index 3097575aca..ea03ad9869 100644
--- a/byterun/freelist.h
+++ b/byterun/freelist.h
@@ -22,14 +22,14 @@
#include "misc.h"
#include "mlvalues.h"
-extern asize_t fl_cur_size; /* size in words */
-
-char *fl_allocate (mlsize_t);
-void fl_init_merge (void);
-void fl_reset (void);
-char *fl_merge_block (char *);
-void fl_add_block (char *);
-void make_free_blocks (value *, mlsize_t, int);
+extern asize_t caml_fl_cur_size; /* size in words */
+
+char *caml_fl_allocate (mlsize_t);
+void caml_fl_init_merge (void);
+void caml_fl_reset (void);
+char *caml_fl_merge_block (char *);
+void caml_fl_add_block (char *);
+void caml_make_free_blocks (value *, mlsize_t, int);
#endif /* CAML_FREELIST_H */
diff --git a/byterun/gc_ctrl.c b/byterun/gc_ctrl.c
index 88a377ff6a..6a657980b1 100644
--- a/byterun/gc_ctrl.c
+++ b/byterun/gc_ctrl.c
@@ -29,16 +29,16 @@
extern unsigned long caml_max_stack_size; /* defined in stacks.c */
#endif
-double stat_minor_words = 0.0,
- stat_promoted_words = 0.0,
- stat_major_words = 0.0;
+double caml_stat_minor_words = 0.0,
+ caml_stat_promoted_words = 0.0,
+ caml_stat_major_words = 0.0;
-long stat_minor_collections = 0,
- stat_major_collections = 0,
- stat_heap_size = 0, /* bytes */
- stat_top_heap_size = 0, /* bytes */
- stat_compactions = 0,
- stat_heap_chunks = 0;
+long caml_stat_minor_collections = 0,
+ caml_stat_major_collections = 0,
+ caml_stat_heap_size = 0, /* bytes */
+ caml_stat_top_heap_size = 0, /* bytes */
+ caml_stat_compactions = 0,
+ caml_stat_heap_chunks = 0;
extern asize_t caml_major_heap_increment; /* bytes; see major_gc.c */
extern unsigned long caml_percent_free; /* see major_gc.c */
@@ -201,27 +201,28 @@ static value heap_stats (int returnstats)
chunk = Chunk_next (chunk);
}
- Assert (heap_chunks == stat_heap_chunks);
- Assert (live_words + free_words + fragments == Wsize_bsize (stat_heap_size));
+ Assert (heap_chunks == caml_stat_heap_chunks);
+ Assert (live_words + free_words + fragments
+ == Wsize_bsize (caml_stat_heap_size));
if (returnstats){
CAMLlocal1 (res);
/* get a copy of these before allocating anything... */
- double minwords = stat_minor_words
+ double minwords = caml_stat_minor_words
+ (double) Wsize_bsize (caml_young_end - caml_young_ptr);
- double prowords = stat_promoted_words;
- double majwords = stat_major_words + (double) caml_allocated_words;
- long mincoll = stat_minor_collections;
- long majcoll = stat_major_collections;
- long heap_words = Wsize_bsize (stat_heap_size);
- long cpct = stat_compactions;
- long top_heap_words = Wsize_bsize (stat_top_heap_size);
+ double prowords = caml_stat_promoted_words;
+ double majwords = caml_stat_major_words + (double) caml_allocated_words;
+ long mincoll = caml_stat_minor_collections;
+ long majcoll = caml_stat_major_collections;
+ long heap_words = Wsize_bsize (caml_stat_heap_size);
+ long cpct = caml_stat_compactions;
+ long top_heap_words = Wsize_bsize (caml_stat_top_heap_size);
res = caml_alloc_tuple (15);
- Store_field (res, 0, copy_double (minwords));
- Store_field (res, 1, copy_double (prowords));
- Store_field (res, 2, copy_double (majwords));
+ Store_field (res, 0, caml_copy_double (minwords));
+ Store_field (res, 1, caml_copy_double (prowords));
+ Store_field (res, 2, caml_copy_double (majwords));
Store_field (res, 3, Val_long (mincoll));
Store_field (res, 4, Val_long (majcoll));
Store_field (res, 5, Val_long (heap_words));
@@ -241,37 +242,37 @@ static value heap_stats (int returnstats)
}
#ifdef DEBUG
-void heap_check (void)
+void caml_heap_check (void)
{
heap_stats (0);
}
#endif
-CAMLprim value gc_stat(value v)
+CAMLprim value caml_gc_stat(value v)
{
Assert (v == Val_unit);
return heap_stats (1);
}
-CAMLprim value gc_counters(value v)
+CAMLprim value caml_gc_counters(value v)
{
CAMLparam0 (); /* v is ignored */
CAMLlocal1 (res);
/* get a copy of these before allocating anything... */
- double minwords = stat_minor_words
+ double minwords = caml_stat_minor_words
+ (double) Wsize_bsize (caml_young_end - caml_young_ptr);
- double prowords = stat_promoted_words;
- double majwords = stat_major_words + (double) caml_allocated_words;
+ double prowords = caml_stat_promoted_words;
+ double majwords = caml_stat_major_words + (double) caml_allocated_words;
res = caml_alloc_tuple (3);
- Store_field (res, 0, copy_double (minwords));
- Store_field (res, 1, copy_double (prowords));
- Store_field (res, 2, copy_double (majwords));
+ Store_field (res, 0, caml_copy_double (minwords));
+ Store_field (res, 1, caml_copy_double (prowords));
+ Store_field (res, 2, caml_copy_double (majwords));
CAMLreturn (res);
}
-CAMLprim value gc_get(value v)
+CAMLprim value caml_gc_get(value v)
{
CAMLparam0 (); /* v is ignored */
CAMLlocal1 (res);
@@ -317,7 +318,7 @@ static long norm_minsize (long int s)
return s;
}
-CAMLprim value gc_set(value v)
+CAMLprim value caml_gc_set(value v)
{
unsigned long newpf, newpm;
asize_t newheapincr;
@@ -359,39 +360,39 @@ CAMLprim value gc_set(value v)
return Val_unit;
}
-CAMLprim value gc_minor(value v)
+CAMLprim value caml_gc_minor(value v)
{ Assert (v == Val_unit);
caml_minor_collection ();
return Val_unit;
}
-CAMLprim value gc_major(value v)
+CAMLprim value caml_gc_major(value v)
{ Assert (v == Val_unit);
caml_empty_minor_heap ();
caml_finish_major_cycle ();
- final_do_calls ();
+ caml_final_do_calls ();
return Val_unit;
}
-CAMLprim value gc_full_major(value v)
+CAMLprim value caml_gc_full_major(value v)
{ Assert (v == Val_unit);
caml_empty_minor_heap ();
caml_finish_major_cycle ();
- final_do_calls ();
+ caml_final_do_calls ();
caml_empty_minor_heap ();
caml_finish_major_cycle ();
- final_do_calls ();
+ caml_final_do_calls ();
return Val_unit;
}
-CAMLprim value gc_major_slice (value v)
+CAMLprim value caml_gc_major_slice (value v)
{
Assert (Is_long (v));
caml_empty_minor_heap ();
return Val_long (caml_major_collection_slice (Long_val (v)));
}
-CAMLprim value gc_compaction(value v)
+CAMLprim value caml_gc_compaction(value v)
{ Assert (v == Val_unit);
caml_empty_minor_heap ();
caml_finish_major_cycle ();
@@ -400,9 +401,9 @@ CAMLprim value gc_compaction(value v)
return Val_unit;
}
-void init_gc (unsigned long minor_size, unsigned long major_size,
- unsigned long major_incr, unsigned long percent_fr,
- unsigned long percent_m)
+void caml_init_gc (unsigned long minor_size, unsigned long major_size,
+ unsigned long major_incr, unsigned long percent_fr,
+ unsigned long percent_m)
{
unsigned long major_heap_size = Bsize_wsize (norm_heapincr (major_size));
diff --git a/byterun/gc_ctrl.h b/byterun/gc_ctrl.h
index 8b8b89daeb..b5a2e87f79 100644
--- a/byterun/gc_ctrl.h
+++ b/byterun/gc_ctrl.h
@@ -19,24 +19,24 @@
#include "misc.h"
extern double
- stat_minor_words,
- stat_promoted_words,
- stat_major_words;
+ caml_stat_minor_words,
+ caml_stat_promoted_words,
+ caml_stat_major_words;
extern long
- stat_minor_collections,
- stat_major_collections,
- stat_heap_size,
- stat_top_heap_size,
- stat_compactions,
- stat_heap_chunks;
+ caml_stat_minor_collections,
+ caml_stat_major_collections,
+ caml_stat_heap_size,
+ caml_stat_top_heap_size,
+ caml_stat_compactions,
+ caml_stat_heap_chunks;
-void init_gc (unsigned long, unsigned long, unsigned long,
- unsigned long, unsigned long);
+void caml_init_gc (unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long);
#ifdef DEBUG
-void heap_check (void);
+void caml_heap_check (void);
#endif
#endif /* CAML_GC_CTRL_H */
diff --git a/byterun/globroots.c b/byterun/globroots.c
index 154cabef08..684dfed961 100644
--- a/byterun/globroots.c
+++ b/byterun/globroots.c
@@ -55,7 +55,7 @@ struct global_root_list caml_global_roots = { NULL, { NULL, }, 0 };
/* Register a global C root */
-void register_global_root(value *r)
+void caml_register_global_root(value *r)
{
struct global_root * update[MAX_LEVEL];
struct global_root * e, * f;
@@ -95,7 +95,7 @@ void register_global_root(value *r)
/* Un-register a global C root */
-void remove_global_root(value *r)
+void caml_remove_global_root(value *r)
{
struct global_root * update[MAX_LEVEL];
struct global_root * e, * f;
diff --git a/byterun/hash.c b/byterun/hash.c
index a6e3970fd0..17748e3933 100644
--- a/byterun/hash.c
+++ b/byterun/hash.c
@@ -26,7 +26,7 @@ static long hash_univ_limit, hash_univ_count;
static void hash_aux(value obj);
-CAMLprim value hash_univ_param(value count, value limit, value obj)
+CAMLprim value caml_hash_univ_param(value count, value limit, value obj)
{
hash_univ_limit = Long_val(limit);
hash_univ_count = Long_val(count);
@@ -142,7 +142,7 @@ static void hash_aux(value obj)
/* Hashing variant tags */
-CAMLexport value hash_variant(char * tag)
+CAMLexport value caml_hash_variant(char * tag)
{
value accu;
/* Same hashing algorithm as in ../typing/btype.ml, function hash_variant */
@@ -155,4 +155,3 @@ CAMLexport value hash_variant(char * tag)
platforms */
return (int32) accu;
}
-
diff --git a/byterun/instrtrace.c b/byterun/instrtrace.c
index de96d5105c..aba9787490 100644
--- a/byterun/instrtrace.c
+++ b/byterun/instrtrace.c
@@ -24,19 +24,19 @@
#include "opnames.h"
#include "prims.h"
-extern code_t start_code;
+extern code_t caml_start_code;
-long icount = 0;
+long caml_icount = 0;
-void stop_here () {}
+void caml_stop_here () {}
-int trace_flag = 0;
+int caml_trace_flag = 0;
-void disasm_instr(pc)
+void caml_disasm_instr(pc)
code_t pc;
{
int instr = *pc;
- printf("%6ld %s", (long) (pc - start_code),
+ printf("%6ld %s", (long) (pc - caml_start_code),
instr < 0 || instr > STOP ? "???" : names_of_instructions[instr]);
pc++;
switch(instr) {
diff --git a/byterun/instrtrace.h b/byterun/instrtrace.h
index b65aca87b1..6b899766b0 100644
--- a/byterun/instrtrace.h
+++ b/byterun/instrtrace.h
@@ -22,10 +22,10 @@
#include "mlvalues.h"
#include "misc.h"
-extern int trace_flag;
-extern long icount;
-void stop_here (void);
-void disasm_instr (code_t pc);
+extern int caml_trace_flag;
+extern long caml_icount;
+void caml_stop_here (void);
+void caml_disasm_instr (code_t pc);
#endif
diff --git a/byterun/intern.c b/byterun/intern.c
index 1b4b672229..34b22340a0 100644
--- a/byterun/intern.c
+++ b/byterun/intern.c
@@ -293,7 +293,7 @@ static void intern_rec(value *dest)
intern_cleanup();
caml_failwith("input_value: code mismatch");
}
- v = (value) (code_area_start + ofs);
+ v = (value) (caml_code_area_start + ofs);
break;
case CODE_INFIXPOINTER:
ofs = read32u();
@@ -378,8 +378,8 @@ static void intern_add_to_heap(mlsize_t whsize)
(header_t *) intern_extra_block + Wsize_bsize(request);
Assert(intern_dest <= end_extra_block);
if (intern_dest < end_extra_block){
- make_free_blocks ((value *) intern_dest, end_extra_block - intern_dest,
- 0);
+ caml_make_free_blocks ((value *) intern_dest,
+ end_extra_block - intern_dest, 0);
}
caml_add_to_heap(intern_extra_block);
}
@@ -564,8 +564,8 @@ unsigned char * caml_code_checksum(void)
struct MD5Context ctx;
caml_MD5Init(&ctx);
caml_MD5Update(&ctx,
- (unsigned char *) code_area_start,
- code_area_end - code_area_start);
+ (unsigned char *) caml_code_area_start,
+ caml_code_area_end - caml_code_area_start);
caml_MD5Final(checksum, &ctx);
checksum_computed = 1;
}
@@ -578,7 +578,7 @@ unsigned char * caml_code_checksum(void)
unsigned char * caml_code_checksum(void)
{
- return code_md5;
+ return caml_code_md5;
}
#endif
diff --git a/byterun/interp.c b/byterun/interp.c
index 59a1a0720c..146baa7744 100644
--- a/byterun/interp.c
+++ b/byterun/interp.c
@@ -100,10 +100,10 @@ sp is a local copy of the global variable caml_extern_sp. */
#ifdef THREADED_CODE
#define Restart_curr_instr \
- goto *(jumptable[saved_code[pc - 1 - start_code]])
+ goto *(jumptable[caml_saved_code[pc - 1 - caml_start_code]])
#else
#define Restart_curr_instr \
- curr_instr = saved_code[pc - 1 - start_code]; \
+ curr_instr = caml_saved_code[pc - 1 - caml_start_code]; \
goto dispatch_instr
#endif
@@ -225,8 +225,8 @@ value caml_interprete(code_t prog, asize_t prog_size)
if (prog == NULL) { /* Interpreter is initializing */
#ifdef THREADED_CODE
- instr_table = (char **) jumptable;
- instr_base = Jumptbl_base;
+ caml_instr_table = (char **) jumptable;
+ caml_instr_base = Jumptbl_base;
#endif
return Val_unit;
}
@@ -258,7 +258,7 @@ value caml_interprete(code_t prog, asize_t prog_size)
#ifdef THREADED_CODE
#ifdef DEBUG
next_instr:
- if (icount-- == 0) stop_here ();
+ if (caml_icount-- == 0) caml_stop_here ();
Assert(sp >= caml_stack_low);
Assert(sp <= caml_stack_high);
#endif
@@ -266,8 +266,8 @@ value caml_interprete(code_t prog, asize_t prog_size)
#else
while(1) {
#ifdef DEBUG
- if (icount-- == 0) stop_here ();
- if (trace_flag) disasm_instr(pc);
+ if (caml_icount-- == 0) caml_stop_here ();
+ if (caml_trace_flag) caml_disasm_instr(pc);
Assert(sp >= caml_stack_low);
Assert(sp <= caml_stack_high);
#endif
diff --git a/byterun/intext.h b/byterun/intext.h
index a361745224..5f831e1b63 100644
--- a/byterun/intext.h
+++ b/byterun/intext.h
@@ -165,10 +165,10 @@ unsigned char * caml_code_checksum (void);
#ifndef NATIVE_CODE
#include "fix_code.h"
-#define code_area_start ((char *) start_code)
-#define code_area_end ((char *) start_code + code_size)
+#define caml_code_area_start ((char *) caml_start_code)
+#define caml_code_area_end ((char *) caml_start_code + caml_code_size)
#else
-extern char * code_area_start, * code_area_end;
+extern char * caml_code_area_start, * caml_code_area_end;
#endif
/* </private> */
diff --git a/byterun/ints.c b/byterun/ints.c
index 7e68b91bb0..2106fbd663 100644
--- a/byterun/ints.c
+++ b/byterun/ints.c
@@ -295,7 +295,7 @@ CAMLprim value caml_int32_of_float(value v)
{ return caml_copy_int32((int32)(Double_val(v))); }
CAMLprim value caml_int32_to_float(value v)
-{ return copy_double((double)(Int32_val(v))); }
+{ return caml_copy_double((double)(Int32_val(v))); }
CAMLprim value caml_int32_compare(value v1, value v2)
{
@@ -336,7 +336,7 @@ CAMLprim value caml_int32_float_of_bits(value vi)
{
union { float d; int32 i; } u;
u.i = Int32_val(vi);
- return copy_double(u.d);
+ return caml_copy_double(u.d);
}
/* 64-bit integers */
@@ -470,7 +470,7 @@ CAMLprim value caml_int64_of_float(value v)
CAMLprim value caml_int64_to_float(value v)
{
int64 i = Int64_val(v);
- return copy_double(I64_to_double(i));
+ return caml_copy_double(I64_to_double(i));
}
CAMLprim value caml_int64_of_int32(value v)
@@ -558,7 +558,7 @@ CAMLprim value caml_int64_float_of_bits(value vi)
{
union { double d; int64 i; } u;
u.i = Int64_val(vi);
- return copy_double(u.d);
+ return caml_copy_double(u.d);
}
/* Native integers */
@@ -692,7 +692,7 @@ CAMLprim value caml_nativeint_of_float(value v)
{ return caml_copy_nativeint((long)(Double_val(v))); }
CAMLprim value caml_nativeint_to_float(value v)
-{ return copy_double((double)(Nativeint_val(v))); }
+{ return caml_copy_double((double)(Nativeint_val(v))); }
CAMLprim value caml_nativeint_of_int32(value v)
{ return caml_copy_nativeint(Int32_val(v)); }
diff --git a/byterun/major_gc.c b/byterun/major_gc.c
index e2fbc83d22..4c9545e1d5 100644
--- a/byterun/major_gc.c
+++ b/byterun/major_gc.c
@@ -45,7 +45,7 @@ unsigned long caml_allocated_words;
double caml_extra_heap_memory;
unsigned long caml_fl_size_at_phase_change = 0;
-extern char *fl_merge; /* Defined in freelist.c. */
+extern char *caml_fl_merge; /* Defined in freelist.c. */
static char *markhp, *chunk, *limit;
@@ -60,7 +60,7 @@ static void realloc_gray_vals (void)
value *new;
Assert (gray_vals_cur == gray_vals_end);
- if (gray_vals_size < stat_heap_size / 128){
+ if (gray_vals_size < caml_stat_heap_size / 128){
caml_gc_message (0x08, "Growing gray_vals to %luk bytes\n",
(long) gray_vals_size * sizeof (value) / 512);
new = (value *) realloc ((char *) gray_vals,
@@ -103,7 +103,7 @@ static void start_cycle (void)
gc_subphase = Subphase_main;
markhp = NULL;
#ifdef DEBUG
- heap_check ();
+ caml_heap_check ();
#endif
}
@@ -222,7 +222,7 @@ static void mark_slice (long work)
}else{
/* Subphase_weak is done. Handle finalised values. */
gray_vals_cur = gray_vals_ptr;
- final_update ();
+ caml_final_update ();
gray_vals_ptr = gray_vals_cur;
gc_subphase = Subphase_final;
}
@@ -231,13 +231,13 @@ static void mark_slice (long work)
/* Initialise the sweep phase. */
gray_vals_cur = gray_vals_ptr;
caml_gc_sweep_hp = caml_heap_start;
- fl_init_merge ();
+ caml_fl_init_merge ();
caml_gc_phase = Phase_sweep;
chunk = caml_heap_start;
caml_gc_sweep_hp = chunk;
limit = chunk + Chunk_size (chunk);
work = 0;
- caml_fl_size_at_phase_change = fl_cur_size;
+ caml_fl_size_at_phase_change = caml_fl_cur_size;
}
}
gray_vals_cur = gray_vals_ptr;
@@ -261,11 +261,11 @@ static void sweep_slice (long work)
void (*final_fun)(value) = Custom_ops_val(Val_hp(hp))->finalize;
if (final_fun != NULL) final_fun(Val_hp(hp));
}
- caml_gc_sweep_hp = fl_merge_block (Bp_hp (hp));
+ caml_gc_sweep_hp = caml_fl_merge_block (Bp_hp (hp));
break;
case Caml_blue:
/* Only the blocks of the free-list are blue. See [freelist.c]. */
- fl_merge = Bp_hp (hp);
+ caml_fl_merge = Bp_hp (hp);
break;
default: /* gray or black */
Assert (Color_hd (hd) == Caml_black);
@@ -277,7 +277,7 @@ static void sweep_slice (long work)
chunk = Chunk_next (chunk);
if (chunk == NULL){
/* Sweeping is done. */
- ++ stat_major_collections;
+ ++ caml_stat_major_collections;
work = 0;
caml_gc_phase = Phase_idle;
}else{
@@ -298,7 +298,7 @@ long caml_major_collection_slice (long howmuch)
long computed_work;
/*
Free memory at the start of the GC cycle (garbage + free list) (assumed):
- FM = stat_heap_size * caml_percent_free
+ FM = caml_stat_heap_size * caml_percent_free
/ (100 + caml_percent_free)
Assuming steady state and enforcing a constant allocation rate, then
@@ -310,28 +310,28 @@ long caml_major_collection_slice (long howmuch)
Proportion of G consumed since the previous slice:
PH = caml_allocated_words / G
= caml_allocated_words * 3 * (100 + caml_percent_free)
- / (2 * stat_heap_size * caml_percent_free)
+ / (2 * caml_stat_heap_size * caml_percent_free)
Proportion of extra-heap memory consumed since the previous slice:
PE = caml_extra_heap_memory
Proportion of total work to do in this slice:
P = max (PH, PE)
Amount of marking work for the GC cycle:
- MW = stat_heap_size * 100 / (100 + caml_percent_free)
+ MW = caml_stat_heap_size * 100 / (100 + caml_percent_free)
Amount of sweeping work for the GC cycle:
- SW = stat_heap_size
+ SW = caml_stat_heap_size
Amount of marking work for this slice:
MS = P * MW
- MS = P * stat_heap_size * 100 / (100 + caml_percent_free)
+ MS = P * caml_stat_heap_size * 100 / (100 + caml_percent_free)
Amount of sweeping work for this slice:
SS = P * SW
- SS = P * stat_heap_size
+ SS = P * caml_stat_heap_size
This slice will either mark 2*MS words or sweep 2*SS words.
*/
if (caml_gc_phase == Phase_idle) start_cycle ();
p = (double) caml_allocated_words * 3.0 * (100 + caml_percent_free)
- / Wsize_bsize (stat_heap_size) / caml_percent_free / 2.0;
+ / Wsize_bsize (caml_stat_heap_size) / caml_percent_free / 2.0;
if (p < caml_extra_heap_memory) p = caml_extra_heap_memory;
caml_gc_message (0x40, "allocated_words = %lu\n", caml_allocated_words);
@@ -341,10 +341,10 @@ long caml_major_collection_slice (long howmuch)
(unsigned long) (p * 1000000));
if (caml_gc_phase == Phase_mark){
- computed_work = 2 * (long) (p * Wsize_bsize (stat_heap_size) * 100
+ computed_work = 2 * (long) (p * Wsize_bsize (caml_stat_heap_size) * 100
/ (100 + caml_percent_free));
}else{
- computed_work = 2 * (long) (p * Wsize_bsize (stat_heap_size));
+ computed_work = 2 * (long) (p * Wsize_bsize (caml_stat_heap_size));
}
caml_gc_message (0x40, "ordered work = %ld words\n", howmuch);
caml_gc_message (0x40, "computed work = %ld words\n", computed_work);
@@ -360,7 +360,7 @@ long caml_major_collection_slice (long howmuch)
if (caml_gc_phase == Phase_idle) caml_compact_heap_maybe ();
- stat_major_words += caml_allocated_words;
+ caml_stat_major_words += caml_allocated_words;
caml_allocated_words = 0;
caml_extra_heap_memory = 0.0;
return computed_work;
@@ -380,7 +380,7 @@ void caml_finish_major_cycle (void)
Assert (caml_gc_phase == Phase_sweep);
while (caml_gc_phase == Phase_sweep) sweep_slice (LONG_MAX);
Assert (caml_gc_phase == Phase_idle);
- stat_major_words += caml_allocated_words;
+ caml_stat_major_words += caml_allocated_words;
caml_allocated_words = 0;
}
@@ -421,17 +421,17 @@ void caml_init_major_heap (asize_t heap_size)
asize_t page_table_size;
page_table_entry *page_table_block;
- stat_heap_size = clip_heap_chunk_size (heap_size);
- stat_top_heap_size = stat_heap_size;
- Assert (stat_heap_size % Page_size == 0);
- caml_heap_start = (char *) caml_alloc_for_heap (stat_heap_size);
+ caml_stat_heap_size = clip_heap_chunk_size (heap_size);
+ caml_stat_top_heap_size = caml_stat_heap_size;
+ Assert (caml_stat_heap_size % Page_size == 0);
+ caml_heap_start = (char *) caml_alloc_for_heap (caml_stat_heap_size);
if (caml_heap_start == NULL)
caml_fatal_error ("Fatal error: not enough memory for the initial heap.\n");
Chunk_next (caml_heap_start) = NULL;
- caml_heap_end = caml_heap_start + stat_heap_size;
+ caml_heap_end = caml_heap_start + caml_stat_heap_size;
Assert ((unsigned long) caml_heap_end % Page_size == 0);
- stat_heap_chunks = 1;
+ caml_stat_heap_chunks = 1;
caml_page_low = Page (caml_heap_start);
caml_page_high = Page (caml_heap_end);
@@ -447,8 +447,9 @@ void caml_init_major_heap (asize_t heap_size)
caml_page_table [i] = In_heap;
}
- fl_init_merge ();
- make_free_blocks ((value *) caml_heap_start, Wsize_bsize (stat_heap_size), 1);
+ caml_fl_init_merge ();
+ caml_make_free_blocks ((value *) caml_heap_start,
+ Wsize_bsize (caml_stat_heap_size), 1);
caml_gc_phase = Phase_idle;
gray_vals_size = 2048;
gray_vals = (value *) malloc (gray_vals_size * sizeof (value));
diff --git a/byterun/memory.c b/byterun/memory.c
index af7837d75d..702500a844 100644
--- a/byterun/memory.c
+++ b/byterun/memory.c
@@ -150,15 +150,17 @@ int caml_add_to_heap (char *m)
Chunk_next (m) = cur;
*last = m;
- ++ stat_heap_chunks;
+ ++ caml_stat_heap_chunks;
}
/* Update the heap bounds as needed. */
/* already done: if (m < caml_heap_start) heap_start = m; */
if (m + Chunk_size (m) > caml_heap_end) caml_heap_end = m + Chunk_size (m);
- stat_heap_size += Chunk_size (m);
- if (stat_heap_size > stat_top_heap_size) stat_top_heap_size = stat_heap_size;
+ caml_stat_heap_size += Chunk_size (m);
+ if (caml_stat_heap_size > caml_stat_top_heap_size){
+ caml_stat_top_heap_size = caml_stat_heap_size;
+ }
return 0;
}
@@ -175,7 +177,7 @@ static char *expand_heap (mlsize_t request)
malloc_request = caml_round_heap_chunk_size (Bhsize_wosize (request));
caml_gc_message (0x04, "Growing heap to %luk bytes\n",
- (stat_heap_size + malloc_request) / 1024);
+ (caml_stat_heap_size + malloc_request) / 1024);
mem = caml_alloc_for_heap (malloc_request);
if (mem == NULL){
caml_gc_message (0x04, "No room for growing heap\n", 0);
@@ -207,8 +209,9 @@ void caml_shrink_heap (char *chunk)
*/
if (chunk == caml_heap_start) return;
- stat_heap_size -= Chunk_size (chunk);
- caml_gc_message (0x04, "Shrinking heap to %luk bytes\n", stat_heap_size/1024);
+ caml_stat_heap_size -= Chunk_size (chunk);
+ caml_gc_message (0x04, "Shrinking heap to %luk bytes\n",
+ caml_stat_heap_size / 1024);
#ifdef DEBUG
{
@@ -219,7 +222,7 @@ void caml_shrink_heap (char *chunk)
}
#endif
- -- stat_heap_chunks;
+ -- caml_stat_heap_chunks;
/* Remove [chunk] from the list of chunks. */
cp = &caml_heap_start;
@@ -253,7 +256,7 @@ value caml_alloc_shr (mlsize_t wosize, tag_t tag)
char *hp, *new_block;
if (wosize > Max_wosize) caml_raise_out_of_memory ();
- hp = fl_allocate (wosize);
+ hp = caml_fl_allocate (wosize);
if (hp == NULL){
new_block = expand_heap (wosize);
if (new_block == NULL) {
@@ -262,8 +265,8 @@ value caml_alloc_shr (mlsize_t wosize, tag_t tag)
else
caml_raise_out_of_memory ();
}
- fl_add_block (new_block);
- hp = fl_allocate (wosize);
+ caml_fl_add_block (new_block);
+ hp = caml_fl_allocate (wosize);
}
Assert (Is_in_heap (Val_hp (hp)));
@@ -312,7 +315,8 @@ void caml_adjust_gc_speed (mlsize_t mem, mlsize_t max)
caml_urge_major_slice ();
}
if (caml_extra_heap_memory > (double) Wsize_bsize (caml_minor_heap_size)
- / 2.0 / (double) Wsize_bsize (stat_heap_size)) {
+ / 2.0
+ / (double) Wsize_bsize (caml_stat_heap_size)) {
caml_urge_major_slice ();
}
}
diff --git a/byterun/memory.h b/byterun/memory.h
index d73f49e136..f98e151521 100644
--- a/byterun/memory.h
+++ b/byterun/memory.h
@@ -363,16 +363,16 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */
#define End_roots() caml_local_roots = caml__roots_block.next; }
-/* [register_global_root] registers a global C variable as a memory root
- for the duration of the program, or until [remove_global_root] is
+/* [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 register_global_root (value *);
+CAMLextern void caml_register_global_root (value *);
-/* [remove_global_root] removes a memory root registered on a global C
- variable with [register_global_root]. */
+/* [caml_remove_global_root] removes a memory root registered on a global C
+ variable with [caml_register_global_root]. */
-CAMLextern void remove_global_root (value *);
+CAMLextern void caml_remove_global_root (value *);
#endif /* CAML_MEMORY_H */
diff --git a/byterun/meta.c b/byterun/meta.c
index 722de8c68f..22fe00845b 100644
--- a/byterun/meta.c
+++ b/byterun/meta.c
@@ -39,10 +39,10 @@ CAMLprim value caml_reify_bytecode(value prog, value len)
{
value clos;
#ifdef ARCH_BIG_ENDIAN
- fixup_endianness((code_t) prog, (asize_t) Long_val(len));
+ caml_fixup_endianness((code_t) prog, (asize_t) Long_val(len));
#endif
#ifdef THREADED_CODE
- thread_code((code_t) prog, (asize_t) Long_val(len));
+ caml_thread_code((code_t) prog, (asize_t) Long_val(len));
#endif
clos = caml_alloc_small (1, Closure_tag);
Code_val(clos) = (code_t) prog;
diff --git a/byterun/minor_gc.c b/byterun/minor_gc.c
index 25340d75fb..4cf7077791 100644
--- a/byterun/minor_gc.c
+++ b/byterun/minor_gc.c
@@ -192,7 +192,7 @@ void caml_empty_minor_heap (void)
}
caml_oldify_mopup ();
if (caml_young_ptr < caml_young_start) caml_young_ptr = caml_young_start;
- stat_minor_words += Wsize_bsize (caml_young_end - caml_young_ptr);
+ caml_stat_minor_words += Wsize_bsize (caml_young_end - caml_young_ptr);
caml_young_ptr = caml_young_end;
caml_young_limit = caml_young_start;
caml_ref_table_ptr = ref_table;
@@ -200,7 +200,7 @@ void caml_empty_minor_heap (void)
caml_gc_message (0x02, ">", 0);
caml_in_minor_collection = 0;
}
- final_empty_young ();
+ caml_final_empty_young ();
#ifdef DEBUG
{
value *p;
@@ -221,12 +221,12 @@ void caml_minor_collection (void)
caml_empty_minor_heap ();
- stat_promoted_words += caml_allocated_words - prev_alloc_words;
- ++ stat_minor_collections;
+ caml_stat_promoted_words += caml_allocated_words - prev_alloc_words;
+ ++ caml_stat_minor_collections;
caml_major_collection_slice (0);
caml_force_major_slice = 0;
- final_do_calls ();
+ caml_final_do_calls ();
caml_empty_minor_heap ();
}
diff --git a/byterun/mlvalues.h b/byterun/mlvalues.h
index 97bad2f53c..c0712dbf03 100644
--- a/byterun/mlvalues.h
+++ b/byterun/mlvalues.h
@@ -197,7 +197,7 @@ typedef opcode_t * code_t;
#define Lazy_tag 246
/* Another special case: variants */
-CAMLextern value hash_variant(char * tag);
+CAMLextern value caml_hash_variant(char * tag);
/* 2- If tag >= No_scan_tag : a sequence of bytes. */
@@ -225,8 +225,10 @@ CAMLextern mlsize_t caml_string_length (value); /* size in bytes */
#define Double_val(v) (* (double *)(v))
#define Store_double_val(v,d) (* (double *)(v) = (d))
#else
-CAMLextern double Double_val (value);
-CAMLextern void Store_double_val (value,double);
+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) caml_Store_double_val(v)
#endif
/* Arrays of floating-point numbers. */
@@ -272,10 +274,11 @@ CAMLextern header_t caml_atom_table[];
#ifndef NATIVE_CODE
#define Is_atom(v) ((v) >= Atom(0) && (v) <= Atom(255))
#else
-CAMLextern char * static_data_start, * static_data_end;
+CAMLextern char * caml_static_data_start, * caml_static_data_end;
#define Is_atom(v) \
- ((((char *)(v) >= static_data_start && (char *)(v) < static_data_end) || \
- ((v) >= Atom(0) && (v) <= Atom(255))))
+ ((((char *)(v) >= caml_static_data_start \
+ && (char *)(v) < caml_static_data_end) \
+ || ((v) >= Atom(0) && (v) <= Atom(255))))
#endif
/* Booleans are integers 0 or 1 */
diff --git a/byterun/obj.c b/byterun/obj.c
index 3817f9f872..277c24180a 100644
--- a/byterun/obj.c
+++ b/byterun/obj.c
@@ -155,10 +155,12 @@ CAMLprim value caml_obj_truncate (value v, value newsize)
/* [lazy_is_forward] is obsolete. Stays here to make bootstrapping
easier for patched versions of 3.07. To be removed before 3.08. FIXME */
-CAMLprim value lazy_is_forward (value v)
+/*
+CAMLxxprim value lazy_is_forward (value v)
{
return Val_bool (Is_block (v) && Tag_val (v) == Forward_tag);
}
+*/
CAMLprim value caml_lazy_follow_forward (value v)
{
diff --git a/byterun/roots.c b/byterun/roots.c
index 3f66a1cacc..31e2f9580f 100644
--- a/byterun/roots.c
+++ b/byterun/roots.c
@@ -58,7 +58,7 @@ void caml_oldify_local_roots (void)
caml_oldify_one(*(gr->root), gr->root);
}
/* Finalised values */
- final_do_young_roots (&caml_oldify_one);
+ caml_final_do_young_roots (&caml_oldify_one);
/* Hook */
if (caml_scan_roots_hook != NULL) (*caml_scan_roots_hook)(&caml_oldify_one);
}
@@ -85,7 +85,7 @@ void caml_do_roots (scanning_action f)
f(*(gr->root), gr->root);
}
/* Finalised values */
- final_do_strong_roots (f);
+ caml_final_do_strong_roots (f);
/* Hook */
if (caml_scan_roots_hook != NULL) (*caml_scan_roots_hook)(f);
}
diff --git a/byterun/signals.c b/byterun/signals.c
index a7e36148cf..a76feb3178 100644
--- a/byterun/signals.c
+++ b/byterun/signals.c
@@ -292,7 +292,7 @@ CAMLprim value caml_install_signal_handler(value signal_number, value action)
if (Is_block(action)) {
if (caml_signal_handlers == 0) {
caml_signal_handlers = caml_alloc(NSIG, 0);
- register_global_root(&caml_signal_handlers);
+ caml_register_global_root(&caml_signal_handlers);
}
caml_modify(&Field(caml_signal_handlers, sig), Field(action, 0));
}
diff --git a/byterun/startup.c b/byterun/startup.c
index b8bb795014..a2cf6181f9 100644
--- a/byterun/startup.c
+++ b/byterun/startup.c
@@ -236,7 +236,7 @@ static int parse_command_line(char **argv)
switch(argv[i][1]) {
#ifdef DEBUG
case 't':
- trace_flag = 1;
+ caml_trace_flag = 1;
break;
#endif
case 'v':
@@ -304,7 +304,7 @@ static void parse_camlrunparam(void)
}
}
-extern void init_ieee_floats (void);
+extern void caml_init_ieee_floats (void);
#ifdef _WIN32
extern void caml_signal_thread(void * lpParam);
@@ -326,7 +326,7 @@ CAMLexport void caml_main(char **argv)
/* Machine-dependent initialization of the floating-point hardware
so that it behaves as much as possible as specified in IEEE */
- init_ieee_floats();
+ caml_init_ieee_floats();
caml_init_custom_operations();
caml_ext_table_init(&caml_shared_libs_path, 8);
caml_external_raise = NULL;
@@ -362,8 +362,8 @@ CAMLexport void caml_main(char **argv)
/* Read the table of contents (section descriptors) */
caml_read_section_descriptors(fd, &trail);
/* Initialize the abstract machine */
- init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
- percent_free_init, max_percent_free_init);
+ caml_init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
+ percent_free_init, max_percent_free_init);
caml_init_stack (max_stack_init);
init_atoms();
/* Initialize the interpreter */
@@ -371,8 +371,8 @@ CAMLexport void caml_main(char **argv)
/* Initialize the debugger, if needed */
caml_debugger_init();
/* Load the code */
- code_size = caml_seek_section(fd, &trail, "CODE");
- load_code(fd, code_size);
+ caml_code_size = caml_seek_section(fd, &trail, "CODE");
+ caml_load_code(fd, caml_code_size);
/* Build the table of primitives */
shared_lib_path = read_section(fd, &trail, "DLPT");
shared_libs = read_section(fd, &trail, "DLLS");
@@ -401,7 +401,7 @@ CAMLexport void caml_main(char **argv)
#endif
/* Execute the program */
caml_debugger(PROGRAM_START);
- res = caml_interprete(start_code, code_size);
+ res = caml_interprete(caml_start_code, caml_code_size);
if (Is_exception_result(res)) {
caml_exn_bucket = Extract_exception(res);
if (caml_debugger_in_use) {
@@ -420,7 +420,7 @@ CAMLexport void caml_startup_code(code_t code, asize_t code_size,
{
value res;
- init_ieee_floats();
+ caml_init_ieee_floats();
caml_init_custom_operations();
#ifdef DEBUG
caml_verb_gc = 63;
@@ -428,16 +428,16 @@ CAMLexport void caml_startup_code(code_t code, asize_t code_size,
parse_camlrunparam();
caml_external_raise = NULL;
/* Initialize the abstract machine */
- init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
- percent_free_init, max_percent_free_init);
+ caml_init_gc (minor_heap_init, heap_size_init, heap_chunk_init,
+ percent_free_init, max_percent_free_init);
caml_init_stack (max_stack_init);
init_atoms();
/* Initialize the interpreter */
caml_interprete(NULL, 0);
/* Load the code */
- start_code = code;
+ caml_start_code = code;
#ifdef THREADED_CODE
- thread_code(start_code, code_size);
+ caml_thread_code(caml_start_code, code_size);
#endif
/* Use the builtin table of primitives */
caml_prim_table.size = caml_prim_table.capacity = -1;
@@ -450,7 +450,7 @@ CAMLexport void caml_startup_code(code_t code, asize_t code_size,
/* Run the code */
caml_init_exceptions();
caml_sys_init("", argv);
- res = caml_interprete(start_code, code_size);
+ res = caml_interprete(caml_start_code, code_size);
if (Is_exception_result(res))
caml_fatal_uncaught_exception(Extract_exception(res));
}
diff --git a/byterun/str.c b/byterun/str.c
index 6a61849e37..08bbf839e7 100644
--- a/byterun/str.c
+++ b/byterun/str.c
@@ -53,14 +53,14 @@ CAMLprim value caml_create_string(value len)
CAMLprim value caml_string_get(value str, value index)
{
long idx = Long_val(index);
- if (idx < 0 || idx >= caml_string_length(str)) array_bound_error();
+ if (idx < 0 || idx >= caml_string_length(str)) caml_array_bound_error();
return Val_int(Byte_u(str, idx));
}
CAMLprim value caml_string_set(value str, value index, value newval)
{
long idx = Long_val(index);
- if (idx < 0 || idx >= caml_string_length(str)) array_bound_error();
+ if (idx < 0 || idx >= caml_string_length(str)) caml_array_bound_error();
Byte_u(str, idx) = Int_val(newval);
return Val_unit;
}
diff --git a/byterun/sys.c b/byterun/sys.c
index d3cf71a22d..108a706708 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -299,10 +299,10 @@ CAMLprim value caml_sys_time(value unit)
#endif
struct tms t;
times(&t);
- return copy_double((double)(t.tms_utime + t.tms_stime) / CLK_TCK);
+ return caml_copy_double((double)(t.tms_utime + t.tms_stime) / CLK_TCK);
#else
/* clock() is standard ANSI C */
- return copy_double((double)clock() / CLOCKS_PER_SEC);
+ return caml_copy_double((double)clock() / CLOCKS_PER_SEC);
#endif
}