X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-vegid.c;h=ca0555e3d099ab879cd298e037a56c1796b14a77;hb=7489fcb466935b3eeb36e99afbbb87188278cb91;hp=436b566ad12b418494cd9c6e4cd6aae0c8dcff68;hpb=fc80554e0cd4c7739c64fe8bc8b87a77d3c19d07;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-vegid.c b/liblttng-ust/lttng-context-vegid.c index 436b566a..ca0555e3 100644 --- a/liblttng-ust/lttng-context-vegid.c +++ b/liblttng-ust/lttng-context-vegid.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include "context-internal.h" #include "creds.h" @@ -61,7 +61,7 @@ void lttng_context_vegid_reset(void) } static -size_t vegid_get_size(struct lttng_ctx_field *field, size_t offset) +size_t vegid_get_size(struct lttng_ust_ctx_field *field, size_t offset) { size_t size = 0; @@ -71,9 +71,9 @@ size_t vegid_get_size(struct lttng_ctx_field *field, size_t offset) } static -void vegid_record(struct lttng_ctx_field *field, +void vegid_record(struct lttng_ust_ctx_field *field, struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan) + struct lttng_ust_channel_buffer *chan) { gid_t vegid; @@ -83,34 +83,49 @@ void vegid_record(struct lttng_ctx_field *field, } static -void vegid_get_value(struct lttng_ctx_field *field, - struct lttng_ctx_value *value) +void vegid_get_value(struct lttng_ust_ctx_field *field, + struct lttng_ust_ctx_value *value) { value->u.s64 = get_vegid(); } -int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx) +int lttng_add_vegid_to_ctx(struct lttng_ust_ctx **ctx) { - struct lttng_ctx_field *field; - - field = lttng_append_context(ctx); - if (!field) + struct lttng_ust_ctx_field *field; + struct lttng_ust_type_common *type; + int ret; + + type = lttng_ust_create_type_integer(sizeof(gid_t) * CHAR_BIT, + lttng_alignof(gid_t) * CHAR_BIT, + lttng_is_signed_type(gid_t), + BYTE_ORDER, 10); + if (!type) return -ENOMEM; + field = lttng_append_context(ctx); + if (!field) { + ret = -ENOMEM; + goto error_context; + } if (lttng_find_context(*ctx, "vegid")) { - lttng_remove_context_field(ctx, field); - return -EEXIST; + ret = -EEXIST; + goto error_find_context; + } + field->event_field->name = strdup("vegid"); + if (!field->event_field->name) { + ret = -ENOMEM; + goto error_name; } - field->event_field.name = "vegid"; - field->event_field.type.atype = atype_integer; - field->event_field.type.u.integer.size = sizeof(gid_t) * CHAR_BIT; - field->event_field.type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT; - field->event_field.type.u.integer.signedness = lttng_is_signed_type(gid_t); - field->event_field.type.u.integer.reverse_byte_order = 0; - field->event_field.type.u.integer.base = 10; - field->event_field.type.u.integer.encoding = lttng_encode_none; + field->event_field->type = type; field->get_size = vegid_get_size; field->record = vegid_record; field->get_value = vegid_get_value; lttng_context_update(*ctx); return 0; + +error_name: +error_find_context: + lttng_remove_context_field(ctx, field); +error_context: + lttng_ust_destroy_type(type); + return ret; }