Commit ec2f1751 authored by Maria Jan Matejka's avatar Maria Jan Matejka Committed by Maria Matejka
Browse files

Config: Make the parser and lexer reentrant.

This is part of the multithreading journey. The parser and lexer were
using loads of global variables and all of these are now packed into
struct cf_context and others.

Note that the config API has changed a bit:

* cfg_alloc[zu]?(size) is now cf_alloc[zu]?(ctx, size)
* cf_error(msg, ...) requires struct cf_context *ctx
* config_parse() and cli_parse() are now called differently
* there is a brand new CF_CTX section in *.Y files which participates
  in struct cf_context construction
parent 53b7a70f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @s

# conf/Makefile declarations needed for all other modules
conf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o)
conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h)
conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h context.h)
cf-local = $(conf-y-targets): $(s)config.Y

src-o-files = $(patsubst %.c,$(o)%.o,$(src))
@@ -194,10 +194,10 @@ static-scan:
	$(Q)scan-build $(STATIC_SCAN_FLAGS) $(MAKE) -$(MAKEFLAGS)

tags:
	cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
	cd $(srcdir) ; etags -lc `find $(dirs) -name '*.[chYl]'`

cscope:
	cd $(srcdir) ; find $(dirs) -name '*.[chY]' > cscope.files ; cscope -b
	cd $(srcdir) ; find $(dirs) -name '*.[chYl]' > cscope.files ; cscope -b

# Install

+2 −0
Original line number Diff line number Diff line
@@ -9,3 +9,5 @@
CF_CLI(QUIT,,, [[Quit the client]])
CF_CLI(EXIT,,, [[Exit the client]])
CF_CLI(HELP,,, [[Description of the help system]])

CF_END
+6 −5
Original line number Diff line number Diff line
src := cf-parse.tab.c cf-lex.c conf.c
src := cf-parse.tab.c cf-lex.c conf.c symbols.c
obj := $(src-o-files)

$(all-daemon)
@@ -13,21 +13,22 @@ endif
$(o)cf-parse.y: $(s)gen_parser.m4
$(o)keywords.h: $(s)gen_keywords.m4
$(o)commands.h: $(s)gen_commands.m4
$(o)context.h: $(s)gen_context.m4

$(conf-y-targets): $(s)confbase.Y $(s)flowspec.Y
	$(M4) $(M4FLAGS) -P $(if $(word 2,$(filter %.m4,$^)),$(error "Too many M4 scripts for one target"),$(filter %.m4,$^)) $(filter %.Y,$^) >$@

$(o)cf-parse.tab.h: $(o)cf-parse.tab.c

$(o)cf-parse.tab.c: $(o)cf-parse.y
	$(BISON) $(BISON_DEBUG) $(BISONFLAGS) -dv -pcf_ -b $(@:.tab.c=) $<
$(o)cf-parse.tab.c: $(o)cf-parse.y $(o)context.h
	$(BISON) $(BISON_DEBUG) $(BISONFLAGS) -dv -pcfx_ -b $(@:.tab.c=) $<

$(o)cf-lex.c: $(s)cf-lex.l
	$(FLEX) $(FLEX_DEBUG) -f -s -B -8 -Pcf_ -o$@ $<
	$(FLEX) $(FLEX_DEBUG) -f -s -B -8 -Pcfx_ -o$@ $<

$(o)cf-lex.o: CFLAGS+=-Wno-sign-compare -Wno-unused-function

prepare: $(o)keywords.h $(o)commands.h $(o)cf-parse.tab.h
prepare: $(o)keywords.h $(o)commands.h $(o)cf-parse.tab.h $(o)context.h

$(addprefix $(o), cf-parse.y keywords.h commands.h cf-parse.tab.h cf-parse.tab.c cf-lex.c): $(objdir)/.dir-stamp

+117 −415

File changed.

Preview size limit exceeded, changes collapsed.

+71 −101

File changed.

Preview size limit exceeded, changes collapsed.

Loading