qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "M. Warner Losh" <imp@bsdimp.com>
To: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/4] add byteordered types and accessor functions to qemu.
Date: Wed, 27 Aug 2008 08:20:35 -0600 (MDT)	[thread overview]
Message-ID: <20080827.082035.619298951.imp@bsdimp.com> (raw)
In-Reply-To: <1219844723-17469-1-git-send-email-kraxel@redhat.com>

In message: <1219844723-17469-1-git-send-email-kraxel@redhat.com>
            Gerd Hoffmann <kraxel@redhat.com> writes:
: +typedef struct { uint16_t le; } le16 __attribute__((__aligned__(2)));
: +typedef struct { uint32_t le; } le32;
: +typedef struct { uint64_t le; } le64;
: +typedef struct { uint16_t be; } be16 __attribute__((__aligned__(2)));
: +typedef struct { uint32_t be; } be32;
: +typedef struct { uint64_t be; } be64;

This is likely still wrong.

There's no packing to ensure that these structures are the right size.
There's no asserts to make sure that these structures really are the
right size.
They are using raw GCCisms, which is both verbose and non-portable.
This may not be a concern in qemu.

#define packed(x) __attribute__((__aligned__(x))) __attribute__((__packed__))
typedef struct { uint16_t le; } le16 packed(2);
typedef struct { uint32_t le; } le32 packed(4);
typedef struct { uint64_t le; } le64 packed(8);
typedef struct { uint16_t be; } be16 packed(2);
typedef struct { uint32_t be; } be32 packed(4);
typedef struct { uint64_t be; } be64 packed(8);
#undef packed

However, something just feels wrong with this approach.  I'm sure
there's other subtleties that will bite you with it...

Warner

      parent reply	other threads:[~2008-08-27 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 13:45 [Qemu-devel] [PATCH 1/4] add byteordered types and accessor functions to qemu Gerd Hoffmann
2008-08-27 13:45 ` [Qemu-devel] [PATCH 2/4] pci: add config space struct (from qemu-xen) Gerd Hoffmann
2008-08-27 13:45 ` [Qemu-devel] [PATCH 3/4] pci: add default pci subsystem id for all devices Gerd Hoffmann
2008-08-27 13:45 ` [Qemu-devel] [PATCH 4/4] pci: use pci_config_header in pci.c Gerd Hoffmann
2008-08-27 14:20 ` M. Warner Losh [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=20080827.082035.619298951.imp@bsdimp.com \
    --to=imp@bsdimp.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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).