36 lines
879 B
C
36 lines
879 B
C
#ifndef GSTAT_H
|
|
#define GSTAT_H
|
|
|
|
/* Program-wide statistics */
|
|
|
|
#if GSTAT_ENABLED
|
|
|
|
#include "atomic.h"
|
|
|
|
struct _gstats {
|
|
struct atomic_u64_padded GSTAT_SOCK_BYTES_SENT;
|
|
struct atomic_u64_padded GSTAT_SOCK_BYTES_RECEIVED;
|
|
struct atomic_u64_padded GSTAT_MEMORY_COMMITTED;
|
|
struct atomic_u64_padded GSTAT_MEMORY_RESERVED;
|
|
struct atomic_u64_padded GSTAT_NUM_ARENAS;
|
|
};
|
|
|
|
extern struct _gstats _g_gstats;
|
|
|
|
#define gstat_set(name, value) atomic_u64_fetch_set(&_g_gstats.name.v, (value))
|
|
#define gstat_add(name, value) atomic_u64_fetch_add_u64(&_g_gstats.name.v, (value))
|
|
#define gstat_sub(name, value) atomic_u64_fetch_add_i64(&_g_gstats.name.v, -((i64)(value)))
|
|
#define gstat_get(name) atomic_u64_fetch(&_g_gstats.name.v)
|
|
|
|
#else
|
|
|
|
#define gstat_set(name, value)
|
|
#define gstat_add(name, value)
|
|
#define gstat_sub(name, value)
|
|
#define gstat_get(name) 0
|
|
|
|
#endif
|
|
|
|
|
|
#endif
|