From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 5448C8027D for ; Sat, 14 Oct 2017 00:42:29 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=dra-news@metastack.com; spf=Pass smtp.mailfrom=dra-news@metastack.com; spf=None smtp.helo=postmaster@outmail148107.authsmtp.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dra-news@metastack.com) identity=pra; client-ip=62.13.148.107; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of dra-news@metastack.com designates 62.13.148.107 as permitted sender) identity=mailfrom; client-ip=62.13.148.107; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@outmail148107.authsmtp.com) identity=helo; client-ip=62.13.148.107; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="postmaster@outmail148107.authsmtp.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AgfB3GRHipSL7iIHXwAuFNZ1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ75os2wAkXT6L1XgUPTWs2DsrQf1LqQ7viocFdDyKjCmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWapAQfERTnNAdz?= =?us-ascii?q?Ov+9WsuL15z2hKiO/MiZWQRDhDOnbftNajDw5SfWsMQNy8M2MKc6yjPApH1Fa+?= =?us-ascii?q?Vfg2RyKgTX1zL1+929+oJUzyTRpf8n8NNQGfH+drkiQLpESigmPn444sr2pTHC?= =?us-ascii?q?SxGO7z0SSDNFvABPBl3p5Q/7Ut/Yti/hsfJlkH2WJ8SzS70rQhyn4rtiUwPhgy?= =?us-ascii?q?RBPDk8pjKEwvdshb5W9Ury7yd0xJTZNcTMbKJz?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BTAACnQOFZh2uUDT5cGQEBAQEBAQEBA?= =?us-ascii?q?QEBBwEBAQEBFAEBAQEBAQEBAQEBBwEBAQEBgmaCIC6PBo4+QwEBBoErmEMKhTs?= =?us-ascii?q?ChFZDFAEBAQEBAQEBAQEBEgEBAQgNCQgoL4I4BQEeAQWCOwEBAQMBeQULAgEIG?= =?us-ascii?q?C4yJQIEAQ0NiggFCQMBrjSLNwEBAQEBBQEBAQEBAQEBIIMtggeBCYIygXaBNIU?= =?us-ascii?q?Hg0CCEiAFkhGPNZRrDIIIiXSHCpVCAgQLAhqBOTaBejQhJV6CZYJrgXOJb0QBg?= =?us-ascii?q?RABAQE?= X-IPAS-Result: =?us-ascii?q?A0BTAACnQOFZh2uUDT5cGQEBAQEBAQEBAQEBBwEBAQEBFAE?= =?us-ascii?q?BAQEBAQEBAQEBBwEBAQEBgmaCIC6PBo4+QwEBBoErmEMKhTsChFZDFAEBAQEBA?= =?us-ascii?q?QEBAQEBEgEBAQgNCQgoL4I4BQEeAQWCOwEBAQMBeQULAgEIGC4yJQIEAQ0Nigg?= =?us-ascii?q?FCQMBrjSLNwEBAQEBBQEBAQEBAQEBIIMtggeBCYIygXaBNIUHg0CCEiAFkhGPN?= =?us-ascii?q?ZRrDIIIiXSHCpVCAgQLAhqBOTaBejQhJV6CZYJrgXOJb0QBgRABAQE?= X-IronPort-AV: E=Sophos;i="5.43,373,1503352800"; d="scan'208";a="240948173" Received: from outmail148107.authsmtp.com ([62.13.148.107]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2017 00:42:28 +0200 Received: from mail-c242.authsmtp.com (mail-c242.authsmtp.com [62.13.128.242]) by punt22.authsmtp.com (8.14.2/8.14.2/) with ESMTP id v9DMgQDh002800; Fri, 13 Oct 2017 23:42:26 +0100 (BST) Received: from romulus.metastack.com (114.212-105-213.static.virginmediabusiness.co.uk [213.105.212.114]) (authenticated bits=0) by mail.authsmtp.com (8.15.2/8.15.2) with ESMTPSA id v9DMgOde072551 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 13 Oct 2017 23:42:25 +0100 (BST) (envelope-from dra-news@metastack.com) Received: from remus.metastack.local (remus.metastack.com [172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id v9DMgN45029355; Fri, 13 Oct 2017 23:42:24 +0100 Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%10]) with mapi id 14.03.0361.001; Fri, 13 Oct 2017 23:42:23 +0100 From: David Allsopp To: "Richard W.M. Jones" , =?iso-8859-1?Q?Laurent_Th=E9venoux?= CC: "caml-list@inria.fr" Thread-Topic: [Caml-list] Interfacing C with OCaml and file descriptors Thread-Index: AQHTRBIf8B1kYdtALUykKj4bdvCgOaLiPhaAgAAhQHA= Date: Fri, 13 Oct 2017 22:42:23 +0000 Message-ID: References: <3380AF33-0E0F-46E9-BF03-E61B65E6B838@inria.fr> <20171013213741.ke5ptnxrq2w3n6oq@annexia.org> In-Reply-To: <20171013213741.ke5ptnxrq2w3n6oq@annexia.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [85.255.234.198] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 172.16.0.20 X-Server-Quench: c92bb6ac-b067-11e7-97f7-002590a15db9 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCd1ZAARAlZZVg1f DC4bFwdFRBksPQFF ChxFJgxfNl8UURhQ KkJXbgESJgRHAnZS R3kJW1VTQF9yU2d3 YQhXIwdcYVRPXwB0 UklLXFNTEBpqBAMA SFgXJmQlCFETeHly YENjEHdaVUU0Jk9/ EBxSRD4bN2dmb30e URVfagpTJgRXfh9H b1l/BXIINTcOKBgV TUcAFDk0OXBbKT9J d0ksK04fW0gCFT86 SFgpVSouAU1NYA46 KhhuI1gQVEgQNkh6 PVY6UkgZKwMVEBY2 X-Authentic-SMTP: 61633634383431.1025:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 213.105.212.114/25 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. Subject: RE: [Caml-list] Interfacing C with OCaml and file descriptors Richard W.M. Jones wrote: > On Fri, Oct 13, 2017 at 12:57:33PM +0200, Laurent Th=E9venoux wrote: > > Hi, > > > > I have a naive question about file descriptors and C interface (when > interfacing C with OCaml). >=20 > Firstly, you're confused about the difference between 'FILE *' and a file > descriptor. They are not the same thing at all. Read some basic Unix > texts about the difference. >=20 > Once you've sorted that out, it turns out that you can (currently) cast a > Unix.file_descr from OCaml directly into a C int file descriptor using > Int_val: >=20 > int fd =3D Int_val (fdv); > read (fd, buf, len); FWIW, note that this is not portable - it won't work on Windows, since Unix= .file_descr is a struct. > It would be really nice if there was an official C function defined by > OCaml to do this in a portable and future-proof way! One possibility might be to include the CRT_fd_val macro already in the win= 32unix version of unixsupport.h and make it an "official" conversion.=20 David=20