public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Rubira Branco <rrbranco@br.ibm.com>
To: Rajat Jain <Rajat.Jain@infogain.com>
Cc: kernelnewbies@nl.linux.org, linux-newbie@vger.kernel.org
Subject: Re: Padding in gcc
Date: Tue, 10 Jul 2007 17:15:28 -0300	[thread overview]
Message-ID: <1184098528.5730.12.camel@localhost.localdomain> (raw)
In-Reply-To: <C86899CCB10A6C4E93D5978DCB232D4B0575FCC7@GDCMX01.igglobal.com>

[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]

On Mon, 2007-07-09 at 17:10 +0530, Rajat Jain wrote:
> Hi,
> 
> Perhaps a little offtopic but no harm in trying ...
> 
> 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?
> 
> Thanks,
> 
> Rajat
> -
> 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

Unless you explicitly say this structure is packed
(__attribute__((packed))) gcc will align it... for sure you need to take
care for yourself when you are trying to use different cache lines for
members of this structure.

Anyway, the code itself is portable, since you are just using C.


cya,


rodrigo (BSDaemon).

-- 
Rodrigo Rubira Branco
Software Engineer 
Advanced Linux Response Team (ALRT) / Linux on Power Toolchain
IBM Linux Technology Center (IBM/LTC)
rrbranco@br.ibm.com

GPG KeyID: 1FCEDEA1

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      parent reply	other threads:[~2007-07-10 20:15 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
2007-07-10 20:15 ` Rodrigo Rubira Branco [this message]

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=1184098528.5730.12.camel@localhost.localdomain \
    --to=rrbranco@br.ibm.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