From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80656 invoked by alias); 18 Dec 2015 22:16:04 -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 80645 invoked by uid 89); 18 Dec 2015 22:16:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:D*cornell.edu, loadlibrary, formulating, jay X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 18 Dec 2015 22:16:02 +0000 Received: by mail-wm0-f41.google.com with SMTP id l126so2316924wml.1 for ; Fri, 18 Dec 2015 14:16:01 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.200.134 with SMTP id js6mr7503876wjc.114.1450476959402; Fri, 18 Dec 2015 14:15:59 -0800 (PST) Received: by 10.194.185.74 with HTTP; Fri, 18 Dec 2015 14:15:59 -0800 (PST) In-Reply-To: <063E0A50-A359-4F85-8DCF-AFD3B5504973@gmail.com> References: <5673E92C.7090400@redhat.com> <567466D0.5020305@redhat.com> <063E0A50-A359-4F85-8DCF-AFD3B5504973@gmail.com> Date: Fri, 18 Dec 2015 22:16:00 -0000 Message-ID: Subject: Re: does it matter how I construct an aggregate struct type if its size is the same? From: Hayden Livingston To: Jay Cc: Andrew Haley , "libffi-discuss@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015/txt/msg00111.txt.bz2 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? 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? This would mean you have to use only 1 compiler. 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. On Fri, Dec 18, 2015 at 1:42 PM, Jay wrote: > Still beware of alignment. > > - Jay > > On Dec 18, 2015, at 12:04 PM, Andrew Haley wrote: > >> On 18/12/15 15:16, Hayden Livingston wrote: >>> Thanks, Andrew. Where is this exception? In ABIs? >>> >>> So you're suggesting I use char's to construct my ffi_types? >> >> Well, it can be awkward. Some targets pass the components of a >> struct in registers. But this only matters if you pass a struct >> by value, which is a fairly unusual thing to do in C. If you're >> passing a struct by reference, then yes, you can just create a >> char array of the right size. >> >> Andrew. >>