Refactoring: remove struct_size from struct lttng_ust_ctx_value
[lttng-ust.git] / include / ust-context-provider.h
CommitLineData
53569322 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
53569322 3 *
c0c0989a 4 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
28b9540b
MJ
5 *
6 * The context provider feature is part of the ABI and used by the Java jni
7 * interface. This header should be moved to the public header directory once
8 * some test code and documentation is written.
53569322
MD
9 */
10
c0c0989a
MJ
11#ifndef _LTTNG_UST_CONTEXT_PROVIDER_H
12#define _LTTNG_UST_CONTEXT_PROVIDER_H
13
b4051ad8 14#include <stddef.h>
53569322
MD
15#include <lttng/ust-events.h>
16#include <urcu/hlist.h>
17
fa194c41
MJ
18#include "ust-dynamic-type.h"
19
daacdbfc
MD
20/*
21 * Context value
22 *
23 * IMPORTANT: this structure is part of the ABI between the probe and
35c1f459
MD
24 * UST. Additional selectors may be added in the future, mapping to new
25 * union fields, which means the overall size of this structure may
26 * increase. This means this structure should never be nested within a
27 * public structure interface, nor embedded in an array.
daacdbfc
MD
28 */
29
30struct lttng_ust_ctx_value {
35c1f459 31 enum lttng_ust_dynamic_type sel; /* Type selector */
fa194c41
MJ
32 union {
33 int64_t s64;
34 uint64_t u64;
35 const char *str;
36 double d;
37 } u;
38};
39
daacdbfc
MD
40/*
41 * Context field
42 *
43 * IMPORTANT: this structure is part of the ABI between the probe and
44 * UST. Fields need to be only added at the end, never reordered, never
45 * removed.
46 *
47 * The field @struct_size should be used to determine the size of the
48 * structure. It should be queried before using additional fields added
49 * at the end of the structure.
50 */
51
52struct lttng_ust_ctx_field {
53 uint32_t struct_size;
54 void *priv;
fa194c41 55
daacdbfc
MD
56 struct lttng_ust_event_field *event_field;
57 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset);
58 void (*record)(struct lttng_ust_ctx_field *field,
fa194c41
MJ
59 struct lttng_ust_lib_ring_buffer_ctx *ctx,
60 struct lttng_channel *chan);
daacdbfc
MD
61 void (*get_value)(struct lttng_ust_ctx_field *field,
62 struct lttng_ust_ctx_value *value);
63 void (*destroy)(struct lttng_ust_ctx_field *field);
fa194c41 64 char *field_name; /* Has ownership, dynamically allocated. */
daacdbfc
MD
65
66 /* End of base ABI. Fields below should be used after checking struct_size. */
fa194c41
MJ
67};
68
daacdbfc
MD
69/*
70 * All context fields for a given event/channel
71 *
72 * IMPORTANT: this structure is part of the ABI between the probe and
73 * UST. Fields need to be only added at the end, never reordered, never
74 * removed.
75 *
76 * The field @struct_size should be used to determine the size of the
77 * structure. It should be queried before using additional fields added
78 * at the end of the structure.
79 */
80
81struct lttng_ust_ctx {
82 uint32_t struct_size;
83
84 struct lttng_ust_ctx_field **fields;
fa194c41
MJ
85 unsigned int nr_fields;
86 unsigned int allocated_fields;
87 unsigned int largest_align;
daacdbfc
MD
88
89 /* End of base ABI. Fields below should be used after checking struct_size. */
fa194c41
MJ
90};
91
daacdbfc
MD
92/*
93 * Context provider
94 *
95 * IMPORTANT: this structure is part of the ABI between the probe and
96 * UST. Fields need to be only added at the end, never reordered, never
97 * removed.
98 *
99 * The field @struct_size should be used to determine the size of the
100 * structure. It should be queried before using additional fields added
101 * at the end of the structure.
102 */
103
53569322 104struct lttng_ust_context_provider {
daacdbfc
MD
105 uint32_t struct_size;
106
53569322 107 char *name;
daacdbfc
MD
108 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset);
109 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
110 struct lttng_ust_lib_ring_buffer_ctx *ctx,
111 struct lttng_channel *chan);
daacdbfc
MD
112 void (*get_value)(struct lttng_ust_ctx_field *field,
113 struct lttng_ust_ctx_value *value);
53569322 114 struct cds_hlist_node node;
daacdbfc
MD
115
116 /* End of base ABI. Fields below should be used after checking struct_size. */
53569322
MD
117};
118
119int lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider);
120void lttng_ust_context_provider_unregister(struct lttng_ust_context_provider *provider);
121
53569322 122void lttng_ust_context_set_session_provider(const char *name,
daacdbfc
MD
123 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset),
124 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
125 struct lttng_ust_lib_ring_buffer_ctx *ctx,
126 struct lttng_channel *chan),
daacdbfc
MD
127 void (*get_value)(struct lttng_ust_ctx_field *field,
128 struct lttng_ust_ctx_value *value));
53569322 129
daacdbfc
MD
130int lttng_ust_add_app_context_to_ctx_rcu(const char *name, struct lttng_ust_ctx **ctx);
131int lttng_ust_context_set_provider_rcu(struct lttng_ust_ctx **_ctx,
53569322 132 const char *name,
daacdbfc
MD
133 size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset),
134 void (*record)(struct lttng_ust_ctx_field *field,
53569322
MD
135 struct lttng_ust_lib_ring_buffer_ctx *ctx,
136 struct lttng_channel *chan),
daacdbfc
MD
137 void (*get_value)(struct lttng_ust_ctx_field *field,
138 struct lttng_ust_ctx_value *value));
53569322
MD
139
140#endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */
This page took 0.033494 seconds and 4 git commands to generate.