DPDK usage discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Ferruh Yigit <ferruh.yigit@amd.com>
Cc: Antonio Di Bacco <a.dibacco.ks@gmail.com>, users@dpdk.org
Subject: Re: Anonymous structs in DPDK
Date: Tue, 13 Dec 2022 16:34:47 -0800	[thread overview]
Message-ID: <20221213163447.14a96ea0@hermes.local> (raw)
In-Reply-To: <acc52634-c88a-597a-65bd-21683bac7deb@amd.com>

On Tue, 13 Dec 2022 13:55:10 +0000
Ferruh Yigit <ferruh.yigit@amd.com> wrote:

> On 12/13/2022 12:51 PM, Antonio Di Bacco wrote:
> > I noticed that DPDK include files have a number of anonymous/unnamed struct:
> > 
> > For example:
> > 
> > /**
> >  * The rte_spinlock_t type.
> >  */
> > typedef struct {
> >         volatile int locked; /**< lock status 0 = unlocked, 1 = locked */
> > } rte_spinlock_t;
> > 
> > This choice doesn't allow to use forward declaration. I need forward
> > declaration because I'm using a rte_spinlock_t pointer in a C++ class
> > and I don't want to include rte_spinlock.h to prevent my application
> > to include it as well.
> > 
> > Is there any reason to use unnamed structures?
> >   
> 
> Hi Antonio Di,
> 
> I don't think there is a specific reason to not use named struct, I
> assume that is only because there was no need to have it.
> 
> So if you need, you can send a simple patch to convert anonymous struct
> to named struct, although I am not clear why you can't include
> 'rte_spinlock.h' in the file you declare your class.
> 
> Cheers,
> ferruh

Why not include rte_spinlock.h? Spinlocks are meant to be embedded
in the object using it. Using spinlocks by reference adds more space
and causes a cache miss.

  reply	other threads:[~2022-12-14  0:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 12:51 Antonio Di Bacco
2022-12-13 13:55 ` Ferruh Yigit
2022-12-14  0:34   ` Stephen Hemminger [this message]
2022-12-14  8:03     ` Antonio Di Bacco
2022-12-14  8:12       ` Pavel Vazharov
2022-12-14  8:16         ` Antonio Di Bacco

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=20221213163447.14a96ea0@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=a.dibacco.ks@gmail.com \
    --cc=ferruh.yigit@amd.com \
    --cc=users@dpdk.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).