diff6-10.chapter18.txtこのページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。 last mod. 2008-08-28 (木) 09:55:27
16,18c16,17 < < User primitives are declared in an implementation file or struct...end module < expression using the external keyword: --- > User primitives are declared in an implementation file or struct...end > module expression using the external keyword: 25,26c24 < << < external input : in_channel -> string -> int -> int -> int --- > << external input : in_channel -> string -> int -> int -> int 37c35 < ``manifest'' external functions --- > "manifest" external functions 48,49c46 < << < external input2 : in_channel * string * int * int -> int = "input2" --- > << external input2 : in_channel * string * int * int -> int = "input2" 55,56c52 < << < type int_endo = int -> int --- > << type int_endo = int -> int 75,76c71 < << < CAMLprim value input(value channel, value buffer, value offset, value length) --- > <<CAMLprim value input(value channel, value buffer, value offset, value length) 92,93c87 < << < CAMLprim value add_nat_native(value nat1, value ofs1, value len1, --- > <<CAMLprim value add_nat_native(value nat1, value ofs1, value len1, 112,113c106 < << < external add_nat: nat -> int -> int -> nat -> int -> int -> int -> --- > << external add_nat: nat -> int -> int -> nat -> int -> int -> int -> 125c118 < called the ``stub code'', is a simple wrapper around the first function that --- > called the "stub code", is a simple wrapper around the first function that 129,130c122 < << < CAMLprim value input(value channel, value buffer, value offset, value length) --- > <<CAMLprim value input(value channel, value buffer, value offset, value length) 142,143c134 < << < long getblock(struct channel * channel, char * p, long n) --- > <<long getblock(struct channel * channel, char * p, long n) 152c143 < ---------------------------------------------------- --- > ----------------------------------------------------- 154,155c145,146 < ---------------------------------------------------- < |caml/mlvalues.h|definition of the value type, and | --- > ----------------------------------------------------- > | caml/mlvalues.h|definition of the value type, and | 165c156 < |caml/callback.h|callback from C to Caml (see | --- > |caml/callback.h |callback from C to Caml (see | 173c164 < ---------------------------------------------------- --- > ----------------------------------------------------- 188c179 < that are not in this standard set result in the ``unavailable C primitive'' --- > that are not in this standard set result in the "unavailable C primitive" 191c182 < In the ``custom runtime'' mode, the Caml linker scans the object files and --- > In the "custom runtime" mode, the Caml linker scans the object files and 204c195 < To link in ``custom runtime'' mode, execute the ocamlc command with: --- > To link in "custom runtime" mode, execute the ocamlc command with: 261,264c252,255 < This facility is currently supported and known to work well under Linux and < Windows (the native Windows port). It is supported, but not fully tested yet, < under FreeBSD, Tru64, Solaris and Irix. It is not supported yet under other < Unixes, Cygwin for Windows, and MacOS. --- > This facility is currently supported and known to work well under Linux, > MacOS X, and Windows (the native Windows port). It is supported, but not fully > tested yet, under FreeBSD, Tru64, Solaris and Irix. It is not supported yet > under other Unixes and under Cygwin for Windows. 326,327c317,318 < raises the ``DLL hell'' problem: some care must be taken to ensure that the < right versions of the shared libraries are found at start-up time. --- > raises the "DLL hell" problem: some care must be taken to ensure that the right > versions of the shared libraries are found at start-up time. 353c344 < system integrating the desired C libraries, then generate ``pure'' bytecode --- > system integrating the desired C libraries, then generate "pure" bytecode 357,359c348,349 < of the ``Unix'' and ``Threads'' libraries, do: < << < ocamlc -make-runtime -o /home/me/ocamlunixrun unix.cma threads.cma --- > of the "Unix" and "Threads" libraries, do: > << ocamlc -make-runtime -o /home/me/ocamlunixrun unix.cma threads.cma 384c374 < one of the `alloc_*' functions below); --- > one of the `caml_alloc_*' functions below); 411c401 < ------------------------------------------------- --- > -------------------------------------------------- 413,414c403,404 < ------------------------------------------------- < |0 to No_scan_tag-1|A structured block (an array| --- > -------------------------------------------------- > | 0 to No_scan_tag-1|A structured block (an array| 438c428 < ------------------------------------------------- --- > -------------------------------------------------- 473c463 < |int |Unboxed integer values. | --- > | int |Unboxed integer values. | 527c517 < |() |Val_int(0) | --- > | () |Val_int(0) | 544,549c534,548 < Objects are represented as zero-tagged blocks. The first field of the block < refers to the object class and associated method suite, in a format that cannot < easily be exploited from C. The remaining fields of the object contain the < values of the instance variables of the object. Instance variables are stored < in the order in which they appear in the class definition (taking inherited < classes into account). --- > Objects are represented as blocks with tag Object_tag. The first field of the > block refers to the object class and associated method suite, in a format that > cannot easily be exploited from C. The second field contains a unique object > ID, used for comparisons. The remaining fields of the object contain the values > of the instance variables of the object. It is unsafe to access directly > instance variables, as the type system provides no guaranteee about the > instance variables contained by an object. > One may extract a public method from an object using the C function > caml_get_public_method (declared in <caml/mlvalues.h>.) Since public method > tags are hashed in the same way as variant tags, and methods are functions > taking self as first argument, if you want to do the method call foo#bar from > the C side, you should call: > << callback(caml_get_public_method(foo, hash_variant("bar")), foo); > >> > 567c566 < field number 1 contains the representation of the pair (v, v'), but not as a --- > field number 1 contains the representation of the pair (v, v'), rather than a 654c653 < - Atom(t) returns an ``atom'' (zero-sized block) with tag t. Zero-sized blocks --- > - Atom(t) returns an "atom" (zero-sized block) with tag t. Zero-sized blocks 658,664c657,663 < - alloc(n, t) returns a fresh block of size n with tag t. If t is less than < No_scan_tag, then the fields of the block are initialized with a valid value < in order to satisfy the GC constraints. < - alloc_tuple(n) returns a fresh block of size n words, with tag 0. < - alloc_string(n) returns a string value of length n characters. The string < initially contains garbage. < - copy_string(s) returns a string value containing a copy of the --- > - caml_alloc(n, t) returns a fresh block of size n with tag t. If t is less > than No_scan_tag, then the fields of the block are initialized with a valid > value in order to satisfy the GC constraints. > - caml_alloc_tuple(n) returns a fresh block of size n words, with tag 0. > - caml_alloc_string(n) returns a string value of length n characters. The > string initially contains garbage. > - caml_copy_string(s) returns a string value containing a copy of the 666,679c665,678 < - copy_double(d) returns a floating-point value initialized with the double d. < < - copy_int32(i), copy_int64(i) and copy_nativeint(i) return a value of Caml < type int32, int64 and nativeint, respectively, initialized with the integer < i. < - alloc_array(f, a) allocates an array of values, calling function f over each < element of the input array a to transform it into a value. The array a is an < array of pointers terminated by the null pointer. The function f receives < each pointer as argument, and returns a value. The zero-tagged block < returned by alloc_array(f, a) is filled with the values returned by the < successive calls to f. (This function must not be used to build an array of < floating-point numbers.) < - copy_string_array(p) allocates an array of strings, copied from the pointer < to a string array p (a `char **'). --- > - caml_copy_double(d) returns a floating-point value initialized with the > double d. > - caml_copy_int32(i), copy_int64(i) and caml_copy_nativeint(i) return a value > of Caml type int32, int64 and nativeint, respectively, initialized with the > integer i. > - caml_alloc_array(f, a) allocates an array of values, calling function f over > each element of the input array a to transform it into a value. The array a > is an array of pointers terminated by the null pointer. The function f > receives each pointer as argument, and returns a value. The zero-tagged > block returned by alloc_array(f, a) is filled with the values returned by > the successive calls to f. (This function must not be used to build an array > of floating-point numbers.) > - caml_copy_string_array(p) allocates an array of strings, copied from the > pointer to a string array p (a `char **'). p must be NULL-terminated. 686,687c685,686 < The following functions are slightly more efficient than alloc, but also much < more difficult to use. --- > The following functions are slightly more efficient than caml_alloc, but also > much more difficult to use. 698,709c697,708 < - alloc_small(n, t) returns a fresh small block of size n <= Max_young_wosize < words, with tag t. If this block is a structured block (i.e. if t < < No_scan_tag), then the fields of the block (initially containing garbage) < must be initialized with legal values (using direct assignment to the fields < of the block) before the next allocation. < - alloc_shr(n, t) returns a fresh block of size n, with tag t. The size of < the block can be greater than `Max_young_wosize'. (It can also be smaller, < but in this case it is more efficient to call alloc_small instead of < alloc_shr.) If this block is a structured block (i.e. if t < No_scan_tag), < then the fields of the block (initially containing garbage) must be < initialized with legal values (using the initialize function described < below) before the next allocation. --- > - caml_alloc_small(n, t) returns a fresh small block of size n <= > Max_young_wosize words, with tag t. If this block is a structured block > (i.e. if t < No_scan_tag), then the fields of the block (initially > containing garbage) must be initialized with legal values (using direct > assignment to the fields of the block) before the next allocation. > - caml_alloc_shr(n, t) returns a fresh block of size n, with tag t. The size > of the block can be greater than `Max_young_wosize'. (It can also be > smaller, but in this case it is more efficient to call caml_alloc_small > instead of caml_alloc_shr.) If this block is a structured block (i.e. if t > < No_scan_tag), then the fields of the block (initially containing garbage) > must be initialized with legal values (using the initialize function > described below) before the next allocation. 718,721c717,720 < - failwith(s), where s is a null-terminated C string (with type `char *'), < raises exception Failure with argument s. < - invalid_argument(s), where s is a null-terminated C string (with type `char < *'), raises exception Invalid_argument with argument s. --- > - caml_failwith(s), where s is a null-terminated C string (with type `char > *'), raises exception Failure with argument s. > - caml_invalid_argument(s), where s is a null-terminated C string (with type > `char *'), raises exception Invalid_argument with argument s. 729,730c728,729 < - raise_constant(id) raises the exception id with no argument; < - raise_with_arg(id, v) raises the exception id with the Caml value v as --- > - caml_raise_constant(id) raises the exception id with no argument; > - caml_raise_with_arg(id, v) raises the exception id with the Caml value v as 732,733c731,732 < - raise_with_string(id, s), where s is a null-terminated C string, raises the < exception id with a copy of the C string s as argument. --- > - caml_raise_with_string(id, s), where s is a null-terminated C string, raises > the exception id with a copy of the C string s as argument. 752,753c751,752 < begin with a call to one of the CAMLparam macros and return with CAMLreturn or < CAMLreturn0. --- > begin with a call to one of the CAMLparam macros and return with CAMLreturn, > CAMLreturn0, or CAMLreturnT. 761,762c760,762 < The macros CAMLreturn and CAMLreturn0 are used to replace the C keyword < return. Every occurence of return x must be replaced by CAMLreturn (x), every --- > The macros CAMLreturn, CAMLreturn0, and CAMLreturnT are used to replace the C > keyword return. Every occurence of return x must be replaced by CAMLreturn (x) > if x has type value, or CAMLreturnT (t, x) (where t is the type of x); every 772,773c772 < << < void foo (value v1, value v2, value v3) --- > <<void foo (value v1, value v2, value v3) 786c785,786 < CAMLlocal macros. Arrays of values are declared with CAMLlocalN. --- > CAMLlocal macros. Arrays of values are declared with CAMLlocalN. These macros > must be used at the beginning of the function, not in a nested block. 792c792 < local variables. You can also use them in nested C blocks within the function. --- > local variables. 794,795c794 < << < value bar (value v1, value v2, value v3) --- > <<value bar (value v1, value v2, value v3) 799c798 < result = alloc (3, 0); --- > result = caml_alloc (3, 0); 813,814c812 < << < value bar (value v1, value v2, value v3) --- > <<value bar (value v1, value v2, value v3) 818c816 < result = alloc (3, 0); --- > result = caml_alloc (3, 0); 835,836c833,834 < register_global_root(&v) just before a valid value is stored in v for the first < time. --- > caml_register_global_root(&v) just before a valid value is stored in v for the > first time. 838c836 < remove_global_root(&v). --- > caml_remove_global_root(&v). 848,849c846,847 < alloc_small and alloc_shr. You can ignore those rules if you stick to the < simplified allocation function alloc. --- > caml_alloc_small and caml_alloc_shr. You can ignore those rules if you stick to > the simplified allocation function caml_alloc. 853,854c851,852 < been allocated with alloc_small, filling is performed by direct assignment to < the fields of the block: --- > been allocated with caml_alloc_small, filling is performed by direct assignment > to the fields of the block: 858,859c856,857 < If the block has been allocated with alloc_shr, filling is performed through < the initialize function: --- > If the block has been allocated with caml_alloc_shr, filling is performed > through the caml_initialize function: 861c859 < initialize(&Field(v, n), v_n); --- > caml_initialize(&Field(v, n), v_n); 876,880c874,878 < is safe only if v is a block newly allocated by alloc_small; that is, if no < allocation took place between the allocation of v and the assignment to the < field. In all other cases, never assign directly. If the block has just been < allocated by alloc_shr, use initialize to assign a value to a field for the < first time: --- > is safe only if v is a block newly allocated by caml_alloc_small; that is, > if no allocation took place between the allocation of v and the assignment to > the field. In all other cases, never assign directly. If the block has just > been allocated by caml_alloc_shr, use caml_initialize to assign a value to a > field for the first time: 882c880 < initialize(&Field(v, n), w); --- > caml_initialize(&Field(v, n), w); 885c883 < value; then, call the modify function: --- > value; then, call the caml_modify function: 887c885 < modify(&Field(v, n), w); --- > caml_modify(&Field(v, n), w); 894,895c892 < << < value alloc_list_int(int i1, int i2) --- > <<value alloc_list_int(int i1, int i2) 900c897 < r = alloc(2, 0); /* Allocate a cons cell */ --- > r = caml_alloc(2, 0); /* Allocate a cons cell */ 903c900 < result = alloc(2, 0); /* Allocate the other cons cell */ --- > result = caml_alloc(2, 0); /* Allocate the other cons cell */ 914,916c911,912 < alloc_small, and filled by direct assignments on their fields. < << < value alloc_list_int(int i1, int i2) --- > caml_alloc_small, and filled by direct assignments on their fields. > <<value alloc_list_int(int i1, int i2) 921c917 < r = alloc_small(2, 0); /* Allocate a cons cell */ --- > r = caml_alloc_small(2, 0); /* Allocate a cons cell */ 924c920 < result = alloc_small(2, 0); /* Allocate the other cons cell */ --- > result = caml_alloc_small(2, 0); /* Allocate the other cons cell */ 933,934c929 < << < value alloc_list_int(int i1, int i2) --- > <<value alloc_list_int(int i1, int i2) 939c934 < r = alloc_small(2, 0); /* Allocate a cons cell */ --- > r = caml_alloc_small(2, 0); /* Allocate a cons cell */ 942c937 < tail = alloc_small(2, 0); /* Allocate the other cons cell */ --- > tail = caml_alloc_small(2, 0); /* Allocate the other cons cell */ 945,946c940,941 < modify(&Field(r, 1), tail); /* cdr of the result = tail */ < return r; --- > caml_modify(&Field(r, 1), tail); /* cdr of the result = tail */ > CAMLreturn (r); 950,952c945 < allocation of tail has taken place since r was allocated. tail is not < registered as a root because there is no allocation between the assignment < where it takes its value and the modify statement that uses the value. --- > allocation of tail has taken place since r was allocated. 962,963c955 < << < type window (* The type "window" remains abstract *) --- > <<type window (* The type "window" remains abstract *) 969d960 < external mvwin: window -> int -> int -> unit = "curses_mvwin" 978,979c969 < << < ocamlc -c curses.mli --- > << ocamlc -c curses.mli 984,987c974,1015 < curses.o, looks like: < << < #include <curses.h> < #include <mlvalues.h> --- > curses_stubs.c, looks like this: > <<#include <curses.h> > #include <caml/mlvalues.h> > #include <caml/memory.h> > #include <caml/alloc.h> > #include <caml/custom.h> > > /* Encapsulation of opaque window handles (of type WINDOW *) > as Caml custom blocks. */ > > static struct custom_operations curses_window_ops = { > "fr.inria.caml.curses_windows", > custom_finalize_default, > custom_compare_default, > custom_hash_default, > custom_serialize_default, > custom_deserialize_default > }; > > /* Accessing the WINDOW * part of a Caml custom block */ > #define Window_val(v) (*((WINDOW **) Data_custom_val(v))) > > /* Allocating a Caml custom block to hold the given WINDOW * */ > static value alloc_window(WINDOW * w) > { > value v = alloc_custom(&curses_window_ops, sizeof(WINDOW *), 0, 1); > Window_val(v) = w; > return v; > } > > value caml_curses_initscr(value unit) > { > CAMLparam1 (unit); > CAMLreturn (alloc_window(initscr())); > } > > value caml_curses_endwin(value unit) > { > CAMLparam1 (unit); > endwin(); > CAMLreturn (Val_unit); > } 989c1017 < value curses_initscr(value unit) --- > value caml_curses_refresh(value unit) 992,994c1020,1021 < CAMLreturn ((value) initscr()); /* OK to coerce directly from WINDOW * to < value since that's a block created by malloc() < */ --- > refresh(); > CAMLreturn (Val_unit); 997c1024 < value curses_wrefresh(value win) --- > value caml_curses_wrefresh(value win) 1000c1027 < wrefresh((WINDOW *) win); --- > wrefresh(Window_val(win)); 1004c1031 < value curses_newwin(value nlines, value ncols, value x0, value y0) --- > value caml_curses_newwin(value nlines, value ncols, value x0, value y0) 1007,1008c1034,1035 < CAMLreturn ((value) newwin(Int_val(nlines), Int_val(ncols), < Int_val(x0), Int_val(y0))); --- > CAMLreturn (alloc_window(newwin(Int_val(nlines), Int_val(ncols), > Int_val(x0), Int_val(y0)))); 1011c1038 < value curses_addch(value c) --- > value caml_curses_addch(value c) 1018c1045,1052 < value curses_addstr(value s) --- > value caml_curses_mvwaddch(value win, value x, value y, value c) > { > CAMLparam4 (win, x, y, c); > mvwaddch(Window_val(win), Int_val(x), Int_val(y), Int_val(c)); > CAMLreturn (Val_unit); > } > > value caml_curses_addstr(value s) 1024a1059,1065 > value caml_curses_mvwaddstr(value win, value x, value y, value s) > { > CAMLparam4 (win, x, y, s); > mvwaddstr(Window_val(win), Int_val(x), Int_val(y), String_val(s)); > CAMLreturn (Val_unit); > } > 1028,1030c1069,1070 < The file curses.c can be compiled with: < << < cc -c -I/usr/local/lib/ocaml curses.c --- > The file curses_stubs.c can be compiled with: > << cc -c -I/usr/local/lib/ocaml curses.c 1033,1034c1073 < << < ocamlc -c curses.c --- > << ocamlc -c curses.c 1039,1040c1078 < << < open Curses --- > <<open Curses 1046c1084 < for i = 1 to 100000 do () done; --- > Unix.sleep 5; 1049,1055c1087,1089 < To compile this program, run: < << < ocamlc -c test.ml < >> < Finally, to link everything together: < << < ocamlc -custom -o test test.cmo curses.o -cclib -lcurses --- > To compile and link this program, run: > << ocamlc -custom -o test unix.cma test.ml curses_stubs.o -cclib > -lcurses 1076,1080c1110,1114 < - callback(f, a) applies the functional value f to the value a and return the < value returned by f. < - callback2(f, a, b) applies the functional value f (which is assumed to be a < curried Caml function with two arguments) to a and b. < - callback3(f, a, b, c) applies the functional value f (a curried Caml --- > - caml_callback(f, a) applies the functional value f to the value a and return > the value returned by f. > - caml_callback2(f, a, b) applies the functional value f (which is assumed to > be a curried Caml function with two arguments) to a and b. > - caml_callback3(f, a, b, c) applies the functional value f (a curried Caml 1082c1116 < - callbackN(f, n, args) applies the functional value f to the n arguments --- > - caml_callbackN(f, n, args) applies the functional value f to the n arguments 1091,1098c1125,1132 < use the functions callback_exn, callback2_exn, callback3_exn, callbackN_exn. < These functions take the same arguments as their non-_exn counterparts, but < catch escaping exceptions and return them to the C code. The return value v of < the callback*_exn functions must be tested with the macro < Is_exception_result(v). If the macro returns ``false'', no exception occured, < and v is the value returned by the Caml function. If Is_exception_result(v) < returns ``true'', an exception escaped, and its value (the exception < descriptor) can be recovered using Extract_exception(v). --- > use the functions caml_callback_exn, caml_callback2_exn, caml_callback3_exn, > caml_callbackN_exn. These functions take the same arguments as their non-_exn > counterparts, but catch escaping exceptions and return them to the C code. The > return value v of the caml_callback*_exn functions must be tested with the > macro Is_exception_result(v). If the macro returns "false", no exception > occured, and v is the value returned by the Caml function. If > Is_exception_result(v) returns "true", an exception escaped, and its value (the > exception descriptor) can be recovered using Extract_exception(v). 1112,1113c1146 < << < let f x = print_string "f is applied to "; print_int n; print_newline() --- > << let f x = print_string "f is applied to "; print_int n; print_newline() 1122,1123c1155 < << < void call_caml_f(int arg) --- > << void call_caml_f(int arg) 1125c1157 < callback(*caml_named_value("test function"), Val_int(arg)); --- > caml_callback(*caml_named_value("test function"), Val_int(arg)); 1134,1135c1166 < << < void call_caml_f(int arg) --- > << void call_caml_f(int arg) 1142c1173 < callback(*closure_f, Val_int(arg)); --- > caml_callback(*closure_f, Val_int(arg)); 1155,1156c1186 < << < exception Error of string --- > << exception Error of string 1164,1165c1194 < << < void raise_error(char * msg) --- > << void raise_error(char * msg) 1167c1196 < raise_with_string(*caml_named_value("test exception"), msg); --- > caml_raise_with_string(*caml_named_value("test exception"), msg); 1188,1192c1217,1221 < code. The argv argument is a C array of strings (type char **) which < represents the command-line arguments, as passed as second argument to main. < The Caml array Sys.argv will be initialized from this parameter. For the < bytecode compiler, argv[0] and argv[1] are also consulted to find the file < containing the bytecode. --- > code. The argv argument is a C array of strings (type char **), terminated > with a NULL pointer, which represents the command-line arguments, as passed > as second argument to main. The Caml array Sys.argv will be initialized from > this parameter. For the bytecode compiler, argv[0] and argv[1] are also > consulted to find the file containing the bytecode. 1277,1278c1306 < << < (* File mod.ml -- some ``useful'' Caml functions *) --- > <<(* File mod.ml -- some ``useful'' Caml functions *) 1291,1292c1319 < << < /* File modwrap.c -- wrappers around the Caml functions */ --- > <</* File modwrap.c -- wrappers around the Caml functions */ 1303c1330 < return Int_val(callback(*fib_closure, Val_int(n))); --- > return Int_val(caml_callback(*fib_closure, Val_int(n))); 1311c1338,1339 < return strdup(String_val(callback(*format_result_closure, Val_int(n)))); --- > return strdup(String_val(caml_callback(*format_result_closure, > Val_int(n)))); 1319,1320c1347 < << < ocamlc -custom -output-obj -o modcaml.o mod.ml --- > << ocamlc -custom -output-obj -o modcaml.o mod.ml 1328c1355 < Now, we can use the two fonctions fib and format_result in any C program, --- > Now, we can use the two functions fib and format_result in any C program, 1330,1331c1357 < << < /* File main.c -- a sample client for the Caml functions */ --- > <</* File main.c -- a sample client for the Caml functions */ 1349,1350c1375 < << < cc -o prog main.c mod.a -lcurses --- > << cc -o prog main.c mod.a -lcurses 1374a1400 > 1378,1381c1404,1406 < as first argument to the function. The finalize field can also be NULL to < indicate that no finalization function is associated with the block. < IMPORTANT NOTE: the v parameter of this function is of type value, but it < must not be declared using the CAMLparam macros. --- > as first argument to the function. The finalize field can also be > custom_finalize_default to indicate that no finalization function is > associated with the block. 1390,1391c1415 < data from the second block. NOTE: You must use CAMLparam to declare v1 and < v2 and CAMLreturn to return the result. --- > data from the second block. 1402,1403c1426 < returns 0) must have the same hash value. NOTE: You must use CAMLparam to < declare v and CAMLreturn to return the result. --- > returns 0) must have the same hash value. 1418,1419c1441 < on a 32-bit architecture and on a 64-bit architecture, respectively. NOTE: < You must use CAMLparam to declare v and CAMLreturn to return the result. --- > on a 32-bit architecture and on a 64-bit architecture, respectively. 1438a1461,1465 > Note: the finalize, compare, hash, serialize and deserialize functions > attached to custom block descriptors must never trigger a garbage collection. > Within these functions, do not call any of the Caml allocation functions, and > do not perform a callback into Caml code. Do not use CAMLparam to register the > parameters to these functions, and do not use CAMLreturn to return the result. 1444,1447c1471,1474 < Custom blocks must be allocated via the alloc_custom function. < alloc_custom(ops, size, used, max) returns a fresh custom block, with room for < size bytes of user data, and whose associated operations are given by ops (a < pointer to a struct custom_operations, usually statically allocated as a C --- > Custom blocks must be allocated via the caml_alloc_custom function. > caml_alloc_custom(ops, size, used, max) returns a fresh custom block, with room > for size bytes of user data, and whose associated operations are given by ops > (a pointer to a struct custom_operations, usually statically allocated as a C 1454c1481 < blocks and avoid having large amount of ``floating garbage'' (unreferenced --- > blocks and avoid having large amount of "floating garbage" (unreferenced 1478,1479c1505,1506 < 1. But if you later find that the finalization functions are not called ``often < enough'', consider increasing the used / max ratio. --- > 1. But if you later find that the finalization functions are not called "often > enough", consider increasing the used / max ratio. 1503c1530 < -------------------------------------------------- --- > ------------------------------------------------------- 1505,1552c1532,1579 < -------------------------------------------------- < |serialize_int_1 |Write a 1-byte integer < |serialize_int_2 |Write a 2-byte integer < |serialize_int_4 |Write a 4-byte integer < |serialize_int_8 |Write a 8-byte integer < |serialize_float_4 |Write a 4-byte float < |serialize_float_8 |Write a 8-byte float < |serialize_block_1 |Write an array of 1-byte < | |quantities < |serialize_block_2 |Write an array of 2-byte < | |quantities < |serialize_block_4 |Write an array of 4-byte < | |quantities < |serialize_block_8 |Write an array of 8-byte < | |quantities < |deserialize_uint_1 |Read an unsigned 1-byte < | |integer < |deserialize_sint_1 |Read a signed 1-byte integer < | | < |deserialize_uint_2 |Read an unsigned 2-byte < | |integer < |deserialize_sint_2 |Read a signed 2-byte integer < | | < |deserialize_uint_4 |Read an unsigned 4-byte < | |integer < |deserialize_sint_4 |Read a signed 4-byte integer < | | < |deserialize_uint_8 |Read an unsigned 8-byte < | |integer < |deserialize_sint_8 |Read a signed 8-byte integer < | | < |deserialize_float_4|Read a 4-byte float < |deserialize_float_8|Read an 8-byte float < |deserialize_block_1|Read an array of 1-byte < | |quantities < |deserialize_block_2|Read an array of 2-byte < | |quantities < |deserialize_block_4|Read an array of 4-byte < | |quantities < |deserialize_block_8|Read an array of 8-byte < | |quantities < |deserialize_error |Signal an error during < | |deserialization; input_value < | |or Marshal.from_... raise a < | |Failure exception after < | |cleaning up their internal < | |data structures < -------------------------------------------------- --- > ------------------------------------------------------- > | caml_serialize_int_1 |Write a 1-byte integer | > |caml_serialize_int_2 |Write a 2-byte integer | > |caml_serialize_int_4 |Write a 4-byte integer | > |caml_serialize_int_8 |Write a 8-byte integer | > |caml_serialize_float_4 |Write a 4-byte float | > |caml_serialize_float_8 |Write a 8-byte float | > |caml_serialize_block_1 |Write an array of 1-byte | > | |quantities | > |caml_serialize_block_2 |Write an array of 2-byte | > | |quantities | > |caml_serialize_block_4 |Write an array of 4-byte | > | |quantities | > |caml_serialize_block_8 |Write an array of 8-byte | > | |quantities | > |caml_deserialize_uint_1 |Read an unsigned 1-byte | > | |integer | > |caml_deserialize_sint_1 |Read a signed 1-byte integer| > | | | > |caml_deserialize_uint_2 |Read an unsigned 2-byte | > | |integer | > |caml_deserialize_sint_2 |Read a signed 2-byte integer| > | | | > |caml_deserialize_uint_4 |Read an unsigned 4-byte | > | |integer | > |caml_deserialize_sint_4 |Read a signed 4-byte integer| > | | | > |caml_deserialize_uint_8 |Read an unsigned 8-byte | > | |integer | > |caml_deserialize_sint_8 |Read a signed 8-byte integer| > | | | > |caml_deserialize_float_4|Read a 4-byte float | > |caml_deserialize_float_8|Read an 8-byte float | > |caml_deserialize_block_1|Read an array of 1-byte | > | |quantities | > |caml_deserialize_block_2|Read an array of 2-byte | > | |quantities | > |caml_deserialize_block_4|Read an array of 4-byte | > | |quantities | > |caml_deserialize_block_8|Read an array of 8-byte | > | |quantities | > |caml_deserialize_error |Signal an error during | > | |deserialization; input_value| > | |or Marshal.from_... raise a | > | |Failure exception after | > | |cleaning up their internal | > | |data structures | > ------------------------------------------------------- 1589,1593c1616,1620 < functions. alloc_final(n, f, used, max) returns a fresh custom block of size n < words, with finalization function f. The first word is reserved for storing the < custom operations; the other n-1 words are available for your data. The two < parameters used and max are used to control the speed of garbage collection, as < described for alloc_custom. --- > functions. caml_alloc_final(n, f, used, max) returns a fresh custom block of > size n words, with finalization function f. The first word is reserved for > storing the custom operations; the other n-1 words are available for your data. > The two parameters used and max are used to control the speed of garbage > collection, as described for caml_alloc_custom. 1604,1605c1631,1632 < This command is available only under Cygwin, but not for the < native Win32 port. --- > This command is available only under Cygwin, but not for the native Win32 > port. 1607,1608d1633 < MacOS: < This command is not available. 1654,1655c1679 < << < ocamlmklib -o zip zip.cmo zip.cmx zipstubs.o -lz -L/usr/local/zlib --- > <<ocamlmklib -o zip zip.cmo zip.cmx zipstubs.o -lz -L/usr/local/zlib 1658,1659c1682 < << < ocamlc -a -o zip.cma zip.cmo -dllib -lzip \ --- > <<ocamlc -a -o zip.cma zip.cmo -dllib -lzip \ 1668,1669c1691 < << < ocamlc -a -custom -o zip.cma zip.cmo -cclib -lzip \ --- > <<ocamlc -a -custom -o zip.cma zip.cmo -cclib -lzip \ 1678,1679c1700 < << < ocamlmklib -o zip zip.cmo -lz -L/usr/local/zlib --- > <<ocamlmklib -o zip zip.cmo -lz -L/usr/local/zlib 1682,1683c1703 < << < ocamlmklib -o zip zip.cmx -lz -L/usr/local/zlib --- > <<ocamlmklib -o zip zip.cmx -lz -L/usr/local/zlib 1686,1687c1706 < << < ocamlmklib -o zip zipstubs.o -lz -L/usr/local/zlib --- > <<ocamlmklib -o zip zipstubs.o -lz -L/usr/local/zlib |