From: "Michael S. Tsirkin" <mst@redhat.com>
To: virtio@lists.oasis-open.org, virtio-dev@lists.oasis-open.org
Cc: cohuck@redhat.com
Subject: [virtio] [PATCH] introduction: document bitfield notation
Date: Wed, 28 Feb 2018 21:16:32 +0200 [thread overview]
Message-ID: <1519845375-28741-1-git-send-email-mst@redhat.com> (raw)
Bitfields are a useful and familiar way to specify sub-byte structure
layout. The only issue is that bitfield order isn't portable across
architectures. Document that we list bitfields from least to
most significant one, and warn about portability issues.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
introduction.tex | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/introduction.tex b/introduction.tex
index 979881e..3cb7a70 100644
--- a/introduction.tex
+++ b/introduction.tex
@@ -157,5 +157,23 @@ in little-endian byte order.
in big-endian byte order.
\end{description}
+When documenting sub-byte data fields, C-like bitfield notation
+is used. Fields within an integer are always listed in order,
+from the least significant to the most significant bit.
+
+For example:
+\begin{lstlisting}
+be16 A : 15;
+be16 B : 1;
+\end{lstlisting}
+documents the value A stored in the low 15 bit of a 16 bit
+integer and the value B stored in the high bit of the 16 bit
+integer, the integer in turn using the big-endian byte order.
+
+Note that this notation typically matches the way bitfields are
+packed by C compilers on little-endian architectures but not the
+way bitfields are packed by C compilers on big-endian
+architectures.
+
\newpage
--
MST
---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that
generates this mail. Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php
next reply other threads:[~2018-02-28 19:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 19:16 Michael S. Tsirkin [this message]
2018-03-05 11:14 ` [virtio] [PATCH] introduction: document bitfield notation Stefan Hajnoczi
2018-03-05 14:20 ` [virtio] " Cornelia Huck
2018-03-05 14:26 ` Michael S. Tsirkin
2018-03-05 16:04 ` Cornelia Huck
2018-03-05 21:11 ` Michael S. Tsirkin
2018-03-06 8:21 ` Cornelia Huck
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=1519845375-28741-1-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=cohuck@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtio@lists.oasis-open.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