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 7A87C7FEF2 for ; Sun, 28 Feb 2016 01:12:47 +0100 (CET) IronPort-PHdr: 9a23:HNGuvRP8I0wR4ujVRX0l6mtUPXoX/o7sNwtQ0KIMzox0KPj7rarrMEGX3/hxlliBBdydsKIbzbSL+Pm/ByQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTokb7vsMSMPU1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbaKvdK09SflcDS86G2Ez/szi8xfZHiWV4X5Jd2wSmR1MBkDg5Q3zWpT4+n//s+Nh0S2ZNOX5SLk1XXKp6KI9G0ygszsOKzNsqDKfscd3lq8O+B8= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mmatalka@gmail.com; spf=Pass smtp.mailfrom=mmatalka@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f51.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mmatalka@gmail.com) identity=pra; client-ip=74.125.82.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="mmatalka@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of mmatalka@gmail.com designates 74.125.82.51 as permitted sender) identity=mailfrom; client-ip=74.125.82.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="mmatalka@gmail.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@mail-wm0-f51.google.com) identity=helo; client-ip=74.125.82.51; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="postmaster@mail-wm0-f51.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BAAAAnO9JWjjNSfUpehHmoYwQDhxmMToc8OxEBAQEBAQEBARABAQEBBwsLCR8xgi2CLS4BGx4DEhAWNAEEDxEBBQFXh2cBAxIEoDSCB4ExPjGNHYJXhFQKGScNUYQQAQUKBIYEiTuDbgWXDI1iiRaFXo0ML4EPNoIsFAiBSGqIKAEBAQ X-IPAS-Result: A0BAAAAnO9JWjjNSfUpehHmoYwQDhxmMToc8OxEBAQEBAQEBARABAQEBBwsLCR8xgi2CLS4BGx4DEhAWNAEEDxEBBQFXh2cBAxIEoDSCB4ExPjGNHYJXhFQKGScNUYQQAQUKBIYEiTuDbgWXDI1iiRaFXo0ML4EPNoIsFAiBSGqIKAEBAQ X-IronPort-AV: E=Sophos;i="5.22,511,1449529200"; d="scan'208";a="166198503" Received: from mail-wm0-f51.google.com ([74.125.82.51]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 28 Feb 2016 01:12:46 +0100 Received: by mail-wm0-f51.google.com with SMTP id l68so17061922wml.0 for ; Sat, 27 Feb 2016 16:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version; bh=iWWuCZekKnHNLrutByr+7tzDIcpwMCzLXa/4FPbmthM=; b=nCv0O9mylE5aX5A3ONblzDUlTrWbUAyOSkJ/xCLRZHfxzAFMcuDK7APIl2LMZG1PEV lN9avWnNuZKCmwpN+gq13TulcyfD6dIYG9cwsCrNiPwKTG1RiRjDCw4vEzaho/NeMSll ggA3Roo6DSlZ2kmjldYEEFg+CW1Mm9ur5EgAuIsnqFmLd7N6mju3qQuXxXny+KB/6cdl 266gk40KWjRGOe8Tzb0WcL91YUf89TUYMkHcgqNLhKzCe+Zh6Hyqy5/bNTZcPpJeWRSW ZhPBC9fNmP85GCdV2TT+Kgrd7ur7iBkOk93wek5iQvtyo+vz2f70aWSgwe1oxLv9kHDa qUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=iWWuCZekKnHNLrutByr+7tzDIcpwMCzLXa/4FPbmthM=; b=ilwwEa7g1Yx9FgxDnDiLadPqIjcIQHNoDeSFko8kNVTQrQpOggH2yGfGEPKoS9e/VC umKcQYFDcKKXkjsjCHLTbhaMI1J+mBnLI1L0BC1bkoXHLMWYdVDMU3MkpPLac2VF4qFH piSyesC+963piW6FtzCsp3Uwnqaac6Q8uE9Hb5ntEbFEtGSDc3EOr/Vp0j4gPC/qZjiK xFM/AF5v2p3DpyyKl4D9SRHBQeRuK0czs522EasMMkCr7c8+MpocnNC7lADQ55ofnzEN 7zTfdIouzfKpeOU2XLCIID6iwf24XRDO1U1po36+2ipV0LRpf6P8N7z4qIm8WtS4ZHCr nIbw== X-Gm-Message-State: AD7BkJLRninDCXdrDnmxXlNCqWFk3afO67XEzpaGFlL0IgtXLlx4IZFQq2EAvfgHVmBIrg== X-Received: by 10.194.52.8 with SMTP id p8mr7672865wjo.62.1456618366614; Sat, 27 Feb 2016 16:12:46 -0800 (PST) Received: from localhost ([37.153.108.22]) by smtp.gmail.com with ESMTPSA id 77sm9279272wmp.18.2016.02.27.16.12.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Feb 2016 16:12:45 -0800 (PST) From: Malcolm Matalka To: caml-list@inria.fr Date: Sun, 28 Feb 2016 00:12:41 +0000 Message-ID: <86ziulheva.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Subject: [Caml-list] ctypes - Advice for binding big structs? I have a large/complex struct I am trying to create bindings for operations on it in Ocaml. I have an API that tells me how many bytes the struct is so I can allocate it just fine and pass it around to C functions I've bound with ctypes. But some data in it is accessed via members. I started implementing a structure in ctypes for it, but it's getting large and awkward. Are there any best practices around doing this? Some concerns I have: - It seems fragile - a different version of the library might have different members in the struct so keeping my ocaml code in-synch seems error prone. - It's annoying because the struct has a lot of members I don't care about in my case. I only want access to a few members that have important details. - The struct is large with lots of types that I don't necessarily want to create so creating the struct becomes somewhat awkward. If I know the size of the types I might be able to pretend it's an array of N chars or something instead of trying to implement the type just to fill out this struct, but I don't know if that is valid. - I thought about making C code that implements getters/setters for the struct elements I want. The C code will always be correct, but that also feels like a lot of overhead if I'm using this struct in a tight loop. I really just want to access that piece of memory, going in and out of a C call just seems like too much work. Any suggestions? Thanks, /Malcolm