From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92599 invoked by alias); 18 Dec 2015 22:24:37 -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 92589 invoked by uid 89); 18 Dec 2015 22:24:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1590, our, HTo:U*libffi-discuss X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 18 Dec 2015 22:24:36 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EF3EB8E6E3 for ; Fri, 18 Dec 2015 22:24:34 +0000 (UTC) Received: from zebedee.pink (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBIMOXi3010884; Fri, 18 Dec 2015 17:24:34 -0500 Subject: Re: does it matter how I construct an aggregate struct type if its size is the same? To: libffi-discuss@sourceware.org References: <5673E92C.7090400@redhat.com> <567466D0.5020305@redhat.com> <063E0A50-A359-4F85-8DCF-AFD3B5504973@gmail.com> From: Andrew Haley X-Enigmail-Draft-Status: N1110 Message-ID: <567487A1.4040803@redhat.com> Date: Fri, 18 Dec 2015 22:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015/txt/msg00112.txt.bz2 On 18/12/15 22:15, Hayden Livingston wrote: > Sorry, I should have been clearer -- I'm absolutely talking about > passing by value. But isn't it on a per argument basis and on its > size? If you have a data structure that is 9 bytes, after alignment > let's say it's 12, isn't that all that matters? No. > I mean I'm new to this but it seems that if you have a function > compiled by compiler 1, and let's say it is "exported", i.e. some body > else can call into this code via dlopen/loadlibrary you can't > arbitrarily decide how things should be passed right? It has to be on > an ABI-level, and the ABI I'm guessing says parameter 1 if it's size < > X can be passed on the stack, or use some registers, but does an ABI > also specify that struct member 1 if is less than X size can be passed > in register? Yes, it often does exactly that. So if you have an arg which is 2 ints then the 2 ints get passed in 2 registers. Float members get passed in float registers, etc. These days that's the way things are usually done, with some exceptions such as legacy 32-bit x86. The ABI really does need to know what is inside the struct. > This would mean you have to use only 1 compiler. Huh? Its the ABI. > While typing this email, a thought occurred to me that probably we > programmers know this, and therefore never make our public > dlopen/loadlibrary APIs take structs that are not completely opaque? > > Sorry I'm formulating some of my thoughts .. but I'm new to this. Fair enough. Andrew.