]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: split the constructors to a separate file
authorMaria Matejka <mq@ucw.cz>
Mon, 11 Feb 2019 15:44:14 +0000 (16:44 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 20 Feb 2019 21:30:54 +0000 (22:30 +0100)
filter/Makefile
filter/decl.m4
filter/f-inst.h

index 18fd813733013a0fe0e12aee19450b82a7e3e0d0..78d39638cc8c62318c2b9e44e8de12dc473db111 100644 (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)
index bdbb3e2767805f7ffb0640296aedb927f0cafc2d..7ff22c2ec81b587695f6650c0e3ff9f62753b407 100644 (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)
 ')
index 1423e685630c3718dda934aa6d086295c3697cda..ad9948572030a91e6500a93dfd241d6b4b040d92 100644 (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__)