DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	"Gajdzica, MaciejX T" <maciejx.t.gajdzica@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config files with new syntax
Date: Thu, 4 Jun 2015 17:29:13 +0000	[thread overview]
Message-ID: <3EB4FA525960D640B5BDFFD6A3D89126323714C7@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <20150601063412.5805c879@urahara>



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen
> Hemminger
> Sent: Monday, June 1, 2015 2:34 PM
> To: Gajdzica, MaciejX T
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config
> files with new syntax
> 
> On Fri, 29 May 2015 17:43:08 +0200
> Maciej Gajdzica <maciejx.t.gajdzica@intel.com> wrote:
> 
> > +/**
> > + * Find object of name *name* in *obj_array* which is constant size array
> of
> > + * elements that have field *name*.
> > + *
> > + * @param obj_array
> > + *  Constant size array
> > + * @param name
> > + *  name of object to find.
> > + * @return
> > + *  Pointer to object in *obj_array* or NULL if not found.
> > + */
> > +#define APP_PARAM_FIND(obj_array, key)                          \
> > +({                                                              \
> > +	ssize_t obj_idx;                                            \
> > +	const ssize_t obj_count = RTE_DIM(obj_array);               \
> > +                                                                \
> > +	for (obj_idx = 0; obj_idx < obj_count; obj_idx++) {         \
> > +		if (!APP_PARAM_VALID(&((obj_array)[obj_idx])))          \
> > +			continue;                                           \
> > +			                                                    \
> > +		if (strcmp(key, (obj_array)[obj_idx].name) == 0)        \
> > +			break;                                              \
> > +	}                                                           \
> > +	obj_idx < obj_count ? obj_idx : -ENOENT;                    \
> > +})
> 
> Converting all the functions to macro's is a step backwards in several ways.
>  * macro's are hard to support
>  * macro's lead to lots of programming errors
>  * macro's look ugly
> 
> Why not use real functions, or make the example into C++ if you have
> to do generic programming.

We are using macros here only because C language does not offer us a better choice (i.e. support for templates). The alternative would be to write a quasi-identical function per each object type, which would lead to unnecessary code duplication.

We did our best to keep the number of macros small and to implement each macro as straightforward as possible.

All the DPDK sample applications are written in C, so this is the main reason we want to keep this application as C code. As people expect C code from DPDK sample apps, it is easier for people to reuse parts of this application.

  reply	other threads:[~2015-06-04 17:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29 15:43 [dpdk-dev] [PATCH 00/11] ip_pipeline: ip_pipeline application enhancements Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config files with new syntax Maciej Gajdzica
2015-06-01 13:34   ` Stephen Hemminger
2015-06-04 17:29     ` Dumitrescu, Cristian [this message]
2015-05-29 15:43 ` [dpdk-dev] [PATCH 02/11] ip_pipeline: added config checks Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 03/11] ip_pipeline: modified init to match new params struct Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 04/11] ip_pipeline: moved pipelines to separate folder Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 05/11] ip_pipeline: added master pipeline Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 06/11] ip_pipeline: added application thread Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 07/11] ip_pipeline: moved config files to separate folder Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 08/11] ip_pipeline: added new implementation of passthrough pipeline Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 09/11] ip_pipeline: added new implementation of firewall pipeline Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 10/11] ip_pipeline: added new implementation of routing pipeline Maciej Gajdzica
2015-05-29 15:43 ` [dpdk-dev] [PATCH 11/11] ip_pipeline: added new implementation of flow classification pipeline Maciej Gajdzica
2015-06-23 13:48 ` [dpdk-dev] [PATCH 00/11] ip_pipeline: ip_pipeline application enhancements Thomas Monjalon
2015-06-23 13:54   ` Gajdzica, MaciejX T

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=3EB4FA525960D640B5BDFFD6A3D89126323714C7@IRSMSX108.ger.corp.intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=maciejx.t.gajdzica@intel.com \
    --cc=stephen@networkplumber.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).