1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
3 * counter/counter-internal.h
5 * LTTng Counters Internal Header
7 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #ifndef _LTTNG_COUNTER_INTERNAL_H
11 #define _LTTNG_COUNTER_INTERNAL_H
13 #include <linux/types.h>
14 #include <linux/percpu.h>
15 #include <counter/counter-types.h>
16 #include <counter/config.h>
18 static inline int lttng_counter_validate_indexes(const struct lib_counter_config
*config
,
19 struct lib_counter
*counter
,
20 const size_t *dimension_indexes
)
22 size_t nr_dimensions
= counter
->nr_dimensions
, i
;
24 for (i
= 0; i
< nr_dimensions
; i
++) {
25 if (unlikely(dimension_indexes
[i
] >= counter
->dimensions
[i
].max_nr_elem
))
31 static inline size_t lttng_counter_get_index(const struct lib_counter_config
*config
,
32 struct lib_counter
*counter
,
33 const size_t *dimension_indexes
)
35 size_t nr_dimensions
= counter
->nr_dimensions
, i
;
38 for (i
= 0; i
< nr_dimensions
; i
++) {
39 struct lib_counter_dimension
*dimension
= &counter
->dimensions
[i
];
40 const size_t *dimension_index
= &dimension_indexes
[i
];
42 index
+= *dimension_index
* dimension
->stride
;
47 #endif /* _LTTNG_COUNTER_INTERNAL_H */
This page took 0.032785 seconds and 4 git commands to generate.