From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 9BDC27F30A for ; Tue, 12 Mar 2013 16:13:14 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jdimino@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jdimino@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="jdimino@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jdimino@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjcBAMBFP1EmacjlmWdsb2JhbABDxGOBPx4OAQEBAQEICwsHFCiCKAEBBAFAAQE3AQQLCwsNLiISAQUBHAYTCIgGBgOiY4pygzGBCgEFjnUGjw0Hg0CWWYV7iRkWKYQt X-IPAS-Result: AjcBAMBFP1EmacjlmWdsb2JhbABDxGOBPx4OAQEBAQEICwsHFCiCKAEBBAFAAQE3AQQLCwsNLiISAQUBHAYTCIgGBgOiY4pygzGBCgEFjnUGjw0Hg0CWWYV7iRkWKYQt X-IronPort-AV: E=Sophos;i="4.84,831,1355094000"; d="scan'208";a="7080622" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Mar 2013 16:13:13 +0100 Received: from [172.27.22.15] (helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UFQt7-00038S-AZ for caml-list@inria.fr; Tue, 12 Mar 2013 11:13:13 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1UFQt5-000714-Pa for caml-list@inria.fr; Tue, 12 Mar 2013 11:13:11 -0400 Received: from mail-oa0-f72.google.com ([209.85.219.72]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UFQt5-0001LV-N7 for caml-list@inria.fr; Tue, 12 Mar 2013 11:13:11 -0400 Received: by mail-oa0-f72.google.com with SMTP id j6so30202886oag.3 for ; Tue, 12 Mar 2013 08:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Qawj358tq8xCenoJH+74GhXmSn50cfgXGA2xJIBf9Qc=; b=X+V207jv1LN/yKwCthnvuc8MiUTmC/FoGtRyFJJcCpYTrh38LZVzkjgDkU9Ak1Ee1u VqG0CqAVBCyPRKDhzz37kL7DIkuLEe2F/vV7UxFKw72H4dGuYyTNHRqlHwOZrT5F82Jg 6QsMWZXmOB2lB+FqvKC/adMvC59Gci2kQ5ZOs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=Qawj358tq8xCenoJH+74GhXmSn50cfgXGA2xJIBf9Qc=; b=cTSL23wlxs5LNCPeHc9hkjhgNmD+ZNDjtK5DJ0KN0LzGGw9U1xwLW45RranphN1oKx G/W/j7H/5l/hhG+69pfUCYD0Y+oErkc1z0ec11TXNjM5E8eKGYJOkCCaT+fl6HIvjdTw WBHnbltcwEbi5ccH29fE9AqOEMOTGQWyN/ONgQdQKRrfZpP4Si59lS9h5Xx+w6uzZ/tE FeAmXscnJgkHmGVVRJ5UA0y+219L92jcX5wUCGOlWS5eE4rlSFmfxXdiCIw0EZE9+Xf7 1FCBlQd11vu3djKddnn6ro1cJjDCV+pRtbAjwWJaRPEbW2ExdL4PANKFVbAquZx4AUB2 fLkA== X-Received: by 10.50.189.170 with SMTP id gj10mr12364261igc.1.1363101191322; Tue, 12 Mar 2013 08:13:11 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.189.170 with SMTP id gj10mr12364248igc.1.1363101191167; Tue, 12 Mar 2013 08:13:11 -0700 (PDT) Received: by 10.50.29.48 with HTTP; Tue, 12 Mar 2013 08:13:11 -0700 (PDT) In-Reply-To: <513F41BC.7070509@inria.fr> References: <513F41BC.7070509@inria.fr> Date: Tue, 12 Mar 2013 15:13:11 +0000 Message-ID: From: Jeremie Dimino To: Romain Bardou Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkOvy3k9euHFQRa4iaOcQqpT5BIrERBrIpk1JjqYf/1VBsDfFuOoMb6CWkZO1hD3SQBb11soi3QanPGd6kKWi5YQmF2W7pnEsuIaJTYVBjf+rIL+hpxzw4rDKB/k2TooAIFrvFeTMJAkYrSQVdkRZfhPVOxrA== Subject: Re: [Caml-list] Auxiliary C function which manipulates the OCaml heap Hi, On Tue, Mar 12, 2013 at 2:54 PM, Romain Bardou wrote: > However, this function does not use CAMLreturn, as it does not return an > OCaml value but a C value (actually void). So the compiler emits a warning: > "unused variable 'caml__frame'" if I use CAMLparam in aux. > > Is it ok to call CAMLlocal in this way? The documentation says it cannot be > called inside nested blocks. Is an auxiliary function considered a nested > block? No, you must use [CAMLreturn0] in this case. > Note that the caller of "aux", or (in another case) the caller of the caller > of "aux", has called CAMLparam. If this was not the case, would it make a > difference? No, CAMLparam macros are only for the current function. They register the C local variables as local roots. In sub-function they are different local variables (different position on the stack) so you need to register them too. > Similarly, if "aux" had some OCaml value arguments, should it call CAMLparam > even though the caller of "aux" has declared them to the GC using CAMLparam > or CAMLlocal? Yes. > Similarly, if "aux" did return an OCaml value, should it call CAMLreturn > (and thus CAMLparam) to return the value, or should it use the normal > "return"? You must use [CAMLreturnT(C-type, expr)] in this case. And for other cases you can also use Begin_roots and End_roots.