common: replace container_of with a C++ safe implementation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 10 Jun 2022 19:10:32 +0000 (15:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 13 Jun 2022 20:34:47 +0000 (16:34 -0400)
As more code moves to a more idiomatic C++ style, structures like
typically end up becoming classes that use different access controls,
virtual functions, etc. This, in turn, makes them adopt a non standard
layout and causes GCC and clang to emit the following warning when
container_of is used:

error: 'offsetof' within non-standard-layout type 'foo' is conditionally-supported [-Werror=invalid-offsetof]

This new implementation of container_of makes use of a pointer to a data
member to find the parent's address.

The use of ptr_to_member against the null dummy_parent makes me uneasy
as it seems equivalent to performing arithmetic on a null pointer, which
I understand is undefined behavior (C++11 Standard 5.7.5).

However, Boost.Instrusive uses an approach that seems roughly equivalent
to lttng::utils::container_of() [1].

It seems like a reasonable compromise that works on all mainstream
compilers.

[1] https://github.com/boostorg/intrusive/blob/3c5c8cec3f0356a028a4b56ba6cac2256340dab1/include/boost/intrusive/detail/parent_from_member.hpp#L92

Change-Id: Ia6287e1648bce85dfe6de936f17ec5df46ea648d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
68 files changed:
src/bin/lttng-relayd/connection.cpp
src/bin/lttng-relayd/ctf-trace.cpp
src/bin/lttng-relayd/index.cpp
src/bin/lttng-relayd/live.cpp
src/bin/lttng-relayd/main.cpp
src/bin/lttng-relayd/session.cpp
src/bin/lttng-relayd/sessiond-trace-chunks.cpp
src/bin/lttng-relayd/stream.cpp
src/bin/lttng-relayd/viewer-stream.cpp
src/bin/lttng-sessiond/agent.cpp
src/bin/lttng-sessiond/buffer-registry.cpp
src/bin/lttng-sessiond/condition-internal.cpp
src/bin/lttng-sessiond/consumer.cpp
src/bin/lttng-sessiond/dispatch.cpp
src/bin/lttng-sessiond/event-notifier-error-accounting.cpp
src/bin/lttng-sessiond/event.cpp
src/bin/lttng-sessiond/lttng-syscall.cpp
src/bin/lttng-sessiond/notification-thread-events.cpp
src/bin/lttng-sessiond/save.cpp
src/bin/lttng-sessiond/session.cpp
src/bin/lttng-sessiond/snapshot.cpp
src/bin/lttng-sessiond/thread.cpp
src/bin/lttng-sessiond/trace-ust.cpp
src/bin/lttng-sessiond/tracker.cpp
src/bin/lttng-sessiond/ust-app.cpp
src/bin/lttng-sessiond/ust-registry-session.cpp
src/bin/lttng-sessiond/ust-registry.cpp
src/common/actions/action.cpp
src/common/actions/list.cpp
src/common/actions/notify.cpp
src/common/actions/rate-policy.cpp
src/common/actions/rotate-session.cpp
src/common/actions/snapshot-session.cpp
src/common/actions/start-session.cpp
src/common/actions/stop-session.cpp
src/common/compat/directory-handle.cpp
src/common/conditions/buffer-usage.cpp
src/common/conditions/condition.cpp
src/common/conditions/event-rule-matches.cpp
src/common/conditions/session-consumed-size.cpp
src/common/conditions/session-rotation.cpp
src/common/consumer/consumer-stream.cpp
src/common/consumer/consumer.cpp
src/common/error-query.cpp
src/common/evaluation.cpp
src/common/event-expr/event-expr.cpp
src/common/event-field-value.cpp
src/common/event-rule/event-rule.cpp
src/common/event-rule/jul-logging.cpp
src/common/event-rule/kernel-kprobe.cpp
src/common/event-rule/kernel-syscall.cpp
src/common/event-rule/kernel-tracepoint.cpp
src/common/event-rule/kernel-uprobe.cpp
src/common/event-rule/log4j-logging.cpp
src/common/event-rule/python-logging.cpp
src/common/event-rule/user-tracepoint.cpp
src/common/fd-handle.cpp
src/common/fd-tracker/fd-tracker.cpp
src/common/fd-tracker/inode.cpp
src/common/hashtable/hashtable.cpp
src/common/kernel-probe.cpp
src/common/location.cpp
src/common/macros.hpp
src/common/session-descriptor.cpp
src/common/trace-chunk.cpp
src/common/trigger.cpp
src/common/userspace-probe.cpp
src/lib/lttng-ctl/rotate.cpp

index fb53862a436bde4a4c84b1cc7e6a467049efa444..711de3a5cff81a76a2ae3bd9fb8e1ca4cc6311bf 100644 (file)
@@ -37,7 +37,7 @@ struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connectio
                DBG2("Relay connection by sock %d not found", sock);
                goto end;
        }
-       conn = caa_container_of(node, struct relay_connection, sock_n);
+       conn = lttng::utils::container_of(node, &relay_connection::sock_n);
        if (!connection_get(conn)) {
                conn = NULL;
        }
