0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Filter: split the constructors to a separate file

This commit is contained in:
Maria Matejka 2019-02-11 16:44:14 +01:00
parent 75206f266f
commit 87bd7cd7b0
3 changed files with 27 additions and 9 deletions

View File

@ -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)
$(all-daemon)
$(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))
@ -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
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
$(o)f-inst-decl.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(M4) $(M4FLAGS_FILTERS) -P $^ >$@
$(o)inst-gen.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp
$(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
$(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_targets := $(tests_targets) $(tests-target-files)

View File

@ -19,9 +19,10 @@ m4_divert(-1)m4_dnl
# 13 constructor body
# Flush the completed instruction
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_STRUCT, `FID_ZONE(1, Per-instruction structure)')
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_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]], [[
FID_ENUM
INST_NAME(),
@ -42,9 +48,11 @@ m4_undivert(101)
FID_UNION
struct f_inst_[[]]INST_NAME() i_[[]]INST_NAME();
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)
) {
)
FID_H ; FID_C
{
struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
what_->fi_code = fi_code;
what_->lineno = ifs->lino;
@ -53,6 +61,7 @@ m4_undivert(102)
m4_undivert(103)
return what_;
}
FID_ALL
FID_END
]])')
@ -103,6 +112,11 @@ m4_define(STRING, `FID_MEMBER(const char *, s)')
m4_m4wrap(`
INST_FLUSH()
m4_divert(0)
FID_C
#include "nest/bird.h"
#include "filter/filter.h"
#include "filter/f-inst.h"
FID_H
/* Filter instruction codes */
enum f_instruction_code {
m4_undivert(4)
@ -121,6 +135,7 @@ struct f_inst {
};
};
FID_ALL
/* Instruction constructors */
m4_undivert(3)
')

View File

@ -16,7 +16,7 @@
#include "filter/data.h"
/* 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__)