2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2009-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * LTTng UST pthread_id context.
13 #include <lttng/ust-events.h>
14 #include <lttng/ust-tracer.h>
15 #include <lttng/ringbuffer-context.h>
17 #include "context-internal.h"
20 size_t pthread_id_get_size(void *priv
__attribute__((unused
)),
25 size
+= lttng_ust_ring_buffer_align(offset
, lttng_ust_rb_alignof(unsigned long));
26 size
+= sizeof(unsigned long);
31 void pthread_id_record(void *priv
__attribute__((unused
)),
32 struct lttng_ust_ring_buffer_ctx
*ctx
,
33 struct lttng_ust_channel_buffer
*chan
)
35 unsigned long pthread_id
;
37 pthread_id
= (unsigned long) pthread_self();
38 chan
->ops
->event_write(ctx
, &pthread_id
, sizeof(pthread_id
), lttng_ust_rb_alignof(pthread_id
));
42 void pthread_id_get_value(void *priv
__attribute__((unused
)),
43 struct lttng_ust_ctx_value
*value
)
45 value
->u
.s64
= (unsigned long) pthread_self();
48 static const struct lttng_ust_ctx_field
*ctx_field
= lttng_ust_static_ctx_field(
49 lttng_ust_static_event_field("pthread_id",
50 lttng_ust_static_type_integer(sizeof(unsigned long) * CHAR_BIT
,
51 lttng_ust_rb_alignof(unsigned long) * CHAR_BIT
,
52 lttng_ust_is_signed_type(unsigned long),
60 int lttng_add_pthread_id_to_ctx(struct lttng_ust_ctx
**ctx
)
64 if (lttng_find_context(*ctx
, ctx_field
->event_field
->name
)) {
66 goto error_find_context
;
68 ret
= lttng_ust_context_append(ctx
, ctx_field
);