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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 3C01E7F04B for ; Mon, 3 Apr 2017 17:36:07 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=info@gerd-stolpmann.de; spf=None smtp.mailfrom=info@gerd-stolpmann.de; spf=None smtp.helo=postmaster@mout.kundenserver.de Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Adrd/DxCuWYrmLJIUxkyJUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPvypcbcNUDSrc9gkEXOFd2CrakV16yO6+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fdbghMizexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfO?= =?us-ascii?q?pWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnM?= =?us-ascii?q?VhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Xymp4aV2Rx/ykC?= =?us-ascii?q?oJKiA38G/XhMJzgqxUrh2uqB5jzIDbe4yVKPhzc7nBcd8GS2dMXMBcXDFBDIOm?= =?us-ascii?q?aIsPCvIMM+dGoInnulQFsAawBRWrBOPr0j9Ig2X53as80+88FgzG3QogH9wJsH?= =?us-ascii?q?nPo9X6Kr0SXv2swKnT0TXDaPdW2S/46IfSdBAhp+uAUq9ufsfIz0QkCgDLjk2I?= =?us-ascii?q?pID7Ij+ZyP4Bv3aF4+diT+6jlnArpgBrrjSyyMogl5HFi4EVx1ze6Cl0w4g4Kc?= =?us-ascii?q?e5RUN/e9KoDZpduzycOoBrWM0tWXtotzw/yrAeuZ60YiwKyJM/yh7abPyHbpSI?= =?us-ascii?q?7gjgVOaMJzd3mWxqeLSkhxms60ig1PPzVtOu3FlXsCVJitjMtnYT2BzP8sWLVO?= =?us-ascii?q?Zx8lm71TqRyQze6PtILV0qmafaMZIt37A9mocLvUTGBCD2mUH2jKGMdkUj/+il?= =?us-ascii?q?8+XnYrPopp+bLIJ0hR/xMr4zlcCmGuQ4Lg8OX2yD+eS5zrLj+0v5TK9XgfIoiq?= =?us-ascii?q?XZqozVJdwHpq6lBA9Yypos5Ay6DzeiydgYmXgHLElZeB+clIjoO1TOIOjiAvul?= =?us-ascii?q?glSsli1rx/HcMbH7DJXNNCuLrLC0VLJw+0NNgCc8yspY+doAB7UMK+7pV0DZsN?= =?us-ascii?q?3DElkjLlrwi+3uDdE40oIFRSrbCaacNObWsESUzuMpOeiFIoEP7mXTMf8gstHj?= =?us-ascii?q?l3NxokMaebGs1J0RICS5GPphC0qUe3apmcsGFX8Ptww4CuDn3g7RGQVPbmq/Cv?= =?us-ascii?q?pvrgowD5irWN/O?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CrAACMa+JYhoN+49RdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFQEBAQECAQEBAQgBAQEBiHebZpdghiICg0ZCFQEBAQEBAQEBAQEBEgE?= =?us-ascii?q?BAQgLCwgoL4IzIIJDAQICASMVRgsLDgwCJgICVwYBDAgBAYoBDAGqXoImilYBA?= =?us-ascii?q?QEHAgElgQuEUYJ3gmqHWoJfBZxtgVsCm0+GYJN1NYEnOyEUQYRqgXGHeyqCEwE?= =?us-ascii?q?BAQ?= X-IPAS-Result: =?us-ascii?q?A0CrAACMa+JYhoN+49RdGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBiHebZpdghiICg0ZCFQEBAQEBAQEBAQEBEgEBAQgLCwgoL4IzI?= =?us-ascii?q?IJDAQICASMVRgsLDgwCJgICVwYBDAgBAYoBDAGqXoImilYBAQEHAgElgQuEUYJ?= =?us-ascii?q?3gmqHWoJfBZxtgVsCm0+GYJN1NYEnOyEUQYRqgXGHeyqCEwEBAQ?= X-IronPort-AV: E=Sophos;i="5.36,270,1486422000"; d="scan'208";a="219029384" Received: from mout.kundenserver.de ([212.227.126.131]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 03 Apr 2017 17:35:40 +0200 Received: from office1.lan.sumadev.de ([85.183.69.161]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0McRym-1cdObj3XBg-00HgT9; Mon, 03 Apr 2017 17:35:39 +0200 Received: from gerdbook.fritz.box (gerdbook.fritz.box [192.168.5.104]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 51BC9DC05D; Mon, 3 Apr 2017 17:35:39 +0200 (CEST) To: Alexey Egorov , caml-list References: <1491173922.446722065@f400.i.mail.ru> From: Gerd Stolpmann Message-ID: <37807ca9-e783-f69e-04f1-e8edf653f8d3@gerd-stolpmann.de> Date: Mon, 3 Apr 2017 17:35:39 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1491173922.446722065@f400.i.mail.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:4mtbJzx0i0dgSEEmkK+2J4LqOwJLZTJ5S4CbL5btHyOiGK8S51i eRQf5xhJDBtkrCC8miKnyoprRheCgEDmGJTxR0FW850Q1ZlsBEm+XZE9I4VVV0eCO4H0mSF eXPSeLqfSFsY5DGbWg+aCpnPh/6FePJhrTxrmrdpRLDp14KXlRPVT/FY2zcjItOVF82IRXo Lt6TgFByaFyJ6WxiW3Oag== X-UI-Out-Filterresults: notjunk:1;V01:K0:vT6LnjkRr0E=:0CRP4mHThQyAjA56+ZY6TK 3aleQtdV54nTvXRvPArt5mGkopldc+lgS7irrXcR6PkYrgB9+Ik30izs4WqRadsv+4s9Z+/1e sngJSOScs20Dbtpju0JbSvg/qp4THwoHFoPwik8XnYzveJnD1vYf80SpDjJypGemNNYOd6plT 4KxuxG1dz8/UYVzNDBtDDXr7YVBcsUcdSO1QNL1nQn51bRu2GGpcXjv3rbz0PDTpnPMjzm4Xh 60l7UPlwJz58R5KZSgcVH25BYTDavZLVKFhpcK6SGO2Pdvc+IvzosU8DOUYMM5+Qzwak+R1b8 gQoHRPPY2hPVofE30bW5UVSeKKqqkC3Z2MrtGRJJDZb0tPcuQgTHSiecgGjFf8acwPQe6GmX6 Gaj2zg8jJ86QFFq0diMnXWXhbEoO5eUz+RhfrnFfc7s8mG1QzVBNVaWIVmIOu3lo47bx/qk1n yEKieaXKacz4eQmnk+vmWRAvgU123v1TVJjua2L+OV8V48ISdSi4eMSBV4Ue6iE6/6wFNOl+b fhsk9744xU45TdeO19+BOask1Fd1wxFPaWLRsNGvdC5I7zIYrNMyeafzw6N/f+DITV4mFZsIa Q3Z0Rt8AFlZ29SY9KFIEC/4ppnCtObyS2aLOg1e+fKt53mtO9qGciPcpOVc5zwyqjJ7y+d9OA II35v03rJjIGE8gGYPqBUbviN/CQ5l/99kibFS3KpO01jFE7XuPRJwgmlq7tKg+nQ3Fdmn5L6 Wm43b3TfRX/+4jj5 Subject: Re: [Caml-list] Some questions regarding OCaml FFI On 03.04.17 00:58, Alexey Egorov wrote: > Hello, > > I have some questions about OCaml FFI: > > 1) Should I declare local variable with CAMLlocalN if its used "temporarily", for example: > CAMLreturn(Val_long(1)); > vs > CAMLlocal1(longval); > longval = Val_long(1); > CAMLreturn(longval); The specialty of a CAMLlocal variable is that the value is then a local root, and this has important effects on the garbage collector. In particular the value is considered as reachable (and thus not deallocated if it is the last reference to it), and second, if the block for this value is moved to a new memory address, the pointer is updated. Of course, this all is only meaningful if the value is really a block (and not just an integer). So in your case this alone means that CAMLlocal is not needed. Also, you only need this if you call into the OCaml runtime for memory allocation (i.e. a GC is possible). You do not do this here (CAMLreturn is harmless in this respect - just deletes the local roots). > 2) Should I call 'caml_acquire_runtime_system()' prior to calling OCaml functions from C main()? If so - should I call it before or after 'caml_startup()'? Hah! The new naming is not clearer than the old... No, you don't need to. Gerd