Commit | Line | Data |
---|---|---|
a58c490f | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
a58c490f | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
a58c490f | 5 | * |
a58c490f JG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_CONDITION_INTERNAL_H | |
9 | #define LTTNG_CONDITION_INTERNAL_H | |
10 | ||
11 | #include <lttng/condition/condition.h> | |
12 | #include <common/macros.h> | |
9e620ea7 JG |
13 | #include <common/payload-view.h> |
14 | #include <common/payload.h> | |
a58c490f JG |
15 | #include <stdbool.h> |
16 | #include <urcu/list.h> | |
4655b864 | 17 | #include <urcu/ref.h> |
a58c490f | 18 | #include <stdint.h> |
3897deca | 19 | #include <sys/types.h> |
a58c490f JG |
20 | |
21 | typedef void (*condition_destroy_cb)(struct lttng_condition *condition); | |
22 | typedef bool (*condition_validate_cb)(const struct lttng_condition *condition); | |
3647288f JG |
23 | typedef int (*condition_serialize_cb)( |
24 | const struct lttng_condition *condition, | |
c0a66c84 | 25 | struct lttng_payload *payload); |
a58c490f JG |
26 | typedef bool (*condition_equal_cb)(const struct lttng_condition *a, |
27 | const struct lttng_condition *b); | |
c0a66c84 JG |
28 | typedef ssize_t (*condition_create_from_payload_cb)( |
29 | struct lttng_payload_view *view, | |
a58c490f JG |
30 | struct lttng_condition **condition); |
31 | ||
32 | struct lttng_condition { | |
4655b864 JR |
33 | /* Reference counting is only exposed to internal users. */ |
34 | struct urcu_ref ref; | |
a58c490f JG |
35 | enum lttng_condition_type type; |
36 | condition_validate_cb validate; | |
37 | condition_serialize_cb serialize; | |
38 | condition_equal_cb equal; | |
39 | condition_destroy_cb destroy; | |
40 | }; | |
41 | ||
42 | struct lttng_condition_comm { | |
43 | /* enum lttng_condition_type */ | |
44 | int8_t condition_type; | |
45 | char payload[]; | |
46 | }; | |
47 | ||
4655b864 JR |
48 | LTTNG_HIDDEN |
49 | void lttng_condition_get(struct lttng_condition *condition); | |
50 | ||
51 | LTTNG_HIDDEN | |
52 | void lttng_condition_put(struct lttng_condition *condition); | |
53 | ||
a58c490f JG |
54 | LTTNG_HIDDEN |
55 | void lttng_condition_init(struct lttng_condition *condition, | |
56 | enum lttng_condition_type type); | |
57 | ||
58 | LTTNG_HIDDEN | |
59 | bool lttng_condition_validate(const struct lttng_condition *condition); | |
60 | ||
61 | LTTNG_HIDDEN | |
c0a66c84 JG |
62 | ssize_t lttng_condition_create_from_payload( |
63 | struct lttng_payload_view *view, | |
a58c490f JG |
64 | struct lttng_condition **condition); |
65 | ||
66 | LTTNG_HIDDEN | |
3647288f | 67 | int lttng_condition_serialize(const struct lttng_condition *condition, |
c0a66c84 | 68 | struct lttng_payload *payload); |
a58c490f JG |
69 | |
70 | LTTNG_HIDDEN | |
71 | bool lttng_condition_is_equal(const struct lttng_condition *a, | |
72 | const struct lttng_condition *b); | |
73 | ||
0de2479d SM |
74 | LTTNG_HIDDEN |
75 | const char *lttng_condition_type_str(enum lttng_condition_type type); | |
76 | ||
a58c490f | 77 | #endif /* LTTNG_CONDITION_INTERNAL_H */ |