Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: nils@as68123.uab.ericsson.se (Nils Carlson)
Subject: [ltt-dev] [UST PATCH] Fixes container_of macro redefinition warnings
Date: Thu, 23 Sep 2010 16:27:15 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1009231620200.17976@as68123.uab.ericsson.se> (raw)
In-Reply-To: <1285188767-17296-1-git-send-email-david.goulet@polymtl.ca>

Commente below...

On Wed, 22 Sep 2010, David Goulet wrote:

> On urcu commit 453629a9317adef5b96c3d55e4dcd98db680997a, the
> container_of macro was moved to urcu/compiler.h. Since, multiple
> warnings appear about redefinition
>

I think we should consider things in a more general sense. This is a 
little bit of what I think the Qemu/KVM people were complaining about.

We are terrible namespace polluters. Ideally, when you make a library,
you want to provide a limited set of external api's that are well defined
and well maintained and consistent over versions. You then want to hide
EVERYTHING else. This means that we should put some effort into hiding
all the macros and functions that we don't want to explicity export.

So I suggest we prefix all out internal-only macros which are visible in
global header files with __ust_. I would suggest Mathieu do the same with
urcu. If we don't want to support the macros, then they should have a 
private namespace. I think container_of is an excellent example of this, 
we use it, but it's not ours to export.

So a NACK here. Instead, call it __ust_container_of and then fix all the 
call sites.

/Nils




> Signed-off-by: David Goulet <david.goulet at polymtl.ca>
> ---
> include/ust/core.h           |    2 ++
> include/ust/kcompat/simple.h |    3 ++-
> 2 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/include/ust/core.h b/include/ust/core.h
> index 0172614..d5a1f4d 100644
> --- a/include/ust/core.h
> +++ b/include/ust/core.h
> @@ -141,8 +141,10 @@ static __inline__ int get_count_order(unsigned int count)
> 	return order;
> }
>
> +#ifndef container_of
> #define container_of(ptr, type, member) ({                      \
>         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
>         (type *)( (char *)__mptr - offsetof(type,member) );})
> +#endif /* containter_of */
>
> #endif /* UST_CORE_H */
> diff --git a/include/ust/kcompat/simple.h b/include/ust/kcompat/simple.h
> index 762d802..586b2ed 100644
> --- a/include/ust/kcompat/simple.h
> +++ b/include/ust/kcompat/simple.h
> @@ -28,10 +28,11 @@
>  * @member:	the name of the member within the struct.
>  *
>  */
> +#ifndef container_of
> #define container_of(ptr, type, member) ({			\
> 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
> 	(type *)( (char *)__mptr - offsetof(type,member) );})
> -
> +#endif /* container_of */
>
> /* libkcompat: from rcupdate.h */
>
> -- 
> 1.7.3
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>




  parent reply	other threads:[~2010-09-23 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 20:52 David Goulet
2010-09-22 21:25 ` Mathieu Desnoyers
2010-09-23 14:27 ` Nils Carlson [this message]
2010-09-23 14:40   ` David Goulet

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=alpine.DEB.2.00.1009231620200.17976@as68123.uab.ericsson.se \
    --to=nils@as68123.uab.ericsson.se \
    /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