/*
- * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
- * 2016 - EfficiOS Inc., Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * SPDX-License-Identifier: LGPL-2.1-only
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (C) 2016 EfficiOS Inc.
+ * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com>
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
#include "org_lttng_ust_agent_context_LttngContextApi.h"
#include <string.h>
#include <inttypes.h>
#include <lttng/ust-events.h>
-#include <lttng/ringbuffer-config.h>
-#include <lttng/ust-context-provider.h>
+#include <lttng/ringbuffer-context.h>
+#include <ust-context-provider.h>
-#include "helper.h"
+#include "ust-helper.h"
#include "lttng_ust_context.h"
enum lttng_ust_jni_type {
return NULL;
}
-static size_t get_size_cb(struct lttng_ctx_field *field, size_t offset)
+static size_t get_size_cb(struct lttng_ust_ctx_field *field, size_t offset)
{
struct lttng_ust_jni_ctx_entry *jctx;
size_t size = 0;
- const char *ctx_name = field->event_field.name;
+ const char *ctx_name = field->event_field->name;
enum lttng_ust_jni_type jni_type;
- 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 */
jctx = lookup_ctx_by_name(ctx_name);
if (!jctx) {
case JNI_TYPE_NULL:
break;
case JNI_TYPE_INTEGER:
- size += lib_ring_buffer_align(offset, lttng_alignof(int32_t));
+ size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(int32_t));
size += sizeof(int32_t); /* variant */
break;
case JNI_TYPE_LONG:
- size += lib_ring_buffer_align(offset, lttng_alignof(int64_t));
+ size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(int64_t));
size += sizeof(int64_t); /* variant */
break;
case JNI_TYPE_DOUBLE:
- size += lib_ring_buffer_align(offset, lttng_alignof(double));
+ size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(double));
size += sizeof(double); /* variant */
break;
case JNI_TYPE_FLOAT:
- size += lib_ring_buffer_align(offset, lttng_alignof(float));
+ size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(float));
size += sizeof(float); /* variant */
break;
case JNI_TYPE_SHORT:
- size += lib_ring_buffer_align(offset, lttng_alignof(int16_t));
+ size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(int16_t));
size += sizeof(int16_t); /* variant */
break;
case JNI_TYPE_BYTE: /* Fall-through. */
case JNI_TYPE_BOOLEAN:
- 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); /* variant */
break;
case JNI_TYPE_STRING:
}
-static void record_cb(struct lttng_ctx_field *field,
+static void record_cb(struct lttng_ust_ctx_field *field,
struct lttng_ust_lib_ring_buffer_ctx *ctx,
- struct lttng_channel *chan)
+ struct lttng_ust_channel_buffer *lttng_chan_buf)
{
struct lttng_ust_jni_ctx_entry *jctx;
- const char *ctx_name = field->event_field.name;
+ const char *ctx_name = field->event_field->name;
enum lttng_ust_jni_type jni_type;
char sel_char;
switch (jni_type) {
case JNI_TYPE_NULL:
sel_char = LTTNG_UST_DYNAMIC_TYPE_NONE;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
break;
case JNI_TYPE_INTEGER:
{
int32_t v = jctx->value._integer;
sel_char = LTTNG_UST_DYNAMIC_TYPE_S32;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_LONG:
int64_t v = jctx->value._long;
sel_char = LTTNG_UST_DYNAMIC_TYPE_S64;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_DOUBLE:
double v = jctx->value._double;
sel_char = LTTNG_UST_DYNAMIC_TYPE_DOUBLE;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_FLOAT:
float v = jctx->value._float;
sel_char = LTTNG_UST_DYNAMIC_TYPE_FLOAT;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_SHORT:
int16_t v = jctx->value._short;
sel_char = LTTNG_UST_DYNAMIC_TYPE_S16;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_BYTE:
char v = jctx->value._byte;
sel_char = LTTNG_UST_DYNAMIC_TYPE_S8;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_BOOLEAN:
char v = jctx->value._boolean;
sel_char = LTTNG_UST_DYNAMIC_TYPE_S8;
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(v));
+ lttng_chan_buf->ops->event_write(ctx, &v, sizeof(v));
break;
}
case JNI_TYPE_STRING:
} else {
sel_char = LTTNG_UST_DYNAMIC_TYPE_NONE;
}
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ lttng_ust_lib_ring_buffer_align_ctx(ctx, lttng_ust_rb_alignof(char));
+ lttng_chan_buf->ops->event_write(ctx, &sel_char, sizeof(sel_char));
if (str) {
- chan->ops->event_write(ctx, str, strlen(str) + 1);
+ lttng_chan_buf->ops->event_write(ctx, str, strlen(str) + 1);
}
break;
}
}
}
-static void get_value_cb(struct lttng_ctx_field *field,
- struct lttng_ctx_value *value)
+static void get_value_cb(struct lttng_ust_ctx_field *field,
+ struct lttng_ust_ctx_value *value)
{
struct lttng_ust_jni_ctx_entry *jctx;
- const char *ctx_name = field->event_field.name;
+ const char *ctx_name = field->event_field->name;
enum lttng_ust_jni_type jni_type;
jctx = lookup_ctx_by_name(ctx_name);
if (!provider) {
goto error_provider;
}
+ provider->struct_size = sizeof(*provider);
provider->name = provider_name_cstr;
provider->get_size = get_size_cb;
provider->record = record_cb;