fix: media: v4l2: abstract timeval handling in v4l2_buffer (v5.6)
[lttng-modules.git] / lttng-context-interruptible.c
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-context-interruptible.c
4 *
5 * LTTng interruptible context.
6 *
7 * Copyright (C) 2009-2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include <linux/irqflags.h>
14 #include <lttng-events.h>
15 #include <wrapper/ringbuffer/frontend_types.h>
16 #include <wrapper/vmalloc.h>
17 #include <lttng-tracer.h>
18
19 /*
20 * Interruptible at value -1 means "unknown".
21 */
22
23 static
24 size_t interruptible_get_size(size_t offset)
25 {
26 size_t size = 0;
27
28 size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
29 size += sizeof(int8_t);
30 return size;
31 }
32
33 static
34 void interruptible_record(struct lttng_ctx_field *field,
35 struct lib_ring_buffer_ctx *ctx,
36 struct lttng_channel *chan)
37 {
38 struct lttng_probe_ctx *lttng_probe_ctx = ctx->priv;
39 int8_t interruptible = lttng_probe_ctx->interruptible;
40
41 lib_ring_buffer_align_ctx(ctx, lttng_alignof(interruptible));
42 chan->ops->event_write(ctx, &interruptible, sizeof(interruptible));
43 }
44
45 static
46 void interruptible_get_value(struct lttng_ctx_field *field,
47 struct lttng_probe_ctx *lttng_probe_ctx,
48 union lttng_ctx_value *value)
49 {
50 int8_t interruptible = lttng_probe_ctx->interruptible;
51
52 value->s64 = interruptible;
53 }
54
55 int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx)
56 {
57 struct lttng_ctx_field *field;
58
59 field = lttng_append_context(ctx);
60 if (!field)
61 return -ENOMEM;
62 if (lttng_find_context(*ctx, "interruptible")) {
63 lttng_remove_context_field(ctx, field);
64 return -EEXIST;
65 }
66 field->event_field.name = "interruptible";
67 field->event_field.type.atype = atype_integer;
68 field->event_field.type.u.basic.integer.size = sizeof(int8_t) * CHAR_BIT;
69 field->event_field.type.u.basic.integer.alignment = lttng_alignof(int8_t) * CHAR_BIT;
70 field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(int8_t);
71 field->event_field.type.u.basic.integer.reverse_byte_order = 0;
72 field->event_field.type.u.basic.integer.base = 10;
73 field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
74 field->get_size = interruptible_get_size;
75 field->record = interruptible_record;
76 field->get_value = interruptible_get_value;
77 lttng_context_update(*ctx);
78 wrapper_vmalloc_sync_all();
79 return 0;
80 }
81 EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx);
This page took 0.031159 seconds and 4 git commands to generate.