From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 331F8BBC1 for ; Thu, 10 Apr 2008 18:49:01 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AowAABfi/UfU4363k2dsb2JhbACRTQEBAQEJAwkJFpl3 X-IronPort-AV: E=Sophos;i="4.25,636,1199660400"; d="scan'208";a="24852902" Received: from moutng.kundenserver.de ([212.227.126.183]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Apr 2008 18:49:00 +0200 Received: from [134.158.129.229] (polvisit10.in2p3.fr [134.158.129.229]) by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis) id 0ML25U-1JjzxM062j-0001NH; Thu, 10 Apr 2008 18:49:00 +0200 Message-ID: <47FE4533.5090402@kende.fr> Date: Thu, 10 Apr 2008 18:49:55 +0200 From: Mathias Kende User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Question about CAMLparamx macros References: <47FE3E65.7030907@rice.edu> In-Reply-To: <47FE3E65.7030907@rice.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V01U2FsdGVkX1+HGAEK73z80O5DFdFs691QEF7HCsg9w5EmVqz fuRGYDuHFzww4NsfI/nn6AVH4A2tasB0kPN8vKywzmVC63WDh6 Vp/8L832UqlclnWoBwKAd/e9YFWeUqL X-Spam: no; 0.00; alloc:01 foo:01 foo:01 camlparam:01 camlreturn:01 mathias:98 mathias:98 caml-list:01 functions:01 macros:01 macros:01 int:01 int:01 callback:02 callback:02 Raj Bandyopadhyay a écrit : > Do I have to use the CAMLparamx/CAMLlocalx/CAMLreturnx macros in the > above cases? Would it cause problems if I used them anyway? You should at least use these macros when the GC may be triggered during your C function (e.g. with calls to some of the alloc_ functions) and you have local "value", even if your function does not accept value as argument and/or does not return a "value" variable. > value foo(int x){ > return caml_callback(); > } > > should be replaced by > > value foo(int x){ > CAMLparam0(); > CAMLreturn(caml_callback()); > } I believe that the first is correct, but I am not a real guru of this Ocaml-C binding, so I am not sure of this. Mathias