Refactoring: type description structures
[lttng-modules.git] / src / lttng-context-interruptible.c
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
79150a49
JD
3 * lttng-context-interruptible.c
4 *
5 * LTTng interruptible context.
6 *
7 * Copyright (C) 2009-2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
79150a49
JD
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/sched.h>
13#include <linux/irqflags.h>
2df37e95 14#include <lttng/events.h>
437d5aa5 15#include <lttng/events-internal.h>
24591303 16#include <ringbuffer/frontend_types.h>
241ae9a8 17#include <wrapper/vmalloc.h>
2df37e95 18#include <lttng/tracer.h>
79150a49
JD
19
20/*
21 * Interruptible at value -1 means "unknown".
22 */
23
24static
25size_t interruptible_get_size(size_t offset)
26{
27 size_t size = 0;
28
29 size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
30 size += sizeof(int8_t);
31 return size;
32}
33
34static
437d5aa5 35void interruptible_record(struct lttng_kernel_ctx_field *field,
79150a49
JD
36 struct lib_ring_buffer_ctx *ctx,
37 struct lttng_channel *chan)
38{
39 struct lttng_probe_ctx *lttng_probe_ctx = ctx->priv;
40 int8_t interruptible = lttng_probe_ctx->interruptible;
41
42 lib_ring_buffer_align_ctx(ctx, lttng_alignof(interruptible));
43 chan->ops->event_write(ctx, &interruptible, sizeof(interruptible));
44}
45
46static
437d5aa5 47void interruptible_get_value(struct lttng_kernel_ctx_field *field,
79150a49
JD
48 struct lttng_probe_ctx *lttng_probe_ctx,
49 union lttng_ctx_value *value)
50{
51 int8_t interruptible = lttng_probe_ctx->interruptible;
52
53 value->s64 = interruptible;
54}
55
437d5aa5
MD
56static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
57 lttng_kernel_static_event_field("interruptible",
58 lttng_kernel_static_type_integer_from_type(int8_t, __BYTE_ORDER, 10),
59 false, false, false),
60 interruptible_get_size,
61 NULL,
62 interruptible_record,
63 interruptible_get_value,
64 NULL, NULL);
65
66int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx)
79150a49 67{
437d5aa5 68 int ret;
79150a49 69
437d5aa5 70 if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
79150a49 71 return -EEXIST;
437d5aa5 72 ret = lttng_kernel_context_append(ctx, ctx_field);
263b6c88 73 wrapper_vmalloc_sync_mappings();
437d5aa5 74 return ret;
79150a49
JD
75}
76EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx);
This page took 0.039574 seconds and 4 git commands to generate.