remove_file outfile;
raise x
+(* List of primitives declared in caml/mlvalues.h, to avoid duplicate
+ declarations in generated .c files *)
+
+let mlvalues_primitives = [
+ "caml_get_public_method";
+ "caml_hash_variant";
+ "caml_string_length";
+ "caml_Double_val";
+ "caml_Store_double_val";
+ "caml_Int64_val";
+ "caml_atom_table";
+ "caml_set_oo_id";
+]
+
(* Output a bytecode executable as a C file *)
let link_bytecode_as_c ppf tolink outfile =
(Marshal.to_string sections []);
output_string outchan "\n};\n\n";
(* The table of primitives *)
- Symtable.output_primitive_table outchan;
+ Symtable.output_primitive_table outchan mlvalues_primitives;
(* The entry point *)
output_string outchan "\
\nvoid caml_startup(char ** argv)\
#else\n\
typedef long value;\n\
#endif\n";
- Symtable.output_primitive_table poc;
+ Symtable.output_primitive_table poc [];
output_string poc "\
#ifdef __cplusplus\n\
}\n\
open Printf
-let output_primitive_table outchan =
+let output_primitive_table outchan blacklist =
let prim = all_primitives() in
for i = 0 to Array.length prim - 1 do
- fprintf outchan "extern value %s();\n" prim.(i)
+ let p = prim.(i) in
+ if not (List.mem p blacklist) then
+ fprintf outchan "extern value %s();\n" p
done;
fprintf outchan "typedef value (*primitive)();\n";
fprintf outchan "primitive caml_builtin_cprim[] = {\n";
for i = 0 to Array.length prim - 1 do
- fprintf outchan " %s,\n" prim.(i)
+ fprintf outchan " (primitive)%s,\n" prim.(i)
done;
fprintf outchan " (primitive) 0 };\n";
fprintf outchan "const char * caml_names_of_builtin_cprim[] = {\n";
val initial_global_table: unit -> Obj.t array
val output_global_map: out_channel -> unit
val output_primitive_names: out_channel -> unit
-val output_primitive_table: out_channel -> unit
+val output_primitive_table: out_channel -> string list -> unit
val data_global_map: unit -> Obj.t
val data_primitive_names: unit -> string
val transl_const: Lambda.structured_constant -> Obj.t