From: "pradeep singh" <2500.pradeep@gmail.com>
To: Rajat Jain <Rajat.Jain@infogain.com>
Cc: kernelnewbies@nl.linux.org, linux-newbie@vger.kernel.org
Subject: Re: Padding in gcc
Date: Mon, 9 Jul 2007 20:51:12 +0530 [thread overview]
Message-ID: <366312910707090821k5690fadbra8030bf657a8bd5c@mail.gmail.com> (raw)
In-Reply-To: <C86899CCB10A6C4E93D5978DCB232D4B052E0024@GDCMX01.igglobal.com>
On 7/9/07, Rajat Jain <Rajat.Jain@infogain.com> wrote:
>
>
>
> Hi,
>
> >>
> >> Can we always rely on the fact that gcc will pad the following structure?
> >>
> >> typedef struct {
> >> int descrp; SYSCALL64_STRUCT_ATTR;
> >> (Automatic padding here?)
> >> long long pos; SYSCALL64_STRUCT_ATTR;
> >> int mode; SYSCALL64_STRUCT_ATTR;
> >> } lseek64_t;
> >>
> >> What is the correct way to make it portable? Explicitly added padding
> fields?
>
> >may be i am missing something but why is this not portable? And how
> >does padding makes this portable?
>
> Hi ... sorry I could not ask very well, what I wanted to. I have a piece of
> code that ASSUMES that the above structure is padded (and I do not want to
> change that code). So how can I make sure that this structure is always
> padded (Is there any other way apart from adding explicit padding field?)
>
> So like we have a "packed" gcc attribute, do we have a "padded" gcc
> attribute or something like that (that ensures that gcc will always pad this
> structure.).
GCC will always pad it for best alignment depending on the
architecture. There is attribute to avoid this padding though.
But padding is done by default depending on architecture for which you
compile your program.
So as long as cross compiliation process is correct, it should work i guess.
OTOH do you want to add just a fixed number of bytes irrespective of
the architecture?
Thanks
[PS : psbl has blacklisted me ,please CC to newbies too, just in case]
>
> Thanks,
> Rajat
>
>
--
play the game
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
next prev parent reply other threads:[~2007-07-09 15:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-09 11:40 Padding in gcc Rajat Jain
2007-07-09 14:38 ` pradeep singh
2007-07-09 14:52 ` Rajat Jain
2007-07-09 15:21 ` pradeep singh [this message]
2007-07-10 20:15 ` Rodrigo Rubira Branco
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=366312910707090821k5690fadbra8030bf657a8bd5c@mail.gmail.com \
--to=2500.pradeep@gmail.com \
--cc=Rajat.Jain@infogain.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-newbie@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