From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 26B5FBC37 for ; Tue, 9 Feb 2010 07:53:24 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhcEAFiVcEs+BBBle2dsb2JhbACBMoIAmBEBARYkA6t2kBeBL4JKWwQ X-IronPort-AV: E=Sophos;i="4.49,435,1262559600"; d="scan'208";a="44008981" Received: from smtp-101-monday.nerim.net (HELO kraid.nerim.net) ([62.4.16.101]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Feb 2010 07:53:02 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by kraid.nerim.net (Postfix) with ESMTP id 71BB8CF0C8; Tue, 9 Feb 2010 07:53:01 +0100 (CET) Received: from glinka.lesours ([192.168.0.1]) by hector.lesours with esmtp (Exim 4.71) (envelope-from ) id 1Nejy1-0000jQ-Ee; Tue, 09 Feb 2010 07:53:01 +0100 Message-ID: <4B71065F.6050601@starynkevitch.net> Date: Tue, 09 Feb 2010 07:53:19 +0100 From: Basile STARYNKEVITCH User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: guillaume.yziquel@citycable.ch Cc: Luca de Alfaro , caml-list@inria.fr Subject: Re: [Caml-list] Re: How to wrap around C++? References: <28fa90931002071813k7330ad34s7a2ec8b4cf1c3d11@mail.gmail.com> <7b0bd61a1002080803n6cda4bc5g9eeb8d559538598f@mail.gmail.com> <28fa90931002080833y2ca71705q319a3193d3e75d9f@mail.gmail.com> <4B704D68.4000404@citycable.ch> In-Reply-To: <4B704D68.4000404@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 ocaml:01 runtime:01 pointers:01 invocation:01 runtime:01 camlreturn:01 faiencerie:01 92340:01 reine:01 garbage:01 garbage:01 Guillaume Yziquel wrote: > Essentially, the garbage collector will run potentially each time you > allocate an OCaml value. caml_copy_string? the GC may run. The garbage collector may also run when calling (from C or C++ code) a callback, that is a function like caml_callback ... (see section 18.7 of the manual), since this apply an Ocaml closure which of course will allocate Ocaml values. In practical terms, you should consider that the Ocaml GC can be invoked by any C function from the Ocaml runtime (as seen by your C or C++ code) and that it moves pointers at every invocation. So you better be safe and play carefully Ocaml rules. Unless you really understand all the details of Ocaml runtime, I strongly recommend against playing tricks with Ocaml, for instance trying to avoid CAMLlocalX or CAMLparamX or CAMLreturn macros. 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} ***