34 lines
700 B
C
34 lines
700 B
C
#ifndef GSTAT_H
|
|
#define GSTAT_H
|
|
|
|
/* Program-wide statistics */
|
|
|
|
#if GSTAT_ENABLED
|
|
|
|
#include "atomic.h"
|
|
|
|
struct _gstats {
|
|
struct atomic_u64 GSTAT_SOCK_BYTES_SENT;
|
|
struct atomic_u64 GSTAT_SOCK_BYTES_RECEIVED;
|
|
struct atomic_u64 GSTAT_MEMORY_COMMITTED;
|
|
struct atomic_u64 GSTAT_MEMORY_RESERVED;
|
|
struct atomic_u64 GSTAT_NUM_ARENAS;
|
|
};
|
|
|
|
extern struct _gstats _g_gstats;
|
|
|
|
#define gstat_add(name, v) atomic_u64_eval_add_u64(&_g_gstats.name, (v))
|
|
#define gstat_sub(name, v) atomic_u64_eval_add_i64(&_g_gstats.name, -((i64)(v)))
|
|
#define gstat_get(name) atomic_u64_eval(&_g_gstats.name)
|
|
|
|
#else
|
|
|
|
#define gstat_add(name, v)
|
|
#define gstat_sub(name, v)
|
|
#define gstat_get(name) 0
|
|
|
|
#endif
|
|
|
|
|
|
#endif
|