Filter: split the constructors to a separate file
This commit is contained in:
parent
75206f266f
commit
87bd7cd7b0
3 changed files with 27 additions and 9 deletions
|
@ -1,9 +1,9 @@
|
||||||
src := filter.c f-util.c tree.c trie.c
|
src := filter.c f-util.c tree.c trie.c inst-gen.c
|
||||||
obj := $(src-o-files)
|
obj := $(src-o-files)
|
||||||
$(all-daemon)
|
$(all-daemon)
|
||||||
$(cf-local)
|
$(cf-local)
|
||||||
|
|
||||||
$(conf-y-targets) $(conf-lex-targets): $(o)f-inst-decl.h
|
$(conf-y-targets) $(conf-lex-targets) $(src-o-files): $(o)inst-gen.h
|
||||||
|
|
||||||
M4FLAGS_FILTERS=$(filter-out -s,$(M4FLAGS))
|
M4FLAGS_FILTERS=$(filter-out -s,$(M4FLAGS))
|
||||||
|
|
||||||
|
@ -16,13 +16,16 @@ $(o)f-inst-interpret.c: $(s)interpret.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(o)f-inst-same.c: $(s)same.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
$(o)f-inst-same.c: $(s)same.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
||||||
|
|
||||||
$(o)f-inst-decl.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
$(o)inst-gen.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
$(M4) $(M4FLAGS_FILTERS) -DTARGET=H -P $^ >$@
|
||||||
|
|
||||||
|
$(o)inst-gen.c: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
|
$(M4) $(M4FLAGS_FILTERS) -DTARGET=C -P $^ >$@
|
||||||
|
|
||||||
$(o)f-inst-dump.c: $(s)dump.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
$(o)f-inst-dump.c: $(s)dump.m4 $(s)f-inst.c $(objdir)/.dir-stamp
|
||||||
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
|
||||||
|
|
||||||
$(o)filter.o: $(o)f-inst-interpret.c $(o)f-inst-postfixify.c $(o)f-inst-same.c $(o)f-inst-dump.c $(o)f-inst-decl.h
|
$(o)filter.o: $(o)f-inst-interpret.c $(o)f-inst-postfixify.c $(o)f-inst-same.c $(o)f-inst-dump.c $(o)inst-gen.h
|
||||||
|
|
||||||
tests_src := tree_test.c filter_test.c trie_test.c
|
tests_src := tree_test.c filter_test.c trie_test.c
|
||||||
tests_targets := $(tests_targets) $(tests-target-files)
|
tests_targets := $(tests_targets) $(tests-target-files)
|
||||||
|
|
|
@ -19,9 +19,10 @@ m4_divert(-1)m4_dnl
|
||||||
# 13 constructor body
|
# 13 constructor body
|
||||||
|
|
||||||
# Flush the completed instruction
|
# Flush the completed instruction
|
||||||
|
|
||||||
m4_define(FID_END, `m4_divert(-1)')
|
m4_define(FID_END, `m4_divert(-1)')
|
||||||
|
|
||||||
|
m4_dnl m4_debugmode(aceflqtx)
|
||||||
|
|
||||||
m4_define(FID_ZONE, `m4_divert($1) /* $2 for INST_NAME() */')
|
m4_define(FID_ZONE, `m4_divert($1) /* $2 for INST_NAME() */')
|
||||||
m4_define(FID_STRUCT, `FID_ZONE(1, Per-instruction structure)')
|
m4_define(FID_STRUCT, `FID_ZONE(1, Per-instruction structure)')
|
||||||
m4_define(FID_UNION, `FID_ZONE(2, Union member)')
|
m4_define(FID_UNION, `FID_ZONE(2, Union member)')
|
||||||
|
@ -32,6 +33,11 @@ m4_define(FID_STRUCT_IN, `m4_divert(101)')
|
||||||
m4_define(FID_NEW_ARGS, `m4_divert(102)')
|
m4_define(FID_NEW_ARGS, `m4_divert(102)')
|
||||||
m4_define(FID_NEW_BODY, `m4_divert(103)')
|
m4_define(FID_NEW_BODY, `m4_divert(103)')
|
||||||
|
|
||||||
|
m4_define(FID_ALL, `/* fidall */m4_ifdef([[FID_CURDIV]], [[m4_divert(FID_CURDIV)m4_undefine([[FID_CURDIV]])]])')
|
||||||
|
m4_define(FID_C, `m4_ifelse(TARGET, [[C]], FID_ALL, [[m4_define(FID_CURDIV, m4_divnum)m4_divert(-1)]])')
|
||||||
|
m4_define(FID_H, `m4_ifelse(TARGET, [[H]], FID_ALL, [[m4_define(FID_CURDIV, m4_divnum)m4_divert(-1)]])')
|
||||||
|
|
||||||
|
|
||||||
m4_define(INST_FLUSH, `m4_ifdef([[INST_NAME]], [[
|
m4_define(INST_FLUSH, `m4_ifdef([[INST_NAME]], [[
|
||||||
FID_ENUM
|
FID_ENUM
|
||||||
INST_NAME(),
|
INST_NAME(),
|
||||||
|
@ -42,9 +48,11 @@ m4_undivert(101)
|
||||||
FID_UNION
|
FID_UNION
|
||||||
struct f_inst_[[]]INST_NAME() i_[[]]INST_NAME();
|
struct f_inst_[[]]INST_NAME() i_[[]]INST_NAME();
|
||||||
FID_NEW
|
FID_NEW
|
||||||
static inline struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code
|
struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code
|
||||||
m4_undivert(102)
|
m4_undivert(102)
|
||||||
) {
|
)
|
||||||
|
FID_H ; FID_C
|
||||||
|
{
|
||||||
struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
|
struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
|
||||||
what_->fi_code = fi_code;
|
what_->fi_code = fi_code;
|
||||||
what_->lineno = ifs->lino;
|
what_->lineno = ifs->lino;
|
||||||
|
@ -53,6 +61,7 @@ m4_undivert(102)
|
||||||
m4_undivert(103)
|
m4_undivert(103)
|
||||||
return what_;
|
return what_;
|
||||||
}
|
}
|
||||||
|
FID_ALL
|
||||||
FID_END
|
FID_END
|
||||||
]])')
|
]])')
|
||||||
|
|
||||||
|
@ -103,6 +112,11 @@ m4_define(STRING, `FID_MEMBER(const char *, s)')
|
||||||
m4_m4wrap(`
|
m4_m4wrap(`
|
||||||
INST_FLUSH()
|
INST_FLUSH()
|
||||||
m4_divert(0)
|
m4_divert(0)
|
||||||
|
FID_C
|
||||||
|
#include "nest/bird.h"
|
||||||
|
#include "filter/filter.h"
|
||||||
|
#include "filter/f-inst.h"
|
||||||
|
FID_H
|
||||||
/* Filter instruction codes */
|
/* Filter instruction codes */
|
||||||
enum f_instruction_code {
|
enum f_instruction_code {
|
||||||
m4_undivert(4)
|
m4_undivert(4)
|
||||||
|
@ -121,6 +135,7 @@ struct f_inst {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FID_ALL
|
||||||
/* Instruction constructors */
|
/* Instruction constructors */
|
||||||
m4_undivert(3)
|
m4_undivert(3)
|
||||||
')
|
')
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "filter/data.h"
|
#include "filter/data.h"
|
||||||
|
|
||||||
/* Include generated filter instruction declarations */
|
/* Include generated filter instruction declarations */
|
||||||
#include "filter/f-inst-decl.h"
|
#include "filter/inst-gen.h"
|
||||||
|
|
||||||
#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
|
#define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue