From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Cc: Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [patch] add byteordered types
Date: Wed, 27 Aug 2008 19:19:14 +0100 [thread overview]
Message-ID: <20080827181914.GC27491@shareable.org> (raw)
In-Reply-To: <48B57EB9.2050106@redhat.com>
Gerd Hoffmann wrote:
> Anthony Liguori wrote:
> > Personally, I dislike the whole struct thing. I even further dislike
> > having multiple sets of conversion functions that are used in different
> > places in the code.
> >
> > Are we sure that this is something that we want to do?
>
> As far I know this struct trick is the only way to have gcc check access
> to variables with an specific byteorder is done the correct way. Avi
> sguuested that and I also think this checking would be useful. I could
> live without that though if there is an agreement that we'll just stick
> with the current, unchecked cpu_to_<order><size> functions.
Provided you always use the type, and want access only via the macros,
the fact its a struct is pretty much invisible, and modern compilers
optimise them quite well like integers.
I'm not sure if a "long enum le32 { max = LONG_MAX, min = LONG_MIN }"
can be used instead of a struct (same for other "short enum" etc.), to
get some warnings instead of errors, and allow bitwise operations.
Changing in steps would work:
1. Change all QEMU source to use the new type names (as integers),
while continuing to use the cpu_to_XY and XY_to_cpu functions.
Doesn't have to be all at once.
It's probably not that much work to change all the mainline source,
as you can use the type-safe version to catch all places that
need changing :-)
Let it settle for a while, until contributors start using
the new type names in patches.
2. _Then_ change those types to structs and make the functions type-safe.
A small patch.
3. Fix the few that got missed.
That's less invasive than changing the function names everywhere.
-- Jamie
prev parent reply other threads:[~2008-08-27 18:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 11:44 [Qemu-devel] [patch] add byteordered types Gerd Hoffmann
2008-08-27 12:20 ` Paul Brook
2008-08-27 13:04 ` Gerd Hoffmann
2008-08-27 13:24 ` Gerd Hoffmann
2008-08-27 13:55 ` Paul Brook
2008-08-27 14:12 ` M. Warner Losh
2008-08-27 13:56 ` Paul Brook
2008-08-27 14:35 ` Gerd Hoffmann
2008-08-27 14:47 ` M. Warner Losh
2008-08-27 15:06 ` Gerd Hoffmann
2008-08-27 15:49 ` Anthony Liguori
2008-08-27 16:20 ` Gerd Hoffmann
2008-08-27 17:57 ` Anthony Liguori
2008-08-28 8:36 ` Gerd Hoffmann
2008-08-27 18:19 ` Jamie Lokier [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=20080827181914.GC27491@shareable.org \
--to=jamie@shareable.org \
--cc=paul@codesourcery.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).