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 A623780143 for ; Sat, 3 Jun 2017 08:44:33 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=rich@annexia.org; spf=Pass smtp.mailfrom=rich@annexia.org; spf=Pass smtp.helo=postmaster@annexia.org Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of rich@annexia.org) identity=pra; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of rich@annexia.org designates 80.68.91.176 as permitted sender) identity=mailfrom; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="rich@annexia.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@annexia.org designates 80.68.91.176 as permitted sender) identity=helo; client-ip=80.68.91.176; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rich@annexia.org"; x-sender="postmaster@annexia.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" IronPort-PHdr: =?us-ascii?q?9a23=3AjHGW1RDBq7n1HSNK3/SSUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPv9p8bcNUDSrc9gkEXOFd2CrakV1ayL7OigATVGusfe9ihaMdRlbFwst4?= =?us-ascii?q?Y/p08aPIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0Iu?= =?us-ascii?q?frymUoHdgN6q2O+s5pbdfxtHhCanYbN1MR66sRjdutMYjIZmK6s90BvEr3lVcO?= =?us-ascii?q?hS2W9kOEifkhj468qy5pJv7zhct/c8/MNcTKv2eLg1QrNfADk6KW4549Hluwfe?= =?us-ascii?q?RgWV/HscVWsWkhtMAwfb6RzxQ4n8vCjnuOdjwSeWJcL5Q6w6VjSk9KdrVQTniD?= =?us-ascii?q?wbOD4j8WHYkdJ/gaRGqx+8vRN/worUYIaINPpie67WYN0XSXZdUstXSidMBJ63?= =?us-ascii?q?YYkSAOobJetWoYnzqUUToxW9CgajGP7gxTFTi3/qwaE3yfgtHR3c0QA+Gd8FrX?= =?us-ascii?q?TarM/yNKcXSe25wrXGzTTfYPNWwzj98pXHeQ0hrv2WWrx8a9fax00oFwPDkFqQ?= =?us-ascii?q?soLpNC6S2+QXsmiU8+pgWPm1hG4hrQF+vDeuxsY2hYXTgYIV0F/E+Dx/zY0oK9?= =?us-ascii?q?O4T0t7bsSlEJtWryyaNo12QtkjQ25yoio6xKcGtJimdyYJ0JQq3x3SZ+Cdf4WJ?= =?us-ascii?q?4R/vTuKcLSpiiH54er+yhhC/+lW6xOLmTMm7ylNKozJFktbSsnAN0ATe5dKBSv?= =?us-ascii?q?t74Eig1jeP2BrJ5uFDO0A0mrLXK58nwrEuipoeqUfOEjPslEj3j6KabEEp9vWy?= =?us-ascii?q?5+j6YLjrp4eQN4puhQH/NqQulNa/AeM9MgUWRWib+Piz1L348ELjRrVKiOM5k6?= =?us-ascii?q?bYsJ/AP8gbobS5AwBN3oY59xm/Fyum0MgfnXQfMF1KYheHj4zwN1HKIfD4Fuu/?= =?us-ascii?q?jk+3kDZrwvDGJqfuDo/MLnjFirfhfKxy51RSyAopnphj4MdfA7QFZfbyQVPZtd?= =?us-ascii?q?rCDxZ/PRbn7fzgDYA37IIVWWuVDuemdoaU+X2P4O80aaHYfo4euB70Lf4o9//n?= =?us-ascii?q?y3gjlglOLuGSwZILZSXgTbxdKEKDbC+0jw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CoCAA1WjJZ/7BbRFBcHRgNg0YoOoENg?= =?us-ascii?q?yWbHgIBFgEBAQaBI5gRLoh0QhUBAQEBAQEBAQEBAWoogjMigwR7EyEFKIpREQy?= =?us-ascii?q?wIItMhhs8ij+FJwWeMgGBWoVGi32CaI8flF41IoEKgQEIRoQ2AQoBAQGCQz82A?= =?us-ascii?q?QGJawEBAQ?= X-IPAS-Result: =?us-ascii?q?A0CoCAA1WjJZ/7BbRFBcHRgNg0YoOoENgyWbHgIBFgEBAQa?= =?us-ascii?q?BI5gRLoh0QhUBAQEBAQEBAQEBAWoogjMigwR7EyEFKIpREQywIItMhhs8ij+FJ?= =?us-ascii?q?wWeMgGBWoVGi32CaI8flF41IoEKgQEIRoQ2AQoBAQGCQz82AQGJawEBAQ?= X-IronPort-AV: E=Sophos;i="5.39,287,1493676000"; d="scan'208";a="227172859" Received: from annexia.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 03 Jun 2017 08:44:32 +0200 Received: from rich by annexia.org with local (Exim 4.84_2) (envelope-from ) id 1dH2nX-00055B-GM for caml-list@inria.fr; Sat, 03 Jun 2017 07:44:31 +0100 Date: Sat, 3 Jun 2017 07:44:31 +0100 From: "Richard W.M. Jones" To: caml-list@inria.fr Message-ID: <20170603064431.GL28111@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [Caml-list] Matching exceptions in C code I'm trying to catch a Unix_error exception in C code, and extract the errno from it. Getting the errno is fine, but the problem is matching on the Unix.Unix_error exception. My original code used the documented method: retv = caml_callbackN_exn (*cb, 4, args); if (Is_exception_result (retv)) { retv = Extract_exception (retv); if (Field (retv, 0) == *caml_named_value ("Unix.Unix_error")) ... However the if statement never matched the exception. (I verified on the OCaml side that the correct exception is being thrown). After reading: http://caml.inria.fr/pub/ml-archives/caml-list/2006/05/097f63cfb39a80418f95c70c3c520aa8.en.html http://caml.inria.fr/pub/ml-archives/caml-list/2009/06/797e2f797f57b8ea2a2c0e431a2df312.en.html it seems I'm not the first person to have this problem. It may be that Unix is linked twice, but I'm not really sure about that. I'm using -output-obj with unix.cmxa linked into the object file, and also -lunix in the link step, which is the documented way to do things, but I don't know if that means the Unix module initializes itself twice. Anyway, I modified the code to this, which *works* and is actually more convenient than the documented method (the real code matches on several other system exceptions as well): ... retv = Extract_exception (retv); exn_name = String_val (Field (Field (retv, 0), 0)); if (strcmp (exn_name, "Unix.Unix_error") == 0) { int errcode = code_of_unix_error (Field (retv, 1)); The questions are: (a) Will this continue to work in future? It seems to be undocumented. (b) Could we have some sort of official function to hide the details? Rich.