[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Basile STARYNKEVITCH <basile@s...> |
| Subject: | Re: [Caml-list] problem creating .cma library |
Guillaume Yziquel wrote:
>
> However, I had a look at
>
> https://yquem.inria.fr/caml/svn/ocaml/version/3.09/byterun/sys.c
>
> and more specifically at the function
>
>> CAMLprim value caml_sys_exit(value retcode)
>> {
>> #ifndef NATIVE_CODE
>> caml_debugger(PROGRAM_EXIT);
>> #endif
>> exit(Int_val(retcode));
>> return Val_unit;
>> }
>
> or the function
>
>> CAMLprim value caml_sys_close(value fd)
>> {
>> close(Int_val(fd));
>> return Val_unit;
>> }
>
> Why do these functions not follow the usual CAMLparam/CAMLreturn macro
> stuff?
>
Because they are written by the Ocaml guys (Damien knows really well the Ocaml garbage collector; he wrote it). And
also, because these particular functions do not do any allocation of Ocaml values (either directly or indirectly).
My advice for people coding C code for ocaml is the following:
1. *always* use the CAMLparam/CAMLreturn/... macros.
2. if you dare not using them for some very few functions (because they don't allocate, ...) add a big fat comment with
a warning inside.
Regards
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***