b193fb3a99f6e465060583cecca0614f1e949758
[lttng-ust.git] / libcounter / counter-types.h
1 /*
2 * counter/counter-types.h
3 *
4 * LTTng Counters Types
5 *
6 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 #ifndef _LTTNG_COUNTER_TYPES_H
28 #define _LTTNG_COUNTER_TYPES_H
29
30 #include <stdint.h>
31 #include <stddef.h>
32 #include <stdbool.h>
33 #include <sys/types.h>
34 #include <lttng/counter-config.h>
35 #include <lttng/ust-config.h>
36 #include "shm_types.h"
37
38 struct lib_counter_dimension {
39 /*
40 * Max. number of indexable elements.
41 */
42 size_t max_nr_elem;
43 /*
44 * The stride for a dimension is the multiplication factor which
45 * should be applied to its index to take into account other
46 * dimensions nested inside.
47 */
48 size_t stride;
49 };
50
51 struct lib_counter_layout {
52 void *counters;
53 unsigned long *overflow_bitmap;
54 unsigned long *underflow_bitmap;
55 int shm_fd;
56 size_t shm_len;
57 struct lttng_counter_shm_handle handle;
58 };
59
60 enum lib_counter_arithmetic {
61 LIB_COUNTER_ARITHMETIC_MODULAR,
62 LIB_COUNTER_ARITHMETIC_SATURATE,
63 };
64
65 struct lib_counter {
66 size_t nr_dimensions;
67 int64_t allocated_elem;
68 struct lib_counter_dimension *dimensions;
69 enum lib_counter_arithmetic arithmetic;
70 union {
71 struct {
72 int32_t max, min;
73 } limits_32_bit;
74 struct {
75 int64_t max, min;
76 } limits_64_bit;
77 } saturation;
78 union {
79 int8_t s8;
80 int16_t s16;
81 int32_t s32;
82 int64_t s64;
83 } global_sum_step; /* 0 if unused */
84 struct lib_counter_config config;
85
86 struct lib_counter_layout global_counters;
87 struct lib_counter_layout *percpu_counters;
88
89 bool is_daemon;
90 struct lttng_counter_shm_object_table *object_table;
91 };
92
93 #endif /* _LTTNG_COUNTER_TYPES_H */
This page took 0.030359 seconds and 3 git commands to generate.