X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Fust-core.c;h=2633832b801bab42ad311b73ab23752449d77caf;hb=4e48b5d;hp=0b1fcf0b787724781e3dc855f00b41e6393e1ed1;hpb=a084756d092167324ee09d3f819cc45407b58233;p=lttng-ust.git diff --git a/liblttng-ust/ust-core.c b/liblttng-ust/ust-core.c index 0b1fcf0b..2633832b 100644 --- a/liblttng-ust/ust-core.c +++ b/liblttng-ust/ust-core.c @@ -9,9 +9,12 @@ #include #include +#include "context-internal.h" #include "ust-events-internal.h" #include #include "lttng-tracer-core.h" +#include "lttng-rb-clients.h" +#include "lttng-counter-client.h" #include "jhash.h" static CDS_LIST_HEAD(lttng_transport_list); @@ -87,7 +90,7 @@ void lttng_counter_transport_unregister(struct lttng_counter_transport *transpor * Needed by comm layer. */ struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session, - struct lttng_ust_enum_desc *enum_desc) + const struct lttng_ust_enum_desc *enum_desc) { struct lttng_enum *_enum; struct cds_hlist_head *head; @@ -105,26 +108,26 @@ struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *sessio return NULL; } -size_t lttng_ust_dummy_get_size(struct lttng_ust_ctx_field *field, size_t offset) +size_t lttng_ust_dummy_get_size(void *priv __attribute__((unused)), + size_t offset) { size_t size = 0; - size += lib_ring_buffer_align(offset, lttng_alignof(char)); + size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(char)); size += sizeof(char); /* tag */ return size; } -void lttng_ust_dummy_record(struct lttng_ust_ctx_field *field, +void lttng_ust_dummy_record(void *priv __attribute__((unused)), struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan) + struct lttng_ust_channel_buffer *chan) { char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE; - lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char)); - chan->ops->event_write(ctx, &sel_char, sizeof(sel_char)); + chan->ops->event_write(ctx, &sel_char, sizeof(sel_char), lttng_ust_rb_alignof(sel_char)); } -void lttng_ust_dummy_get_value(struct lttng_ust_ctx_field *field, +void lttng_ust_dummy_get_value(void *priv __attribute__((unused)), struct lttng_ust_ctx_value *value) { value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE; @@ -137,3 +140,86 @@ int lttng_context_is_app(const char *name) } return 1; } + +struct lttng_ust_channel_buffer *lttng_ust_alloc_channel_buffer(void) +{ + struct lttng_ust_channel_buffer *lttng_chan_buf; + struct lttng_ust_channel_common *lttng_chan_common; + struct lttng_ust_channel_buffer_private *lttng_chan_buf_priv; + + lttng_chan_buf = zmalloc(sizeof(struct lttng_ust_channel_buffer)); + if (!lttng_chan_buf) + goto lttng_chan_buf_error; + lttng_chan_buf->struct_size = sizeof(struct lttng_ust_channel_buffer); + lttng_chan_common = zmalloc(sizeof(struct lttng_ust_channel_common)); + if (!lttng_chan_common) + goto lttng_chan_common_error; + lttng_chan_common->struct_size = sizeof(struct lttng_ust_channel_common); + lttng_chan_buf_priv = zmalloc(sizeof(struct lttng_ust_channel_buffer_private)); + if (!lttng_chan_buf_priv) + goto lttng_chan_buf_priv_error; + lttng_chan_buf->parent = lttng_chan_common; + lttng_chan_common->type = LTTNG_UST_CHANNEL_TYPE_BUFFER; + lttng_chan_common->child = lttng_chan_buf; + lttng_chan_buf->priv = lttng_chan_buf_priv; + lttng_chan_common->priv = <tng_chan_buf_priv->parent; + lttng_chan_buf_priv->pub = lttng_chan_buf; + lttng_chan_buf_priv->parent.pub = lttng_chan_common; + + return lttng_chan_buf; + +lttng_chan_buf_priv_error: + free(lttng_chan_common); +lttng_chan_common_error: + free(lttng_chan_buf); +lttng_chan_buf_error: + return NULL; +} + +void lttng_ust_free_channel_common(struct lttng_ust_channel_common *chan) +{ + switch (chan->type) { + case LTTNG_UST_CHANNEL_TYPE_BUFFER: + { + struct lttng_ust_channel_buffer *chan_buf; + + chan_buf = (struct lttng_ust_channel_buffer *)chan->child; + free(chan_buf->parent); + free(chan_buf->priv); + free(chan_buf); + break; + } + default: + abort(); + } +} + +void lttng_ust_ring_buffer_clients_init(void) +{ + lttng_ring_buffer_metadata_client_init(); + lttng_ring_buffer_client_overwrite_init(); + lttng_ring_buffer_client_overwrite_rt_init(); + lttng_ring_buffer_client_discard_init(); + lttng_ring_buffer_client_discard_rt_init(); +} + +void lttng_ust_ring_buffer_clients_exit(void) +{ + lttng_ring_buffer_client_discard_rt_exit(); + lttng_ring_buffer_client_discard_exit(); + lttng_ring_buffer_client_overwrite_rt_exit(); + lttng_ring_buffer_client_overwrite_exit(); + lttng_ring_buffer_metadata_client_exit(); +} + +void lttng_ust_counter_clients_init(void) +{ + lttng_counter_client_percpu_64_modular_init(); + lttng_counter_client_percpu_32_modular_init(); +} + +void lttng_ust_counter_clients_exit(void) +{ + lttng_counter_client_percpu_32_modular_exit(); + lttng_counter_client_percpu_64_modular_exit(); +}