From: Roland Dreier <rdreier@cisco.com>
To: arne.redlich@xiranet.com
Cc: James.Bottomley@HansenPartnership.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] srp.h: avoid padding of structs
Date: Tue, 18 Apr 2006 09:33:04 -0700 [thread overview]
Message-ID: <adairp6j133.fsf@cisco.com> (raw)
In-Reply-To: <1145377662.8447.2.camel@confield.dd.xiranet.com> (Arne Redlich's message of "Tue, 18 Apr 2006 18:27:42 +0200")
Arne> Sure - I wasn't aware that gcc will produce different code
Arne> even if it doesn't have to insert padding bytes.
Yes, it gets paranoid about alignment. For example, if you build the
following on ia64:
struct foo { int a; };
struct bar { int b; } __attribute__((packed));
int c(struct foo *x) { return x->a; }
int d(struct bar *x) { return x->b; }
Then c() compiles to:
0: 13 40 00 40 10 10 [MBB] ld4 r8=[r32]
6: 00 00 00 00 10 80 nop.b 0x0
c: 08 00 84 00 br.ret.sptk.many b0;;
and d() compiles to:
10: 09 70 00 40 00 21 [MMI] mov r14=r32
16: f0 10 80 00 42 00 adds r15=2,r32
1c: 34 00 01 84 adds r32=3,r32;;
20: 19 80 04 1c 00 14 [MMB] ld1 r16=[r14],1
26: f0 00 3c 00 20 00 ld1 r15=[r15]
2c: 00 00 00 20 nop.b 0x0;;
30: 09 70 00 1c 00 10 [MMI] ld1 r14=[r14]
36: 80 00 80 00 20 e0 ld1 r8=[r32]
3c: f1 78 bd 53 shl r15=r15,16;;
40: 01 00 00 00 01 00 [MII] nop.m 0x0
46: e0 70 dc ee 29 00 shl r14=r14,8
4c: 81 38 9d 53 shl r8=r8,24;;
50: 0b 70 40 1c 0e 20 [MMI] or r14=r16,r14;;
56: f0 70 3c 1c 40 00 or r15=r14,r15
5c: 00 00 04 00 nop.i 0x0;;
60: 11 00 00 00 01 00 [MIB] nop.m 0x0
66: 80 78 20 1c 40 80 or r8=r15,r8
6c: 08 00 84 00 br.ret.sptk.many b0;;
We should use __attribute__((packed)) only when it's really needed.
- R.
next prev parent reply other threads:[~2006-04-18 16:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-16 19:34 [PATCH] srp.h: avoid padding of structs Arne Redlich
2006-04-17 9:17 ` Arne Redlich
[not found] ` <20050823221723.GE31949@krispykreme>
2006-04-18 16:05 ` Roland Dreier
2006-04-18 16:27 ` Arne Redlich
2006-04-18 16:33 ` Roland Dreier [this message]
2006-04-28 14:53 ` Arne Redlich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adairp6j133.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=arne.redlich@xiranet.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).