libosmocore
UNKNOWN
Osmocom core library
Toggle main menu visibility
Loading...
Searching...
No Matches
counter.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
osmocom/core/defs.h
>
4
7
9
struct
osmo_counter
{
10
struct
llist_head
list
;
11
const
char
*
name
;
12
const
char
*
description
;
13
unsigned
long
value
;
14
unsigned
long
previous
;
15
};
16
19
OSMO_DEPRECATED
(
"Implement as osmo_stat_item instead"
)
20
static
inline
void
osmo_counter_dec
(struct
osmo_counter
*ctr)
21
{
22
ctr->value--;
23
}
24
27
OSMO_DEPRECATED
(
"Implement as osmo_stat_item instead"
)
28
static
inline
void
osmo_counter_inc
(struct
osmo_counter
*ctr)
29
{
30
ctr->value++;
31
}
32
34
OSMO_DEPRECATED_OUTSIDE
(
"Implement as osmo_stat_item instead"
)
35
static
inline
unsigned
long
osmo_counter_get
(struct
osmo_counter
*ctr)
36
{
37
return
ctr->value;
38
}
39
41
OSMO_DEPRECATED
(
"Implement as osmo_stat_item instead"
)
42
static
inline
void
osmo_counter_reset
(struct
osmo_counter
*ctr)
43
{
44
ctr->value = 0;
45
}
46
47
struct
osmo_counter
*
osmo_counter_alloc
(
const
char
*
name
)
48
OSMO_DEPRECATED
(
"Implement as osmo_stat_item instead"
);
49
50
void
osmo_counter_free
(
struct
osmo_counter
*ctr)
51
OSMO_DEPRECATED
(
"Implement as osmo_stat_item instead"
);
52
53
int
osmo_counters_for_each
(
int
(*handle_counter)(
struct
osmo_counter
*,
void
*),
void
*
data
);
54
55
int
osmo_counters_count
(
void
);
56
57
struct
osmo_counter
*
osmo_counter_get_by_name
(
const
char
*
name
);
58
59
int
osmo_counter_difference
(
struct
osmo_counter
*ctr);
osmo_counter_get_by_name
struct osmo_counter * osmo_counter_get_by_name(const char *name)
Find a counter by its name.
Definition
counter.c:87
osmo_counters_for_each
int osmo_counters_for_each(int(*handle_counter)(struct osmo_counter *, void *), void *data)
Iterate over all counters; call handle_cunter call-back for each.
Definition
counter.c:62
osmo_counter_inc
static void osmo_counter_inc(struct osmo_counter *ctr)
Increment counter by one.
Definition
counter.h:28
osmo_counter_alloc
struct osmo_counter * osmo_counter_alloc(const char *name) OSMO_DEPRECATED("Implement as osmo_stat_item instead")
Allocate a new counter with given name.
Definition
counter.c:37
osmo_counter_difference
int osmo_counter_difference(struct osmo_counter *ctr)
Compute difference between current and previous counter value.
Definition
counter.c:103
osmo_counters_count
int osmo_counters_count(void)
Counts the registered counter.
Definition
counter.c:79
osmo_counter_reset
static void osmo_counter_reset(struct osmo_counter *ctr)
Reset current value of counter to 0.
Definition
counter.h:42
osmo_counter_free
void osmo_counter_free(struct osmo_counter *ctr) OSMO_DEPRECATED("Implement as osmo_stat_item instead")
Release/Destroy a given counter.
Definition
counter.c:52
osmo_counter_get
static unsigned long osmo_counter_get(struct osmo_counter *ctr)
Get current value of counter.
Definition
counter.h:35
osmo_counter_dec
static void osmo_counter_dec(struct osmo_counter *ctr)
Decrement given counter by one.
Definition
counter.h:20
defs.h
General definitions that are meant to be included from header files.
inline
#define inline
Definition
linuxlist.h:22
OSMO_DEPRECATED_OUTSIDE
#define OSMO_DEPRECATED_OUTSIDE(text)
Definition
defs.h:49
OSMO_DEPRECATED
#define OSMO_DEPRECATED(text)
Set the deprecated attribute with a message.
Definition
defs.h:41
data
uint8_t data[0]
llist_head
(double) linked list header structure
Definition
linuxlist.h:46
osmo_counter
Structure representing a single counter.
Definition
counter.h:9
osmo_counter::list
struct llist_head list
internal list head
Definition
counter.h:10
osmo_counter::description
const char * description
humn-readable description
Definition
counter.h:12
osmo_counter::name
const char * name
human-readable name
Definition
counter.h:11
osmo_counter::value
unsigned long value
current value
Definition
counter.h:13
osmo_counter::previous
unsigned long previous
previous value
Definition
counter.h:14
include
osmocom
core
counter.h
Generated by
1.18.0