struct ea_class *attribute; /* For SYM_ATTRIBUTE */
struct f_val *val; /* For SYM_CONSTANT */
uint offset; /* For SYM_VARIABLE */
+ struct channel_config *ch_config; /* For SYM_COUNTER */
};
char name[0];
#define SYM_FILTER 4
#define SYM_TABLE 5
#define SYM_ATTRIBUTE 6
+#define SYM_COUNTER 7
#define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */
#define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff)
case SYM_ATTRIBUTE:
$$ = f_new_inst(FI_EA_GET, $1->attribute);
break;
+ case SYM_COUNTER:
+ $$ = f_new_inst(FI_COUNTER, $1);
+ break;
default:
cf_error("Can't get value of symbol %s", $1->name);
}
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
}
+ INST(FI_COUNTER, 0, 1) {
+ SYMBOL;
+ NEVER_CONSTANT;
+ RESULT(T_INT, i, get_stats_sum(sym));
+ }
+
INST(FI_CONSTANT, 0, 1) {
FID_MEMBER(
struct f_val,
#include "filter/filter.h"
#include "filter/f-inst.h"
#include "filter/data.h"
+#include "proto/stats/stats.h" /* provides function get_stats_sum used in f-inst.c */
/* Exception bits */
{
this_channel = channel_config_get(&channel_stats, $2->name, $1, this_proto);
STATS_CC->max_generation = 16;
+ /* from filter/config.Y:
+ cf_define_symbol($3, SYM_VARIABLE | $2, offset, $3->scope->slots++) */
+ $2 = cf_define_symbol($2, SYM_COUNTER, ch_config, this_channel);
}
stats_proto:
u8 max_generation;
};
-
+static inline int
+get_stats_sum(struct symbol *sym)
+{
+ if (sym->ch_config->channel)
+ return (int) ((struct stats_channel *) sym->ch_config->channel)->sum;
+ else
+ return 0;
+}
#endif