@@ -110,7 +110,7 @@ end:
 static void rcu_free_connection(struct rcu_head *head)
 {
        struct relay_connection *conn =
-               caa_container_of(head, struct relay_connection, rcu_node);
+               lttng::utils::container_of(head, &relay_connection::rcu_node);
 
        lttcomm_destroy_sock(conn->sock);
        if (conn->viewer_session) {
@@ -132,7 +132,7 @@ static void destroy_connection(struct relay_connection *conn)
 static void connection_release(struct urcu_ref *ref)
 {
        struct relay_connection *conn =
-               caa_container_of(ref, struct relay_connection, ref);
+               lttng::utils::container_of(ref, &relay_connection::ref);
 
        if (conn->in_socket_ht) {
                struct lttng_ht_iter iter;
index cad67b78e2517296f06e3610b2d7b3d7e25d2ce2..ba4a29092ca537f28e68153027823840f3882fdc 100644 (file)
@@ -23,7 +23,7 @@ static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
 static void rcu_destroy_ctf_trace(struct rcu_head *rcu_head)
 {
        struct ctf_trace *trace =
-               caa_container_of(rcu_head, struct ctf_trace, rcu_node);
+               lttng::utils::container_of(rcu_head, &ctf_trace::rcu_node);
 
        free(trace);
 }
@@ -53,7 +53,7 @@ static void ctf_trace_destroy(struct ctf_trace *trace)
 static void ctf_trace_release(struct urcu_ref *ref)
 {
        struct ctf_trace *trace =
-               caa_container_of(ref, struct ctf_trace, ref);
+               lttng::utils::container_of(ref, &ctf_trace::ref);
        int ret;
        struct lttng_ht_iter iter;
 
@@ -156,7 +156,7 @@ struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
                DBG("CTF Trace path %s not found", subpath);
                goto end;
        }
-       trace = caa_container_of(node, struct ctf_trace, node);
+       trace = lttng::utils::container_of(node, &ctf_trace::node);
        if (!ctf_trace_get(trace)) {
                trace = NULL;
        }
index e7846a5b9233b9141d6c9ffd48717aa188d93641..a20ae2658a505cfab8431546e458e960ac83f203 100644 (file)
@@ -120,7 +120,7 @@ struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
        lttng_ht_lookup(stream->indexes_ht, &net_seq_num, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node) {
-               index = caa_container_of(node, struct relay_index, index_n);
+               index = lttng::utils::container_of(node, &relay_index::index_n);
        } else {
                struct relay_index *oldindex;
 
@@ -200,7 +200,7 @@ static void index_destroy(struct relay_index *index)
 static void index_destroy_rcu(struct rcu_head *rcu_head)
 {
        struct relay_index *index =
-               caa_container_of(rcu_head, struct relay_index, rcu_node);
+               lttng::utils::container_of(rcu_head, &relay_index::rcu_node);
 
        index_destroy(index);
 }
@@ -208,7 +208,7 @@ static void index_destroy_rcu(struct rcu_head *rcu_head)
 /* Stream lock must be held by the caller. */
 static void index_release(struct urcu_ref *ref)
 {
-       struct relay_index *index = caa_container_of(ref, struct relay_index, ref);
+       struct relay_index *index = lttng::utils::container_of(ref, &relay_index::ref);
        struct relay_stream *stream = index->stream;
        int ret;
        struct lttng_ht_iter iter;
index ef830d4ba0d4daa7a391f5c6d6e06753fad0bb78..abbec8c20e89e02253a0dce83a38a138909b9dff 100644 (file)
@@ -970,7 +970,7 @@ void *thread_dispatcher(void *data __attribute__((unused)))
                                /* Continue thread execution */
                                break;
                        }
-                       conn = caa_container_of(node, struct relay_connection, qnode);
+                       conn = lttng::utils::container_of(node, &relay_connection::qnode);
                        DBG("Dispatching viewer request waiting on sock %d",
                                        conn->sock->fd);
 
index e1c74e358ebff36c9426cba3c2cc82a1ece4b3c8..41c5e1d4419d740b452528410b2345156717cfbe 100644 (file)
@@ -1329,7 +1329,7 @@ static void *relay_thread_dispatcher(void *data __attribute__((unused)))
                                /* Continue thread execution */
                                break;
                        }
-                       new_conn = caa_container_of(node, struct relay_connection, qnode);
+                       new_conn = lttng::utils::container_of(node, &relay_connection::qnode);
 
                        DBG("Dispatching request waiting on sock %d", new_conn->sock->fd);
 
index a776587b333a66c2c499d558b0c28c162fc8ae96..6e29fbc741afd1efe32723f7342f8cc809fa9a3c 100644 (file)
@@ -464,7 +464,7 @@ struct relay_session *session_get_by_id(uint64_t id)
                DBG("Session find by ID %" PRIu64 " id NOT found", id);
                goto end;
        }
-       session = caa_container_of(node, struct relay_session, session_n);
+       session = lttng::utils::container_of(node, &relay_session::session_n);
        DBG("Session find by ID %" PRIu64 " id found", id);
        if (!session_get(session)) {
                session = NULL;
@@ -609,7 +609,7 @@ static void destroy_session(struct relay_session *session)
 static void session_release(struct urcu_ref *ref)
 {
        struct relay_session *session =
-                       caa_container_of(ref, struct relay_session, ref);
+                       lttng::utils::container_of(ref, &relay_session::ref);
 
        destroy_session(session);
 }
index 60f1b975453c5612a4b1ee136cc4ce91c37e1fe3..eba9a1989ab07fd2cf21c5865e089d6ca72099db 100644 (file)
@@ -93,15 +93,15 @@ int trace_chunk_registry_ht_key_match(struct cds_lfht_node *node,
                        (struct trace_chunk_registry_ht_key *) _key;
        struct trace_chunk_registry_ht_element *registry;
 
-       registry = container_of(node, typeof(*registry), ht_node);
+       registry = lttng::utils::container_of(node, &trace_chunk_registry_ht_element::ht_node);
        return key->sessiond_uuid == registry->key.sessiond_uuid;
 }
 
 static
 void trace_chunk_registry_ht_element_free(struct rcu_head *node)
 {
-       struct trace_chunk_registry_ht_element *element =
-                       container_of(node, typeof(*element), rcu_node);
+       struct trace_chunk_registry_ht_element *element = lttng::utils::container_of(
+                       node, &trace_chunk_registry_ht_element::rcu_node);
 
        free(element);
 }
@@ -110,7 +110,7 @@ static
 void trace_chunk_registry_ht_element_release(struct urcu_ref *ref)
 {
        struct trace_chunk_registry_ht_element *element =
-                       container_of(ref, typeof(*element), ref);
+                       lttng::utils::container_of(ref, &trace_chunk_registry_ht_element::ref);
        char uuid_str[LTTNG_UUID_STR_LEN];
 
        lttng_uuid_to_str(element->key.sessiond_uuid, uuid_str);
@@ -167,7 +167,8 @@ struct trace_chunk_registry_ht_element *trace_chunk_registry_ht_element_find(
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (node) {
-               element = container_of(node, typeof(*element), ht_node);
+               element = lttng::utils::container_of(
+                               node, &trace_chunk_registry_ht_element::ht_node);
                /*
                 * Only consider the look-up as successful if a reference
                 * could be acquired.
@@ -236,8 +237,8 @@ int trace_chunk_registry_ht_element_create(
                 * was already published and release the reference to the copy
                 * we created if successful.
                 */
-               published_element = container_of(published_node,
-                               typeof(*published_element), ht_node);
+               published_element = lttng::utils::container_of(published_node,
+                               &trace_chunk_registry_ht_element::ht_node);
                if (trace_chunk_registry_ht_element_get(published_element)) {
                        DBG("Acquired reference to trace chunk registry of sessiond {%s}",
                                        uuid_str);
index 9f7bfcb15bb513229118302765c8c8f2655f7f91..fbecdc55804acdc151732a17188b13fa1b969186 100644 (file)
@@ -54,7 +54,7 @@ struct relay_stream *stream_get_by_id(uint64_t stream_id)
                DBG("Relay stream %" PRIu64 " not found", stream_id);
                goto end;
        }
-       stream = caa_container_of(node, struct relay_stream, node);
+       stream = lttng::utils::container_of(node, &relay_stream::node);
        if (!stream_get(stream)) {
                stream = NULL;
        }
@@ -760,7 +760,7 @@ static void stream_destroy(struct relay_stream *stream)
 static void stream_destroy_rcu(struct rcu_head *rcu_head)
 {
        struct relay_stream *stream =
-               caa_container_of(rcu_head, struct relay_stream, rcu_node);
+               lttng::utils::container_of(rcu_head, &relay_stream::rcu_node);
 
        stream_destroy(stream);
 }
@@ -772,7 +772,7 @@ static void stream_destroy_rcu(struct rcu_head *rcu_head)
 static void stream_release(struct urcu_ref *ref)
 {
        struct relay_stream *stream =
-               caa_container_of(ref, struct relay_stream, ref);
+               lttng::utils::container_of(ref, &relay_stream::ref);
        struct relay_session *session;
 
        session = stream->trace->session;
index 2790903adb7962d706eeb8bb0e660b7229c17d26..f37d8e33040d991d7ea3ecd818508d1d9ac1f3f2 100644 (file)
@@ -48,7 +48,7 @@ static void viewer_stream_destroy(struct relay_viewer_stream *vstream)
 static void viewer_stream_destroy_rcu(struct rcu_head *head)
 {
        struct relay_viewer_stream *vstream =
-               caa_container_of(head, struct relay_viewer_stream, rcu_node);
+               lttng::utils::container_of(head, &relay_viewer_stream::rcu_node);
 
        viewer_stream_destroy(vstream);
 }
@@ -269,7 +269,7 @@ struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id)
                DBG("Relay viewer stream %" PRIu64 " not found", id);
                goto end;
        }
-       vstream = caa_container_of(node, struct relay_viewer_stream, stream_n);
+       vstream = lttng::utils::container_of(node, &relay_viewer_stream::stream_n);
        if (!viewer_stream_get(vstream)) {
                vstream = NULL;
        }
index 2a880a19c800722a6f3bc4c785f43632e61aef28..31f1634bd70b70a681b6479433e0eb743fe72492 100644 (file)
@@ -202,9 +202,9 @@ static void add_unique_agent_event(struct lttng_ht *ht,
 static void destroy_event_agent_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_str *node =
-               caa_container_of(head, struct lttng_ht_node_str, head);
+               lttng::utils::container_of(head, &lttng_ht_node_str::head);
        struct agent_event *event =
-               caa_container_of(node, struct agent_event, node);
+               lttng::utils::container_of(node, &agent_event::node);
 
        agent_destroy_event(event);
 }
@@ -215,9 +215,9 @@ static void destroy_event_agent_rcu(struct rcu_head *head)
 static void destroy_app_agent_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_ulong *node =
-               caa_container_of(head, struct lttng_ht_node_ulong, head);
+               lttng::utils::container_of(head, &lttng_ht_node_ulong::head);
        struct agent_app *app =
-               caa_container_of(node, struct agent_app, node);
+               lttng::utils::container_of(node, &agent_app::node);
 
        free(app);
 }
@@ -1013,7 +1013,7 @@ struct agent_app *agent_find_app_by_sock(int sock)
        if (node == NULL) {
                goto error;
        }
-       app = caa_container_of(node, struct agent_app, node);
+       app = lttng::utils::container_of(node, &agent_app::node);
 
        DBG3("Agent app pid %d found by sock %d.", app->pid, sock);
        return app;
@@ -1388,7 +1388,7 @@ struct agent_event *agent_find_event(const char *name,
        }
 
        DBG3("Agent event found %s.", name);
-       return caa_container_of(node, struct agent_event, node);
+       return lttng::utils::container_of(node, &agent_event::node);
 
 error:
        DBG3("Agent event NOT found %s.", name);
@@ -1414,7 +1414,7 @@ static
 void destroy_app_ctx_rcu(struct rcu_head *head)
 {
        struct agent_app_ctx *ctx =
-                       caa_container_of(head, struct agent_app_ctx, rcu_node);
+                       lttng::utils::container_of(head, &agent_app_ctx::rcu_node);
 
        destroy_app_ctx(ctx);
 }
@@ -1443,7 +1443,7 @@ void agent_destroy(struct agent *agt)
                 * value is not important since we have to continue anyway
                 * destroying the object.
                 */
-               event = caa_container_of(node, struct agent_event, node);
+               event = lttng::utils::container_of(node, &agent_event::node);
                (void) agent_disable_event(event, agt->domain);
 
                ret = lttng_ht_del(agt->events, &iter);
@@ -1512,7 +1512,7 @@ void agent_app_ht_clean(void)
                        the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) {
                struct agent_app *app;
 
-               app = caa_container_of(node, struct agent_app, node);
+               app = lttng::utils::container_of(node, &agent_app::node);
                agent_destroy_app_by_sock(app->sock->fd);
        }
        rcu_read_unlock();
@@ -1598,7 +1598,7 @@ void agent_by_event_notifier_domain_ht_destroy(void)
        cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht,
                        &iter.iter, node, node) {
                struct agent *agent =
-                               caa_container_of(node, struct agent, node);
+                               lttng::utils::container_of(node, &agent::node);
                const int ret = lttng_ht_del(
                                the_trigger_agents_ht_by_domain, &iter);
 
@@ -1629,7 +1629,7 @@ struct agent *agent_find_by_event_notifier_domain(
                goto end;
        }
 
-       agt = caa_container_of(node, struct agent, node);
+       agt = lttng::utils::container_of(node, &agent::node);
 
 end:
        return agt;
index 360af749d587d6ebe4c5d09807d55d116295100c..ab7d11ae4f51f093c4907f74a23377034cff3cf5 100644 (file)
@@ -202,7 +202,7 @@ struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
        if (!node) {
                goto end;
        }
-       reg = caa_container_of(node, struct buffer_reg_uid, node);
+       reg = lttng::utils::container_of(node, &buffer_reg_uid::node);
 
 end:
        return reg;
@@ -314,7 +314,7 @@ struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id)
        if (!node) {
                goto end;
        }
-       reg = caa_container_of(node, struct buffer_reg_pid, node);
+       reg = lttng::utils::container_of(node, &buffer_reg_pid::node);
 
 end:
        return reg;
@@ -472,7 +472,7 @@ struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
        if (!node) {
                goto end;
        }
-       chan = caa_container_of(node, struct buffer_reg_channel, node);
+       chan = lttng::utils::container_of(node, &buffer_reg_channel::node);
 
 end:
        return chan;
@@ -630,9 +630,9 @@ void buffer_reg_uid_remove(struct buffer_reg_uid *regp)
 static void rcu_free_buffer_reg_uid(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct buffer_reg_uid *reg =
-               caa_container_of(node, struct buffer_reg_uid, node);
+               lttng::utils::container_of(node, &buffer_reg_uid::node);
 
        buffer_reg_session_destroy(reg->registry, reg->domain);
        free(reg);
@@ -641,9 +641,9 @@ static void rcu_free_buffer_reg_uid(struct rcu_head *head)
 static void rcu_free_buffer_reg_pid(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct buffer_reg_pid *reg =
-               caa_container_of(node, struct buffer_reg_pid, node);
+               lttng::utils::container_of(node, &buffer_reg_pid::node);
 
        buffer_reg_session_destroy(reg->registry, LTTNG_DOMAIN_UST);
        free(reg);
index 7daa53625190769284ecb0586387cba9d7bc5044..d932fac13bd139c723c3b1ef4aca1a3866245045 100644 (file)
@@ -27,8 +27,8 @@ unsigned long lttng_condition_buffer_usage_hash(
        unsigned long condition_type;
        struct lttng_condition_buffer_usage *condition;
 
-       condition = container_of(_condition,
-                       struct lttng_condition_buffer_usage, parent);
+       condition = lttng::utils::container_of(_condition,
+                       &lttng_condition_buffer_usage::parent);
 
        condition_type = (unsigned long) condition->parent.type;
        hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
@@ -64,8 +64,8 @@ unsigned long lttng_condition_session_consumed_size_hash(
        struct lttng_condition_session_consumed_size *condition;
        uint64_t val;
 
-       condition = container_of(_condition,
-                       struct lttng_condition_session_consumed_size, parent);
+       condition = lttng::utils::container_of(_condition,
+                       &lttng_condition_session_consumed_size::parent);
 
        hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
        if (condition->session_name) {
@@ -83,8 +83,8 @@ unsigned long lttng_condition_session_rotation_hash(
        unsigned long hash, condition_type;
        struct lttng_condition_session_rotation *condition;
 
-       condition = container_of(_condition,
-                       struct lttng_condition_session_rotation, parent);
+       condition = lttng::utils::container_of(_condition,
+                       &lttng_condition_session_rotation::parent);
        condition_type = (unsigned long) condition->parent.type;
        hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
        LTTNG_ASSERT(condition->session_name);
index b87e1d73d2d065ef21ee19c4a015b2c00946c396..c0f8eb5894e8fae8cb070109d4820ebec62ddff2 100644 (file)
@@ -414,7 +414,7 @@ struct consumer_socket *consumer_find_socket(int key,
                        &iter);
        node = lttng_ht_iter_get_node_ulong(&iter);
        if (node != NULL) {
-               socket = caa_container_of(node, struct consumer_socket, node);
+               socket = lttng::utils::container_of(node, &consumer_socket::node);
        }
 
        return socket;
@@ -481,9 +481,9 @@ void consumer_del_socket(struct consumer_socket *sock,
 static void destroy_socket_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_ulong *node =
-               caa_container_of(head, struct lttng_ht_node_ulong, head);
+               lttng::utils::container_of(head, &lttng_ht_node_ulong::head);
        struct consumer_socket *socket =
-               caa_container_of(node, struct consumer_socket, node);
+               lttng::utils::container_of(node, &consumer_socket::node);
 
        free(socket);
 }
@@ -566,7 +566,7 @@ void consumer_destroy_output_sockets(struct consumer_output *obj)
 static void consumer_release_output(struct urcu_ref *ref)
 {
        struct consumer_output *obj =
-               caa_container_of(ref, struct consumer_output, ref);
+               lttng::utils::container_of(ref, &consumer_output::ref);
 
        consumer_destroy_output_sockets(obj);
 
index 8e80c29855e934576b0a17f8814433d835f0114f..82bf1c2d3128a026a0d8eb62b18eb9a4b2e70353 100644 (file)
@@ -284,7 +284,7 @@ static void *thread_dispatch_ust_registration(void *data)
                                break;
                        }
 
-                       ust_cmd = caa_container_of(node, struct ust_command, node);
+                       ust_cmd = lttng::utils::container_of(node, &ust_command::node);
 
                        DBG("Dispatching UST registration pid:%d ppid:%d uid:%d"
                                        " gid:%d sock:%d name:%s (version %d.%d)",
@@ -476,7 +476,7 @@ error:
                if (node == NULL) {
                        break;
                }
-               ust_cmd = caa_container_of(node, struct ust_command, node);
+               ust_cmd = lttng::utils::container_of(node, &ust_command::node);
                ret = close(ust_cmd->sock);
                if (ret < 0) {
                        PERROR("close ust sock exit dispatch %d", ust_cmd->sock);
index 285cdbf5992376d9a975af2049f6ed9894876787..70ffb86ef01bf74a8423d54c9202774102b763e9 100644 (file)
@@ -128,7 +128,7 @@ static void free_ust_error_accounting_entry(struct rcu_head *head)
 {
        int i;
        struct ust_error_accounting_entry *entry =
-                       caa_container_of(head, typeof(*entry), rcu_head);
+                       lttng::utils::container_of(head, &ust_error_accounting_entry::rcu_head);
 
        for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
                lttng_ust_ctl_release_object(-1, entry->cpu_counters[i]);
@@ -155,7 +155,7 @@ static
 void ust_error_accounting_entry_release(struct urcu_ref *entry_ref)
 {
        struct ust_error_accounting_entry *entry =
-                       container_of(entry_ref, typeof(*entry), ref);
+                       lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref);
 
        rcu_read_lock();
        cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node);
@@ -322,8 +322,7 @@ enum event_notifier_error_accounting_status get_error_counter_index_for_token(
        lttng_ht_lookup(state->indices_ht, &tracer_token, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node) {
-               index_entry = caa_container_of(
-                               node, const struct index_ht_entry, node);
+               index_entry = lttng::utils::container_of(node, &index_ht_entry::node);
                *error_counter_index = index_entry->error_counter_index;
                status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
        } else {
@@ -1328,8 +1327,8 @@ void event_notifier_error_accounting_unregister_event_notifier(
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node) {
                int del_ret;
-               struct index_ht_entry *index_entry = caa_container_of(
-                               node, typeof(*index_entry), node);
+               struct index_ht_entry *index_entry =
+                               lttng::utils::container_of(node, &index_ht_entry::node);
                enum lttng_index_allocator_status index_alloc_status;
 
                index_alloc_status = lttng_index_allocator_release(
index 797219dff8cf893be2c5055b6026aea15e3a2b3a..65b7220ef13603ad1d84f9952e1bde0854dd80de 100644 (file)
@@ -267,7 +267,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
        }
 
        do {
-               uevent = caa_container_of(node, struct ltt_ust_event, node);
+               uevent = lttng::utils::container_of(node, &ltt_ust_event::node);
                LTTNG_ASSERT(uevent);
 
                if (uevent->enabled == 0) {
@@ -869,7 +869,7 @@ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
        }
 
        do {
-               aevent = caa_container_of(node, struct agent_event, node);
+               aevent = lttng::utils::container_of(node, &agent_event::node);
                ret = event_agent_disable_one(usess, agt, aevent);
 
                if (ret != LTTNG_OK) {
index a3030bcf47e2d27aa3aea3a97de897ea66a1e594..8a4ce39ea8e6bcd6b9fbf71d9cd39f02d2f99ad1 100644 (file)
@@ -210,7 +210,7 @@ static struct syscall *lookup_syscall(struct lttng_ht *ht, const char *name)
        lttng_ht_lookup(ht, (void *) name, &iter);
        node = lttng_ht_iter_get_node_str(&iter);
        if (node) {
-               ksyscall = caa_container_of(node, struct syscall, node);
+               ksyscall = lttng::utils::container_of(node, &syscall::node);
        }
 
        return ksyscall;
index d6c0d813550a21398a8e6e1987e4f2d437697c83..ef066f49bf6156d390f0befe9e83b70e47003648 100644 (file)
@@ -225,8 +225,8 @@ int match_client_id(struct cds_lfht_node *node, const void *key)
 {
        /* This double-cast is intended to supress pointer-to-cast warning. */
        const notification_client_id id = *((notification_client_id *) key);
-       const struct notification_client *client = caa_container_of(
-                       node, struct notification_client, client_id_ht_node);
+       const struct notification_client *client = lttng::utils::container_of(
+                       node, &notification_client::client_id_ht_node);
 
        return client->id == id;
 }
@@ -325,8 +325,8 @@ static
 int match_session(struct cds_lfht_node *node, const void *key)
 {
        const char *name = (const char *) key;
-       struct session_info *session_info = caa_container_of(
-               node, struct session_info, sessions_ht_node);
+       struct session_info *session_info = lttng::utils::container_of(
+               node, &session_info::sessions_ht_node);
 
        return !strcmp(session_info->name, name);
 }
@@ -493,7 +493,7 @@ enum lttng_object_type get_condition_binding_object(
 static
 void free_channel_info_rcu(struct rcu_head *node)
 {
-       free(caa_container_of(node, struct channel_info, rcu_node));
+       free(lttng::utils::container_of(node, &channel_info::rcu_node));
 }
 
 static
@@ -517,7 +517,7 @@ void channel_info_destroy(struct channel_info *channel_info)
 static
 void free_session_info_rcu(struct rcu_head *node)
 {
-       free(caa_container_of(node, struct session_info, rcu_node));
+       free(lttng::utils::container_of(node, &session_info::rcu_node));
 }
 
 /* Don't call directly, use the ref-counting mechanism. */
@@ -672,7 +672,7 @@ static
 void notification_client_list_release(struct urcu_ref *list_ref)
 {
        struct notification_client_list *list =
-                       container_of(list_ref, typeof(*list), ref);
+                       lttng::utils::container_of(list_ref, &notification_client_list::ref);
        struct notification_client_list_element *client_list_element, *tmp;
 
        lttng_condition_put(list->condition);
@@ -816,8 +816,8 @@ struct notification_client_list *get_client_list_from_condition(
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (node) {
-               list = container_of(node, struct notification_client_list,
-                               notification_trigger_clients_ht_node);
+               list = lttng::utils::container_of(node,
+                               &notification_client_list::notification_trigger_clients_ht_node);
                list = notification_client_list_get(list) ? list : NULL;
        }
 
@@ -1284,7 +1284,7 @@ end:
 static
 void free_notification_client_rcu(struct rcu_head *node)
 {
-       free(caa_container_of(node, struct notification_client, rcu_node));
+       free(lttng::utils::container_of(node, &notification_client::rcu_node));
 }
 
 static
@@ -4207,9 +4207,8 @@ bool evaluate_buffer_usage_condition(const struct lttng_condition *condition,
        bool result = false;
        uint64_t threshold;
        enum lttng_condition_type condition_type;
-       const struct lttng_condition_buffer_usage *use_condition = container_of(
-                       condition, struct lttng_condition_buffer_usage,
-                       parent);
+       const struct lttng_condition_buffer_usage *use_condition = lttng::utils::container_of(
+                       condition, &lttng_condition_buffer_usage::parent);
 
        if (use_condition->threshold_bytes.set) {
                threshold = use_condition->threshold_bytes.value;
@@ -4265,9 +4264,8 @@ bool evaluate_session_consumed_size_condition(
 {
        uint64_t threshold;
        const struct lttng_condition_session_consumed_size *size_condition =
-                       container_of(condition,
-                               struct lttng_condition_session_consumed_size,
-                               parent);
+                       lttng::utils::container_of(condition,
+                               &lttng_condition_session_consumed_size::parent);
 
        threshold = size_condition->consumed_threshold_bytes.value;
        DBG("Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
@@ -4750,10 +4748,9 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s
        }
 
        evaluation = lttng_evaluation_event_rule_matches_create(
-                       container_of(lttng_trigger_get_const_condition(
+                       lttng::utils::container_of(lttng_trigger_get_const_condition(
                                                     element->trigger),
-                                       struct lttng_condition_event_rule_matches,
-                                       parent),
+                                       &lttng_condition_event_rule_matches::parent),
                        notification->capture_buffer,
                        notification->capture_buf_size, false);
 
index 757b97226a1bb5be53eb2650add9f204fd13a1be..5db70faef47e98f0c865e65e69916365beab3a89 100644 (file)
@@ -199,7 +199,7 @@ int save_ust_channel_attributes(struct config_writer *writer,
         * Fetch the monitor timer which is located in the parent of
         * lttng_ust_channel_attr
         */
-       channel = caa_container_of(attr, struct ltt_ust_channel, attr);
+       channel = lttng::utils::container_of(attr, &ltt_ust_channel::attr);
        ret = config_writer_write_element_unsigned_int(writer,
                config_element_monitor_timer_interval,
                channel->monitor_timer_interval);
@@ -1155,7 +1155,7 @@ int save_ust_events(struct config_writer *writer,
 
        rcu_read_lock();
        cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
-               event = caa_container_of(node, struct ltt_ust_event, node);
+               event = lttng::utils::container_of(node, &ltt_ust_event::node);
 
                if (event->internal) {
                        /* Internal events must not be exposed to clients */
@@ -1243,7 +1243,7 @@ int save_agent_events(struct config_writer *writer,
                struct ltt_ust_event fake_event;
 
                memset(&fake_event, 0, sizeof(fake_event));
-               agent_event = caa_container_of(node, struct agent_event, node);
+               agent_event = lttng::utils::container_of(node, &agent_event::node);
 
                /*
                 * Initialize a fake ust event to reuse the same serialization
@@ -2135,7 +2135,7 @@ int save_ust_domain(struct config_writer *writer,
        rcu_read_lock();
        cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
                        &iter.iter, node, node) {
-               ust_chan = caa_container_of(node, struct ltt_ust_channel, node);
+               ust_chan = lttng::utils::container_of(node, &ltt_ust_channel::node);
                if (domain == ust_chan->domain) {
                        ret = save_ust_channel(writer, ust_chan, session->ust_session);
                        if (ret != LTTNG_OK) {
index 1846024fcc60670d505a740db81125c7ec1e0aec..e9d7261031d632fc44e4f820621a8e471a3e9e74 100644 (file)
@@ -876,7 +876,7 @@ enum lttng_error_code session_kernel_open_packets(struct ltt_session *session)
 
        cds_lfht_first(session->kernel_session->consumer->socks->ht, &iter.iter);
        node = cds_lfht_iter_get_node(&iter.iter);
-       socket = container_of(node, typeof(*socket), node.node);
+       socket = caa_container_of(node, typeof(*socket), node.node);
 
        cds_list_for_each_entry(chan,
                        &session->kernel_session->channel_list.head, list) {
@@ -979,7 +979,7 @@ void session_release(struct urcu_ref *ref)
        int ret;
        struct ltt_ust_session *usess;
        struct ltt_kernel_session *ksess;
-       struct ltt_session *session = container_of(ref, typeof(*session), ref);
+       struct ltt_session *session = lttng::utils::container_of(ref, &ltt_session::ref);
        const bool session_published = session->published;
 
        LTTNG_ASSERT(!session->chunk_being_archived);
@@ -1183,7 +1183,7 @@ struct ltt_session *session_find_by_id(uint64_t id)
        if (node == NULL) {
                goto end;
        }
-       ls = caa_container_of(node, struct ltt_session, node);
+       ls = lttng::utils::container_of(node, &ltt_session::node);
 
        DBG3("Session %" PRIu64 " found by id.", id);
        return session_get(ls) ? ls : NULL;
@@ -1456,7 +1456,7 @@ bool sample_session_id_by_name(const char *name, uint64_t *id)
                goto end;
        }
 
-       ls = caa_container_of(node, struct ltt_session, node_by_name);
+       ls = lttng::utils::container_of(node, &ltt_session::node_by_name);
        *id = ls->id;
        found = true;
 
index 1601f17ccc2f0918f1bb81b0c6cc0fe00796ca23..e0ffe69c0b1a5303cebfe908ab99cee7eb2220d1 100644 (file)
@@ -276,7 +276,7 @@ struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
                DBG3("Snapshot output not found with id %" PRId32, id);
                goto error;
        }
-       output = caa_container_of(node, struct snapshot_output, node);
+       output = lttng::utils::container_of(node, &snapshot_output::node);
 
 error:
        return output;
index 201917396462230165f91a931c33373d2a556eff..fd9136fe5562b4e5acee6a70bef36061572b38c0 100644 (file)
@@ -54,7 +54,7 @@ void lttng_thread_destroy(struct lttng_thread *thread)
 static
 void lttng_thread_release(struct urcu_ref *ref)
 {
-       lttng_thread_destroy(container_of(ref, struct lttng_thread, ref));
+       lttng_thread_destroy(lttng::utils::container_of(ref, &lttng_thread::ref));
 }
 
 static
index 6f423c9c6485d459afb5e452d5c0be476dd862a2..4a3e74de7792b8bc0b195b98f8bc15d9db9e5a10 100644 (file)
@@ -185,7 +185,7 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
 
        DBG2("Trace UST channel %s found by name", name);
 
-       return caa_container_of(node, struct ltt_ust_channel, node);
+       return lttng::utils::container_of(node, &ltt_ust_channel::node);
 
 error:
        DBG2("Trace UST channel %s not found by name", name);
@@ -224,7 +224,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
 
        DBG2("Trace UST event %s found", key.name);
 
-       return caa_container_of(node, struct ltt_ust_event, node);
+       return lttng::utils::container_of(node, &ltt_ust_event::node);
 
 error:
        DBG2("Trace UST event %s NOT found", key.name);
@@ -257,7 +257,7 @@ struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
        if (!node) {
                goto end;
        }
-       agt = caa_container_of(node, struct agent, node);
+       agt = lttng::utils::container_of(node, &agent::node);
 
 end:
        return agt;
@@ -793,7 +793,7 @@ static struct ust_id_tracker_node *id_tracker_lookup(
        lttng_ht_lookup(id_tracker->ht, (void *) _id, iter);
        node = lttng_ht_iter_get_node_ulong(iter);
        if (node) {
-               return caa_container_of(node, struct ust_id_tracker_node, node);
+               return lttng::utils::container_of(node, &ust_id_tracker_node::node);
        } else {
                return NULL;
        }
@@ -1203,9 +1203,9 @@ end:
 static void destroy_context_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_ulong *node =
-               caa_container_of(head, struct lttng_ht_node_ulong, head);
+               lttng::utils::container_of(head, &lttng_ht_node_ulong::head);
        struct ltt_ust_context *ctx =
-               caa_container_of(node, struct ltt_ust_context, node);
+               lttng::utils::container_of(node, &ltt_ust_context::node);
 
        trace_ust_destroy_context(ctx);
 }
@@ -1225,7 +1225,7 @@ static void destroy_contexts(struct lttng_ht *ht)
        rcu_read_lock();
        cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
                /* Remove from ordered list. */
-               ctx = caa_container_of(node, struct ltt_ust_context, node);
+               ctx = lttng::utils::container_of(node, &ltt_ust_context::node);
                cds_list_del(&ctx->list);
                /* Remove from channel's hash table. */
                ret = lttng_ht_del(ht, &iter);
@@ -1272,9 +1272,9 @@ void trace_ust_destroy_context(struct ltt_ust_context *ctx)
 static void destroy_event_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_str *node =
-               caa_container_of(head, struct lttng_ht_node_str, head);
+               lttng::utils::container_of(head, &lttng_ht_node_str::head);
        struct ltt_ust_event *event =
-               caa_container_of(node, struct ltt_ust_event, node);
+               lttng::utils::container_of(node, &ltt_ust_event::node);
 
        trace_ust_destroy_event(event);
 }
@@ -1321,9 +1321,9 @@ static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel)
 static void destroy_channel_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_str *node =
-               caa_container_of(head, struct lttng_ht_node_str, head);
+               lttng::utils::container_of(head, &lttng_ht_node_str::head);
        struct ltt_ust_channel *channel =
-               caa_container_of(node, struct ltt_ust_channel, node);
+               lttng::utils::container_of(node, &ltt_ust_channel::node);
 
        _trace_ust_destroy_channel(channel);
 }
@@ -1395,7 +1395,7 @@ static void destroy_channels(struct lttng_ht *channels)
        rcu_read_lock();
        cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
                struct ltt_ust_channel *chan =
-                       caa_container_of(node, struct ltt_ust_channel, node);
+                       lttng::utils::container_of(node, &ltt_ust_channel::node);
 
                trace_ust_delete_channel(channels, chan);
                trace_ust_destroy_channel(chan);
index 9e29b73247c33ed21f5b19c77aadeaa6cf9fc978..10f8dd59811a4e99f51d6c5fba025e347c4d7df8 100644 (file)
@@ -41,8 +41,8 @@ struct process_attr_tracker_value_node {
 
 static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head)
 {
-       struct process_attr_tracker_value_node *node =
-                       container_of(rcu_head, typeof(*node), rcu_head);
+       struct process_attr_tracker_value_node *node = lttng::utils::container_of(
+                       rcu_head, &process_attr_tracker_value_node::rcu_head);
 
        free(node);
 }
@@ -177,9 +177,9 @@ static struct process_attr_tracker_value_node *process_attr_tracker_lookup(
        node = cds_lfht_iter_get_node(&iter);
        rcu_read_unlock();
 
-       return node ? container_of(node, struct process_attr_tracker_value_node,
-                                     inclusion_set_ht_node) :
-                     NULL;
+       return node ? lttng::utils::container_of(node,
+                                     &process_attr_tracker_value_node::inclusion_set_ht_node) :
+                           NULL;
 }
 
 /* Protected by session mutex held by caller. */
index 16848191d6f6d8f8b2bde23e207d3a3f47b8824c..0246501a53a31c69bc1ea3a9cddbaec75c67f6d4 100644 (file)
@@ -287,7 +287,7 @@ static void close_notify_sock_rcu(struct rcu_head *head)
 {
        int ret;
        struct ust_app_notify_sock_obj *obj =
-               caa_container_of(head, struct ust_app_notify_sock_obj, head);
+               lttng::utils::container_of(head, &ust_app_notify_sock_obj::head);
 
        /* Must have a valid fd here. */
        LTTNG_ASSERT(obj->fd >= 0);
@@ -380,8 +380,8 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event,
 static
 void free_ust_app_event_notifier_rule_rcu(struct rcu_head *head)
 {
-       struct ust_app_event_notifier_rule *obj = caa_container_of(
-                       head, struct ust_app_event_notifier_rule, rcu_head);
+       struct ust_app_event_notifier_rule *obj = lttng::utils::container_of(
+                       head, &ust_app_event_notifier_rule::rcu_head);
 
        free(obj);
 }
@@ -480,7 +480,7 @@ static
 void delete_ust_app_channel_rcu(struct rcu_head *head)
 {
        struct ust_app_channel *ua_chan =
-               caa_container_of(head, struct ust_app_channel, rcu_head);
+               lttng::utils::container_of(head, &ust_app_channel::rcu_head);
 
        lttng_ht_destroy(ua_chan->ctx);
        lttng_ht_destroy(ua_chan->events);
@@ -902,7 +902,7 @@ static
 void delete_ust_app_session_rcu(struct rcu_head *head)
 {
        struct ust_app_session *ua_sess =
-               caa_container_of(head, struct ust_app_session, rcu_head);
+               lttng::utils::container_of(head, &ust_app_session::rcu_head);
 
        lttng_ht_destroy(ua_sess->channels);
        free(ua_sess);
@@ -1126,9 +1126,9 @@ static
 void delete_ust_app_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_ulong *node =
-               caa_container_of(head, struct lttng_ht_node_ulong, head);
+               lttng::utils::container_of(head, &lttng_ht_node_ulong::head);
        struct ust_app *app =
-               caa_container_of(node, struct ust_app, pid_n);
+               lttng::utils::container_of(node, &ust_app::pid_n);
 
        DBG3("Call RCU deleting app PID %d", app->pid);
        delete_ust_app(app);
@@ -1470,7 +1470,7 @@ struct ust_app *ust_app_find_by_sock(int sock)
                goto error;
        }
 
-       return caa_container_of(node, struct ust_app, sock_n);
+       return lttng::utils::container_of(node, &ust_app::sock_n);
 
 error:
        return NULL;
@@ -1495,7 +1495,7 @@ static struct ust_app *find_app_by_notify_sock(int sock)
                goto error;
        }
 
-       return caa_container_of(node, struct ust_app, notify_sock_n);
+       return lttng::utils::container_of(node, &ust_app::notify_sock_n);
 
 error:
        return NULL;
@@ -1535,7 +1535,7 @@ static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht,
                goto end;
        }
 
-       event = caa_container_of(node, struct ust_app_event, node);
+       event = lttng::utils::container_of(node, &ust_app_event::node);
 
 end:
        return event;
@@ -1565,8 +1565,8 @@ static struct ust_app_event_notifier_rule *find_ust_app_event_notifier_rule(
                goto end;
        }
 
-       event_notifier_rule = caa_container_of(
-                       node, struct ust_app_event_notifier_rule, node);
+       event_notifier_rule = lttng::utils::container_of(
+                       node, &ust_app_event_notifier_rule::node);
 end:
        return event_notifier_rule;
 }
@@ -2506,7 +2506,7 @@ static struct ust_app_session *lookup_session_by_app(
                goto error;
        }
 
-       return caa_container_of(node, struct ust_app_session, node);
+       return lttng::utils::container_of(node, &ust_app_session::node);
 
 error:
        return NULL;
@@ -2833,7 +2833,7 @@ struct ust_app_ctx *find_ust_app_context(struct lttng_ht *ht,
                goto end;
        }
 
-       app_ctx = caa_container_of(node, struct ust_app_ctx, node);
+       app_ctx = lttng::utils::container_of(node, &ust_app_ctx::node);
 
 end:
        return app_ctx;
@@ -2965,7 +2965,7 @@ static int enable_ust_app_channel(struct ust_app_session *ua_sess,
                goto error;
        }
 
-       ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+       ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
 
        ret = enable_ust_channel(app, ua_sess, ua_chan);
        if (ret < 0) {
@@ -3680,7 +3680,7 @@ static int ust_app_channel_allocate(struct ust_app_session *ua_sess,
        lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);
        ua_chan_node = lttng_ht_iter_get_node_str(&iter);
        if (ua_chan_node != NULL) {
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
                goto end;
        }
 
@@ -3945,7 +3945,7 @@ struct ust_app *ust_app_find_by_pid(pid_t pid)
 
        DBG2("Found UST app by pid %d", pid);
 
-       app = caa_container_of(node, struct ust_app, pid_n);
+       app = lttng::utils::container_of(node, &ust_app::pid_n);
 
 error:
        return app;
@@ -4270,7 +4270,7 @@ void ust_app_unregister(int sock)
        node = lttng_ht_iter_get_node_ulong(&ust_app_sock_iter);
        LTTNG_ASSERT(node);
 
-       lta = caa_container_of(node, struct ust_app, sock_n);
+       lta = lttng::utils::container_of(node, &ust_app::sock_n);
        DBG("PID %d unregistering with sock %d", lta->pid, sock);
 
        /*
@@ -4763,7 +4763,7 @@ int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
                /* If the session if found for the app, the channel must be there */
                LTTNG_ASSERT(ua_chan_node);
 
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
                /* The channel must not be already disabled */
                LTTNG_ASSERT(ua_chan->enabled == 1);
 
@@ -4866,7 +4866,7 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess,
                                        "Skipping", uchan->name, usess->id, app->pid);
                        continue;
                }
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
 
                ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
                                uevent->filter, uevent->attr.loglevel,
@@ -5025,7 +5025,7 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess,
                        continue;
                }
 
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
 
                /* Get event node */
                ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
@@ -5098,7 +5098,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess,
                /* If the channel is not found, there is a code flow error */
                LTTNG_ASSERT(ua_chan_node);
 
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
 
                ret = create_ust_app_event(ua_chan, uevent, app);
                pthread_mutex_unlock(&ua_sess->lock);
@@ -5642,7 +5642,7 @@ static int destroy_trace(struct ltt_ust_session *usess, struct ust_app *app)
                /* Session is being or is deleted. */
                goto end;
        }
-       ua_sess = caa_container_of(node, struct ust_app_session, node);
+       ua_sess = lttng::utils::container_of(node, &ust_app_session::node);
 
        health_code_update();
        destroy_app_session(app, ua_sess);
@@ -6326,7 +6326,7 @@ static struct ust_app_session *find_session_by_objd(struct ust_app *app,
                goto error;
        }
 
-       ua_sess = caa_container_of(node, struct ust_app_session, ust_objd_node);
+       ua_sess = lttng::utils::container_of(node, &ust_app_session::ust_objd_node);
 
 error:
        return ua_sess;
@@ -6354,7 +6354,7 @@ static struct ust_app_channel *find_channel_by_objd(struct ust_app *app,
                goto error;
        }
 
-       ua_chan = caa_container_of(node, struct ust_app_channel, ust_objd_node);
+       ua_chan = lttng::utils::container_of(node, &ust_app_channel::ust_objd_node);
 
 error:
        return ua_chan;
@@ -7253,7 +7253,7 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
                /* If the session is found for the app, the channel must be there */
                LTTNG_ASSERT(ua_chan_node);
 
-               ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+               ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
 
                if (overwrite) {
                        uint64_t _lost;
index b78091a04f4ca277ac033b2c60b85670922abf4d..6e21cee00c6d314419761d6a494d7b41c2084bec 100644 (file)
@@ -88,7 +88,7 @@ void destroy_channel_rcu(struct rcu_head *head)
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lsu::registry_channel *chan =
-               caa_container_of(head, lsu::registry_channel, _rcu_head);
+               lttng::utils::container_of(head, &lsu::registry_channel::_rcu_head);
        DIAGNOSTIC_POP
 
        delete chan;
@@ -149,7 +149,7 @@ void destroy_enum_rcu(struct rcu_head *head)
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lsu::registry_enum *reg_enum =
-               caa_container_of(head, lsu::registry_enum, rcu_head);
+               lttng::utils::container_of(head, &lsu::registry_enum::rcu_head);
        DIAGNOSTIC_POP
 
        destroy_enum(reg_enum);
@@ -434,7 +434,7 @@ lttng::sessiond::ust::registry_channel& lsu::registry_session::get_channel(
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       auto chan = caa_container_of(node, lsu::registry_channel, _node);
+       auto chan = lttng::utils::container_of(node, &lsu::registry_channel::_node);
        DIAGNOSTIC_POP
        return *chan;
 }
@@ -654,7 +654,7 @@ lsu::registry_session::get_enumeration(const char *enum_name, uint64_t enum_id)
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       reg_enum = caa_container_of(node, lsu::registry_enum, node);
+       reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
        DIAGNOSTIC_POP
 
        return lsu::registry_enum::const_rcu_protected_reference{*reg_enum, std::move(rcu_lock)};
@@ -682,7 +682,7 @@ lsu::registry_enum *lsu::registry_session::_lookup_enum(
 
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
-       reg_enum = caa_container_of(node, lsu::registry_enum, node);
+       reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
        DIAGNOSTIC_POP
 
 end:
index 323fdd6a757b82a0a6938adec9bb41cb1d520e25..2a7d6217a501b605eca4dd50c763b3d94025f5e7 100644 (file)
@@ -33,11 +33,11 @@ namespace lsu = lttng::sessiond::ust;
  */
 static void ust_registry_event_destroy_rcu(struct rcu_head *head)
 {
-       struct lttng_ht_node_u64 *node = caa_container_of(head, struct lttng_ht_node_u64, head);
+       struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        DIAGNOSTIC_PUSH
        DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
        lttng::sessiond::ust::registry_event *event =
-                       caa_container_of(node, lttng::sessiond::ust::registry_event, _node);
+                       lttng::utils::container_of(node, &lttng::sessiond::ust::registry_event::_node);
        DIAGNOSTIC_POP
 
        lttng::sessiond::ust::registry_event_destroy(event);
index 74dec1247468324df9c42d57ccff7567a740c697..bc9e3580a769632f6f09000eb05318d84501bc24 100644 (file)
@@ -73,7 +73,7 @@ static
 void action_destroy_ref(struct urcu_ref *ref)
 {
        struct lttng_action *action =
-                       container_of(ref, struct lttng_action, ref);
+                       lttng::utils::container_of(ref, &lttng_action::ref);
 
        action->destroy(action);
 }
index 1d962152b0e825e9b422542d7d37126c9de5e18b..4de7d81e8a04eeed57210a5b7b08a87e2e6d78df 100644 (file)
@@ -48,7 +48,7 @@ static struct lttng_action_list *action_list_from_action(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_list, parent);
+       return lttng::utils::container_of(action, &lttng_action_list::parent);
 }
 
 static const struct lttng_action_list *action_list_from_action_const(
@@ -56,7 +56,7 @@ static const struct lttng_action_list *action_list_from_action_const(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_list, parent);
+       return lttng::utils::container_of(action, &lttng_action_list::parent);
 }
 
 static bool lttng_action_list_validate(struct lttng_action *action)
@@ -258,8 +258,6 @@ static enum lttng_action_status lttng_action_list_add_error_query_results(
 {
        unsigned int i, count;
        enum lttng_action_status action_status;
-       const struct lttng_action_list *list =
-                       container_of(action, typeof(*list), parent);
 
        action_status = lttng_action_list_get_count(action, &count);
        if (action_status != LTTNG_ACTION_STATUS_OK) {
index ff117321e0b73d7e0e0b7e30fc6b865cd7085660..d58dcbe3621b54e1dd139e91a90b743257637a34 100644 (file)
@@ -21,7 +21,7 @@ static struct lttng_action_notify *action_notify_from_action(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_notify, parent);
+       return lttng::utils::container_of(action, &lttng_action_notify::parent);
 }
 
 static const struct lttng_action_notify *action_notify_from_action_const(
@@ -29,7 +29,7 @@ static const struct lttng_action_notify *action_notify_from_action_const(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_notify, parent);
+       return lttng::utils::container_of(action, &lttng_action_notify::parent);
 }
 
 static
index c9c7a05197c2cbea1d8f8be4c8d30c8f2f07b1a1..303b4a781765ab71f4a739073c0ac168b95b71c0 100644 (file)
@@ -348,7 +348,7 @@ static struct lttng_rate_policy_every_n *rate_policy_every_n_from_rate_policy(
 {
        LTTNG_ASSERT(policy);
 
-       return container_of(policy, struct lttng_rate_policy_every_n, parent);
+       return lttng::utils::container_of(policy, &lttng_rate_policy_every_n::parent);
 }
 
 static const struct lttng_rate_policy_every_n *
@@ -357,7 +357,7 @@ rate_policy_every_n_from_rate_policy_const(
 {
        LTTNG_ASSERT(policy);
 
-       return container_of(policy, struct lttng_rate_policy_every_n, parent);
+       return lttng::utils::container_of(policy, &lttng_rate_policy_every_n::parent);
 }
 
 static int lttng_rate_policy_every_n_serialize(
@@ -560,8 +560,8 @@ rate_policy_once_after_n_from_rate_policy(struct lttng_rate_policy *policy)
 {
        LTTNG_ASSERT(policy);
 
-       return container_of(
-                       policy, struct lttng_rate_policy_once_after_n, parent);
+       return lttng::utils::container_of(
+                       policy, &lttng_rate_policy_once_after_n::parent);
 }
 
 static const struct lttng_rate_policy_once_after_n *
@@ -570,8 +570,8 @@ rate_policy_once_after_n_from_rate_policy_const(
 {
        LTTNG_ASSERT(policy);
 
-       return container_of(
-                       policy, struct lttng_rate_policy_once_after_n, parent);
+       return lttng::utils::container_of(
+                       policy, &lttng_rate_policy_once_after_n::parent);
 }
 static int lttng_rate_policy_once_after_n_serialize(
                struct lttng_rate_policy *policy, struct lttng_payload *payload)
index 9c9a2a466ddbe52adfbc4e1ac0e10d06c38f3706..b25731484891788f64e34b804baf4882b25929b7 100644 (file)
@@ -49,7 +49,7 @@ static struct lttng_action_rotate_session *action_rotate_session_from_action(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_rotate_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_rotate_session::parent);
 }
 
 static const struct lttng_action_rotate_session *
@@ -57,7 +57,7 @@ action_rotate_session_from_action_const(const struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_rotate_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_rotate_session::parent);
 }
 
 static bool lttng_action_rotate_session_validate(struct lttng_action *action)
index 6639ea55ea219e20140af602268f20b1cfc30634..6af260c93e35a3e7cb2659429cd0a6f0f849bf53 100644 (file)
@@ -66,8 +66,8 @@ action_snapshot_session_from_action(struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(
-                       action, struct lttng_action_snapshot_session, parent);
+       return lttng::utils::container_of(
+                       action, &lttng_action_snapshot_session::parent);
 }
 
 static const struct lttng_action_snapshot_session *
@@ -75,8 +75,8 @@ action_snapshot_session_from_action_const(const struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(
-                       action, struct lttng_action_snapshot_session, parent);
+       return lttng::utils::container_of(
+                       action, &lttng_action_snapshot_session::parent);
 }
 
 static bool lttng_action_snapshot_session_validate(struct lttng_action *action)
index 91bb3505e5115e7c489e5072e469c3c8ee69b580..2c9f799727e43ad454ab32610c16fe14000b68a6 100644 (file)
@@ -49,7 +49,7 @@ static struct lttng_action_start_session *action_start_session_from_action(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_start_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_start_session::parent);
 }
 
 static const struct lttng_action_start_session *
@@ -57,7 +57,7 @@ action_start_session_from_action_const(const struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_start_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_start_session::parent);
 }
 
 static bool lttng_action_start_session_validate(struct lttng_action *action)
@@ -90,8 +90,8 @@ static bool lttng_action_start_session_is_equal(
        bool is_equal = false;
        struct lttng_action_start_session *a, *b;
 
-       a = container_of(_a, struct lttng_action_start_session, parent);
-       b = container_of(_b, struct lttng_action_start_session, parent);
+       a = lttng::utils::container_of(_a, &lttng_action_start_session::parent);
+       b = lttng::utils::container_of(_b, &lttng_action_start_session::parent);
 
        /* Action is not valid if this is not true. */
        LTTNG_ASSERT(a->session_name);
index d395c66d64e11eea2a3e85ad0f7b7e0901c95c10..08a6665dd0c196b63dbe3ee255f8037cf872027c 100644 (file)
@@ -49,7 +49,7 @@ static struct lttng_action_stop_session *action_stop_session_from_action(
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_stop_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_stop_session::parent);
 }
 
 static const struct lttng_action_stop_session *
@@ -57,7 +57,7 @@ action_stop_session_from_action_const(const struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_stop_session, parent);
+       return lttng::utils::container_of(action, &lttng_action_stop_session::parent);
 }
 
 static bool lttng_action_stop_session_validate(struct lttng_action *action)
index 904f59e9489af49604bde85195e23d0eefc79bde..cd4bf1769a739c189576716096304dea956aa70a 100644 (file)
@@ -176,7 +176,7 @@ void lttng_directory_handle_release(struct urcu_ref *ref)
 {
        int ret;
        struct lttng_directory_handle *handle =
-                       container_of(ref, struct lttng_directory_handle, ref);
+                       lttng::utils::container_of(ref, &lttng_directory_handle::ref);
 
        if (handle->destroy_cb) {
                handle->destroy_cb(handle, handle->destroy_cb_data);
@@ -557,7 +557,7 @@ static
 void lttng_directory_handle_release(struct urcu_ref *ref)
 {
        struct lttng_directory_handle *handle =
-                       container_of(ref, struct lttng_directory_handle, ref);
+                       lttng::utils::container_of(ref, &lttng_directory_handle::ref);
 
        free(handle->base_path);
        lttng_directory_handle_invalidate(handle);
index 57e1c79cbd43bfb21b9e2b46e3ad850678a94fff..6830877a189e63f6fc98405eb6a54fd6e2933db8 100644 (file)
@@ -33,8 +33,8 @@ void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition)
 {
        struct lttng_condition_buffer_usage *usage;
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
 
        free(usage->session_name);
        free(usage->channel_name);
@@ -52,8 +52,8 @@ bool lttng_condition_buffer_usage_validate(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->session_name) {
                ERR("Invalid buffer condition: a target session name must be set.");
                goto end;
@@ -92,8 +92,8 @@ int lttng_condition_buffer_usage_serialize(
        }
 
        DBG("Serializing buffer usage condition");
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
 
        session_name_len = strlen(usage->session_name) + 1;
        channel_name_len = strlen(usage->channel_name) + 1;
@@ -142,8 +142,8 @@ bool lttng_condition_buffer_usage_is_equal(const struct lttng_condition *_a,
        bool is_equal = false;
        struct lttng_condition_buffer_usage *a, *b;
 
-       a = container_of(_a, struct lttng_condition_buffer_usage, parent);
-       b = container_of(_b, struct lttng_condition_buffer_usage, parent);
+       a = lttng::utils::container_of(_a, &lttng_condition_buffer_usage::parent);
+       b = lttng::utils::container_of(_b, &lttng_condition_buffer_usage::parent);
 
        if ((a->threshold_ratio.set && !b->threshold_ratio.set) ||
                        (a->threshold_bytes.set && !b->threshold_bytes.set)) {
@@ -598,8 +598,8 @@ lttng_condition_buffer_usage_get_threshold_ratio(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->threshold_ratio.set) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -624,8 +624,8 @@ lttng_condition_buffer_usage_set_threshold_ratio(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        usage->threshold_ratio.set = true;
        usage->threshold_bytes.set = false;
        usage->threshold_ratio.value = threshold_ratio;
@@ -646,8 +646,8 @@ lttng_condition_buffer_usage_get_threshold(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->threshold_bytes.set) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -669,8 +669,8 @@ lttng_condition_buffer_usage_set_threshold(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        usage->threshold_ratio.set = false;
        usage->threshold_bytes.set = true;
        usage->threshold_bytes.value = threshold_bytes;
@@ -691,8 +691,8 @@ lttng_condition_buffer_usage_get_session_name(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->session_name) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -716,8 +716,8 @@ lttng_condition_buffer_usage_set_session_name(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        session_name_copy = strdup(session_name);
        if (!session_name_copy) {
                status = LTTNG_CONDITION_STATUS_ERROR;
@@ -745,8 +745,8 @@ lttng_condition_buffer_usage_get_channel_name(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->channel_name) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -770,8 +770,8 @@ lttng_condition_buffer_usage_set_channel_name(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        channel_name_copy = strdup(channel_name);
        if (!channel_name_copy) {
                status = LTTNG_CONDITION_STATUS_ERROR;
@@ -799,8 +799,8 @@ lttng_condition_buffer_usage_get_domain_type(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        if (!usage->domain.set) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -823,8 +823,8 @@ lttng_condition_buffer_usage_set_domain_type(
                goto end;
        }
 
-       usage = container_of(condition, struct lttng_condition_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(condition,
+                       &lttng_condition_buffer_usage::parent);
        usage->domain.set = true;
        usage->domain.type = type;
 end:
@@ -839,8 +839,8 @@ int lttng_evaluation_buffer_usage_serialize(
        struct lttng_evaluation_buffer_usage *usage;
        struct lttng_evaluation_buffer_usage_comm comm;
 
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_buffer_usage::parent);
        comm.buffer_use = usage->buffer_use;
        comm.buffer_capacity = usage->buffer_capacity;
 
@@ -854,8 +854,8 @@ void lttng_evaluation_buffer_usage_destroy(
 {
        struct lttng_evaluation_buffer_usage *usage;
 
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_buffer_usage::parent);
        free(usage);
 }
 
@@ -894,8 +894,8 @@ lttng_evaluation_buffer_usage_get_usage_ratio(
                goto end;
        }
 
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_buffer_usage::parent);
        *usage_ratio = (double) usage->buffer_use /
                        (double) usage->buffer_capacity;
 end:
@@ -915,8 +915,8 @@ lttng_evaluation_buffer_usage_get_usage(
                goto end;
        }
 
-       usage = container_of(evaluation, struct lttng_evaluation_buffer_usage,
-                       parent);
+       usage = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_buffer_usage::parent);
        *usage_bytes = usage->buffer_use;
 end:
        return status;
index 525932eb2f06d43dcbf183e2239a8a7ed7dbe641..1efab164d8c39610b509c32a1e898cf041836623 100644 (file)
@@ -32,7 +32,7 @@ void lttng_condition_destroy(struct lttng_condition *condition)
 static void condition_destroy_ref(struct urcu_ref *ref)
 {
        struct lttng_condition *condition =
-               container_of(ref, struct lttng_condition, ref);
+               lttng::utils::container_of(ref, &lttng_condition::ref);
 
        condition->destroy(condition);
 }
index 0a926755ecee1eef537805e89604ed8810c38f08..d302500c68a10aeefb381cc92e877167140586c9 100644 (file)
@@ -55,8 +55,8 @@ static bool lttng_condition_event_rule_matches_validate(
                goto end;
        }
 
-       event_rule = container_of(condition,
-                       struct lttng_condition_event_rule_matches, parent);
+       event_rule = lttng::utils::container_of(condition,
+                       &lttng_condition_event_rule_matches::parent);
        if (!event_rule->rule) {
                ERR("Invalid on event condition: a rule must be set");
                goto end;
@@ -167,9 +167,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr,
        case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
        {
                const struct lttng_event_expr_field *field_expr =
-                               container_of(expr,
-                                       const struct lttng_event_expr_field,
-                                       parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_field::parent);
 
                /* Serialize the field name. */
                DBG("Serializing field event expression's field name: '%s'",
@@ -184,9 +183,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr,
        case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
        {
                const struct lttng_event_expr_app_specific_context_field *field_expr =
-                               container_of(expr,
-                                       const struct lttng_event_expr_app_specific_context_field,
-                                       parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_app_specific_context_field::parent);
 
                /* Serialize the provider name. */
                DBG("Serializing app-specific context field event expression's "
@@ -211,9 +209,8 @@ int serialize_event_expr(const struct lttng_event_expr *expr,
        case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
        {
                const struct lttng_event_expr_array_field_element *elem_expr =
-                               container_of(expr,
-                                       const struct lttng_event_expr_array_field_element,
-                                       parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_array_field_element::parent);
                const uint32_t index = elem_expr->index;
 
                /* Serialize the index. */
@@ -247,9 +244,8 @@ lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
                const struct lttng_condition *condition, unsigned int index)
 {
        const struct lttng_condition_event_rule_matches
-                       *event_rule_matches_cond = container_of(condition,
-                                       const struct lttng_condition_event_rule_matches,
-                                       parent);
+                       *event_rule_matches_cond = lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
        struct lttng_capture_descriptor *desc = NULL;
        unsigned int count;
        enum lttng_condition_status status;
@@ -290,8 +286,8 @@ static int lttng_condition_event_rule_matches_serialize(
        }
 
        DBG("Serializing on event condition");
-       event_rule_matches_condition = container_of(condition,
-                       struct lttng_condition_event_rule_matches, parent);
+       event_rule_matches_condition = lttng::utils::container_of(condition,
+                       &lttng_condition_event_rule_matches::parent);
 
        DBG("Serializing on event condition's event rule");
        ret = lttng_event_rule_serialize(
@@ -388,8 +384,8 @@ static bool lttng_condition_event_rule_matches_is_equal(
        bool is_equal = false;
        struct lttng_condition_event_rule_matches *a, *b;
 
-       a = container_of(_a, struct lttng_condition_event_rule_matches, parent);
-       b = container_of(_b, struct lttng_condition_event_rule_matches, parent);
+       a = lttng::utils::container_of(_a, &lttng_condition_event_rule_matches::parent);
+       b = lttng::utils::container_of(_b, &lttng_condition_event_rule_matches::parent);
 
        /* Both event rules must be set or both must be unset. */
        if ((a->rule && !b->rule) || (!a->rule && b->rule)) {
@@ -413,8 +409,8 @@ static void lttng_condition_event_rule_matches_destroy(
 {
        struct lttng_condition_event_rule_matches *event_rule_matches_condition;
 
-       event_rule_matches_condition = container_of(condition,
-                       struct lttng_condition_event_rule_matches, parent);
+       event_rule_matches_condition = lttng::utils::container_of(condition,
+                       &lttng_condition_event_rule_matches::parent);
 
        lttng_event_rule_put(event_rule_matches_condition->rule);
        lttng_dynamic_pointer_array_reset(
@@ -793,8 +789,8 @@ lttng_condition_event_rule_matches_borrow_rule_mutable(
                goto end;
        }
 
-       event_rule = container_of(condition,
-                       struct lttng_condition_event_rule_matches, parent);
+       event_rule = lttng::utils::container_of(condition,
+                       &lttng_condition_event_rule_matches::parent);
        if (!event_rule->rule) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -822,9 +818,8 @@ void lttng_condition_event_rule_matches_set_error_counter_index(
                struct lttng_condition *condition, uint64_t error_counter_index)
 {
        struct lttng_condition_event_rule_matches *event_rule_matches_cond =
-                       container_of(condition,
-                                       struct lttng_condition_event_rule_matches,
-                                       parent);
+                       lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
 
        LTTNG_OPTIONAL_SET(&event_rule_matches_cond->error_counter_index,
                        error_counter_index);
@@ -834,9 +829,8 @@ uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
                const struct lttng_condition *condition)
 {
        const struct lttng_condition_event_rule_matches
-                       *event_rule_matches_cond = container_of(condition,
-                                       const struct lttng_condition_event_rule_matches,
-                                       parent);
+                       *event_rule_matches_cond = lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
 
        return LTTNG_OPTIONAL_GET(event_rule_matches_cond->error_counter_index);
 }
@@ -849,9 +843,8 @@ lttng_condition_event_rule_matches_append_capture_descriptor(
        int ret;
        enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
        struct lttng_condition_event_rule_matches *event_rule_matches_cond =
-                       container_of(condition,
-                                       struct lttng_condition_event_rule_matches,
-                                       parent);
+                       lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
        struct lttng_capture_descriptor *descriptor = NULL;
        const struct lttng_event_rule *rule = NULL;
 
@@ -919,9 +912,8 @@ lttng_condition_event_rule_matches_get_capture_descriptor_count(
 {
        enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
        const struct lttng_condition_event_rule_matches
-                       *event_rule_matches_condition = container_of(condition,
-                                       const struct lttng_condition_event_rule_matches,
-                                       parent);
+                       *event_rule_matches_condition = lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
 
        if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) ||
                        !count) {
@@ -1020,8 +1012,8 @@ static int lttng_evaluation_event_rule_matches_serialize(
        struct lttng_evaluation_event_rule_matches *hit;
        uint32_t capture_payload_size;
 
-       hit = container_of(evaluation,
-                       struct lttng_evaluation_event_rule_matches, parent);
+       hit = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_event_rule_matches::parent);
 
        capture_payload_size = (uint32_t) hit->capture_payload.size;
        ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_payload_size,
@@ -1090,8 +1082,8 @@ static void lttng_evaluation_event_rule_matches_destroy(
 {
        struct lttng_evaluation_event_rule_matches *hit;
 
-       hit = container_of(evaluation,
-                       struct lttng_evaluation_event_rule_matches, parent);
+       hit = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_event_rule_matches::parent);
        lttng_dynamic_buffer_reset(&hit->capture_payload);
        lttng_event_field_value_destroy(hit->captured_values);
        free(hit);
@@ -1445,8 +1437,8 @@ lttng_evaluation_event_rule_matches_get_captured_values(
                goto end;
        }
 
-       hit = container_of(evaluation,
-                       struct lttng_evaluation_event_rule_matches, parent);
+       hit = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_event_rule_matches::parent);
        if (!hit->captured_values) {
                status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE;
                goto end;
@@ -1511,9 +1503,8 @@ lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
                const struct lttng_condition *condition, unsigned int index)
 {
        const struct lttng_condition_event_rule_matches
-                       *event_rule_matches_cond = container_of(condition,
-                                       const struct lttng_condition_event_rule_matches,
-                                       parent);
+                       *event_rule_matches_cond = lttng::utils::container_of(condition,
+                                       &lttng_condition_event_rule_matches::parent);
        struct lttng_capture_descriptor *desc = NULL;
        struct lttng_bytecode *bytecode = NULL;
        unsigned int count;
index abb5db8cef17dca10caaf208b49cfb9034189897..69951b5c27d1ecc728e9f4574c7c6db231b89747 100644 (file)
@@ -28,8 +28,8 @@ void lttng_condition_session_consumed_size_destroy(struct lttng_condition *condi
 {
        struct lttng_condition_session_consumed_size *consumed_size;
 
-       consumed_size = container_of(condition,
-                       struct lttng_condition_session_consumed_size, parent);
+       consumed_size = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
 
        free(consumed_size->session_name);
        free(consumed_size);
@@ -46,8 +46,8 @@ bool lttng_condition_session_consumed_size_validate(
                goto end;
        }
 
-       consumed = container_of(condition, struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
        if (!consumed->session_name) {
                ERR("Invalid session consumed size condition: a target session name must be set.");
                goto end;
@@ -78,9 +78,8 @@ int lttng_condition_session_consumed_size_serialize(
        }
 
        DBG("Serializing session consumed size condition");
-       consumed = container_of(condition,
-                       struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
 
        session_name_len = strlen(consumed->session_name) + 1;
        if (session_name_len > LTTNG_NAME_MAX) {
@@ -114,8 +113,8 @@ bool lttng_condition_session_consumed_size_is_equal(const struct lttng_condition
        bool is_equal = false;
        struct lttng_condition_session_consumed_size *a, *b;
 
-       a = container_of(_a, struct lttng_condition_session_consumed_size, parent);
-       b = container_of(_b, struct lttng_condition_session_consumed_size, parent);
+       a = lttng::utils::container_of(_a, &lttng_condition_session_consumed_size::parent);
+       b = lttng::utils::container_of(_b, &lttng_condition_session_consumed_size::parent);
 
        if (a->consumed_threshold_bytes.set && b->consumed_threshold_bytes.set) {
                uint64_t a_value, b_value;
@@ -368,8 +367,8 @@ lttng_condition_session_consumed_size_get_threshold(
                goto end;
        }
 
-       consumed = container_of(condition, struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
        if (!consumed->consumed_threshold_bytes.set) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -391,8 +390,8 @@ lttng_condition_session_consumed_size_set_threshold(
                goto end;
        }
 
-       consumed = container_of(condition, struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
        consumed->consumed_threshold_bytes.set = true;
        consumed->consumed_threshold_bytes.value = consumed_threshold_bytes;
 end:
@@ -412,8 +411,8 @@ lttng_condition_session_consumed_size_get_session_name(
                goto end;
        }
 
-       consumed = container_of(condition, struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
        if (!consumed->session_name) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -437,8 +436,8 @@ lttng_condition_session_consumed_size_set_session_name(
                goto end;
        }
 
-       consumed = container_of(condition, struct lttng_condition_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(condition,
+                       &lttng_condition_session_consumed_size::parent);
        session_name_copy = strdup(session_name);
        if (!session_name_copy) {
                status = LTTNG_CONDITION_STATUS_ERROR;
@@ -461,8 +460,8 @@ int lttng_evaluation_session_consumed_size_serialize(
        struct lttng_evaluation_session_consumed_size *consumed;
        struct lttng_evaluation_session_consumed_size_comm comm;
 
-       consumed = container_of(evaluation,
-                       struct lttng_evaluation_session_consumed_size, parent);
+       consumed = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_consumed_size::parent);
        comm.session_consumed = consumed->session_consumed;
        return lttng_dynamic_buffer_append(
                        &payload->buffer, &comm, sizeof(comm));
@@ -474,8 +473,8 @@ void lttng_evaluation_session_consumed_size_destroy(
 {
        struct lttng_evaluation_session_consumed_size *consumed;
 
-       consumed = container_of(evaluation, struct lttng_evaluation_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_consumed_size::parent);
        free(consumed);
 }
 
@@ -511,8 +510,8 @@ lttng_evaluation_session_consumed_size_get_consumed_size(
                goto end;
        }
 
-       consumed = container_of(evaluation, struct lttng_evaluation_session_consumed_size,
-                       parent);
+       consumed = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_consumed_size::parent);
        *session_consumed = consumed->session_consumed;
 end:
        return status;
index 82e843465ccb453097a86cde2aa0533ce93c9e4c..7f0896f927adba5b38df6f964eb8ab14e348f9e4 100644 (file)
@@ -87,8 +87,8 @@ bool lttng_condition_session_rotation_validate(
                goto end;
        }
 
-       rotation = container_of(condition,
-                       struct lttng_condition_session_rotation, parent);
+       rotation = lttng::utils::container_of(condition,
+                       &lttng_condition_session_rotation::parent);
        if (!rotation->session_name) {
                ERR("Invalid session rotation condition: a target session name must be set.");
                goto end;
@@ -115,8 +115,8 @@ int lttng_condition_session_rotation_serialize(
        }
 
        DBG("Serializing session rotation condition");
-       rotation = container_of(condition, struct lttng_condition_session_rotation,
-                       parent);
+       rotation = lttng::utils::container_of(condition,
+                       &lttng_condition_session_rotation::parent);
 
        session_name_len = strlen(rotation->session_name) + 1;
        if (session_name_len > LTTNG_NAME_MAX) {
@@ -146,8 +146,8 @@ bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a,
        bool is_equal = false;
        struct lttng_condition_session_rotation *a, *b;
 
-       a = container_of(_a, struct lttng_condition_session_rotation, parent);
-       b = container_of(_b, struct lttng_condition_session_rotation, parent);
+       a = lttng::utils::container_of(_a, &lttng_condition_session_rotation::parent);
+       b = lttng::utils::container_of(_b, &lttng_condition_session_rotation::parent);
 
        /* Both session names must be set or both must be unset. */
        if ((a->session_name && !b->session_name) ||
@@ -172,8 +172,8 @@ void lttng_condition_session_rotation_destroy(
 {
        struct lttng_condition_session_rotation *rotation;
 
-       rotation = container_of(condition,
-                       struct lttng_condition_session_rotation, parent);
+       rotation = lttng::utils::container_of(condition,
+                       &lttng_condition_session_rotation::parent);
 
        free(rotation->session_name);
        free(rotation);
@@ -474,8 +474,8 @@ lttng_condition_session_rotation_get_session_name(
                goto end;
        }
 
-       rotation = container_of(condition, struct lttng_condition_session_rotation,
-                       parent);
+       rotation = lttng::utils::container_of(condition,
+                       &lttng_condition_session_rotation::parent);
        if (!rotation->session_name) {
                status = LTTNG_CONDITION_STATUS_UNSET;
                goto end;
@@ -499,8 +499,8 @@ lttng_condition_session_rotation_set_session_name(
                goto end;
        }
 
-       rotation = container_of(condition,
-                       struct lttng_condition_session_rotation, parent);
+       rotation = lttng::utils::container_of(condition,
+                       &lttng_condition_session_rotation::parent);
        session_name_copy = strdup(session_name);
        if (!session_name_copy) {
                status = LTTNG_CONDITION_STATUS_ERROR;
@@ -522,8 +522,8 @@ int lttng_evaluation_session_rotation_serialize(
        struct lttng_evaluation_session_rotation *rotation;
        struct lttng_evaluation_session_rotation_comm comm = {};
 
-       rotation = container_of(evaluation,
-                       struct lttng_evaluation_session_rotation, parent);
+       rotation = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_rotation::parent);
        comm.id = rotation->id;
        comm.has_location = !!rotation->location;
        ret = lttng_dynamic_buffer_append(
@@ -546,8 +546,8 @@ void lttng_evaluation_session_rotation_destroy(
 {
        struct lttng_evaluation_session_rotation *rotation;
 
-       rotation = container_of(evaluation,
-                       struct lttng_evaluation_session_rotation, parent);
+       rotation = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_rotation::parent);
        lttng_trace_archive_location_put(rotation->location);
        free(rotation);
 }
@@ -564,8 +564,8 @@ lttng_evaluation_session_rotation_get_id(
                goto end;
        }
 
-       rotation = container_of(evaluation,
-                       struct lttng_evaluation_session_rotation, parent);
+       rotation = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_rotation::parent);
        *id = rotation->id;
 end:
        return status;
@@ -591,8 +591,8 @@ lttng_evaluation_session_rotation_completed_get_location(
                goto end;
        }
 
-       rotation = container_of(evaluation,
-                       struct lttng_evaluation_session_rotation, parent);
+       rotation = lttng::utils::container_of(evaluation,
+                       &lttng_evaluation_session_rotation::parent);
        *location = rotation->location;
 end:
        return status;
index c22c7e5f3390f74576bb22fa0bfe10e506ed9a51..33f97c77e66a2e074718ad8ce81b8073c3abe7e8 100644 (file)
@@ -35,9 +35,9 @@
 static void free_stream_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct lttng_consumer_stream *stream =
-               caa_container_of(node, struct lttng_consumer_stream, node);
+               lttng::utils::container_of(node, &lttng_consumer_stream::node);
 
        pthread_mutex_destroy(&stream->lock);
        free(stream);
index a5691b1c27df6deec93703bdc38d19121d3e237b..ae8469ea233038b8478626e3da6fc70f0c014b59 100644 (file)
@@ -209,7 +209,7 @@ static struct lttng_consumer_stream *find_stream(uint64_t key,
        lttng_ht_lookup(ht, &key, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node != NULL) {
-               stream = caa_container_of(node, struct lttng_consumer_stream, node);
+               stream = lttng::utils::container_of(node, &lttng_consumer_stream::node);
        }
 
        rcu_read_unlock();
@@ -257,7 +257,7 @@ struct lttng_consumer_channel *consumer_find_channel(uint64_t key)
        lttng_ht_lookup(the_consumer_data.channel_ht, &key, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node != NULL) {
-               channel = caa_container_of(node, struct lttng_consumer_channel, node);
+               channel = lttng::utils::container_of(node, &lttng_consumer_channel::node);
        }
 
        return channel;
@@ -292,9 +292,9 @@ static void steal_channel_key(uint64_t key)
 static void free_channel_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct lttng_consumer_channel *channel =
-               caa_container_of(node, struct lttng_consumer_channel, node);
+               lttng::utils::container_of(node, &lttng_consumer_channel::node);
 
        switch (the_consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
@@ -316,9 +316,9 @@ static void free_channel_rcu(struct rcu_head *head)
 static void free_relayd_rcu(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct consumer_relayd_sock_pair *relayd =
-               caa_container_of(node, struct consumer_relayd_sock_pair, node);
+               lttng::utils::container_of(node, &consumer_relayd_sock_pair::node);
 
        /*
         * Close all sockets. This is done in the call RCU since we don't want the
@@ -705,7 +705,7 @@ struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key)
        lttng_ht_lookup(the_consumer_data.relayd_ht, &key, &iter);
        node = lttng_ht_iter_get_node_u64(&iter);
        if (node != NULL) {
-               relayd = caa_container_of(node, struct consumer_relayd_sock_pair, node);
+               relayd = lttng::utils::container_of(node, &consumer_relayd_sock_pair::node);
        }
 
 error:
index 8c1bb95414feb84e1300a5570c47cd9ce0c83501..38265fe8bd0d0238e00b1ebbd8349304d59de8aa 100644 (file)
@@ -256,8 +256,7 @@ void lttng_error_query_destroy(struct lttng_error_query *query)
        case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
        {
                struct lttng_error_query_trigger *trigger_query =
-                               container_of(query, typeof(*trigger_query),
-                                       parent);
+                               lttng::utils::container_of(query, &lttng_error_query_trigger::parent);
 
                lttng_trigger_put(trigger_query->trigger);
                free(trigger_query);
@@ -265,9 +264,8 @@ void lttng_error_query_destroy(struct lttng_error_query *query)
        }
        case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
        {
-               struct lttng_error_query_condition *condition_query =
-                               container_of(query, typeof(*condition_query),
-                                       parent);
+               struct lttng_error_query_condition *condition_query = lttng::utils::container_of(
+                               query, &lttng_error_query_condition::parent);
 
                lttng_trigger_put(condition_query->trigger);
                free(condition_query);
@@ -275,9 +273,8 @@ void lttng_error_query_destroy(struct lttng_error_query *query)
        }
        case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
        {
-               struct lttng_error_query_action *action_query =
-                               container_of(query, typeof(*action_query),
-                                       parent);
+               struct lttng_error_query_action *action_query = lttng::utils::container_of(
+                               query, &lttng_error_query_action::parent);
 
                lttng_trigger_put(action_query->trigger);
                lttng_action_path_destroy(action_query->action_path);
@@ -297,7 +294,8 @@ int lttng_error_query_result_counter_serialize(
        const struct lttng_error_query_result_counter *counter_result;
 
        LTTNG_ASSERT(result->type == LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER);
-       counter_result = container_of(result, typeof(*counter_result), parent);
+       counter_result = lttng::utils::container_of(
+                       result, &lttng_error_query_result_counter::parent);
 
        lttng_error_query_result_counter_comm comm = {
                .value = counter_result->value,
@@ -662,7 +660,7 @@ int lttng_error_query_trigger_serialize(const struct lttng_error_query *query,
 {
        int ret;
        const struct lttng_error_query_trigger *query_trigger =
-                       container_of(query, typeof(*query_trigger), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_trigger::parent);
 
        if (!lttng_trigger_validate(query_trigger->trigger)) {
                ret = -1;
@@ -684,7 +682,7 @@ int lttng_error_query_condition_serialize(const struct lttng_error_query *query,
 {
        int ret;
        const struct lttng_error_query_condition *query_trigger =
-                       container_of(query, typeof(*query_trigger), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_condition::parent);
 
        if (!lttng_trigger_validate(query_trigger->trigger)) {
                ret = -1;
@@ -706,7 +704,7 @@ int lttng_error_query_action_serialize(const struct lttng_error_query *query,
 {
        int ret;
        const struct lttng_error_query_action *query_action =
-                       container_of(query, typeof(*query_action), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_action::parent);
 
        if (!lttng_trigger_validate(query_action->trigger)) {
                ret = -1;
@@ -737,7 +735,7 @@ const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
                const struct lttng_error_query *query)
 {
        const struct lttng_error_query_trigger *query_trigger =
-                       container_of(query, typeof(*query_trigger), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_trigger::parent);
 
        return query_trigger->trigger;
 }
@@ -746,7 +744,7 @@ const struct lttng_trigger *lttng_error_query_condition_borrow_target(
                const struct lttng_error_query *query)
 {
        const struct lttng_error_query_condition *query_trigger =
-                       container_of(query, typeof(*query_trigger), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_condition::parent);
 
        return query_trigger->trigger;
 }
@@ -755,17 +753,16 @@ const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
                const struct lttng_error_query *query)
 {
        const struct lttng_error_query_action *query_action =
-                       container_of(query, typeof(*query_action), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_action::parent);
 
        return query_action->trigger;
 }
 
 struct lttng_action *lttng_error_query_action_borrow_action_target(
-       const struct lttng_error_query *query,
-       struct lttng_trigger *trigger)
+               const struct lttng_error_query *query, struct lttng_trigger *trigger)
 {
        const struct lttng_error_query_action *query_action =
-                       container_of(query, typeof(*query_action), parent);
+                       lttng::utils::container_of(query, &lttng_error_query_action::parent);
 
        return get_trigger_action_from_path(
                        trigger, query_action->action_path);
@@ -1071,7 +1068,8 @@ enum lttng_error_query_result_status lttng_error_query_result_counter_get_value(
                goto end;
        }
 
-       counter_result = container_of(result, typeof(*counter_result), parent);
+       counter_result = lttng::utils::container_of(
+                       result, &lttng_error_query_result_counter::parent);
 
        *value = counter_result->value;
        status = LTTNG_ERROR_QUERY_RESULT_STATUS_OK;
index a0fbc9dd905e1c247eedd3f16ae7837341158099..e6ebeec8e2680b07ef37850847bd67ff62281630 100644 (file)
@@ -118,9 +118,8 @@ ssize_t lttng_evaluation_create_from_payload(
                LTTNG_ASSERT(condition->type ==
                                LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
                ret = lttng_evaluation_event_rule_matches_create_from_payload(
-                               container_of(condition,
-                                               const struct lttng_condition_event_rule_matches,
-                                               parent),
+                               lttng::utils::container_of(condition,
+                                               &lttng_condition_event_rule_matches::parent),
                                &evaluation_view, evaluation);
                if (ret < 0) {
                        goto end;
index 1b592bdb121cf54fbc5d8f3204e9c9be0512994a..0dd0398f2797c379499663635c91c8258673d6b0 100644 (file)
@@ -56,10 +56,8 @@ struct lttng_event_expr_field *create_field_event_expr(
                enum lttng_event_expr_type type,
                const char *name)
 {
-       struct lttng_event_expr_field *expr =
-                       container_of(
-                               create_empty_expr(type, sizeof(*expr)),
-                               struct lttng_event_expr_field, parent);
+       struct lttng_event_expr_field *expr = lttng::utils::container_of(
+                       create_empty_expr(type, sizeof(*expr)), &lttng_event_expr_field::parent);
 
        if (!expr) {
                goto error;
@@ -127,11 +125,10 @@ struct lttng_event_expr *lttng_event_expr_app_specific_context_field_create(
                goto error;
        }
 
-       expr = container_of(create_empty_expr(
+       expr = lttng::utils::container_of(create_empty_expr(
                        LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD,
                        sizeof(*expr)),
-                       struct lttng_event_expr_app_specific_context_field,
-                       parent);
+                       &lttng_event_expr_app_specific_context_field::parent);
        if (!expr) {
                goto error;
        }
@@ -172,11 +169,10 @@ struct lttng_event_expr *lttng_event_expr_array_field_element_create(
                goto error;
        }
 
-       expr = container_of(create_empty_expr(
+       expr = lttng::utils::container_of(create_empty_expr(
                        LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT,
                        sizeof(*expr)),
-                       struct lttng_event_expr_array_field_element,
-                       parent);
+                       &lttng_event_expr_array_field_element::parent);
        if (!expr) {
                goto error;
        }
@@ -202,8 +198,8 @@ const char *lttng_event_expr_event_payload_field_get_name(
                goto end;
        }
 
-       ret = container_of(expr,
-                       const struct lttng_event_expr_field, parent)->name;
+       ret = lttng::utils::container_of(expr,
+                       &lttng_event_expr_field::parent)->name;
 
 end:
        return ret;
@@ -218,8 +214,8 @@ const char *lttng_event_expr_channel_context_field_get_name(
                goto end;
        }
 
-       ret = container_of(expr,
-                       const struct lttng_event_expr_field, parent)->name;
+       ret = lttng::utils::container_of(expr,
+                       &lttng_event_expr_field::parent)->name;
 
 end:
        return ret;
@@ -234,9 +230,8 @@ const char *lttng_event_expr_app_specific_context_field_get_provider_name(
                goto end;
        }
 
-       ret = container_of(expr,
-                       const struct lttng_event_expr_app_specific_context_field,
-                       parent)->provider_name;
+       ret = lttng::utils::container_of(expr,
+                       &lttng_event_expr_app_specific_context_field::parent)->provider_name;
 
 end:
        return ret;
@@ -251,9 +246,8 @@ const char *lttng_event_expr_app_specific_context_field_get_type_name(
                goto end;
        }
 
-       ret = container_of(expr,
-                       const struct lttng_event_expr_app_specific_context_field,
-                       parent)->type_name;
+       ret = lttng::utils::container_of(expr,
+                       &lttng_event_expr_app_specific_context_field::parent)->type_name;
 
 end:
        return ret;
@@ -269,9 +263,8 @@ lttng_event_expr_array_field_element_get_parent_expr(
                goto end;
        }
 
-       ret = container_of(expr,
-                       const struct lttng_event_expr_array_field_element,
-                       parent)->array_field_expr;
+       ret = lttng::utils::container_of(expr,
+                       &lttng_event_expr_array_field_element::parent)->array_field_expr;
 
 end:
        return ret;
@@ -288,9 +281,8 @@ enum lttng_event_expr_status lttng_event_expr_array_field_element_get_index(
                goto end;
        }
 
-       *index = container_of(expr,
-                       const struct lttng_event_expr_array_field_element,
-                       parent)->index;
+       *index = lttng::utils::container_of(expr,
+                       &lttng_event_expr_array_field_element::parent)->index;
 
 end:
        return ret;
@@ -321,13 +313,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a,
        case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
        {
                const struct lttng_event_expr_field *field_expr_a =
-                               container_of(expr_a,
-                                       const struct lttng_event_expr_field,
-                                       parent);
+                               lttng::utils::container_of(expr_a,
+                                       &lttng_event_expr_field::parent);
                const struct lttng_event_expr_field *field_expr_b =
-                               container_of(expr_b,
-                                       const struct lttng_event_expr_field,
-                                       parent);
+                               lttng::utils::container_of(expr_b,
+                                       &lttng_event_expr_field::parent);
 
                if (strcmp(field_expr_a->name, field_expr_b->name) != 0) {
                        goto not_equal;
@@ -338,13 +328,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a,
        case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
        {
                const struct lttng_event_expr_app_specific_context_field *field_expr_a =
-                               container_of(expr_a,
-                                       const struct lttng_event_expr_app_specific_context_field,
-                                       parent);
+                               lttng::utils::container_of(expr_a,
+                                       &lttng_event_expr_app_specific_context_field::parent);
                const struct lttng_event_expr_app_specific_context_field *field_expr_b =
-                               container_of(expr_b,
-                                       const struct lttng_event_expr_app_specific_context_field,
-                                       parent);
+                               lttng::utils::container_of(expr_b,
+                                       &lttng_event_expr_app_specific_context_field::parent);
 
                if (strcmp(field_expr_a->provider_name,
                                field_expr_b->provider_name) != 0) {
@@ -361,13 +349,11 @@ bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a,
        case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
        {
                const struct lttng_event_expr_array_field_element *elem_expr_a =
-                               container_of(expr_a,
-                                       const struct lttng_event_expr_array_field_element,
-                                       parent);
+                               lttng::utils::container_of(expr_a,
+                                       &lttng_event_expr_array_field_element::parent);
                const struct lttng_event_expr_array_field_element *elem_expr_b =
-                               container_of(expr_b,
-                                       const struct lttng_event_expr_array_field_element,
-                                       parent);
+                               lttng::utils::container_of(expr_b,
+                                       &lttng_event_expr_array_field_element::parent);
 
                if (!lttng_event_expr_is_equal(elem_expr_a->array_field_expr,
                                elem_expr_b->array_field_expr)) {
@@ -404,8 +390,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr)
        case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
        {
                struct lttng_event_expr_field *field_expr =
-                               container_of(expr,
-                                       struct lttng_event_expr_field, parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_field::parent);
 
                free(field_expr->name);
                break;
@@ -413,9 +399,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr)
        case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
        {
                struct lttng_event_expr_app_specific_context_field *field_expr =
-                               container_of(expr,
-                                       struct lttng_event_expr_app_specific_context_field,
-                                       parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_app_specific_context_field::parent);
 
                free(field_expr->provider_name);
                free(field_expr->type_name);
@@ -424,9 +409,8 @@ void lttng_event_expr_destroy(struct lttng_event_expr *expr)
        case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
        {
                struct lttng_event_expr_array_field_element *elem_expr =
-                               container_of(expr,
-                                       struct lttng_event_expr_array_field_element,
-                                       parent);
+                               lttng::utils::container_of(expr,
+                                       &lttng_event_expr_array_field_element::parent);
 
                lttng_event_expr_destroy(elem_expr->array_field_expr);
                break;
index 3ab12728c769ae9f642fdc236646664e8a49bf1b..8017fd0814983a8a2009d5d44f5d4e78a1120f92 100644 (file)
@@ -39,10 +39,10 @@ struct lttng_event_field_value *lttng_event_field_value_uint_create(
 {
        struct lttng_event_field_value_uint *field_val;
 
-       field_val = container_of(create_empty_field_val(
+       field_val = lttng::utils::container_of(create_empty_field_val(
                        LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT,
                        sizeof(*field_val)),
-                       struct lttng_event_field_value_uint, parent);
+                       &lttng_event_field_value_uint::parent);
        if (!field_val) {
                goto error;
        }
@@ -62,10 +62,10 @@ struct lttng_event_field_value *lttng_event_field_value_int_create(
 {
        struct lttng_event_field_value_int *field_val;
 
-       field_val = container_of(create_empty_field_val(
+       field_val = lttng::utils::container_of(create_empty_field_val(
                        LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT,
                        sizeof(*field_val)),
-                       struct lttng_event_field_value_int, parent);
+                       &lttng_event_field_value_int::parent);
        if (!field_val) {
                goto error;
        }
@@ -86,8 +86,8 @@ struct lttng_event_field_value_enum *create_enum_field_val(
 {
        struct lttng_event_field_value_enum *field_val;
 
-       field_val = container_of(create_empty_field_val(type, size),
-                       struct lttng_event_field_value_enum, parent);
+       field_val = lttng::utils::container_of(create_empty_field_val(type, size),
+                       &lttng_event_field_value_enum::parent);
        if (!field_val) {
                goto error;
        }
@@ -107,10 +107,10 @@ struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
 {
        struct lttng_event_field_value_enum_uint *field_val;
 
-       field_val = container_of(create_enum_field_val(
+       field_val = lttng::utils::container_of(create_enum_field_val(
                        LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM,
                        sizeof(*field_val)),
-                       struct lttng_event_field_value_enum_uint, parent);
+                       &lttng_event_field_value_enum_uint::parent);
        if (!field_val) {
                goto error;
        }
@@ -130,10 +130,10 @@ struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
 {
        struct lttng_event_field_value_enum_int *field_val;
 
-       field_val = container_of(create_enum_field_val(
+       field_val = lttng::utils::container_of(create_enum_field_val(
                        LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM,
                        sizeof(*field_val)),
-                       struct lttng_event_field_value_enum_int, parent);
+                       &lttng_event_field_value_enum_int::parent);
        if (!field_val) {
                goto error;
        }
@@ -150,11 +150,11 @@ end:
 
 struct lttng_event_field_value *lttng_event_field_value_real_create(double val)
 {
-       struct lttng_event_field_value_real *field_val = container_of(
+       struct lttng_event_field_value_real *field_val = lttng::utils::container_of(
                        create_empty_field_val(
                                LTTNG_EVENT_FIELD_VALUE_TYPE_REAL,
                                sizeof(*field_val)),
-                       struct lttng_event_field_value_real, parent);
+                       &lttng_event_field_value_real::parent);
 
        if (!field_val) {
                goto error;
@@ -173,11 +173,11 @@ end:
 struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
                const char *val, size_t size)
 {
-       struct lttng_event_field_value_string *field_val = container_of(
+       struct lttng_event_field_value_string *field_val = lttng::utils::container_of(
                        create_empty_field_val(
                                LTTNG_EVENT_FIELD_VALUE_TYPE_STRING,
                                sizeof(*field_val)),
-                       struct lttng_event_field_value_string, parent);
+                       &lttng_event_field_value_string::parent);
 
        if (!field_val) {
                goto error;
@@ -214,11 +214,11 @@ void destroy_field_val(void *field_val)
 
 struct lttng_event_field_value *lttng_event_field_value_array_create(void)
 {
-       struct lttng_event_field_value_array *field_val = container_of(
+       struct lttng_event_field_value_array *field_val = lttng::utils::container_of(
                        create_empty_field_val(
                                LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY,
                                sizeof(*field_val)),
-                       struct lttng_event_field_value_array, parent);
+                       &lttng_event_field_value_array::parent);
 
        if (!field_val) {
                goto error;
@@ -245,8 +245,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val)
        case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM:
        {
                struct lttng_event_field_value_enum *enum_field_val =
-                               container_of(field_val,
-                                       struct lttng_event_field_value_enum, parent);
+                               lttng::utils::container_of(field_val,
+                                       &lttng_event_field_value_enum::parent);
 
                lttng_dynamic_pointer_array_reset(&enum_field_val->labels);
                break;
@@ -254,8 +254,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val)
        case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING:
        {
                struct lttng_event_field_value_string *str_field_val =
-                               container_of(field_val,
-                                       struct lttng_event_field_value_string, parent);
+                               lttng::utils::container_of(field_val,
+                                       &lttng_event_field_value_string::parent);
 
                free(str_field_val->val);
                break;
@@ -263,9 +263,8 @@ void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val)
        case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY:
        {
                struct lttng_event_field_value_array *array_field_expr =
-                               container_of(field_val,
-                                       struct lttng_event_field_value_array,
-                                       parent);
+                               lttng::utils::container_of(field_val,
+                                       &lttng_event_field_value_array::parent);
 
                lttng_dynamic_pointer_array_reset(&array_field_expr->elems);
                break;
@@ -296,8 +295,8 @@ int lttng_event_field_value_enum_append_label_with_size(
        }
 
        ret = lttng_dynamic_pointer_array_add_pointer(
-                       &container_of(field_val,
-                               struct lttng_event_field_value_enum, parent)->labels,
+                       &lttng::utils::container_of(field_val,
+                               &lttng_event_field_value_enum::parent)->labels,
                        new_label);
        if (ret == 0) {
                new_label = NULL;
@@ -324,8 +323,8 @@ int lttng_event_field_value_array_append(
        LTTNG_ASSERT(array_field_val);
        LTTNG_ASSERT(field_val);
        return lttng_dynamic_pointer_array_add_pointer(
-                       &container_of(array_field_val,
-                               struct lttng_event_field_value_array, parent)->elems,
+                       &lttng::utils::container_of(array_field_val,
+                               &lttng_event_field_value_array::parent)->elems,
                        field_val);
 }
 
@@ -334,8 +333,8 @@ int lttng_event_field_value_array_append_unavailable(
 {
        LTTNG_ASSERT(array_field_val);
        return lttng_dynamic_pointer_array_add_pointer(
-                       &container_of(array_field_val,
-                               struct lttng_event_field_value_array, parent)->elems,
+                       &lttng::utils::container_of(array_field_val,
+                               &lttng_event_field_value_array::parent)->elems,
                        NULL);
 }
 
@@ -368,21 +367,17 @@ lttng_event_field_value_unsigned_int_get_value(
 
        switch (field_val->type) {
        case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT:
-               *val = container_of(field_val,
-                               const struct lttng_event_field_value_uint,
-                               parent)->val;
+               *val = lttng::utils::container_of(field_val,
+                               &lttng_event_field_value_uint::parent)->val;
                break;
        case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM:
        {
-               const struct lttng_event_field_value_enum *field_val_enum = container_of(
-                               field_val,
-                               const struct lttng_event_field_value_enum,
-                               parent);
-               const struct lttng_event_field_value_enum_uint
-                               *field_val_enum_uint = container_of(
-                                               field_val_enum,
-                                               const struct lttng_event_field_value_enum_uint,
-                                               parent);
+               const struct lttng_event_field_value_enum *field_val_enum =
+                               lttng::utils::container_of(
+                                               field_val, &lttng_event_field_value_enum::parent);
+               const struct lttng_event_field_value_enum_uint *field_val_enum_uint =
+                               lttng::utils::container_of(field_val_enum,
+                                               &lttng_event_field_value_enum_uint::parent);
                *val = field_val_enum_uint->val;
                break;
        }
@@ -410,21 +405,17 @@ lttng_event_field_value_signed_int_get_value(
 
        switch (field_val->type) {
        case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT:
-               *val = container_of(field_val,
-                               const struct lttng_event_field_value_int,
-                               parent)->val;
+               *val = lttng::utils::container_of(field_val,
+                               &lttng_event_field_value_int::parent)->val;
                break;
        case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM:
        {
-               const struct lttng_event_field_value_enum *field_val_enum = container_of(
+               const struct lttng_event_field_value_enum *field_val_enum = lttng::utils::container_of(
                                field_val,
-                               const struct lttng_event_field_value_enum,
-                               parent);
-               const struct lttng_event_field_value_enum_int
-                               *field_val_enum_uint = container_of(
-                                               field_val_enum,
-                                               const struct lttng_event_field_value_enum_int,
-                                               parent);
+                               &lttng_event_field_value_enum::parent);
+               const struct lttng_event_field_value_enum_int *field_val_enum_uint =
+                               lttng::utils::container_of(field_val_enum,
+                                               &lttng_event_field_value_enum_int::parent);
                *val = field_val_enum_uint->val;
                break;
        }
@@ -451,8 +442,8 @@ lttng_event_field_value_real_get_value(
                goto end;
        }
 
-       *val = container_of(field_val,
-                       const struct lttng_event_field_value_real, parent)->val;
+       *val = lttng::utils::container_of(field_val,
+                       &lttng_event_field_value_real::parent)->val;
        status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
 
 end:
@@ -479,9 +470,8 @@ lttng_event_field_value_enum_get_label_count(
        }
 
        *count = (unsigned int) lttng_dynamic_pointer_array_get_count(
-                       &container_of(field_val,
-                               const struct lttng_event_field_value_enum,
-                               parent)->labels);
+                       &lttng::utils::container_of(field_val,
+                               &lttng_event_field_value_enum::parent)->labels);
        status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
 
 end:
@@ -500,8 +490,8 @@ const char *lttng_event_field_value_enum_get_label_at_index(
                goto end;
        }
 
-       enum_field_val = container_of(field_val,
-                       const struct lttng_event_field_value_enum, parent);
+       enum_field_val = lttng::utils::container_of(field_val,
+                       &lttng_event_field_value_enum::parent);
 
        if (index >= lttng_dynamic_pointer_array_get_count(&enum_field_val->labels)) {
                ret = NULL;
@@ -526,8 +516,8 @@ enum lttng_event_field_value_status lttng_event_field_value_string_get_value(
                goto end;
        }
 
-       *value = container_of(field_val,
-                       const struct lttng_event_field_value_string, parent)->val;
+       *value = lttng::utils::container_of(field_val,
+                       &lttng_event_field_value_string::parent)->val;
        status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
 
 end:
@@ -547,9 +537,8 @@ enum lttng_event_field_value_status lttng_event_field_value_array_get_length(
        }
 
        *length = (unsigned int) lttng_dynamic_pointer_array_get_count(
-                       &container_of(field_val,
-                               const struct lttng_event_field_value_array,
-                               parent)->elems);
+                       &lttng::utils::container_of(field_val,
+                               &lttng_event_field_value_array::parent)->elems);
        status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
 
 end:
@@ -571,8 +560,8 @@ lttng_event_field_value_array_get_element_at_index(
                goto end;
        }
 
-       array_field_val = container_of(field_val,
-                       const struct lttng_event_field_value_array, parent);
+       array_field_val = lttng::utils::container_of(
+                       field_val, &lttng_event_field_value_array::parent);
 
        if (index >= lttng_dynamic_pointer_array_get_count(&array_field_val->elems)) {
                status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID;
index 8c1b81dbd3ee77e1594a3663da4007ccb72f9ca3..5139eed5a6dbc44daac914f703fc8ca127c1790c 100644 (file)
@@ -65,7 +65,7 @@ enum lttng_domain_type lttng_event_rule_get_domain_type(
 static void lttng_event_rule_release(struct urcu_ref *ref)
 {
        struct lttng_event_rule *event_rule =
-                       container_of(ref, typeof(*event_rule), ref);
+                       lttng::utils::container_of(ref, &lttng_event_rule::ref);
 
        LTTNG_ASSERT(event_rule->destroy);
        event_rule->destroy(event_rule);
index 14fa179eba2276820f3099cb7c70594c05ec7f62..138d9c1020dbcfbda13e5412def50f8dc4bc2f6b 100644 (file)
@@ -32,8 +32,8 @@ static void lttng_event_rule_jul_logging_destroy(struct lttng_event_rule *rule)
                return;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        lttng_log_level_rule_destroy(jul_logging->log_level_rule);
        free(jul_logging->pattern);
@@ -53,8 +53,8 @@ static bool lttng_event_rule_jul_logging_validate(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        /* Required field. */
        if (!jul_logging->pattern) {
@@ -86,8 +86,8 @@ static int lttng_event_rule_jul_logging_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing jul_logging event rule.");
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        pattern_len = strlen(jul_logging->pattern) + 1;
 
@@ -141,8 +141,8 @@ static bool lttng_event_rule_jul_logging_is_equal(
        bool is_equal = false;
        struct lttng_event_rule_jul_logging *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_jul_logging, parent);
-       b = container_of(_b, struct lttng_event_rule_jul_logging, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_jul_logging::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_jul_logging::parent);
 
        /* Quick checks. */
 
@@ -304,8 +304,8 @@ lttng_event_rule_jul_logging_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -357,8 +357,8 @@ static const char *lttng_event_rule_jul_logging_get_internal_filter(
        struct lttng_event_rule_jul_logging *jul_logging;
 
        LTTNG_ASSERT(rule);
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        return jul_logging->internal_filter.filter;
 }
 
@@ -369,8 +369,8 @@ lttng_event_rule_jul_logging_get_internal_filter_bytecode(
        struct lttng_event_rule_jul_logging *jul_logging;
 
        LTTNG_ASSERT(rule);
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        return jul_logging->internal_filter.bytecode;
 }
 
@@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_jul_logging_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_jul_logging *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_jul_logging::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_JUL_LOGGING,
                        lttng_ht_seed);
@@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_jul_logging_generate_lttng_event(
        enum lttng_event_rule_status status;
        const struct lttng_log_level_rule *log_level_rule;
 
-       jul_logging = container_of(
-                       rule, const struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        local_event = zmalloc<lttng_event>();
        if (!local_event) {
@@ -753,8 +753,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_name_pattern(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -783,8 +783,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_name_pattern(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        if (!jul_logging->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -808,8 +808,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_filter(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -838,8 +838,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_filter(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        if (!jul_logging->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -873,8 +873,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_set_log_level_rule(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
 
        if (!log_level_rule_valid(log_level_rule)) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -910,8 +910,8 @@ enum lttng_event_rule_status lttng_event_rule_jul_logging_get_log_level_rule(
                goto end;
        }
 
-       jul_logging = container_of(
-                       rule, struct lttng_event_rule_jul_logging, parent);
+       jul_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_jul_logging::parent);
        if (jul_logging->log_level_rule == NULL) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index bad894e35962141326b7b692246f69ea51328661..239373aa90136f21bcaf5a885cb2deb8b0de9587 100644 (file)
@@ -34,7 +34,7 @@ static void lttng_event_rule_kernel_kprobe_destroy(struct lttng_event_rule *rule
 {
        struct lttng_event_rule_kernel_kprobe *kprobe;
 
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
 
        lttng_kernel_probe_location_destroy(kprobe->location);
        free(kprobe->name);
@@ -51,7 +51,7 @@ static bool lttng_event_rule_kernel_kprobe_validate(
                goto end;
        }
 
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
 
        /* Required field. */
        if (!kprobe->name) {
@@ -88,7 +88,7 @@ static int lttng_event_rule_kernel_kprobe_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing kprobe event rule.");
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
 
        name_len = strlen(kprobe->name) + 1;
        kprobe_comm.name_len = name_len;
@@ -128,8 +128,8 @@ static bool lttng_event_rule_kernel_kprobe_is_equal(const struct lttng_event_rul
        bool is_equal = false;
        struct lttng_event_rule_kernel_kprobe *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_kernel_kprobe, parent);
-       b = container_of(_b, struct lttng_event_rule_kernel_kprobe, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_kernel_kprobe::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_kernel_kprobe::parent);
 
        /* Quick checks */
        if (!!a->name != !!b->name) {
@@ -188,7 +188,7 @@ lttng_event_rule_kernel_kprobe_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_kernel_kprobe *krule =
-                       container_of(rule, typeof(*krule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE,
                        lttng_ht_seed);
@@ -434,7 +434,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_location(
                goto end;
        }
 
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
        *location = kprobe->location;
 
        if (!*location) {
@@ -459,7 +459,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_set_event_name(
                goto end;
        }
 
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
        name_copy = strdup(name);
        if (!name_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -485,7 +485,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_event_name(
                goto end;
        }
 
-       kprobe = container_of(rule, struct lttng_event_rule_kernel_kprobe, parent);
+       kprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_kprobe::parent);
        if (!kprobe->name) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index d006eaa054960b29eeb59edf0e342cc60ba19459..633c4698b3558e1b823005f66fb9338de59648bc 100644 (file)
@@ -29,7 +29,7 @@ static void lttng_event_rule_kernel_syscall_destroy(struct lttng_event_rule *rul
                return;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        free(syscall->pattern);
        free(syscall->filter_expression);
@@ -48,7 +48,7 @@ static bool lttng_event_rule_kernel_syscall_validate(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        /* Required field. */
        if (!syscall->pattern) {
@@ -76,7 +76,7 @@ static int lttng_event_rule_kernel_syscall_serialize(
        }
 
        DBG("Serializing syscall event rule");
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        pattern_len = strlen(syscall->pattern) + 1;
 
@@ -114,8 +114,8 @@ static bool lttng_event_rule_kernel_syscall_is_equal(const struct lttng_event_ru
        bool is_equal = false;
        struct lttng_event_rule_kernel_syscall *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_kernel_syscall, parent);
-       b = container_of(_b, struct lttng_event_rule_kernel_syscall, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_kernel_syscall::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_kernel_syscall::parent);
 
        if (!!a->filter_expression != !!b->filter_expression) {
                goto end;
@@ -154,7 +154,7 @@ static enum lttng_error_code lttng_event_rule_kernel_syscall_generate_filter_byt
 
        LTTNG_ASSERT(rule);
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        /* Generate the filter bytecode. */
        status = lttng_event_rule_kernel_syscall_get_filter(rule, &filter);
@@ -202,7 +202,7 @@ static const char *lttng_event_rule_kernel_syscall_get_internal_filter(
        struct lttng_event_rule_kernel_syscall *syscall;
 
        LTTNG_ASSERT(rule);
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        return syscall->internal_filter.filter;
 }
@@ -214,7 +214,7 @@ lttng_event_rule_kernel_syscall_get_internal_filter_bytecode(
        struct lttng_event_rule_kernel_syscall *syscall;
 
        LTTNG_ASSERT(rule);
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        return syscall->internal_filter.bytecode;
 }
@@ -235,7 +235,7 @@ lttng_event_rule_kernel_syscall_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_kernel_syscall *syscall_rule =
-                       container_of(rule, typeof(*syscall_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL,
                        lttng_ht_seed);
@@ -515,7 +515,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_name_pattern(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -543,7 +543,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_name_pattern(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
        if (!syscall->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -569,7 +569,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_filter(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -597,7 +597,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_filter(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
        if (!syscall->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -619,7 +619,7 @@ lttng_event_rule_kernel_syscall_get_emission_site(
                goto end;
        }
 
-       syscall = container_of(rule, struct lttng_event_rule_kernel_syscall, parent);
+       syscall = lttng::utils::container_of(rule, &lttng_event_rule_kernel_syscall::parent);
        emission_site = syscall->emission_site;
 
 end:
index 0bedfb5010e2cff38281a2381aa22f450bc36879..939b83fbbe954ec3d8519b8b5891d0207af39246 100644 (file)
@@ -31,8 +31,8 @@ static void lttng_event_rule_kernel_tracepoint_destroy(struct lttng_event_rule *
                return;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
 
        free(tracepoint->pattern);
        free(tracepoint->filter_expression);
@@ -51,8 +51,8 @@ static bool lttng_event_rule_kernel_tracepoint_validate(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
 
        /* Required field. */
        if (!tracepoint->pattern) {
@@ -80,8 +80,8 @@ static int lttng_event_rule_kernel_tracepoint_serialize(
        }
 
        DBG("Serializing kernel tracepoint event rule.");
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
 
        pattern_len = strlen(tracepoint->pattern) + 1;
 
@@ -124,8 +124,8 @@ static bool lttng_event_rule_kernel_tracepoint_is_equal(
        bool is_equal = false;
        struct lttng_event_rule_kernel_tracepoint *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_kernel_tracepoint, parent);
-       b = container_of(_b, struct lttng_event_rule_kernel_tracepoint, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_kernel_tracepoint::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_kernel_tracepoint::parent);
 
        if (!!a->filter_expression != !!b->filter_expression) {
                goto end;
@@ -166,8 +166,8 @@ lttng_event_rule_kernel_tracepoint_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
 
        status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -221,8 +221,8 @@ static const char *lttng_event_rule_kernel_tracepoint_get_internal_filter(
        struct lttng_event_rule_kernel_tracepoint *tracepoint;
 
        LTTNG_ASSERT(rule);
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        return tracepoint->internal_filter.filter;
 }
 
@@ -233,8 +233,8 @@ lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode(
        struct lttng_event_rule_kernel_tracepoint *tracepoint;
 
        LTTNG_ASSERT(rule);
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        return tracepoint->internal_filter.bytecode;
 }
 
@@ -252,8 +252,8 @@ static unsigned long lttng_event_rule_kernel_tracepoint_hash(
                const struct lttng_event_rule *rule)
 {
        unsigned long hash;
-       struct lttng_event_rule_kernel_tracepoint *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+       struct lttng_event_rule_kernel_tracepoint *tp_rule = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT,
                        lttng_ht_seed);
@@ -488,8 +488,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_name_pattern
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -518,8 +518,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_name_pattern
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        if (!tracepoint->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -543,8 +543,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_filter(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -573,8 +573,8 @@ enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_filter(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_kernel_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_kernel_tracepoint::parent);
        if (!tracepoint->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index 4e611aca231d7373425205382ee1076d662afa4a..cee5b2e65b30ccf9979c396b75f68419bd6e32c1 100644 (file)
@@ -25,7 +25,7 @@ static void lttng_event_rule_kernel_uprobe_destroy(struct lttng_event_rule *rule
 {
        struct lttng_event_rule_kernel_uprobe *uprobe;
 
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
 
        lttng_userspace_probe_location_destroy(uprobe->location);
        free(uprobe->name);
@@ -42,7 +42,7 @@ static bool lttng_event_rule_kernel_uprobe_validate(
                goto end;
        }
 
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
 
        /* Required field. */
        if (!uprobe->name) {
@@ -78,7 +78,7 @@ static int lttng_event_rule_kernel_uprobe_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing uprobe event rule.");
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
 
        name_len = strlen(uprobe->name) + 1;
 
@@ -122,8 +122,8 @@ static bool lttng_event_rule_kernel_uprobe_is_equal(const struct lttng_event_rul
        bool is_equal = false;
        struct lttng_event_rule_kernel_uprobe *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_kernel_uprobe, parent);
-       b = container_of(_b, struct lttng_event_rule_kernel_uprobe, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_kernel_uprobe::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_kernel_uprobe::parent);
 
        /* uprobe is invalid if this is not true. */
        LTTNG_ASSERT(a->name);
@@ -179,7 +179,7 @@ lttng_event_rule_kernel_uprobe_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_kernel_uprobe *urule =
-                       container_of(rule, typeof(*urule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE,
                        lttng_ht_seed);
@@ -438,7 +438,7 @@ lttng_event_rule_kernel_uprobe_get_location_mutable(
        struct lttng_event_rule_kernel_uprobe *uprobe;
 
        LTTNG_ASSERT(rule);
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
 
        return uprobe->location;
 }
@@ -456,7 +456,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_set_event_name(
                goto end;
        }
 
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
        name_copy = strdup(name);
        if (!name_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -484,7 +484,7 @@ enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_event_name(
                goto end;
        }
 
-       uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
+       uprobe = lttng::utils::container_of(rule, &lttng_event_rule_kernel_uprobe::parent);
        if (!uprobe->name) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index b7386c0ba36f99743055efff6c0ff5a8b04d954e..11e775c3f893f9d4269f76b020d2e9204057c20c 100644 (file)
@@ -32,8 +32,8 @@ static void lttng_event_rule_log4j_logging_destroy(struct lttng_event_rule *rule
                return;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        lttng_log_level_rule_destroy(log4j_logging->log_level_rule);
        free(log4j_logging->pattern);
@@ -53,8 +53,8 @@ static bool lttng_event_rule_log4j_logging_validate(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        /* Required field. */
        if (!log4j_logging->pattern) {
@@ -86,8 +86,8 @@ static int lttng_event_rule_log4j_logging_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing log4j_logging event rule.");
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        pattern_len = strlen(log4j_logging->pattern) + 1;
 
@@ -141,8 +141,8 @@ static bool lttng_event_rule_log4j_logging_is_equal(
        bool is_equal = false;
        struct lttng_event_rule_log4j_logging *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_log4j_logging, parent);
-       b = container_of(_b, struct lttng_event_rule_log4j_logging, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_log4j_logging::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_log4j_logging::parent);
 
        /* Quick checks. */
 
@@ -304,8 +304,8 @@ lttng_event_rule_log4j_logging_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -357,8 +357,8 @@ static const char *lttng_event_rule_log4j_logging_get_internal_filter(
        struct lttng_event_rule_log4j_logging *log4j_logging;
 
        LTTNG_ASSERT(rule);
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        return log4j_logging->internal_filter.filter;
 }
 
@@ -369,8 +369,8 @@ lttng_event_rule_log4j_logging_get_internal_filter_bytecode(
        struct lttng_event_rule_log4j_logging *log4j_logging;
 
        LTTNG_ASSERT(rule);
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        return log4j_logging->internal_filter.bytecode;
 }
 
@@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_log4j_logging_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_log4j_logging *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_log4j_logging::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING,
                        lttng_ht_seed);
@@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_log4j_logging_generate_lttng_event(
        enum lttng_event_rule_status status;
        const struct lttng_log_level_rule *log_level_rule;
 
-       log4j_logging = container_of(
-                       rule, const struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        local_event = zmalloc<lttng_event>();
        if (!local_event) {
@@ -752,8 +752,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_name_pattern(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -782,8 +782,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_name_pattern(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (!log4j_logging->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -807,8 +807,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_filter(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -837,8 +837,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_filter(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (!log4j_logging->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -872,8 +872,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_log_level_rule(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        if (!log_level_rule_valid(log_level_rule)) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -909,8 +909,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_log_level_rule(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (log4j_logging->log_level_rule == NULL) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index 25e967702436e2afc34708a067a32b1ea7ffccd8..47b1e0366a79d94cf942572c5acc64caa85f37cb 100644 (file)
@@ -32,8 +32,8 @@ static void lttng_event_rule_python_logging_destroy(struct lttng_event_rule *rul
                return;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        lttng_log_level_rule_destroy(python_logging->log_level_rule);
        free(python_logging->pattern);
@@ -53,8 +53,8 @@ static bool lttng_event_rule_python_logging_validate(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        /* Required field. */
        if (!python_logging->pattern) {
@@ -86,8 +86,8 @@ static int lttng_event_rule_python_logging_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing python_logging event rule.");
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        pattern_len = strlen(python_logging->pattern) + 1;
 
@@ -141,8 +141,8 @@ static bool lttng_event_rule_python_logging_is_equal(
        bool is_equal = false;
        struct lttng_event_rule_python_logging *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_python_logging, parent);
-       b = container_of(_b, struct lttng_event_rule_python_logging, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_python_logging::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_python_logging::parent);
 
        /* Quick checks. */
 
@@ -304,8 +304,8 @@ lttng_event_rule_python_logging_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        status = lttng_event_rule_python_logging_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -357,8 +357,8 @@ static const char *lttng_event_rule_python_logging_get_internal_filter(
        struct lttng_event_rule_python_logging *python_logging;
 
        LTTNG_ASSERT(rule);
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        return python_logging->internal_filter.filter;
 }
 
@@ -369,8 +369,8 @@ lttng_event_rule_python_logging_get_internal_filter_bytecode(
        struct lttng_event_rule_python_logging *python_logging;
 
        LTTNG_ASSERT(rule);
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        return python_logging->internal_filter.bytecode;
 }
 
@@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_python_logging_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_python_logging *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_python_logging::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING,
                        lttng_ht_seed);
@@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_python_logging_generate_lttng_event(
        enum lttng_event_rule_status status;
        const struct lttng_log_level_rule *log_level_rule;
 
-       python_logging = container_of(
-                       rule, const struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        local_event = zmalloc<lttng_event>();
        if (!local_event) {
@@ -752,8 +752,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_name_pattern(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -782,8 +782,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_name_pattern(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        if (!python_logging->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -807,8 +807,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_filter(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -829,7 +829,7 @@ end:
 enum lttng_event_rule_status lttng_event_rule_python_logging_get_filter(
                const struct lttng_event_rule *rule, const char **expression)
 {
-       struct lttng_event_rule_python_logging *python_logging;
+       const struct lttng_event_rule_python_logging *python_logging;
        enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
 
        if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule) || !expression) {
@@ -837,8 +837,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_filter(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        if (!python_logging->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -874,8 +874,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_set_log_level_rule(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
 
        if (!log_level_rule_valid(log_level_rule)) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -911,8 +911,8 @@ enum lttng_event_rule_status lttng_event_rule_python_logging_get_log_level_rule(
                goto end;
        }
 
-       python_logging = container_of(
-                       rule, struct lttng_event_rule_python_logging, parent);
+       python_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_python_logging::parent);
        if (python_logging->log_level_rule == NULL) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
index 48040fc59292384310ae1ac4fb19e0332266b08b..318bc21c805281bbd3fc46f38501be1e8a2e6704 100644 (file)
@@ -32,8 +32,8 @@ static void lttng_event_rule_user_tracepoint_destroy(struct lttng_event_rule *ru
                return;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        lttng_log_level_rule_destroy(tracepoint->log_level_rule);
        lttng_dynamic_pointer_array_reset(&tracepoint->exclusions);
@@ -54,8 +54,8 @@ static bool lttng_event_rule_user_tracepoint_validate(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        /* Required field. */
        if (!tracepoint->pattern) {
@@ -90,8 +90,8 @@ static int lttng_event_rule_user_tracepoint_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing user tracepoint event rule.");
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &exclusion_count);
        LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
@@ -197,8 +197,8 @@ static bool lttng_event_rule_user_tracepoint_is_equal(
        unsigned int count_a, count_b;
        enum lttng_event_rule_status status;
 
-       a = container_of(_a, struct lttng_event_rule_user_tracepoint, parent);
-       b = container_of(_b, struct lttng_event_rule_user_tracepoint, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_user_tracepoint::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_user_tracepoint::parent);
 
        status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(_a, &count_a);
        LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
@@ -268,8 +268,8 @@ lttng_event_rule_user_tracepoint_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -323,8 +323,8 @@ static const char *lttng_event_rule_user_tracepoint_get_internal_filter(
        struct lttng_event_rule_user_tracepoint *tracepoint;
 
        LTTNG_ASSERT(rule);
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        return tracepoint->internal_filter.filter;
 }
 
@@ -335,8 +335,8 @@ lttng_event_rule_user_tracepoint_get_internal_filter_bytecode(
        struct lttng_event_rule_user_tracepoint *tracepoint;
 
        LTTNG_ASSERT(rule);
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        return tracepoint->internal_filter.bytecode;
 }
 
@@ -410,7 +410,7 @@ static unsigned long lttng_event_rule_user_tracepoint_hash(
        unsigned int i, exclusion_count;
        enum lttng_event_rule_status status;
        struct lttng_event_rule_user_tracepoint *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_user_tracepoint::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT,
                        lttng_ht_seed);
@@ -796,8 +796,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_name_pattern(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -826,8 +826,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        if (!tracepoint->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -851,8 +851,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_filter(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -881,8 +881,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_filter(
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        if (!tracepoint->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -941,8 +941,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_log_level_rule
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        if (!log_level_rule_valid(log_level_rule)) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -978,8 +978,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_log_level_rule
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        if (tracepoint->log_level_rule == NULL) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -1005,8 +1005,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_add_name_pattern_e
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
 
        if (strlen(exclusion) >= LTTNG_SYMBOL_NAME_LEN) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -1043,8 +1043,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_e
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        *count = lttng_dynamic_pointer_array_get_count(&tracepoint->exclusions);
 end:
        return status;
@@ -1064,8 +1064,8 @@ enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_e
                goto end;
        }
 
-       tracepoint = container_of(
-                       rule, struct lttng_event_rule_user_tracepoint, parent);
+       tracepoint = lttng::utils::container_of(
+                       rule, &lttng_event_rule_user_tracepoint::parent);
        if (lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &count) !=
                        LTTNG_EVENT_RULE_STATUS_OK) {
                goto end;
index 579757782702f175315254b3003b001e1355bbae..8a0d95243bcdfebf4035da2981ff13cbaed454d9 100644 (file)
@@ -19,7 +19,7 @@ struct fd_handle {
 static void fd_handle_release(struct urcu_ref *ref)
 {
        int ret;
-       struct fd_handle *handle = container_of(ref, struct fd_handle, ref);
+       struct fd_handle *handle = lttng::utils::container_of(ref, &fd_handle::ref);
 
        LTTNG_ASSERT(handle->fd >= 0);
        ret = close(handle->fd);
index e1f9b14fbba8fa618e072d5addc422f2c5cbdaec..0c24eab5ea016e74b51e818af1bbcbb02c5b24ff 100644 (file)
@@ -163,8 +163,8 @@ static int fd_tracker_restore_handle(
 /* Match function of the tracker's unsuspendable_fds hash table. */
 static int match_fd(struct cds_lfht_node *node, const void *key)
 {
-       struct unsuspendable_fd *entry = caa_container_of(
-                       node, struct unsuspendable_fd, tracker_node);
+       struct unsuspendable_fd *entry = lttng::utils::container_of(
+                       node, &unsuspendable_fd::tracker_node);
 
        return hash_match_key_ulong(
                        (void *) (unsigned long) entry->fd, (void *) key);
@@ -757,8 +757,8 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
                        ret = -EINVAL;
                        goto end_unlock;
                }
-               entry = caa_container_of(
-                               node, struct unsuspendable_fd, tracker_node);
+               entry = lttng::utils::container_of(
+                               node, &unsuspendable_fd::tracker_node);
 
                cds_lfht_del(tracker->unsuspendable_fds, node);
                unsuspendable_fd_destroy(entry);
@@ -825,7 +825,7 @@ static int fs_handle_tracked_get_fd(struct fs_handle *_handle)
 {
        int ret;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        /*
         * TODO This should be optimized as it is a fairly hot path.
@@ -866,7 +866,7 @@ end:
 static void fs_handle_tracked_put_fd(struct fs_handle *_handle)
 {
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        pthread_mutex_lock(&handle->lock);
        handle->in_use = false;
@@ -877,7 +877,7 @@ static int fs_handle_tracked_unlink(struct fs_handle *_handle)
 {
        int ret;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
 
        pthread_mutex_lock(&handle->tracker->lock);
        pthread_mutex_lock(&handle->lock);
@@ -892,7 +892,7 @@ static int fs_handle_tracked_close(struct fs_handle *_handle)
        int ret = 0;
        const char *path = NULL;
        struct fs_handle_tracked *handle =
-                       container_of(_handle, struct fs_handle_tracked, parent);
+                       lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
        struct lttng_directory_handle *inode_directory_handle = NULL;
 
        if (!handle) {
index 95a0f27426c9f943c86aee36d1be11947446f16b..c00f9d81ff1686e8ec16b30cc32095a53884f12c 100644 (file)
@@ -85,8 +85,8 @@ static unsigned long lttng_inode_id_hash(const struct inode_id *id)
 static int lttng_inode_match(struct cds_lfht_node *node, const void *key)
 {
        const struct inode_id *id = (inode_id *) key;
-       const struct lttng_inode *inode = caa_container_of(
-                       node, struct lttng_inode, registry_node);
+       const struct lttng_inode *inode = lttng::utils::container_of(
+                       node, &lttng_inode::registry_node);
 
        return inode->id.device == id->device && inode->id.inode == id->inode;
 }
@@ -94,7 +94,7 @@ static int lttng_inode_match(struct cds_lfht_node *node, const void *key)
 static void lttng_inode_free(struct rcu_head *head)
 {
        struct lttng_inode *inode =
-                       caa_container_of(head, struct lttng_inode, rcu_head);
+                       lttng::utils::container_of(head, &lttng_inode::rcu_head);
 
        free(inode);
 }
@@ -243,7 +243,7 @@ static void lttng_inode_destroy(struct lttng_inode *inode)
 
 static void lttng_inode_release(struct urcu_ref *ref)
 {
-       lttng_inode_destroy(caa_container_of(ref, struct lttng_inode, ref));
+       lttng_inode_destroy(lttng::utils::container_of(ref, &lttng_inode::ref));
 }
 
 static void lttng_inode_get(struct lttng_inode *inode)
@@ -526,8 +526,8 @@ struct lttng_inode *lttng_inode_registry_get_inode(
                        lttng_inode_match, &id, &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (node) {
-               inode = caa_container_of(
-                               node, struct lttng_inode, registry_node);
+               inode = lttng::utils::container_of(
+                               node, &lttng_inode::registry_node);
                lttng_inode_get(inode);
                goto end_unlock;
        }
index 1b40f91f125fa97ef46d409476148d1ef29585dd..3aa3d79d42210dcfb192a21056c1a1a2319c7716 100644 (file)
@@ -36,7 +36,7 @@ static unsigned long max_hash_buckets_size = 0;
 static int match_str(struct cds_lfht_node *node, const void *key)
 {
        struct lttng_ht_node_str *match_node =
-               caa_container_of(node, struct lttng_ht_node_str, node);
+               lttng::utils::container_of(node, &lttng_ht_node_str::node);
 
        return hash_match_key_str(match_node->key, (void *) key);
 }
@@ -47,7 +47,7 @@ static int match_str(struct cds_lfht_node *node, const void *key)
 static int match_ulong(struct cds_lfht_node *node, const void *key)
 {
        struct lttng_ht_node_ulong *match_node =
-               caa_container_of(node, struct lttng_ht_node_ulong, node);
+               lttng::utils::container_of(node, &lttng_ht_node_ulong::node);
 
        return hash_match_key_ulong((void *) match_node->key, (void *) key);
 }
@@ -58,7 +58,7 @@ static int match_ulong(struct cds_lfht_node *node, const void *key)
 static int match_u64(struct cds_lfht_node *node, const void *key)
 {
        struct lttng_ht_node_u64 *match_node =
-               caa_container_of(node, struct lttng_ht_node_u64, node);
+               lttng::utils::container_of(node, &lttng_ht_node_u64::node);
 
        return hash_match_key_u64(&match_node->key, (void *) key);
 }
@@ -69,7 +69,7 @@ static int match_u64(struct cds_lfht_node *node, const void *key)
 static int match_two_u64(struct cds_lfht_node *node, const void *key)
 {
        struct lttng_ht_node_two_u64 *match_node =
-               caa_container_of(node, struct lttng_ht_node_two_u64, node);
+               lttng::utils::container_of(node, &lttng_ht_node_two_u64::node);
 
        return hash_match_key_two_u64((void *) &match_node->key, (void *) key);
 }
@@ -413,7 +413,7 @@ struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht,
        if (!node_ptr) {
                return NULL;
        } else {
-               return caa_container_of(node_ptr, struct lttng_ht_node_ulong, node);
+               return lttng::utils::container_of(node_ptr, &lttng_ht_node_ulong::node);
        }
        LTTNG_ASSERT(node_ptr == &node->node);
 }
@@ -438,7 +438,7 @@ struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(struct lttng_ht *ht,
        if (!node_ptr) {
                return NULL;
        } else {
-               return caa_container_of(node_ptr, struct lttng_ht_node_u64, node);
+               return lttng::utils::container_of(node_ptr, &lttng_ht_node_u64::node);
        }
        LTTNG_ASSERT(node_ptr == &node->node);
 }
@@ -517,7 +517,7 @@ struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
        if (!node) {
                return NULL;
        }
-       return caa_container_of(node, struct lttng_ht_node_str, node);
+       return lttng::utils::container_of(node, &lttng_ht_node_str::node);
 }
 
 /*
@@ -533,7 +533,7 @@ struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
        if (!node) {
                return NULL;
        }
-       return caa_container_of(node, struct lttng_ht_node_ulong, node);
+       return lttng::utils::container_of(node, &lttng_ht_node_ulong::node);
 }
 
 /*
@@ -549,7 +549,7 @@ struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
        if (!node) {
                return NULL;
        }
-       return caa_container_of(node, struct lttng_ht_node_u64, node);
+       return lttng::utils::container_of(node, &lttng_ht_node_u64::node);
 }
 
 /*
@@ -565,5 +565,5 @@ struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
        if (!node) {
                return NULL;
        }
-       return caa_container_of(node, struct lttng_ht_node_two_u64, node);
+       return lttng::utils::container_of(node, &lttng_ht_node_two_u64::node);
 }
index 172527f9a4f33d4cb6cb66db1f10edec9bbf2879..b01b44b960a72bf77b92d34ef9fcb41d1657e32d 100644 (file)
@@ -82,9 +82,8 @@ void lttng_kernel_probe_location_symbol_destroy(
 
        LTTNG_ASSERT(location);
 
-       location_symbol = container_of(location,
-                       struct lttng_kernel_probe_location_symbol,
-                       parent);
+       location_symbol = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        LTTNG_ASSERT(location_symbol);
 
@@ -195,8 +194,8 @@ lttng_kernel_probe_location_address_get_address(
                goto end;
        }
 
-       address_location = container_of(location,
-                       struct lttng_kernel_probe_location_address, parent);
+       address_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_address::parent);
        *offset = address_location->address;
 end:
        return ret;
@@ -214,8 +213,8 @@ const char *lttng_kernel_probe_location_symbol_get_name(
                goto end;
        }
 
-       symbol_location = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       symbol_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
        ret = symbol_location->symbol_name;
 end:
        return ret;
@@ -239,8 +238,8 @@ lttng_kernel_probe_location_symbol_get_offset(
                goto end;
        }
 
-       symbol_location = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       symbol_location = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
        *offset = symbol_location->offset;
 end:
        return ret;
@@ -267,8 +266,8 @@ int lttng_kernel_probe_location_symbol_serialize(
                        LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
 
        original_payload_size = payload->buffer.size;
-       location_symbol = container_of(location,
-                       struct lttng_kernel_probe_location_symbol, parent);
+       location_symbol = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        if (!location_symbol->symbol_name) {
                ret = -LTTNG_ERR_INVALID;
@@ -319,9 +318,8 @@ int lttng_kernel_probe_location_address_serialize(
                        LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
 
        original_payload_size = payload->buffer.size;
-       location_address = container_of(location,
-                       struct lttng_kernel_probe_location_address,
-                       parent);
+       location_address = lttng::utils::container_of(location,
+                       &lttng_kernel_probe_location_address::parent);
 
        location_address_comm.address = location_address->address;
 
@@ -518,9 +516,8 @@ unsigned long lttng_kernel_probe_location_address_hash(
        unsigned long hash = hash_key_ulong(
                        (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS,
                        lttng_ht_seed);
-       struct lttng_kernel_probe_location_address *address_location =
-                       container_of(location, typeof(*address_location),
-                               parent);
+       struct lttng_kernel_probe_location_address *address_location = lttng::utils::container_of(
+                       location, &lttng_kernel_probe_location_address::parent);
 
        hash ^= hash_key_u64(&address_location->address, lttng_ht_seed);
 
@@ -535,10 +532,8 @@ bool lttng_kernel_probe_location_address_is_equal(
        bool is_equal = false;
        struct lttng_kernel_probe_location_address *a, *b;
 
-       a = container_of(_a, struct lttng_kernel_probe_location_address,
-                       parent);
-       b = container_of(_b, struct lttng_kernel_probe_location_address,
-                       parent);
+       a = lttng::utils::container_of(_a, &lttng_kernel_probe_location_address::parent);
+       b = lttng::utils::container_of(_b, &lttng_kernel_probe_location_address::parent);
 
        if (a->address != b->address) {
                goto end;
@@ -555,11 +550,9 @@ unsigned long lttng_kernel_probe_location_symbol_hash(
                const struct lttng_kernel_probe_location *location)
 {
        unsigned long hash = hash_key_ulong(
-                       (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET,
-                       lttng_ht_seed);
-       struct lttng_kernel_probe_location_symbol *symbol_location =
-                       container_of(location, typeof(*symbol_location),
-                               parent);
+                       (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, lttng_ht_seed);
+       struct lttng_kernel_probe_location_symbol *symbol_location = lttng::utils::container_of(
+                       location, &lttng_kernel_probe_location_symbol::parent);
 
        hash ^= hash_key_str(symbol_location->symbol_name, lttng_ht_seed);
        hash ^= hash_key_u64(&symbol_location->offset, lttng_ht_seed);
@@ -575,10 +568,10 @@ bool lttng_kernel_probe_location_symbol_is_equal(
        bool is_equal = false;
        struct lttng_kernel_probe_location_symbol *a, *b;
 
-       a = container_of(_a, struct lttng_kernel_probe_location_symbol,
-                       parent);
-       b = container_of(_b, struct lttng_kernel_probe_location_symbol,
-                       parent);
+       a = lttng::utils::container_of(_a,
+                       &lttng_kernel_probe_location_symbol::parent);
+       b = lttng::utils::container_of(_b,
+                       &lttng_kernel_probe_location_symbol::parent);
 
        LTTNG_ASSERT(a->symbol_name);
        LTTNG_ASSERT(b->symbol_name);
@@ -625,15 +618,12 @@ lttng_kernel_probe_location_symbol_copy(
                const struct lttng_kernel_probe_location *location)
 {
        struct lttng_kernel_probe_location *new_location = NULL;
-       struct lttng_kernel_probe_location_symbol *symbol_location;
        enum lttng_kernel_probe_location_status status;
        const char *symbol_name = NULL;
        uint64_t offset;
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
-       symbol_location = container_of(
-                       location, typeof(*symbol_location), parent);
 
         /* Get probe location offset */
        status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
@@ -664,17 +654,13 @@ lttng_kernel_probe_location_address_copy(
                const struct lttng_kernel_probe_location *location)
 {
        struct lttng_kernel_probe_location *new_location = NULL;
-       struct lttng_kernel_probe_location_address *address_location;
        enum lttng_kernel_probe_location_status status;
        uint64_t address;
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
-       address_location = container_of(
-                       location, typeof(*address_location), parent);
-
 
-        /* Get probe location fields */
+       /* Get probe location fields */
        status = lttng_kernel_probe_location_address_get_address(location, &address);
        if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) {
                ERR("Get kernel probe address failed.");
index 65c0412402a42d2dca6a4f99727293f88c58795f..b09430d617e408f76a88c041bc6fc1d5f96c8cf4 100644 (file)
@@ -31,7 +31,7 @@ static
 void trace_archive_location_destroy_ref(struct urcu_ref *ref)
 {
        struct lttng_trace_archive_location *location =
-                       container_of(ref, struct lttng_trace_archive_location, ref);
+                       lttng::utils::container_of(ref, &lttng_trace_archive_location::ref);
 
        switch (location->type) {
        case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
index ecaaa4cda2edbb0c6fdc273bf67c858ebaa2f2f7..37e6cabcf32e8701b369dab4ce96d3a17dc75724 100644 (file)
@@ -229,14 +229,6 @@ void *memmove(T *d, const U *s, size_t n) = delete;
 #define ARRAY_SIZE(array)   (sizeof(array) / (sizeof((array)[0])))
 #endif
 
-#ifndef container_of
-#define container_of(ptr, type, member)                                        \
-       ({                                                              \
-               const typeof(((type *)NULL)->member) * __ptr = (ptr);   \
-               (type *)((char *)__ptr - offsetof(type, member));       \
-       })
-#endif
-
 #ifndef LTTNG_PACKED
 #define LTTNG_PACKED __attribute__((__packed__))
 #endif
@@ -317,4 +309,18 @@ int lttng_strncpy(char *dst, const char *src, size_t dst_len)
        return 0;
 }
 
+namespace lttng {
+namespace utils {
+template <class Parent, class Member>
+Parent *container_of(const Member *member, const Member Parent::*ptr_to_member)
+{
+       const Parent *dummy_parent = nullptr;
+       auto *offset_of_member = reinterpret_cast<const char *>(&(dummy_parent->*ptr_to_member));
+       auto address_of_parent = reinterpret_cast<const char *>(member) - offset_of_member;
+
+       return reinterpret_cast<Parent *>(address_of_parent);
+}
+} /* namespace utils */
+} /* namespace lttng */
+
 #endif /* _MACROS_H */
index 642c6399fc6e7728693a2d27ff07326b9ded2432..1171b2930ce605c2ee465476cd5d4541cd48a646 100644 (file)
@@ -847,9 +847,8 @@ int lttng_session_descriptor_serialize(
 
        header.base.uri_count = uri_count;
        if (descriptor->type == LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE) {
-               const struct lttng_session_descriptor_live *live =
-                               container_of(descriptor, typeof(*live),
-                               base);
+               const struct lttng_session_descriptor_live *live = lttng::utils::container_of(
+                               descriptor, &lttng_session_descriptor_live::base);
 
                header.live_timer_us = live->live_timer_us;
                header_ptr = &header;
@@ -918,7 +917,7 @@ lttng_session_descriptor_live_get_timer_interval(
 {
        struct lttng_session_descriptor_live *live;
 
-       live = container_of(descriptor, typeof(*live), base);
+       live = lttng::utils::container_of(descriptor, &lttng_session_descriptor_live::base);
        return live->live_timer_us;
 }
 
index beae46ef3110c416bd271aeb8125edef70f33502..488d0814620f32e4351913231d7596abff0fbdae 100644 (file)
@@ -237,8 +237,8 @@ end:
 static
 int fs_handle_untracked_get_fd(struct fs_handle *_handle)
 {
-       struct fs_handle_untracked *handle = container_of(
-                       _handle, struct fs_handle_untracked, parent);
+       struct fs_handle_untracked *handle = lttng::utils::container_of(
+                       _handle, &fs_handle_untracked::parent);
 
        return handle->fd;
 }
@@ -252,8 +252,8 @@ void fs_handle_untracked_put_fd(struct fs_handle *_handle __attribute__((unused)
 static
 int fs_handle_untracked_unlink(struct fs_handle *_handle)
 {
-       struct fs_handle_untracked *handle = container_of(
-                       _handle, struct fs_handle_untracked, parent);
+       struct fs_handle_untracked *handle = lttng::utils::container_of(
+                       _handle, &fs_handle_untracked::parent);
 
        return lttng_directory_handle_unlink_file(
                        handle->location.directory_handle,
@@ -271,8 +271,8 @@ void fs_handle_untracked_destroy(struct fs_handle_untracked *handle)
 static
 int fs_handle_untracked_close(struct fs_handle *_handle)
 {
-       struct fs_handle_untracked *handle = container_of(
-                       _handle, struct fs_handle_untracked, parent);
+       struct fs_handle_untracked *handle = lttng::utils::container_of(
+                       _handle, &fs_handle_untracked::parent);
        int ret = close(handle->fd);
 
        fs_handle_untracked_destroy(handle);
@@ -1462,8 +1462,8 @@ enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
                /*
                 * Does not close the fd; we just "unbox" it from the fs_handle.
                 */
-               fs_handle_untracked_destroy(container_of(
-                               fs_handle, struct fs_handle_untracked, parent));
+               fs_handle_untracked_destroy(lttng::utils::container_of(
+                               fs_handle, &fs_handle_untracked::parent));
        }
 
        return status;
@@ -1861,8 +1861,8 @@ bool lttng_trace_chunk_get(struct lttng_trace_chunk *chunk)
 static
 void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
 {
-       struct lttng_trace_chunk_registry_element *element =
-                       container_of(node, typeof(*element), rcu_node);
+       struct lttng_trace_chunk_registry_element *element = lttng::utils::container_of(
+                       node, &lttng_trace_chunk_registry_element::rcu_node);
 
        free(element);
 }
@@ -1870,8 +1870,7 @@ void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
 static
 void lttng_trace_chunk_release(struct urcu_ref *ref)
 {
-       struct lttng_trace_chunk *chunk = container_of(ref, typeof(*chunk),
-                       ref);
+       struct lttng_trace_chunk *chunk = lttng::utils::container_of(ref, &lttng_trace_chunk::ref);
 
        if (chunk->close_command.is_set) {
                chunk_command func = close_command_get_post_release_func(chunk->close_command.value);
@@ -1903,7 +1902,8 @@ void lttng_trace_chunk_release(struct urcu_ref *ref)
                 */
                lttng_trace_chunk_fini(chunk);
 
-               element = container_of(chunk, typeof(*element), chunk);
+               element = lttng::utils::container_of(
+                               chunk, &lttng_trace_chunk_registry_element::chunk);
                if (element->registry) {
                        rcu_read_lock();
                        cds_lfht_del(element->registry->ht,
@@ -2076,9 +2076,8 @@ lttng_trace_chunk_registry_publish_chunk(
                 * already published and release the reference to the copy we
                 * created if successful.
                 */
-               published_element = container_of(published_node,
-                               typeof(*published_element),
-                               trace_chunk_registry_ht_node);
+               published_element = lttng::utils::container_of(published_node,
+                               &lttng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
                published_chunk = &published_element->chunk;
                if (lttng_trace_chunk_get(published_chunk)) {
                        lttng_trace_chunk_put(&element->chunk);
@@ -2136,9 +2135,8 @@ struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk(
                goto end;
        }
 
-       published_element = container_of(published_node,
-                       typeof(*published_element),
-                       trace_chunk_registry_ht_node);
+       published_element = lttng::utils::container_of(published_node,
+                       &lttng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
        if (lttng_trace_chunk_get(&published_element->chunk)) {
                published_chunk = &published_element->chunk;
        }
index 8e6f0734e8c811c7cf4ed9e5e1b64f92d1a8c7ae..161c1abee7654f4ad5a00852f8e5fd53c2353302 100644 (file)
@@ -112,7 +112,7 @@ const struct lttng_action *lttng_trigger_get_const_action(
 static void trigger_destroy_ref(struct urcu_ref *ref)
 {
        struct lttng_trigger *trigger =
-                       container_of(ref, struct lttng_trigger, ref);
+                       lttng::utils::container_of(ref, &lttng_trigger::ref);
        struct lttng_action *action = lttng_trigger_get_action(trigger);
        struct lttng_condition *condition =
                        lttng_trigger_get_condition(trigger);
index 99893b6432cfa687098f28f115e1798a66c61e27..9798b12c46236b56f2879f53db888c22748e0015 100644 (file)
@@ -117,8 +117,8 @@ void lttng_userspace_probe_location_function_destroy(
 
        LTTNG_ASSERT(location);
 
-       location_function = container_of(location,
-                       struct lttng_userspace_probe_location_function, parent);
+       location_function = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_function::parent);
 
        LTTNG_ASSERT(location_function);
 
@@ -136,9 +136,8 @@ void lttng_userspace_probe_location_tracepoint_destroy(
 
        LTTNG_ASSERT(location);
 
-       location_tracepoint = container_of(location,
-                       struct lttng_userspace_probe_location_tracepoint,
-                       parent);
+       location_tracepoint = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_tracepoint::parent);
 
        LTTNG_ASSERT(location_tracepoint);
 
@@ -225,8 +224,8 @@ static unsigned long lttng_userspace_probe_location_function_hash(
                        (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION,
                        lttng_ht_seed);
        struct lttng_userspace_probe_location_function *function_location =
-                       container_of(location, typeof(*function_location),
-                                       parent);
+                       lttng::utils::container_of(
+                                       location, &lttng_userspace_probe_location_function::parent);
 
        hash ^= hash_key_str(function_location->function_name, lttng_ht_seed);
        hash ^= hash_key_str(function_location->binary_path, lttng_ht_seed);
@@ -244,10 +243,10 @@ static bool lttng_userspace_probe_location_function_is_equal(
        bool is_equal = false;
        struct lttng_userspace_probe_location_function *a, *b;
 
-       a = container_of(_a, struct lttng_userspace_probe_location_function,
-                       parent);
-       b = container_of(_b, struct lttng_userspace_probe_location_function,
-                       parent);
+       a = lttng::utils::container_of(_a,
+                       &lttng_userspace_probe_location_function::parent);
+       b = lttng::utils::container_of(_b,
+                       &lttng_userspace_probe_location_function::parent);
 
        if (a->instrumentation_type != b->instrumentation_type) {
                goto end;
@@ -350,8 +349,8 @@ static unsigned long lttng_userspace_probe_location_tracepoint_hash(
        unsigned long hash = hash_key_ulong(
                        (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT,
                        lttng_ht_seed);
-       struct lttng_userspace_probe_location_tracepoint *tp_location =
-                       container_of(location, typeof(*tp_location), parent);
+       struct lttng_userspace_probe_location_tracepoint *tp_location = lttng::utils::container_of(
+                       location, &lttng_userspace_probe_location_tracepoint::parent);
 
        hash ^= hash_key_str(tp_location->probe_name, lttng_ht_seed);
        hash ^= hash_key_str(tp_location->provider_name, lttng_ht_seed);
@@ -370,10 +369,10 @@ static bool lttng_userspace_probe_location_tracepoint_is_equal(
        bool is_equal = false;
        struct lttng_userspace_probe_location_tracepoint *a, *b;
 
-       a = container_of(_a, struct lttng_userspace_probe_location_tracepoint,
-                       parent);
-       b = container_of(_b, struct lttng_userspace_probe_location_tracepoint,
-                       parent);
+       a = lttng::utils::container_of(_a,
+                       &lttng_userspace_probe_location_tracepoint::parent);
+       b = lttng::utils::container_of(_b,
+                       &lttng_userspace_probe_location_tracepoint::parent);
 
        LTTNG_ASSERT(a->probe_name);
        LTTNG_ASSERT(b->probe_name);
@@ -604,10 +603,10 @@ lttng_userspace_probe_location_function_copy(
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
-       function_location = container_of(
-                       location, typeof(*function_location), parent);
+       function_location = lttng::utils::container_of(
+                       location, &lttng_userspace_probe_location_function::parent);
 
-        /* Get probe location fields */
+       /* Get probe location fields */
        binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
        if (!binary_path) {
                ERR("Userspace probe binary path is NULL");
@@ -678,8 +677,8 @@ lttng_userspace_probe_location_tracepoint_copy(
 
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
-       tracepoint_location = container_of(
-                       location, typeof(*tracepoint_location), parent);
+       tracepoint_location = lttng::utils::container_of(
+                       location, &lttng_userspace_probe_location_tracepoint::parent);
 
        /* Get probe location fields */
        binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
@@ -756,9 +755,8 @@ const char *lttng_userspace_probe_location_function_get_binary_path(
                goto end;
        }
 
-       function_location = container_of(location,
-               struct lttng_userspace_probe_location_function,
-                       parent);
+       function_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_function::parent);
        ret = function_location->binary_path;
 end:
        return ret;
@@ -776,9 +774,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_binary_path(
                goto end;
        }
 
-       tracepoint_location = container_of(location,
-               struct lttng_userspace_probe_location_tracepoint,
-                       parent);
+       tracepoint_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_tracepoint::parent);
        ret = tracepoint_location->binary_path;
 end:
        return ret;
@@ -796,8 +793,8 @@ const char *lttng_userspace_probe_location_function_get_function_name(
                goto end;
        }
 
-       function_location = container_of(location,
-               struct lttng_userspace_probe_location_function, parent);
+       function_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_function::parent);
        ret = function_location->function_name;
 end:
        return ret;
@@ -815,8 +812,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_probe_name(
                goto end;
        }
 
-       tracepoint_location = container_of(location,
-               struct lttng_userspace_probe_location_tracepoint, parent);
+       tracepoint_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_tracepoint::parent);
        ret = tracepoint_location->probe_name;
 end:
        return ret;
@@ -834,8 +831,8 @@ const char *lttng_userspace_probe_location_tracepoint_get_provider_name(
                goto end;
        }
 
-       tracepoint_location = container_of(location,
-               struct lttng_userspace_probe_location_tracepoint, parent);
+       tracepoint_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_tracepoint::parent);
        ret = tracepoint_location->provider_name;
 end:
        return ret;
@@ -853,8 +850,8 @@ int lttng_userspace_probe_location_function_get_binary_fd(
                goto end;
        }
 
-       function_location = container_of(location,
-               struct lttng_userspace_probe_location_function, parent);
+       function_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_function::parent);
        ret = function_location->binary_fd_handle ?
                        fd_handle_get_fd(function_location->binary_fd_handle) : -1;
 end:
@@ -875,8 +872,8 @@ lttng_userspace_probe_location_function_get_instrumentation_type(
                goto end;
        }
 
-       function_location = container_of(location,
-               struct lttng_userspace_probe_location_function, parent);
+       function_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_function::parent);
        type = function_location->instrumentation_type;
 end:
        return type;
@@ -900,8 +897,8 @@ lttng_userspace_probe_location_function_set_instrumentation_type(
                goto end;
        }
 
-       function_location = container_of(location,
-               struct lttng_userspace_probe_location_function, parent);
+       function_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_function::parent);
        function_location->instrumentation_type = instrumentation_type;
 end:
        return status;
@@ -919,8 +916,8 @@ int lttng_userspace_probe_location_tracepoint_get_binary_fd(
                goto end;
        }
 
-       tracepoint_location = container_of(location,
-               struct lttng_userspace_probe_location_tracepoint, parent);
+       tracepoint_location = lttng::utils::container_of(location,
+               &lttng_userspace_probe_location_tracepoint::parent);
        ret = tracepoint_location->binary_fd_handle ?
                        fd_handle_get_fd(tracepoint_location->binary_fd_handle) : -1;
 end:
@@ -1021,9 +1018,8 @@ int lttng_userspace_probe_location_function_serialize(
        LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
                        LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
 
-       location_function = container_of(location,
-                       struct lttng_userspace_probe_location_function,
-                       parent);
+       location_function = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_function::parent);
        if (!location_function->function_name || !location_function->binary_path) {
                ret = -LTTNG_ERR_INVALID;
                goto end;
@@ -1098,9 +1094,8 @@ int lttng_userspace_probe_location_tracepoint_serialize(
        LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
                        LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
 
-       location_tracepoint = container_of(location,
-                       struct lttng_userspace_probe_location_tracepoint,
-                       parent);
+       location_tracepoint = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_tracepoint::parent);
        if (!location_tracepoint->probe_name ||
                        !location_tracepoint->provider_name ||
                        !location_tracepoint->binary_path) {
@@ -1568,8 +1563,8 @@ int lttng_userspace_probe_location_function_set_binary_fd_handle(
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
 
-       function_location = container_of(location,
-                       struct lttng_userspace_probe_location_function, parent);
+       function_location = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_function::parent);
        fd_handle_put(function_location->binary_fd_handle);
        fd_handle_get(binary_fd);
        function_location->binary_fd_handle = binary_fd;
@@ -1587,8 +1582,8 @@ int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
        LTTNG_ASSERT(location);
        LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
 
-       tracepoint_location = container_of(location,
-                       struct lttng_userspace_probe_location_tracepoint, parent);
+       tracepoint_location = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_tracepoint::parent);
        fd_handle_put(tracepoint_location->binary_fd_handle);
        fd_handle_get(binary_fd);
        tracepoint_location->binary_fd_handle = binary_fd;
@@ -1617,9 +1612,8 @@ int lttng_userspace_probe_location_function_flatten(
                goto end;
        }
 
-       probe_function = container_of(location,
-                       struct lttng_userspace_probe_location_function,
-                       parent);
+       probe_function = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_function::parent);
        LTTNG_ASSERT(probe_function->function_name);
        LTTNG_ASSERT(probe_function->binary_path);
 
@@ -1741,9 +1735,8 @@ int lttng_userspace_probe_location_tracepoint_flatten(
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
-       probe_tracepoint = container_of(location,
-                       struct lttng_userspace_probe_location_tracepoint,
-                       parent);
+       probe_tracepoint = lttng::utils::container_of(location,
+                       &lttng_userspace_probe_location_tracepoint::parent);
        LTTNG_ASSERT(probe_tracepoint->probe_name);
        LTTNG_ASSERT(probe_tracepoint->provider_name);
        LTTNG_ASSERT(probe_tracepoint->binary_path);
index 106b8fb489947be591f31e6e44ab863f815ee9d3..3f1848a809c051d03a4571401cca436c8216b583 100644 (file)
@@ -487,9 +487,8 @@ lttng_rotation_schedule_size_threshold_get_threshold(
                goto end;
        }
 
-       size_schedule = container_of(schedule,
-                       struct lttng_rotation_schedule_size_threshold,
-                       parent);
+       size_schedule = lttng::utils::container_of(schedule,
+                       &lttng_rotation_schedule_size_threshold::parent);
        if (size_schedule->size.set) {
                *size_threshold_bytes = size_schedule->size.bytes;
        } else {
@@ -515,9 +514,8 @@ lttng_rotation_schedule_size_threshold_set_threshold(
                goto end;
        }
 
-       size_schedule = container_of(schedule,
-                       struct lttng_rotation_schedule_size_threshold,
-                       parent);
+       size_schedule = lttng::utils::container_of(schedule,
+                       &lttng_rotation_schedule_size_threshold::parent);
        size_schedule->size.bytes = size_threshold_bytes;
        size_schedule->size.set = true;
 end:
@@ -553,9 +551,8 @@ lttng_rotation_schedule_periodic_get_period(
                goto end;
        }
 
-       periodic_schedule = container_of(schedule,
-                       struct lttng_rotation_schedule_periodic,
-                       parent);
+       periodic_schedule = lttng::utils::container_of(schedule,
+                       &lttng_rotation_schedule_periodic::parent);
        if (periodic_schedule->period.set) {
                *period_us = periodic_schedule->period.us;
        } else {
@@ -580,9 +577,8 @@ lttng_rotation_schedule_periodic_set_period(
                goto end;
        }
 
-       periodic_schedule = container_of(schedule,
-                       struct lttng_rotation_schedule_periodic,
-                       parent);
+       periodic_schedule = lttng::utils::container_of(schedule,
+                       &lttng_rotation_schedule_periodic::parent);
        periodic_schedule->period.us = period_us;
        periodic_schedule->period.set = true;
 end:
This page took 0.122977 seconds and 4 git commands to generate.