From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 55339BB9C for ; Fri, 20 Jan 2006 13:39:32 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0KCdW6u032372 for ; Fri, 20 Jan 2006 13:39:32 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA25996 for ; Fri, 20 Jan 2006 13:39:31 +0100 (MET) Received: from [128.93.8.130] (macadam.inria.fr [128.93.8.130]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0KCdV45011692 for ; Fri, 20 Jan 2006 13:39:31 +0100 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: <26EB47FDD566A7469FC862DAF373792F07D737@kaiserslautern1.lmsintl.com> References: <26EB47FDD566A7469FC862DAF373792F07D737@kaiserslautern1.lmsintl.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <9FE64072-F2ED-4324-9482-5E9ECDF9A792@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] C-Interface: CAMLreturn and failwith Date: Fri, 20 Jan 2006 13:39:33 +0100 To: caml users X-Mailer: Apple Mail (2.746.2) X-Miltered: at concorde with ID 43D0DA04.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43D0DA03.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 c-interface:01 camlreturn:01 failwith:01 camlreturn:01 failwith:01 camlprim:01 camlparam:01 camlprim:01 camlparam:01 bytecode:01 handler:01 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Jan 20, 2006, at 13:18, Bauer, Christoph wrote: > Hi, > > a question related to CAMLreturn and failwith in C-Stubcode: > > Is this code correct: > > #include > ... > > CAMLprim value prim( value unit ) > { > CAMLparam0(); > CAMLlocal( result ); > int error; > /* allocate result, error has an errorcode */ > if( error ) failwith( "error"); > else CAMLreturn( result ); > } > > or should it be > > CAMLprim value prim( value unit ) > { > CAMLparam0(); > CAMLlocal( result ); > int error; > /* allocate result, error has an errorcode */ > if( error ) { > caml_local_roots = caml__frame; > failwith( "error"); > } > else CAMLreturn( result ); > } The first one is correct: failwith will take care of deregistering the local roots (actually, the bytecode interpreter does it when failwith longjumps to the exception handler). The second one should work in the current implementation, but it may break in the future. -- Damien