[ltt-dev] [UST PATCH] New naming convention for macro container_of

David Goulet david.goulet at polymtl.ca
Thu Sep 23 12:26:57 EDT 2010


This is the first patch introducing the new naming convention
for the UST tracer. To prevent namespace pollution, __ust_ prefix
is added to visible symbol in global header files.

For this patch, only the container_of macro is renamed and the
redundant definition in kcompat/simple.h is removed.

Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
 include/ust/core.h           |    2 +-
 include/ust/kcompat/simple.h |   12 ------------
 libust/buffers.c             |    6 +++---
 libust/channels.c            |    2 +-
 libust/marker.c              |    2 +-
 libust/tracepoint.c          |    4 ++--
 libust/tracer.c              |    2 +-
 7 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/include/ust/core.h b/include/ust/core.h
index 0172614..e23224a 100644
--- a/include/ust/core.h
+++ b/include/ust/core.h
@@ -141,7 +141,7 @@ static __inline__ int get_count_order(unsigned int count)
 	return order;
 }
 
-#define container_of(ptr, type, member) ({                      \
+#define __ust_container_of(ptr, type, member) ({                      \
         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
         (type *)( (char *)__mptr - offsetof(type,member) );})
 
diff --git a/include/ust/kcompat/simple.h b/include/ust/kcompat/simple.h
index 762d802..38a9be5 100644
--- a/include/ust/kcompat/simple.h
+++ b/include/ust/kcompat/simple.h
@@ -21,18 +21,6 @@
 #ifndef KCOMPAT_SIMPLE_H
 #define KCOMPAT_SIMPLE_H
 
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr:	the pointer to the member.
- * @type:	the type of the container struct this is embedded in.
- * @member:	the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({			\
-	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
-	(type *)( (char *)__mptr - offsetof(type,member) );})
-
-
 /* libkcompat: from rcupdate.h */
 
 struct rcu_head {
diff --git a/libust/buffers.c b/libust/buffers.c
index 374ec61..8a2b90a 100644
--- a/libust/buffers.c
+++ b/libust/buffers.c
@@ -203,7 +203,7 @@ int ust_buffers_create_buf(struct ust_channel *channel, int cpu)
 
 static void ust_buffers_destroy_channel(struct kref *kref)
 {
-	struct ust_channel *chan = container_of(kref, struct ust_channel, kref);
+	struct ust_channel *chan = __ust_container_of(kref, struct ust_channel, kref);
 	free(chan);
 }
 
@@ -225,7 +225,7 @@ static void ust_buffers_destroy_buf(struct ust_buffer *buf)
 /* called from kref_put */
 static void ust_buffers_remove_buf(struct kref *kref)
 {
-	struct ust_buffer *buf = container_of(kref, struct ust_buffer, kref);
+	struct ust_buffer *buf = __ust_container_of(kref, struct ust_buffer, kref);
 	ust_buffers_destroy_buf(buf);
 }
 
@@ -592,7 +592,7 @@ static void ltt_relay_print_buffer_errors(struct ust_channel *channel, int cpu)
 
 static void ltt_relay_release_channel(struct kref *kref)
 {
-	struct ust_channel *ltt_chan = container_of(kref,
+	struct ust_channel *ltt_chan = __ust_container_of(kref,
 			struct ust_channel, kref);
 	free(ltt_chan->buf);
 }
diff --git a/libust/channels.c b/libust/channels.c
index df1a972..4de54a9 100644
--- a/libust/channels.c
+++ b/libust/channels.c
@@ -66,7 +66,7 @@ static struct ltt_channel_setting *lookup_channel(const char *name)
  */
 static void release_channel_setting(struct kref *kref)
 {
-	struct ltt_channel_setting *setting = container_of(kref,
+	struct ltt_channel_setting *setting = __ust_container_of(kref,
 		struct ltt_channel_setting, kref);
 	struct ltt_channel_setting *iter;
 
diff --git a/libust/marker.c b/libust/marker.c
index dbabf3e..761785a 100644
--- a/libust/marker.c
+++ b/libust/marker.c
@@ -235,7 +235,7 @@ static notrace void marker_probe_cb_noarg(const struct marker *mdata,
 
 static void free_old_closure(struct rcu_head *head)
 {
-	struct marker_entry *entry = container_of(head,
+	struct marker_entry *entry = __ust_container_of(head,
 		struct marker_entry, rcu);
 	free(entry->oldptr);
 	/* Make sure we free the data before setting the pending flag to 0 */
diff --git a/libust/tracepoint.c b/libust/tracepoint.c
index 16b4819..63ae17d 100644
--- a/libust/tracepoint.c
+++ b/libust/tracepoint.c
@@ -87,7 +87,7 @@ static inline void *allocate_probes(int count)
 static inline void release_probes(void *old)
 {
 	if (old) {
-		struct tp_probes *tp_probes = container_of(old,
+		struct tp_probes *tp_probes = __ust_container_of(old,
 			struct tp_probes, probes[0]);
 //ust//		call_rcu_sched(&tp_probes->u.rcu, rcu_free_old_probes);
 		synchronize_rcu();
@@ -427,7 +427,7 @@ static void tracepoint_add_old_probes(void *old)
 {
 	need_update = 1;
 	if (old) {
-		struct tp_probes *tp_probes = container_of(old,
+		struct tp_probes *tp_probes = __ust_container_of(old,
 			struct tp_probes, probes[0]);
 		list_add(&tp_probes->u.list, &old_probes);
 	}
diff --git a/libust/tracer.c b/libust/tracer.c
index 8c3f774..ed5e329 100644
--- a/libust/tracer.c
+++ b/libust/tracer.c
@@ -337,7 +337,7 @@ void ltt_release_transport(struct kref *kref)
  */
 void ltt_release_trace(struct kref *kref)
 {
-	struct ust_trace *trace = container_of(kref,
+	struct ust_trace *trace = __ust_container_of(kref,
 			struct ust_trace, kref);
 	ltt_channels_trace_free(trace->channels);
 	free(trace);
-- 
1.7.3





More information about the lttng-dev mailing list