- Move internal fields to struct lttng_ust_channel_ops_private.
- Add private/public relationships between the two structures.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id8018d8e11df6db569e20fffb6f2ed08e47c452e
struct lttng_ust_lib_ring_buffer_channel;
struct lttng_ust_shm_handle;
+struct lttng_ust_channel_ops_private;
/*
* IMPORTANT: this structure is part of the ABI between the probe and
struct lttng_ust_channel_ops {
uint32_t struct_size;
- struct lttng_channel *(*channel_create)(const char *name,
- void *buf_addr,
- size_t subbuf_size, size_t num_subbuf,
- unsigned int switch_timer_interval,
- unsigned int read_timer_interval,
- unsigned char *uuid,
- uint32_t chan_id,
- const int *stream_fds, int nr_stream_fds,
- int64_t blocking_timeout);
- void (*channel_destroy)(struct lttng_channel *chan);
+ struct lttng_ust_channel_ops_private *priv; /* Private channel ops interface */
+
int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
uint32_t event_id);
void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
const void *src, size_t len);
- /*
- * packet_avail_size returns the available size in the current
- * packet. Note that the size returned is only a hint, since it
- * may change due to concurrent writes.
- */
- size_t (*packet_avail_size)(struct lttng_ust_lib_ring_buffer_channel *chan,
- struct lttng_ust_shm_handle *handle);
- int (*is_finalized)(struct lttng_ust_lib_ring_buffer_channel *chan);
- int (*is_disabled)(struct lttng_ust_lib_ring_buffer_channel *chan);
- int (*flush_buffer)(struct lttng_ust_lib_ring_buffer_channel *chan,
- struct lttng_ust_shm_handle *handle);
void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
const char *src, size_t len);
if (!chan)
return NULL;
- chan->chan = transport->ops.channel_create(transport_name, NULL,
+ chan->chan = transport->ops.priv->channel_create(transport_name, NULL,
attr->subbuf_size, attr->num_subbuf,
attr->switch_timer_interval,
attr->read_timer_interval,
{
(void) ustctl_channel_close_wait_fd(chan);
(void) ustctl_channel_close_wakeup_fd(chan);
- chan->chan->ops->channel_destroy(chan->chan);
+ chan->chan->ops->priv->channel_destroy(chan->chan);
free(chan);
}
for (pos = 0; pos < len; pos += reserve_len) {
reserve_len = min_t(size_t,
- chan->ops->packet_avail_size(chan->chan, chan->handle),
+ chan->ops->priv->packet_avail_size(chan->chan, chan->handle),
len - pos);
lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len,
sizeof(char), -1, chan->handle);
int ret;
reserve_len = min_t(ssize_t,
- chan->ops->packet_avail_size(chan->chan, chan->handle),
+ chan->ops->priv->packet_avail_size(chan->chan, chan->handle),
len);
lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len,
sizeof(char), -1, chan->handle);
.name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap",
.ops = {
.struct_size = sizeof(struct lttng_ust_channel_ops),
- .channel_create = _channel_create,
- .channel_destroy = lttng_channel_destroy,
+ .priv = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_channel_ops_private, {
+ .pub = <tng_relay_transport.ops,
+ .channel_create = _channel_create,
+ .channel_destroy = lttng_channel_destroy,
+ .packet_avail_size = NULL, /* Would be racy anyway */
+ .is_finalized = lttng_is_finalized,
+ .is_disabled = lttng_is_disabled,
+ .flush_buffer = lttng_flush_buffer,
+ }),
.event_reserve = lttng_event_reserve,
.event_commit = lttng_event_commit,
.event_write = lttng_event_write,
- .packet_avail_size = NULL, /* Would be racy anyway */
- .is_finalized = lttng_is_finalized,
- .is_disabled = lttng_is_disabled,
- .flush_buffer = lttng_flush_buffer,
.event_strcpy = lttng_event_strcpy,
},
.client_config = &client_config,
.ops = {
.struct_size = sizeof(struct lttng_ust_channel_ops),
- .channel_create = _channel_create,
- .channel_destroy = lttng_channel_destroy,
+ .priv = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_channel_ops_private, {
+ .pub = <tng_relay_transport.ops,
+ .channel_create = _channel_create,
+ .channel_destroy = lttng_channel_destroy,
+ .packet_avail_size = lttng_packet_avail_size,
+ .is_finalized = lttng_is_finalized,
+ .is_disabled = lttng_is_disabled,
+ .flush_buffer = lttng_flush_buffer,
+ }),
.event_reserve = lttng_event_reserve,
.event_commit = lttng_event_commit,
.event_write = lttng_event_write,
- .packet_avail_size = lttng_packet_avail_size,
- .is_finalized = lttng_is_finalized,
- .is_disabled = lttng_is_disabled,
- .flush_buffer = lttng_flush_buffer,
},
.client_config = &client_config,
};
case LTTNG_UST_ABI_DISABLE:
return lttng_channel_disable(channel);
case LTTNG_UST_ABI_FLUSH_BUFFER:
- return channel->ops->flush_buffer(channel->chan, channel->handle);
+ return channel->ops->priv->flush_buffer(channel->chan, channel->handle);
default:
return -EINVAL;
}
uint64_t id; /* Enumeration ID in sessiond */
};
+struct lttng_ust_channel_ops_private {
+ struct lttng_ust_channel_ops *pub; /* Public channels ops interface */
+
+ struct lttng_channel *(*channel_create)(const char *name,
+ void *buf_addr,
+ size_t subbuf_size, size_t num_subbuf,
+ unsigned int switch_timer_interval,
+ unsigned int read_timer_interval,
+ unsigned char *uuid,
+ uint32_t chan_id,
+ const int *stream_fds, int nr_stream_fds,
+ int64_t blocking_timeout);
+ void (*channel_destroy)(struct lttng_channel *chan);
+ /*
+ * packet_avail_size returns the available size in the current
+ * packet. Note that the size returned is only a hint, since it
+ * may change due to concurrent writes.
+ */
+ size_t (*packet_avail_size)(struct lttng_ust_lib_ring_buffer_channel *chan,
+ struct lttng_ust_shm_handle *handle);
+ int (*is_finalized)(struct lttng_ust_lib_ring_buffer_channel *chan);
+ int (*is_disabled)(struct lttng_ust_lib_ring_buffer_channel *chan);
+ int (*flush_buffer)(struct lttng_ust_lib_ring_buffer_channel *chan,
+ struct lttng_ust_shm_handle *handle);
+};
+
static inline
struct lttng_enabler *lttng_event_enabler_as_enabler(
struct lttng_event_enabler *event_enabler)