From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 50218BBAF for ; Sat, 9 Jan 2010 00:53:53 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoDAN9UR0s+BBFpe2dsb2JhbACBRIIal30BARYkA6xRjQmBK4IuVgQ X-IronPort-AV: E=Sophos;i="4.49,245,1262559600"; d="scan'208";a="44494581" Received: from smtp-105-friday.noc.nerim.net (HELO mallaury.nerim.net) ([62.4.17.105]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Jan 2010 00:53:53 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by mallaury.nerim.net (Postfix) with ESMTP id 1A7CEA1062; Sat, 9 Jan 2010 00:53:51 +0100 (CET) Received: from glinka.lesours ([192.168.0.1]) by hector.lesours with esmtp (Exim 4.71) (envelope-from ) id 1NTOeO-00041E-Hz; Sat, 09 Jan 2010 00:53:52 +0100 Message-ID: <4B47C59C.9080505@starynkevitch.net> Date: Sat, 09 Jan 2010 00:54:04 +0100 From: Basile STARYNKEVITCH User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: guillaume.yziquel@citycable.ch Cc: Damien Doligez , caml-list List Subject: Re: [Caml-list] problem creating .cma library References: <56670.41.177.16.252.1262195331.squirrel@41.177.16.252> <4B3BE288.4030701@citycable.ch> <3EE07409-9559-4B91-BA3E-8787D1378275@inria.fr> <4B47C201.7090201@citycable.ch> In-Reply-To: <4B47C201.7090201@citycable.ch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 guillaume:01 ocaml:01 byterun:01 camlprim:01 debugger:01 val:01 val:01 camlprim:01 camlparam:01 camlreturn:01 ocaml:01 damien:01 camlparam:01 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: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***