From: Jan Blunck <jblunck@infradead.org>
To: Shreyansh Jain <shreyansh.jain@nxp.com>
Cc: David Marchand <david.marchand@6wind.com>,
dev@dpdk.org, Jan Viktorin <viktorin@rehivetech.com>
Subject: Re: [dpdk-dev] [RFC PATCH 1/6] eal: define container macro
Date: Thu, 17 Nov 2016 13:06:49 +0100 [thread overview]
Message-ID: <CALe+Z00BZKT660kFvLQC9YxvbpgTki2CpWL9rCKdVW85Qmce+g@mail.gmail.com> (raw)
In-Reply-To: <1479360605-20558-2-git-send-email-shreyansh.jain@nxp.com>
On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain <shreyansh.jain@nxp.com> wrote:
> From: Jan Viktorin <viktorin@rehivetech.com>
>
> Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> ---
> lib/librte_eal/common/include/rte_common.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
> index db5ac91..8152bd9 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
> #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
> #endif
>
> +/**
> + * Return pointer to the wrapping struct instance.
> + * Example:
> + *
> + * struct wrapper {
> + * ...
> + * struct child c;
> + * ...
> + * };
> + *
> + * struct child *x = obtain(...);
> + * struct wrapper *w = container_of(x, struct wrapper, c);
> + */
> +#ifndef container_of
> +#define container_of(p, type, member) \
> + ((type *) (((char *) (p)) - offsetof(type, member)))
Are there any reasons why you choose to implement this in a non-type
safe way? Catching obvious bugs at compile time is in the interest of
us and our users from my point of view.
> +#endif
> +
> #define _RTE_STR(x) #x
> /** Take a macro value and get a string version of it */
> #define RTE_STR(x) _RTE_STR(x)
> --
> 2.7.4
>
next prev parent reply other threads:[~2016-11-17 12:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 5:29 [dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support Shreyansh Jain
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 1/6] eal: define container macro Shreyansh Jain
2016-11-17 12:06 ` Jan Blunck [this message]
2016-11-17 13:01 ` Shreyansh Jain
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure Shreyansh Jain
2016-11-17 11:19 ` Jan Blunck
2016-11-17 13:00 ` Shreyansh Jain
2016-11-17 16:13 ` Jan Blunck
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 3/6] bus: add bus driver layer Shreyansh Jain
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 4/6] eal/common: handle bus abstraction for device/driver objects Shreyansh Jain
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 5/6] eal: supporting bus model in init process Shreyansh Jain
2016-11-17 5:30 ` [dpdk-dev] [RFC PATCH 6/6] eal: removing eth_driver Shreyansh Jain
2016-11-17 12:53 ` Jan Blunck
2016-11-18 13:05 ` Shreyansh Jain
2016-11-17 11:55 ` [dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support Jan Blunck
2016-11-17 13:08 ` Shreyansh Jain
2016-11-17 16:54 ` Jan Blunck
2016-11-20 15:30 ` David Marchand
2016-11-21 9:08 ` Thomas Monjalon
2016-11-21 10:47 ` Jan Blunck
2016-11-23 9:45 ` Shreyansh Jain
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=CALe+Z00BZKT660kFvLQC9YxvbpgTki2CpWL9rCKdVW85Qmce+g@mail.gmail.com \
--to=jblunck@infradead.org \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=shreyansh.jain@nxp.com \
--cc=viktorin@rehivetech.com \
/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).