From: "Michael S. Tsirkin" <mst@redhat.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: virtio-comment@lists.oasis-open.org,
virtio-dev@lists.oasis-open.org, virtio@lists.oasis-open.org
Subject: Re: [virtio] Re: [virtio-comment] [PATCH v2] introduction: document #define syntax
Date: Wed, 21 Apr 2021 04:23:01 -0400 [thread overview]
Message-ID: <20210421040930-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210408221813.7796697c.pasic@linux.ibm.com>
On Thu, Apr 08, 2021 at 10:18:13PM +0200, Halil Pasic wrote:
> On Thu, 18 Mar 2021 14:23:33 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > We use the C #define syntax to refer to numeric values.
> > Let's document that.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > changes from v1:
> > address Cornelia's comments
> >
> >
> > introduction.tex | 23 +++++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
> >
> > diff --git a/introduction.tex b/introduction.tex
> > index cc38e29..47bebf5 100644
> > --- a/introduction.tex
> > +++ b/introduction.tex
> > @@ -210,6 +210,29 @@ \section{Structure Specifications}
> > \begin{lstlisting}
> > CPU_TO_BE16(B << 15 | A)
> > \end{lstlisting}
> > +\section{Constant Specifications}
> > +
> > +In many cases, numeric 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}
> > +/* Field Fld value A description */
> > +#define VIRTIO_FLD_A (1 << 0)
> > +/* Field Fld value B description */
> > +#define VIRTIO_FLD_B (1 << 1)
> > +\end{lstlisting}
> > +documents two numeric values for a field \field{Fld}, with
> > +\field{Fld} having value 1 referring to \field{A} and \field{Fld}
> > +having value 2 referring to \field{B}.
> > +Note that $<<$ refers to the shift-left operation.
> > +
> > +Further, in this case VIRTIO_FLD_A and VIRTIO_FLD_B
> > +refer to values 1 and 2 of Fld respectively. Further, VIRTIO_FLD_XXX refers to
> > +either VIRTIO_FLD_A or VIRTIO_FLD_B.
>
> IMHO we also use the define stuff to do flags, and that does not match
> nicely with the above sentence, since VIRTIO_FLD_F_A does not mean that
> the FLD_F field has value A if we are trying to specify a flag or a
> feature bit. And the left-shift is actually most common in these cases.
>
> I'm not opposed to this change. In the virtio spec we tend to not be
> very rigorous about formalism, and I came to accept that as a given.
> Just wanted to point it out.
>
> Sorry for not commenting on this sooner.
>
> Regards,
> Halil
All true. Do you want to propose an enhancement, or just let it be for
now?
> >
> > \newpage
> >
>
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
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
prev parent reply other threads:[~2021-04-21 8:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 18:23 [virtio] [PATCH v2] introduction: document #define syntax Michael S. Tsirkin
2021-03-19 12:30 ` Cornelia Huck
2021-04-08 20:18 ` [virtio] Re: [virtio-comment] " Halil Pasic
2021-04-21 8:23 ` Michael S. Tsirkin [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=20210421040930-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=pasic@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.