24 #ifndef STATS_COUNTER_H_INCLUDED
25 #define STATS_COUNTER_H_INCLUDED 1
35 #if ! defined(USE_CHECKED_COUNTER_OPS)
36 # define USE_CHECKED_COUNTER_OPS 0
38 #if ! defined(CHECKED_COUNTER_ADD)
39 # if SYSLOG_NG_ENABLE_DEBUG && USE_CHECKED_COUNTER_OPS
40 #define CHECKED_COUNTER_ADD(old_value_expr, add) \
42 gssize _old = (old_value_expr); \
43 gssize _add = (add); \
44 g_assert((_old <= G_MAXSSIZE - _add) && "stats counter add overflow!"); \
47 # define CHECKED_COUNTER_ADD(old_value_expr, add) ((void)(old_value_expr))
51 #if ! defined(CHECKED_COUNTER_SUB)
52 # if SYSLOG_NG_ENABLE_DEBUG && USE_CHECKED_COUNTER_OPS
53 #define CHECKED_COUNTER_SUB(old_value_expr, sub) \
55 gssize _old = (old_value_expr); \
56 gssize _sub = (sub); \
57 g_assert((_old >= _sub) && "stats counter sub underflow!"); \
60 # define CHECKED_COUNTER_SUB(old_value_expr, sub) ((void)(old_value_expr))
64 #define STATS_COUNTER_MAX_VALUE G_MAXSIZE
66 typedef struct _StatsCounterItem
90 g_assert(!stats_counter_read_only(counter));
100 g_assert(!stats_counter_read_only(counter));
110 g_assert(!stats_counter_read_only(counter));
120 g_assert(!stats_counter_read_only(counter));
128 if (counter && !stats_counter_read_only(counter))
142 result = atomic_gssize_get_unsigned(&counter->
value);
153 stats_counter_set(counter, (gsize) MAX(0,
value));
156 static inline gchar *
160 return counter->
name;
167 g_free(counter->
name);
168 memset(counter, 0,
sizeof(*counter));
#define CHECKED_COUNTER_SUB(old_value_expr, sub)
Definition: stats-counter.h:60
#define CHECKED_COUNTER_ADD(old_value_expr, add)
Definition: stats-counter.h:47
Definition: stats-counter.h:67
gchar * name
Definition: stats-counter.h:73
atomic_gssize value
Definition: stats-counter.h:70
atomic_gssize * value_ref
Definition: stats-counter.h:71
gint type
Definition: stats-counter.h:74
gboolean external
Definition: stats-counter.h:75
Definition: atomic-gssize.h:33
GString * value
Definition: test_decode.c:28
GString * result
Definition: test_lexer_block.c:34