public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: gcc@gcc.gnu.org
Subject: RFC: attribute "unpadded"
Date: Fri, 23 Aug 2002 10:43:00 -0000	[thread overview]
Message-ID: <3627294541.1030124478@[192.168.0.103]> (raw)

I want to create a new type attribute "unpadded" that would, on
this code:

 struct S __attribute__((unpadded)) {
   int i;
   char c;
 };

define S to have size 5 and alignment 4 on an ILP32 machine.

The idea is that the normal tail padding of S (the three bytes
after "c" to round it out to a multiple of the alignment) would
be suppressed.  It would be illegal to create arrays of these
types, since the required alignment would not then be provided
to all of the array elements.

The motivation for this comes from work on the C++ ABI, including
the tests for interoperability that we are developing.  The C++
ABI essentially has types like the above, but they are implicit.
Making them explicit gives us a way to express the same thing in C.

This comes up in C++ like so:

 struct A { virtual void f();  char c; };
 struct B : public A { char c2 };

Here, the size of B is 8, not 12, because "c2" is packed into
the tail padding of A.  If A were "unpadded", you could express
this in C as:

 struct A __attribute__((unpadded)) { void *vptr; char c; };
 struct B { struct A __base; char c2; };

If I do not here objections, I will create a patch for this and
check it in shortly.  Rats, we are in Stage 3 -- so I will check
it in after we branch for GCC 3.3.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

             reply	other threads:[~2002-08-23 10:43 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-23 10:43 Mark Mitchell [this message]
2002-08-23 10:49 ` Andrew Haley
2002-08-23 10:50   ` Mark Mitchell
2002-08-23 12:39     ` Andrew Haley
2002-08-23 13:02       ` Neil Booth
2002-08-23 13:20       ` Mark Mitchell
2002-08-23 15:57         ` Zack Weinberg
2002-08-25 19:03           ` Fergus Henderson
2002-08-25 23:59             ` Zack Weinberg
2002-08-26  4:52               ` language-independent types (was: RFC: attribute "unpadded") Fergus Henderson
2002-08-23 16:42   ` RFC: attribute "unpadded" Olivier Galibert
2002-08-25 18:16     ` Mark Mitchell
2002-08-23 10:51 ` Fergus Henderson
2002-08-23 10:53   ` Mark Mitchell
2002-08-23 21:52 ` Alexandre Oliva
2002-08-24 14:05   ` Paul Koning
2002-08-25 18:00     ` Mark Mitchell
2002-08-26  6:41       ` Paul Koning
2002-08-26  8:28         ` Andreas Schwab
2002-08-26  9:23           ` Gabriel Dos Reis
2002-08-26  9:45             ` Mark Mitchell
2002-08-26 10:54               ` Gabriel Dos Reis
2002-08-27  8:00               ` Fergus Henderson
2002-08-27  9:52                 ` Tom Tromey
2002-08-27 10:46                 ` Mark Mitchell
2002-08-27 11:39                   ` Fergus Henderson
2002-08-27 12:01                     ` Mark Mitchell
2002-08-27 12:04                     ` Gabriel Dos Reis
2002-08-27 14:25                     ` Joe Buck
2002-08-29 15:12                 ` Richard Henderson
2002-08-29 15:10               ` Richard Henderson
2002-08-29 15:24                 ` Richard Henderson
2002-08-29 15:30                   ` Mark Mitchell
2002-08-29 16:30                     ` Richard Henderson
2002-08-29 15:29                 ` Mark Mitchell
2002-08-29 15:45                   ` Gabriel Dos Reis
2002-08-29 16:00                     ` Mark Mitchell
2002-08-29 16:06                       ` Gabriel Dos Reis
2002-08-29 16:32                   ` Richard Henderson
2002-08-29 16:49                     ` Mark Mitchell
2002-08-30  0:12                   ` Kai Henningsen
2002-08-26 19:10 ` Jamie Lokier
2002-08-27  0:03   ` Mark Mitchell
2002-08-28  3:50 ` Richard Earnshaw
2002-08-28 10:22   ` Joe Buck
2002-08-28 10:56     ` Richard Earnshaw
2002-08-28 11:20       ` Joe Buck
2002-08-29  2:07         ` Richard Earnshaw
2002-08-28 21:22       ` Fergus Henderson
2002-08-29  2:27         ` Richard Earnshaw
2002-08-23 10:58 Benjamin Kosnik
2002-08-23 11:05 ` Mark Mitchell
2002-08-23 11:14   ` Benjamin Kosnik
2002-08-23 11:34     ` Janis Johnson
2002-08-23 11:39       ` Mark Mitchell
2002-08-23 11:35     ` Mark Mitchell
2002-08-23 12:03       ` Benjamin Kosnik
2002-08-23 16:07 Richard Kenner
2002-08-27 14:43 Richard Kenner
2002-08-27 20:25 ` Fergus Henderson
2002-08-28  4:12 Robert Dewar

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='3627294541.1030124478@[192.168.0.103]' \
    --to=mark@codesourcery.com \
    --cc=gcc@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).