From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16705 invoked by alias); 22 Jun 2017 02:34:50 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 16687 invoked by uid 89); 22 Jun 2017 02:34:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_05,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:64.59.136.138, H*RU:64.59.136.138, compromise, HX-PHP-Originating-Script:501 X-HELO: smtp-out-so.shaw.ca Received: from smtp-out-so.shaw.ca (HELO smtp-out-so.shaw.ca) (64.59.136.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Jun 2017 02:34:46 +0000 Received: from kylheku.com ([70.79.163.252]) by shaw.ca with SMTP id NrxCddBFYyd2DNrxDdcdu9; Wed, 21 Jun 2017 20:34:44 -0600 X-Authority-Analysis: v=2.2 cv=F5wnTupN c=1 sm=1 tr=0 a=95A0EdhkF1LMGt25d7h1IQ==:117 a=95A0EdhkF1LMGt25d7h1IQ==:17 a=IkcTkHD0fZMA:10 a=SMorJkV_YP8A:10 a=LWSFodeU3zMA:10 a=WYz4jDt2BycA:10 a=_GgHL9F0ZgnBCO8dv6UA:9 a=QEXdDO2ut3YA:10 Received: from www-data by kylheku.com with local (Exim 4.72) (envelope-from ) id 1dNrxB-00036a-IB for libffi-discuss@sourceware.org; Wed, 21 Jun 2017 19:34:41 -0700 To: libffi-discuss@sourceware.org Subject: Does a =?UTF-8?Q?FFI=5FSTRUCT=20type=20really=20need=20the=20elem?= =?UTF-8?Q?ents=20array=3F?= X-PHP-Originating-Script: 501:rcmail.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Thu, 22 Jun 2017 02:34:00 -0000 From: Kaz Kylheku Message-ID: X-Sender: kaz@kylheku.com User-Agent: Roundcube Webmail/0.9.2 X-CMAE-Envelope: MS4wfGeKGUHMKLfqlVTPyBFzbzM1rUiwbZwFHUfkTLSKaIhT/YfiYjfMsJok+PMHiBfRa7eMgu29FmML8l71jeRuSFUSYIWuETzJaFSo59i3ceA1KmTUzyX7 69xHT2dJnDKSUJ0VkNa6LBr/CMvXfQWV6kTjKZPtggfdeqxUvlpG02+jF26j7mTn6PlEBoGmFMDKMw== X-SW-Source: 2017/txt/msg00015.txt.bz2 Hi libffi users, Here is the thing. Suppose I have a sophisticated FFI implementation which uses libffi. Of course I've done all the struct layout=20 calculations yourself: the offset of every member, taking into account its alignment=20 to generate any padding in between them and at the end. (I need this in=20 situations not involving libffi!) Yet, I have to mirror this information in the libffi data structure: a FFI_STRUCT type has to have an elements[] array of types. Presumably libffi just walks these, redundantly doing the same calculations to get the offset of every member, total size with padding and alignment. Can't we dispense with the elements[] array and just punch in the size and alignment values into the struct type (that are supposed to be left zero?) Or is there some compromise: a one-element elements[] array (well two,=20 with null termination), where a single element indicates the size and alignment somehow. Or how about a one-element array whose one and only pointer is the null terminator; with the size and alignment punched in: would that work? It's wasteful to allocate, initialize and free these arrays and to have libffi walking over them. Any words of wisdom?