All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Dave Airlie <airlied@linux.ie>,
	linux-arch@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Introduce compat_u64 and compat_s64 types
Date: Fri, 15 Jun 2007 07:45:12 -0600	[thread overview]
Message-ID: <20070615134512.GG8154@parisc-linux.org> (raw)
In-Reply-To: <200706151442.23939.arnd@arndb.de>

On Fri, Jun 15, 2007 at 02:42:23PM +0200, Arnd Bergmann wrote:
> That's what I thought as well at first, since this is how the gcc 
> documentation seems to describe it. However, recent version of gcc
> complain about this:
> 
> gcc-4.1 -Wall -O2 test.c  -c
> test.c:1: warning: 'packed' attribute ignored
> 
> I have tested versions 2.95, 3.3 and 4.1, an they all ignore do the
> right thing when you do not specify the packed attribute.

...

> We might ask the gcc developers to clarify the documentation, which as of 4.1
> states:
> 
>      The `aligned' attribute can only increase the alignment; but you
>      can decrease it by specifying `packed' as well.  See below.
> 
> My understanding is that this only applies to statically allocated variables,
> but not to automatic stack variables and to usage of the type inside of
> a data structure.

Here's a program which illustrates the source of confusion:

#include <stdio.h>
#include <stddef.h>

typedef unsigned long long __attribute__((aligned(4))) compat_u64;

struct foo {
        int y;
        unsigned long long __attribute__((aligned(4))) x;
};

struct bar {
        int y;
        compat_u64 x;
};

int main(void)
{
        printf("offset of foo->x is %lu\n", offsetof(struct foo, x));
        printf("offset of bar->x is %lu\n", offsetof(struct bar, x));
        return 0;
}

output (on ia64, and I'm told other 64-bit platforms) is:

$ ./test 
offset of foo->x is 8
offset of bar->x is 4

I'll try and come up with some wording that works for the GCC manual.

  reply	other threads:[~2007-06-15 13:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200706150159.l5F1xNgM000459@hera.kernel.org>
2007-06-15  8:44 ` drm: fix radeon setparam on 32/64 bit systems David Woodhouse
2007-06-15  8:58   ` Benjamin Herrenschmidt
2007-06-15  9:28     ` Arnd Bergmann
2007-06-15  9:31       ` [PATCH] Introduce compat_u64 and compat_s64 types Arnd Bergmann
2007-06-15  9:55         ` David Miller
2007-06-15 11:55         ` Andi Kleen
2007-06-15 12:00           ` David Woodhouse
2007-06-15 12:38             ` Andi Kleen
2007-06-15 12:03           ` Arnd Bergmann
2007-06-15 12:40             ` Andi Kleen
2007-06-15 12:47               ` David Woodhouse
2007-06-15 13:19               ` Benjamin Herrenschmidt
2007-06-15 12:09           ` David Howells
2007-06-15 12:43             ` Andi Kleen
2007-06-15 12:54               ` Alan Cox
2007-06-15 12:54                 ` Andi Kleen
2007-06-15 13:15                   ` Alan Cox
2007-06-15 13:27                     ` Andi Kleen
2007-06-15 13:32                       ` David Woodhouse
2007-06-15 20:50                   ` Robin Getz
2007-06-15 21:22                     ` Andi Kleen
2007-06-16  8:31                       ` David Woodhouse
2007-06-15 13:00                 ` David Woodhouse
2007-06-15 12:11         ` Matthew Wilcox
2007-06-15 12:38           ` David Woodhouse
2007-06-15 12:42           ` Arnd Bergmann
2007-06-15 13:45             ` Matthew Wilcox [this message]
2007-06-15 13:52               ` Arnd Bergmann
2007-06-15 23:54               ` Benjamin Herrenschmidt
2007-06-15 13:16         ` Benjamin Herrenschmidt
2007-06-16  9:38         ` David Woodhouse
2007-06-16 10:26           ` Arnd Bergmann
2007-06-16 11:21             ` Arnd Bergmann
2007-06-16 11:34               ` David Woodhouse
2007-06-16 13:56                 ` Matthew Wilcox

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=20070615134512.GG8154@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.