Commit | Line | Data |
---|---|---|
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 | 15 | #include <lttng/ust-events.h> |
53569322 | 16 | |
9d315d6d | 17 | #include "common/dynamic-type.h" |
fa194c41 | 18 | |
4e48b5d2 MD |
19 | struct lttng_ust_registered_context_provider; |
20 | ||
daacdbfc MD |
21 | /* |
22 | * Context value | |
23 | * | |
24 | * IMPORTANT: this structure is part of the ABI between the probe and | |
35c1f459 MD |
25 | * UST. Additional selectors may be added in the future, mapping to new |
26 | * union fields, which means the overall size of this structure may | |
27 | * increase. This means this structure should never be nested within a | |
28 | * public structure interface, nor embedded in an array. | |
daacdbfc MD |
29 | */ |
30 | ||
31 | struct lttng_ust_ctx_value { | |
35c1f459 | 32 | enum lttng_ust_dynamic_type sel; /* Type selector */ |
fa194c41 MJ |
33 | union { |
34 | int64_t s64; | |
35 | uint64_t u64; | |
36 | const char *str; | |
37 | double d; | |
38 | } u; | |
39 | }; | |
40 | ||
daacdbfc MD |
41 | /* |
42 | * Context provider | |
43 | * | |
44 | * IMPORTANT: this structure is part of the ABI between the probe and | |
45 | * UST. Fields need to be only added at the end, never reordered, never | |
46 | * removed. | |
47 | * | |
48 | * The field @struct_size should be used to determine the size of the | |
49 | * structure. It should be queried before using additional fields added | |
50 | * at the end of the structure. | |
51 | */ | |
52 | ||
53569322 | 53 | struct lttng_ust_context_provider { |
daacdbfc MD |
54 | uint32_t struct_size; |
55 | ||
4e48b5d2 MD |
56 | const char *name; |
57 | size_t (*get_size)(void *priv, size_t offset); | |
58 | void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx, | |
e7bc0ef6 | 59 | struct lttng_ust_channel_buffer *chan); |
4e48b5d2 MD |
60 | void (*get_value)(void *priv, struct lttng_ust_ctx_value *value); |
61 | void *priv; | |
daacdbfc MD |
62 | |
63 | /* End of base ABI. Fields below should be used after checking struct_size. */ | |
53569322 MD |
64 | }; |
65 | ||
4e48b5d2 MD |
66 | /* |
67 | * Returns an opaque pointer on success, which must be passed to | |
68 | * lttng_ust_context_provider_unregister for unregistration. Returns | |
69 | * NULL on error. | |
70 | */ | |
71 | struct lttng_ust_registered_context_provider *lttng_ust_context_provider_register(struct lttng_ust_context_provider *provider); | |
53569322 | 72 | |
4e48b5d2 | 73 | void lttng_ust_context_provider_unregister(struct lttng_ust_registered_context_provider *reg_provider); |
53569322 MD |
74 | |
75 | #endif /* _LTTNG_UST_CONTEXT_PROVIDER_H */ |