linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: james  woodyatt <jhw@wetware.com>
Cc: linuxppc-dev@lists.linuxppc.org
Subject: Re: Help with cross-endian bitfields?
Date: Mon, 8 May 2000 11:50:49 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.10.10005081150260.312-100000@cassiopeia.home> (raw)
In-Reply-To: <v03110702b53c10dcc4d9@[208.177.152.17]>


On Mon, 8 May 2000, james  woodyatt wrote:
> Daniel Jacobowitz <drow@false.org> wrote:
> >On Fri, May 05, 2000 at 03:27:21PM -0400, jlquinn@us.ibm.com wrote:
> >>
> [...]
> >> Can someone tell me what's going on here?  Am I going to have to have
> >> ifdef's on these structs, or resort to mask macros, or is there a
> >> reasonable solution here.
> >
> >As Dan Malek said, there is no defined ordering.  The compiler is free
> >to do whatever it wishes.  You can't assume that.  (I think.)
> [...]
>
> It's absolutely true.
>
> Not only is there no defined ordering, the ANSI standard says that it
> doesn't even need to use bitfield operations in the machine code.  It's
> allowed to pad arbitrarily between the bitfields.  It's allowed to
> completely ignore the bitfield widths and treat the members like integers.
> It's even allowed to order the very bits themselves in weird ways, if it
> thinks the processor will like it better that way.
>
> Bitfields are just not even remotely portable.
>
> C structures should not be used to represent portable serializations of
> external data.  Period.  Yes, they're convenient-- but your compiler and my
> compiler don't have to agree on practically anything about them.

And we all use gcc to compile Linux kernels... So the only remaining issue is
endianness.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- Linux/{m68k~Amiga,PPC~CHRP} -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

  reply	other threads:[~2000-05-08  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200005060514.AAA05188@lists.linuxppc.org>
2000-05-08  7:03 ` Help with cross-endian bitfields? james woodyatt
2000-05-08  9:50   ` Geert Uytterhoeven [this message]
2000-05-08 14:38 jlquinn
  -- strict thread matches above, loose matches on Subject: below --
2000-05-08 10:13 D.J. Barrow
2000-05-08 14:19 ` Geert Uytterhoeven
2000-05-05 20:47 jlquinn
2000-05-05 19:27 jlquinn
2000-05-05 20:05 ` Dan Malek
2000-05-05 20:45   ` Josh Huber
2000-05-05 20:49 ` Daniel Jacobowitz

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=Pine.LNX.4.10.10005081150260.312-100000@cassiopeia.home \
    --to=geert@linux-m68k.org \
    --cc=jhw@wetware.com \
    --cc=linuxppc-dev@lists.linuxppc.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).