From: "Michael S. Tsirkin" <mst@redhat.com>
To: virtio-comment@lists.oasis-open.org, virtio-dev@lists.oasis-open.org
Cc: virtio@lists.oasis-open.org
Subject: [virtio] [PATCH] introduction: document #define syntax
Date: Tue, 16 Mar 2021 17:13:17 -0400 [thread overview]
Message-ID: <20210316211311.154117-1-mst@redhat.com> (raw)
We use the C #define syntax to refer to numeric values.
Let's document that.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
introduction.tex | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/introduction.tex b/introduction.tex
index cc38e29..4febed2 100644
--- a/introduction.tex
+++ b/introduction.tex
@@ -210,6 +210,27 @@ \section{Structure Specifications}
\begin{lstlisting}
CPU_TO_BE16(B << 15 | A)
\end{lstlisting}
+\section{Constant Specifications}
+
+In many cases, numberic values used in the interface between the device
+and the driver are documented using the C #define and /* */
+comment syntax. Multiple related values are grouped together with
+a common name as a prefix, using _ as a separator.
+Using _XXX as a suffix refers to all values in a group.
+For example:
+
+\begin{lstlisting}
+/* Value A description */
+#define VIRTIO_VALUE_A (1 << 0)
+/* Value B description */
+#define VIRTIO_VALUE_B (1 << 1)
+\end{lstlisting}
+documents two numeric values: 1 meaning Value A and 2 meaning
+Value B. Note that $<<$ refers to the shift-left operation.
+
+Further, in this case VIRTIO_VALUE_A and VIRTIO_VALUE_B
+refer to 1 and 2 respectively. Further, VIRTIO_VALUE_XXX refers to
+either VIRTIO_VALUE_A or VIRTIO_VALUE_B.
\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:[~2021-03-16 21:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 21:13 Michael S. Tsirkin [this message]
2021-03-17 8:43 ` [virtio] [PATCH] introduction: document #define syntax Cornelia Huck
2021-03-18 18:23 ` Michael S. Tsirkin
2021-03-17 15:52 ` [virtio] Re: [virtio-dev] " Stefan Hajnoczi
2021-03-17 17:59 ` [virtio-comment] " Eugenio Perez Martin
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=20210316211311.154117-1-mst@redhat.com \
--to=mst@redhat.com \
--cc=virtio-comment@lists.oasis-open.org \
--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