From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkZcd-0006ns-9m for qemu-devel@nongnu.org; Thu, 06 Jun 2013 08:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkZcW-0001eO-PD for qemu-devel@nongnu.org; Thu, 06 Jun 2013 08:48:55 -0400 Received: from mail-yh0-x235.google.com ([2607:f8b0:4002:c01::235]:41510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkZcW-0001eG-Jv for qemu-devel@nongnu.org; Thu, 06 Jun 2013 08:48:48 -0400 Received: by mail-yh0-f53.google.com with SMTP id a41so694315yho.26 for ; Thu, 06 Jun 2013 05:48:48 -0700 (PDT) Sender: Richard Henderson Message-ID: <51B0852B.9030306@twiddle.net> Date: Thu, 06 Jun 2013 05:48:43 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1369430452-27598-1-git-send-email-rth@twiddle.net> <1370397380.17798.73.camel@liguang.fnst.cn.fujitsu.com> <51AF33E8.4010704@twiddle.net> <1370478487.17798.88.camel@liguang.fnst.cn.fujitsu.com> In-Reply-To: <1370478487.17798.88.camel@liguang.fnst.cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: li guang Cc: qemu-devel@nongnu.org On 06/05/2013 05:28 PM, li guang wrote: > 在 2013-06-05三的 05:49 -0700,Richard Henderson写道: >> On 06/04/2013 06:56 PM, li guang wrote: >>>>> +typedef struct { >>>>> + uint32_t len __attribute__((aligned((sizeof(void *))))); >>>>> + uint32_t cie_offset; >>>>> + tcg_target_long func_start __attribute__((packed)); >>>>> + tcg_target_long func_len __attribute__((packed)); >>> suspicious usage of packed attribute here, >>> since tcg_targe_long is either 32 or 64 bits, >>> not a struct or union. >>> >>> Thanks! >>> >> >> Your question is worded poorly -- what has struct/union got to do with it? One >> can adjust the alignment of any type. Perhaps you don't know what it is that >> __attribute__((packed)) actually does? > > referred from gcc manual: > "This attribute, attached to struct or union type definition, specifies > that each member (other than zero-width bitfields) of the structure or > union is placed to minimize the memory required." > > so, what I mean is as the manual said, this attribute mostly applies to > struct or union. >>From the gcc manual: @cindex @code{packed} attribute The @code{packed} attribute specifies that a variable or structure field should have the smallest possible alignment---one byte for a variable, and one bit for a field, unless you specify a larger value with the @code{aligned} attribute. Notice "or structure field", which is exactly what I have above. > forgive me if the question is fool, > packed means seize minimal memory size, right? It really means minimal alignment. Which means that no padding will be added to ensure alignment. Which can lead to a reduction in memory size, but that's not the major point. r~