SoW-2020-0002: Trace Hit Counters
[deliverable/lttng-ust.git] / libcounter / counter.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * LTTng Counters API
7 */
8
9 #ifndef _LTTNG_COUNTER_H
10 #define _LTTNG_COUNTER_H
11
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <lttng/ust-config.h>
15 #include "counter-types.h"
16 #include "helper.h"
17
18 /* max_nr_elem is for each dimension. */
19 LTTNG_HIDDEN
20 struct lib_counter *lttng_counter_create(const struct lib_counter_config *config,
21 size_t nr_dimensions,
22 const size_t *max_nr_elem,
23 int64_t global_sum_step,
24 int global_counter_fd,
25 int nr_counter_cpu_fds,
26 const int *counter_cpu_fds,
27 bool is_daemon);
28 LTTNG_HIDDEN
29 void lttng_counter_destroy(struct lib_counter *counter);
30
31 LTTNG_HIDDEN
32 int lttng_counter_set_global_shm(struct lib_counter *counter, int fd);
33 LTTNG_HIDDEN
34 int lttng_counter_set_cpu_shm(struct lib_counter *counter, int cpu, int fd);
35
36 LTTNG_HIDDEN
37 int lttng_counter_get_global_shm(struct lib_counter *counter, int *fd, size_t *len);
38 LTTNG_HIDDEN
39 int lttng_counter_get_cpu_shm(struct lib_counter *counter, int cpu, int *fd, size_t *len);
40
41 /*
42 * Has counter received all expected shm ?
43 */
44 LTTNG_HIDDEN
45 bool lttng_counter_ready(struct lib_counter *counter);
46
47 LTTNG_HIDDEN
48 int lttng_counter_read(const struct lib_counter_config *config,
49 struct lib_counter *counter,
50 const size_t *dimension_indexes,
51 int cpu, int64_t *value,
52 bool *overflow, bool *underflow);
53 LTTNG_HIDDEN
54 int lttng_counter_aggregate(const struct lib_counter_config *config,
55 struct lib_counter *counter,
56 const size_t *dimension_indexes,
57 int64_t *value,
58 bool *overflow, bool *underflow);
59 LTTNG_HIDDEN
60 int lttng_counter_clear(const struct lib_counter_config *config,
61 struct lib_counter *counter,
62 const size_t *dimension_indexes);
63
64 #endif /* _LTTNG_COUNTER_H */
This page took 0.036298 seconds and 5 git commands to generate.