aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore2
-rw-r--r--scripts/Kbuild.include12
-rw-r--r--scripts/Makefile11
-rw-r--r--scripts/Makefile.asm-generic24
-rw-r--r--scripts/Makefile.build85
-rw-r--r--scripts/Makefile.clean2
-rw-r--r--scripts/Makefile.headersinst10
-rw-r--r--scripts/Makefile.lib68
-rw-r--r--scripts/Makefile.modpost4
-rw-r--r--scripts/basic/.gitignore2
-rw-r--r--scripts/basic/Makefile3
-rw-r--r--scripts/basic/fixdep.c140
-rw-r--r--scripts/basic/hash.c64
-rwxr-xr-xscripts/bloat-o-meter4
-rwxr-xr-xscripts/checkpatch.pl214
-rwxr-xr-xscripts/checkstack.pl2
-rwxr-xr-xscripts/checksyscalls.sh4
-rwxr-xr-xscripts/checkversion.pl1
-rwxr-xr-xscripts/coccicheck46
-rw-r--r--scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci (renamed from scripts/coccinelle/alloc/drop_kmalloc_cast.cocci)0
-rw-r--r--scripts/coccinelle/api/alloc/kzalloc-simple.cocci (renamed from scripts/coccinelle/alloc/kzalloc-simple.cocci)6
-rw-r--r--scripts/coccinelle/api/err_cast.cocci (renamed from scripts/coccinelle/err_cast.cocci)0
-rw-r--r--scripts/coccinelle/api/kstrdup.cocci39
-rw-r--r--scripts/coccinelle/api/memdup.cocci40
-rw-r--r--scripts/coccinelle/api/memdup_user.cocci35
-rw-r--r--scripts/coccinelle/api/resource_size.cocci (renamed from scripts/coccinelle/resource_size.cocci)0
-rw-r--r--scripts/coccinelle/free/kfree.cocci117
-rw-r--r--scripts/coccinelle/iterators/fen.cocci64
-rw-r--r--scripts/coccinelle/iterators/itnull.cocci58
-rw-r--r--scripts/coccinelle/iterators/list_entry_update.cocci62
-rw-r--r--scripts/coccinelle/locks/call_kern.cocci74
-rw-r--r--scripts/coccinelle/locks/double_lock.cocci92
-rw-r--r--scripts/coccinelle/locks/flags.cocci80
-rw-r--r--scripts/coccinelle/locks/mini_lock.cocci95
-rw-r--r--scripts/coccinelle/misc/doubleinit.cocci53
-rw-r--r--scripts/coccinelle/misc/ifcol.cocci48
-rw-r--r--scripts/coccinelle/null/deref_null.cocci (renamed from scripts/coccinelle/deref_null.cocci)39
-rw-r--r--scripts/coccinelle/null/eno.cocci20
-rw-r--r--scripts/coccinelle/null/kmerr.cocci72
-rw-r--r--scripts/coccinelle/tests/doublebitand.cocci54
-rw-r--r--scripts/coccinelle/tests/doubletest.cocci40
-rwxr-xr-xscripts/config13
-rwxr-xr-xscripts/depmod.sh50
-rw-r--r--scripts/docproc.c (renamed from scripts/basic/docproc.c)5
-rw-r--r--scripts/dtc/Makefile3
-rw-r--r--scripts/dtc/checks.c105
-rw-r--r--scripts/dtc/dtc-lexer.l175
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped551
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped892
-rw-r--r--scripts/dtc/dtc-parser.tab.h_shipped82
-rw-r--r--scripts/dtc/dtc-parser.y160
-rw-r--r--scripts/dtc/dtc.c57
-rw-r--r--scripts/dtc/dtc.h77
-rw-r--r--scripts/dtc/flattree.c192
-rw-r--r--scripts/dtc/fstree.c12
-rw-r--r--scripts/dtc/libfdt/libfdt.h2
-rw-r--r--scripts/dtc/livetree.c345
-rw-r--r--scripts/dtc/srcpos.c258
-rw-r--r--scripts/dtc/srcpos.h99
-rw-r--r--scripts/dtc/treesource.c48
-rw-r--r--scripts/dtc/util.c59
-rw-r--r--scripts/dtc/util.h56
-rw-r--r--scripts/dtc/version_gen.h2
-rw-r--r--scripts/export_report.pl26
-rwxr-xr-xscripts/extract-ikconfig42
-rw-r--r--scripts/gcc-goto.sh5
-rw-r--r--scripts/gen_initramfs_list.sh31
-rw-r--r--scripts/genksyms/Makefile4
-rw-r--r--scripts/genksyms/genksyms.c192
-rw-r--r--scripts/genksyms/genksyms.h7
-rw-r--r--scripts/genksyms/lex.c_shipped427
-rw-r--r--scripts/genksyms/lex.l44
-rw-r--r--scripts/genksyms/parse.c_shipped1071
-rw-r--r--scripts/genksyms/parse.h_shipped72
-rw-r--r--scripts/genksyms/parse.y36
-rwxr-xr-xscripts/get_maintainer.pl1208
-rw-r--r--scripts/gfp-translate7
-rwxr-xr-xscripts/headers.sh2
-rw-r--r--scripts/headers_check.pl6
-rw-r--r--scripts/headers_install.pl7
-rw-r--r--scripts/kallsyms.c10
-rw-r--r--scripts/kconfig/Makefile125
-rw-r--r--scripts/kconfig/conf.c19
-rw-r--r--scripts/kconfig/confdata.c167
-rw-r--r--scripts/kconfig/expr.c44
-rw-r--r--scripts/kconfig/expr.h10
-rw-r--r--scripts/kconfig/gconf.c32
-rw-r--r--scripts/kconfig/gconf.glade1
-rw-r--r--scripts/kconfig/kxgettext.c15
-rw-r--r--scripts/kconfig/lex.zconf.c_shipped40
-rw-r--r--scripts/kconfig/lkc.h16
-rw-r--r--scripts/kconfig/lkc_proto.h3
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh2
-rw-r--r--scripts/kconfig/mconf.c64
-rw-r--r--scripts/kconfig/menu.c46
-rw-r--r--scripts/kconfig/nconf.c509
-rw-r--r--scripts/kconfig/nconf.gui.c22
-rw-r--r--scripts/kconfig/nconf.h3
-rw-r--r--scripts/kconfig/qconf.cc179
-rw-r--r--scripts/kconfig/qconf.h76
-rw-r--r--scripts/kconfig/streamline_config.pl45
-rw-r--r--scripts/kconfig/symbol.c59
-rw-r--r--scripts/kconfig/util.c7
-rw-r--r--scripts/kconfig/zconf.gperf1
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped122
-rw-r--r--scripts/kconfig/zconf.l40
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped603
-rw-r--r--scripts/kconfig/zconf.y37
-rwxr-xr-xscripts/kernel-doc116
-rwxr-xr-xscripts/mkcompile_h30
-rwxr-xr-xscripts/mkuboot.sh2
-rw-r--r--scripts/mod/file2alias.c22
-rw-r--r--scripts/mod/modpost.c49
-rw-r--r--scripts/mod/modpost.h27
-rw-r--r--scripts/mod/sumversion.c19
-rw-r--r--scripts/module-common.lds11
-rwxr-xr-xscripts/namespace.pl147
-rw-r--r--scripts/package/Makefile9
-rw-r--r--scripts/package/builddeb97
-rw-r--r--scripts/package/buildtar6
-rwxr-xr-xscripts/package/mkspec21
-rwxr-xr-xscripts/patch-kernel2
-rw-r--r--scripts/recordmcount.c471
-rw-r--r--scripts/recordmcount.h553
-rwxr-xr-xscripts/recordmcount.pl8
-rw-r--r--scripts/rt-tester/rt-tester.py4
-rw-r--r--scripts/rt-tester/t2-l1-2rt-sameprio.tst5
-rw-r--r--scripts/rt-tester/t2-l1-pi.tst5
-rw-r--r--scripts/rt-tester/t2-l1-signal.tst5
-rw-r--r--scripts/rt-tester/t2-l2-2rt-deadlock.tst5
-rw-r--r--scripts/rt-tester/t3-l1-pi-1rt.tst5
-rw-r--r--scripts/rt-tester/t3-l1-pi-2rt.tst5
-rw-r--r--scripts/rt-tester/t3-l1-pi-3rt.tst5
-rw-r--r--scripts/rt-tester/t3-l1-pi-signal.tst5
-rw-r--r--scripts/rt-tester/t3-l1-pi-steal.tst5
-rw-r--r--scripts/rt-tester/t3-l2-pi.tst5
-rw-r--r--scripts/rt-tester/t4-l2-pi-deboost.tst5
-rw-r--r--scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst5
-rw-r--r--scripts/rt-tester/t5-l4-pi-boost-deboost.tst5
-rw-r--r--scripts/selinux/README2
-rw-r--r--scripts/selinux/genheaders/genheaders.c20
-rwxr-xr-xscripts/setlocalversion20
-rwxr-xr-xscripts/tags.sh19
-rw-r--r--scripts/unifdef.c247
-rw-r--r--scripts/xz_wrap.sh23
145 files changed, 8356 insertions, 4147 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index c5d5db54c009..105b21f08185 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -7,3 +7,5 @@ pnmtologo
7bin2c 7bin2c
8unifdef 8unifdef
9ihex2fw 9ihex2fw
10recordmcount
11docproc
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index ed2773edfe71..be39cd1c74cf 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\
118cc-option-align = $(subst -functions=0,,\ 118cc-option-align = $(subst -functions=0,,\
119 $(call cc-option,-falign-functions=0,-malign-functions=0)) 119 $(call cc-option,-falign-functions=0,-malign-functions=0))
120 120
121# cc-disable-warning
122# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
123cc-disable-warning = $(call try-run,\
124 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
125
121# cc-version 126# cc-version
122# Usage gcc-ver := $(call cc-version) 127# Usage gcc-ver := $(call cc-version)
123cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 128cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
@@ -141,6 +146,11 @@ cc-ldoption = $(call try-run,\
141ld-option = $(call try-run,\ 146ld-option = $(call try-run,\
142 $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) 147 $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
143 148
149# ar-option
150# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
151# Important: no spaces around options
152ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
153
144###### 154######
145 155
146### 156###
@@ -187,6 +197,8 @@ ifneq ($(KBUILD_NOCMDDEP),1)
187# User may override this check using make KBUILD_NOCMDDEP=1 197# User may override this check using make KBUILD_NOCMDDEP=1
188arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 198arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
189 $(filter-out $(cmd_$@), $(cmd_$(1))) ) 199 $(filter-out $(cmd_$@), $(cmd_$(1))) )
200else
201arg-check = $(if $(strip $(cmd_$@)),,1)
190endif 202endif
191 203
192# >'< substitution is for echo to work, 204# >'< substitution is for echo to work,
diff --git a/scripts/Makefile b/scripts/Makefile
index 842dbc2d5aed..df7678febf27 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -6,16 +6,25 @@
6# pnmttologo: Convert pnm files to logo files 6# pnmttologo: Convert pnm files to logo files
7# conmakehash: Create chartable 7# conmakehash: Create chartable
8# conmakehash: Create arrays for initializing the kernel console tables 8# conmakehash: Create arrays for initializing the kernel console tables
9# docproc: Used in Documentation/DocBook
9 10
10hostprogs-$(CONFIG_KALLSYMS) += kallsyms 11hostprogs-$(CONFIG_KALLSYMS) += kallsyms
11hostprogs-$(CONFIG_LOGO) += pnmtologo 12hostprogs-$(CONFIG_LOGO) += pnmtologo
12hostprogs-$(CONFIG_VT) += conmakehash 13hostprogs-$(CONFIG_VT) += conmakehash
13hostprogs-$(CONFIG_IKCONFIG) += bin2c 14hostprogs-$(CONFIG_IKCONFIG) += bin2c
15hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
14 16
15always := $(hostprogs-y) $(hostprogs-m) 17always := $(hostprogs-y) $(hostprogs-m)
16 18
17# The following hostprogs-y programs are only build on demand 19# The following hostprogs-y programs are only build on demand
18hostprogs-y += unifdef 20hostprogs-y += unifdef docproc
21
22# These targets are used internally to avoid "is up to date" messages
23PHONY += build_unifdef
24build_unifdef: scripts/unifdef FORCE
25 @:
26build_docproc: scripts/docproc FORCE
27 @:
19 28
20subdir-$(CONFIG_MODVERSIONS) += genksyms 29subdir-$(CONFIG_MODVERSIONS) += genksyms
21subdir-y += mod 30subdir-y += mod
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
new file mode 100644
index 000000000000..40caf3c26cd5
--- /dev/null
+++ b/scripts/Makefile.asm-generic
@@ -0,0 +1,24 @@
1# include/asm-generic contains a lot of files that are used
2# verbatim by several architectures.
3#
4# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
5# and for each file listed in this file with generic-y creates
6# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
7
8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
9-include $(kbuild-file)
10
11include scripts/Kbuild.include
12
13# Create output directory if not already present
14_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
15
16quiet_cmd_wrap = WRAP $@
17cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
18
19all: $(patsubst %, $(obj)/%, $(generic-y))
20 @:
21
22$(obj)/%.h:
23 $(call cmd,wrap)
24
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a1a5cf95a68d..a0fd5029cfe7 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -49,6 +49,56 @@ ifeq ($(KBUILD_NOPEDANTIC),)
49 $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS) 49 $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS)
50 endif 50 endif
51endif 51endif
52
53#
54# make W=... settings
55#
56# W=1 - warnings that may be relevant and does not occur too often
57# W=2 - warnings that occur quite often but may still be relevant
58# W=3 - the more obscure warnings, can most likely be ignored
59#
60# $(call cc-option, -W...) handles gcc -W.. options which
61# are not supported by all versions of the compiler
62ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
63warning- := $(empty)
64
65warning-1 := -Wextra -Wunused -Wno-unused-parameter
66warning-1 += -Wmissing-declarations
67warning-1 += -Wmissing-format-attribute
68warning-1 += -Wmissing-prototypes
69warning-1 += -Wold-style-definition
70warning-1 += $(call cc-option, -Wmissing-include-dirs)
71warning-1 += $(call cc-option, -Wunused-but-set-variable)
72
73warning-2 := -Waggregate-return
74warning-2 += -Wcast-align
75warning-2 += -Wdisabled-optimization
76warning-2 += -Wnested-externs
77warning-2 += -Wshadow
78warning-2 += $(call cc-option, -Wlogical-op)
79
80warning-3 := -Wbad-function-cast
81warning-3 += -Wcast-qual
82warning-3 += -Wconversion
83warning-3 += -Wpacked
84warning-3 += -Wpadded
85warning-3 += -Wpointer-arith
86warning-3 += -Wredundant-decls
87warning-3 += -Wswitch-default
88warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
89warning-3 += $(call cc-option, -Wvla)
90
91warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
92warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
93warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
94
95ifeq ("$(strip $(warning))","")
96 $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
97endif
98
99KBUILD_CFLAGS += $(warning)
100endif
101
52include scripts/Makefile.lib 102include scripts/Makefile.lib
53 103
54ifdef host-progs 104ifdef host-progs
@@ -209,11 +259,33 @@ cmd_modversions = \
209endif 259endif
210 260
211ifdef CONFIG_FTRACE_MCOUNT_RECORD 261ifdef CONFIG_FTRACE_MCOUNT_RECORD
212cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ 262ifdef BUILD_C_RECORDMCOUNT
263ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
264 RECORDMCOUNT_FLAGS = -w
265endif
266# Due to recursion, we must skip empty.o.
267# The empty.o file is created in the make process in order to determine
268# the target endianness and word size. It is made before all other C
269# files, including recordmcount.
270sub_cmd_record_mcount = \
271 if [ $(@) != "scripts/mod/empty.o" ]; then \
272 $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \
273 fi;
274recordmcount_source := $(srctree)/scripts/recordmcount.c \
275 $(srctree)/scripts/recordmcount.h
276else
277sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
213 "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ 278 "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
214 "$(if $(CONFIG_64BIT),64,32)" \ 279 "$(if $(CONFIG_64BIT),64,32)" \
215 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ 280 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
281 "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
216 "$(if $(part-of-module),1,0)" "$(@)"; 282 "$(if $(part-of-module),1,0)" "$(@)";
283recordmcount_source := $(srctree)/scripts/recordmcount.pl
284endif
285cmd_record_mcount = \
286 if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \
287 $(sub_cmd_record_mcount) \
288 fi;
217endif 289endif
218 290
219define rule_cc_o_c 291define rule_cc_o_c
@@ -229,13 +301,13 @@ define rule_cc_o_c
229endef 301endef
230 302
231# Built-in and composite module parts 303# Built-in and composite module parts
232$(obj)/%.o: $(src)/%.c FORCE 304$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
233 $(call cmd,force_checksrc) 305 $(call cmd,force_checksrc)
234 $(call if_changed_rule,cc_o_c) 306 $(call if_changed_rule,cc_o_c)
235 307
236# Single-part modules are special since we need to mark them in $(MODVERDIR) 308# Single-part modules are special since we need to mark them in $(MODVERDIR)
237 309
238$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE 310$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
239 $(call cmd,force_checksrc) 311 $(call cmd,force_checksrc)
240 $(call if_changed_rule,cc_o_c) 312 $(call if_changed_rule,cc_o_c)
241 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) 313 @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
@@ -295,7 +367,7 @@ quiet_cmd_link_o_target = LD $@
295cmd_link_o_target = $(if $(strip $(obj-y)),\ 367cmd_link_o_target = $(if $(strip $(obj-y)),\
296 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ 368 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
297 $(cmd_secanalysis),\ 369 $(cmd_secanalysis),\
298 rm -f $@; $(AR) rcs $@) 370 rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
299 371
300$(builtin-target): $(obj-y) FORCE 372$(builtin-target): $(obj-y) FORCE
301 $(call if_changed,link_o_target) 373 $(call if_changed,link_o_target)
@@ -321,7 +393,7 @@ $(modorder-target): $(subdir-ym) FORCE
321# 393#
322ifdef lib-target 394ifdef lib-target
323quiet_cmd_link_l_target = AR $@ 395quiet_cmd_link_l_target = AR $@
324cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y) 396cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
325 397
326$(lib-target): $(lib-y) FORCE 398$(lib-target): $(lib-y) FORCE
327 $(call if_changed,link_l_target) 399 $(call if_changed,link_l_target)
@@ -387,7 +459,6 @@ ifneq ($(cmd_files),)
387 include $(cmd_files) 459 include $(cmd_files)
388endif 460endif
389 461
390
391# Declare the contents of the .PHONY variable as phony. We keep that 462# Declare the contents of the .PHONY variable as phony. We keep that
392# information in a variable se we can use it in if_changed and friends. 463# information in a variable se we can use it in if_changed and friends.
393 464
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 6f89fbb56256..686cb0d31c7c 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -45,6 +45,8 @@ __clean-files := $(extra-y) $(always) \
45 $(host-progs) \ 45 $(host-progs) \
46 $(hostprogs-y) $(hostprogs-m) $(hostprogs-) 46 $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
47 47
48__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
49
48# as clean-files is given relative to the current directory, this adds 50# as clean-files is given relative to the current directory, this adds
49# a $(obj) prefix, except for absolute paths 51# a $(obj) prefix, except for absolute paths
50 52
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f89cb87f5c01..a57f5bd5a13d 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
27install-file := $(install)/.install 27install-file := $(install)/.install
28check-file := $(install)/.check 28check-file := $(install)/.check
29 29
30# generic-y list all files an architecture uses from asm-generic
31# Use this to build a list of headers which require a wrapper
32wrapper-files := $(filter $(header-y), $(generic-y))
33
30# all headers files for this dir 34# all headers files for this dir
31all-files := $(header-y) $(objhdr-y) 35header-y := $(filter-out $(generic-y), $(header-y))
36all-files := $(header-y) $(objhdr-y) $(wrapper-files)
32input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ 37input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
33 $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) 38 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
34output-files := $(addprefix $(install)/, $(all-files)) 39output-files := $(addprefix $(install)/, $(all-files))
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
47 cmd_install = \ 52 cmd_install = \
48 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ 53 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
49 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ 54 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
55 for F in $(wrapper-files); do \
56 echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
57 done; \
50 touch $@ 58 touch $@
51 59
52quiet_cmd_remove = REMOVE $(unwanted) 60quiet_cmd_remove = REMOVE $(unwanted)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 54fd1b700131..93b2b5938a2e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -101,14 +101,6 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
101modname_flags = $(if $(filter 1,$(words $(modname))),\ 101modname_flags = $(if $(filter 1,$(words $(modname))),\
102 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 102 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
103 103
104#hash values
105ifdef CONFIG_DYNAMIC_DEBUG
106debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\
107 -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))"
108else
109debug_flags =
110endif
111
112orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ 104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
113 $(ccflags-y) $(CFLAGS_$(basetarget).o) 105 $(ccflags-y) $(CFLAGS_$(basetarget).o)
114_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 106_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
@@ -128,7 +120,9 @@ _c_flags += $(if $(patsubst n%,, \
128endif 120endif
129 121
130ifdef CONFIG_SYMBOL_PREFIX 122ifdef CONFIG_SYMBOL_PREFIX
131_cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) 123_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
124_cpp_flags += $(_sym_flags)
125_a_flags += $(_sym_flags)
132endif 126endif
133 127
134 128
@@ -152,8 +146,7 @@ endif
152 146
153c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 147c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
154 $(__c_flags) $(modkern_cflags) \ 148 $(__c_flags) $(modkern_cflags) \
155 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \ 149 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
156 $(debug_flags)
157 150
158a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 151a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
159 $(__a_flags) $(modkern_aflags) 152 $(__a_flags) $(modkern_aflags)
@@ -204,9 +197,32 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
204# --------------------------------------------------------------------------- 197# ---------------------------------------------------------------------------
205 198
206quiet_cmd_gzip = GZIP $@ 199quiet_cmd_gzip = GZIP $@
207cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \ 200cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
208 (rm -f $@ ; false) 201 (rm -f $@ ; false)
209 202
203# DTC
204# ---------------------------------------------------------------------------
205
206# Generate an assembly file to wrap the output of the device tree compiler
207quiet_cmd_dt_S_dtb= DTB $@
208cmd_dt_S_dtb= \
209( \
210 echo '\#include <asm-generic/vmlinux.lds.h>'; \
211 echo '.section .dtb.init.rodata,"a"'; \
212 echo '.balign STRUCT_ALIGNMENT'; \
213 echo '.global __dtb_$(*F)_begin'; \
214 echo '__dtb_$(*F)_begin:'; \
215 echo '.incbin "$<" '; \
216 echo '__dtb_$(*F)_end:'; \
217 echo '.global __dtb_$(*F)_end'; \
218 echo '.balign STRUCT_ALIGNMENT'; \
219) > $@
220
221$(obj)/%.dtb.S: $(obj)/%.dtb
222 $(call cmd,dt_S_dtb)
223
224quiet_cmd_dtc = DTC $@
225cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<
210 226
211# Bzip2 227# Bzip2
212# --------------------------------------------------------------------------- 228# ---------------------------------------------------------------------------
@@ -246,6 +262,34 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \
246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 262 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
247 (rm -f $@ ; false) 263 (rm -f $@ ; false)
248 264
265# XZ
266# ---------------------------------------------------------------------------
267# Use xzkern to compress the kernel image and xzmisc to compress other things.
268#
269# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
270# of the kernel decompressor. A BCJ filter is used if it is available for
271# the target architecture. xzkern also appends uncompressed size of the data
272# using size_append. The .xz format has the size information available at
273# the end of the file too, but it's in more complex format and it's good to
274# avoid changing the part of the boot code that reads the uncompressed size.
275# Note that the bytes added by size_append will make the xz tool think that
276# the file is corrupt. This is expected.
277#
278# xzmisc doesn't use size_append, so it can be used to create normal .xz
279# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
280# big dictionary would increase the memory usage too much in the multi-call
281# decompression mode. A BCJ filter isn't used either.
282quiet_cmd_xzkern = XZKERN $@
283cmd_xzkern = (cat $(filter-out FORCE,$^) | \
284 sh $(srctree)/scripts/xz_wrap.sh && \
285 $(call size_append, $(filter-out FORCE,$^))) > $@ || \
286 (rm -f $@ ; false)
287
288quiet_cmd_xzmisc = XZMISC $@
289cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
290 xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
291 (rm -f $@ ; false)
292
249# misc stuff 293# misc stuff
250# --------------------------------------------------------------------------- 294# ---------------------------------------------------------------------------
251quote:=" 295quote:="
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 7d22056582c1..56dfafc73c1a 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -35,14 +35,14 @@
35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
36# symbols in the final module linking stage 36# symbols in the final module linking stage
37# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 37# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
38# This is solely usefull to speed up test compiles 38# This is solely useful to speed up test compiles
39PHONY := _modpost 39PHONY := _modpost
40_modpost: __modpost 40_modpost: __modpost
41 41
42include include/config/auto.conf 42include include/config/auto.conf
43include scripts/Kbuild.include 43include scripts/Kbuild.include
44 44
45# When building external modules load the Kbuild file to retreive EXTRA_SYMBOLS info 45# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info
46ifneq ($(KBUILD_EXTMOD),) 46ifneq ($(KBUILD_EXTMOD),)
47 47
48# set src + obj - they may be used when building the .mod.c file 48# set src + obj - they may be used when building the .mod.c file
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index bf8b199ec598..a776371a3502 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,3 +1 @@
1hash
2fixdep fixdep
3docproc
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 09559951df12..4fcef87bb875 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -7,9 +7,8 @@
7# .config is included by main Makefile. 7# .config is included by main Makefile.
8# --------------------------------------------------------------------------- 8# ---------------------------------------------------------------------------
9# fixdep: Used to generate dependency information during build process 9# fixdep: Used to generate dependency information during build process
10# docproc: Used in Documentation/DocBook
11 10
12hostprogs-y := fixdep docproc hash 11hostprogs-y := fixdep
13always := $(hostprogs-y) 12always := $(hostprogs-y)
14 13
15# fixdep is needed to compile other host programs 14# fixdep is needed to compile other host programs
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index ea26b23de082..291228e25984 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -138,38 +138,36 @@ static void print_cmdline(void)
138 printf("cmd_%s := %s\n\n", target, cmdline); 138 printf("cmd_%s := %s\n\n", target, cmdline);
139} 139}
140 140
141char * str_config = NULL; 141struct item {
142int size_config = 0; 142 struct item *next;
143int len_config = 0; 143 unsigned int len;
144 unsigned int hash;
145 char name[0];
146};
144 147
145/* 148#define HASHSZ 256
146 * Grow the configuration string to a desired length. 149static struct item *hashtab[HASHSZ];
147 * Usually the first growth is plenty.
148 */
149static void grow_config(int len)
150{
151 while (len_config + len > size_config) {
152 if (size_config == 0)
153 size_config = 2048;
154 str_config = realloc(str_config, size_config *= 2);
155 if (str_config == NULL)
156 { perror("fixdep:malloc"); exit(1); }
157 }
158}
159 150
151static unsigned int strhash(const char *str, unsigned int sz)
152{
153 /* fnv32 hash */
154 unsigned int i, hash = 2166136261U;
160 155
156 for (i = 0; i < sz; i++)
157 hash = (hash ^ str[i]) * 0x01000193;
158 return hash;
159}
161 160
162/* 161/*
163 * Lookup a value in the configuration string. 162 * Lookup a value in the configuration string.
164 */ 163 */
165static int is_defined_config(const char * name, int len) 164static int is_defined_config(const char *name, int len, unsigned int hash)
166{ 165{
167 const char * pconfig; 166 struct item *aux;
168 const char * plast = str_config + len_config - len; 167
169 for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) { 168 for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) {
170 if (pconfig[ -1] == '\n' 169 if (aux->hash == hash && aux->len == len &&
171 && pconfig[len] == '\n' 170 memcmp(aux->name, name, len) == 0)
172 && !memcmp(pconfig, name, len))
173 return 1; 171 return 1;
174 } 172 }
175 return 0; 173 return 0;
@@ -178,13 +176,19 @@ static int is_defined_config(const char * name, int len)
178/* 176/*
179 * Add a new value to the configuration string. 177 * Add a new value to the configuration string.
180 */ 178 */
181static void define_config(const char * name, int len) 179static void define_config(const char *name, int len, unsigned int hash)
182{ 180{
183 grow_config(len + 1); 181 struct item *aux = malloc(sizeof(*aux) + len);
184 182
185 memcpy(str_config+len_config, name, len); 183 if (!aux) {
186 len_config += len; 184 perror("fixdep:malloc");
187 str_config[len_config++] = '\n'; 185 exit(1);
186 }
187 memcpy(aux->name, name, len);
188 aux->len = len;
189 aux->hash = hash;
190 aux->next = hashtab[hash % HASHSZ];
191 hashtab[hash % HASHSZ] = aux;
188} 192}
189 193
190/* 194/*
@@ -192,40 +196,49 @@ static void define_config(const char * name, int len)
192 */ 196 */
193static void clear_config(void) 197static void clear_config(void)
194{ 198{
195 len_config = 0; 199 struct item *aux, *next;
196 define_config("", 0); 200 unsigned int i;
201
202 for (i = 0; i < HASHSZ; i++) {
203 for (aux = hashtab[i]; aux; aux = next) {
204 next = aux->next;
205 free(aux);
206 }
207 hashtab[i] = NULL;
208 }
197} 209}
198 210
199/* 211/*
200 * Record the use of a CONFIG_* word. 212 * Record the use of a CONFIG_* word.
201 */ 213 */
202static void use_config(char *m, int slen) 214static void use_config(const char *m, int slen)
203{ 215{
204 char s[PATH_MAX]; 216 unsigned int hash = strhash(m, slen);
205 char *p; 217 int c, i;
206 218
207 if (is_defined_config(m, slen)) 219 if (is_defined_config(m, slen, hash))
208 return; 220 return;
209 221
210 define_config(m, slen); 222 define_config(m, slen, hash);
211 223
212 memcpy(s, m, slen); s[slen] = 0; 224 printf(" $(wildcard include/config/");
213 225 for (i = 0; i < slen; i++) {
214 for (p = s; p < s + slen; p++) { 226 c = m[i];
215 if (*p == '_') 227 if (c == '_')
216 *p = '/'; 228 c = '/';
217 else 229 else
218 *p = tolower((int)*p); 230 c = tolower(c);
231 putchar(c);
219 } 232 }
220 printf(" $(wildcard include/config/%s.h) \\\n", s); 233 printf(".h) \\\n");
221} 234}
222 235
223static void parse_config_file(char *map, size_t len) 236static void parse_config_file(const char *map, size_t len)
224{ 237{
225 int *end = (int *) (map + len); 238 const int *end = (const int *) (map + len);
226 /* start at +1, so that p can never be < map */ 239 /* start at +1, so that p can never be < map */
227 int *m = (int *) map + 1; 240 const int *m = (const int *) map + 1;
228 char *p, *q; 241 const char *p, *q;
229 242
230 for (; m < end; m++) { 243 for (; m < end; m++) {
231 if (*m == INT_CONF) { p = (char *) m ; goto conf; } 244 if (*m == INT_CONF) { p = (char *) m ; goto conf; }
@@ -265,7 +278,7 @@ static int strrcmp(char *s, char *sub)
265 return memcmp(s + slen - sublen, sub, sublen); 278 return memcmp(s + slen - sublen, sub, sublen);
266} 279}
267 280
268static void do_config_file(char *filename) 281static void do_config_file(const char *filename)
269{ 282{
270 struct stat st; 283 struct stat st;
271 int fd; 284 int fd;
@@ -273,7 +286,7 @@ static void do_config_file(char *filename)
273 286
274 fd = open(filename, O_RDONLY); 287 fd = open(filename, O_RDONLY);
275 if (fd < 0) { 288 if (fd < 0) {
276 fprintf(stderr, "fixdep: "); 289 fprintf(stderr, "fixdep: error opening config file: ");
277 perror(filename); 290 perror(filename);
278 exit(2); 291 exit(2);
279 } 292 }
@@ -296,12 +309,18 @@ static void do_config_file(char *filename)
296 close(fd); 309 close(fd);
297} 310}
298 311
312/*
313 * Important: The below generated source_foo.o and deps_foo.o variable
314 * assignments are parsed not only by make, but also by the rather simple
315 * parser in scripts/mod/sumversion.c.
316 */
299static void parse_dep_file(void *map, size_t len) 317static void parse_dep_file(void *map, size_t len)
300{ 318{
301 char *m = map; 319 char *m = map;
302 char *end = m + len; 320 char *end = m + len;
303 char *p; 321 char *p;
304 char s[PATH_MAX]; 322 char s[PATH_MAX];
323 int first;
305 324
306 p = strchr(m, ':'); 325 p = strchr(m, ':');
307 if (!p) { 326 if (!p) {
@@ -309,11 +328,11 @@ static void parse_dep_file(void *map, size_t len)
309 exit(1); 328 exit(1);
310 } 329 }
311 memcpy(s, m, p-m); s[p-m] = 0; 330 memcpy(s, m, p-m); s[p-m] = 0;
312 printf("deps_%s := \\\n", target);
313 m = p+1; 331 m = p+1;
314 332
315 clear_config(); 333 clear_config();
316 334
335 first = 1;
317 while (m < end) { 336 while (m < end) {
318 while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) 337 while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
319 m++; 338 m++;
@@ -327,9 +346,20 @@ static void parse_dep_file(void *map, size_t len)
327 if (strrcmp(s, "include/generated/autoconf.h") && 346 if (strrcmp(s, "include/generated/autoconf.h") &&
328 strrcmp(s, "arch/um/include/uml-config.h") && 347 strrcmp(s, "arch/um/include/uml-config.h") &&
329 strrcmp(s, ".ver")) { 348 strrcmp(s, ".ver")) {
330 printf(" %s \\\n", s); 349 /*
350 * Do not list the source file as dependency, so that
351 * kbuild is not confused if a .c file is rewritten
352 * into .S or vice versa. Storing it in source_* is
353 * needed for modpost to compute srcversions.
354 */
355 if (first) {
356 printf("source_%s := %s\n\n", target, s);
357 printf("deps_%s := \\\n", target);
358 } else
359 printf(" %s \\\n", s);
331 do_config_file(s); 360 do_config_file(s);
332 } 361 }
362 first = 0;
333 m = p + 1; 363 m = p + 1;
334 } 364 }
335 printf("\n%s: $(deps_%s)\n\n", target, target); 365 printf("\n%s: $(deps_%s)\n\n", target, target);
@@ -344,11 +374,15 @@ static void print_deps(void)
344 374
345 fd = open(depfile, O_RDONLY); 375 fd = open(depfile, O_RDONLY);
346 if (fd < 0) { 376 if (fd < 0) {
347 fprintf(stderr, "fixdep: "); 377 fprintf(stderr, "fixdep: error opening depfile: ");
348 perror(depfile); 378 perror(depfile);
349 exit(2); 379 exit(2);
350 } 380 }
351 fstat(fd, &st); 381 if (fstat(fd, &st) < 0) {
382 fprintf(stderr, "fixdep: error fstat'ing depfile: ");
383 perror(depfile);
384 exit(2);
385 }
352 if (st.st_size == 0) { 386 if (st.st_size == 0) {
353 fprintf(stderr,"fixdep: %s is empty\n",depfile); 387 fprintf(stderr,"fixdep: %s is empty\n",depfile);
354 close(fd); 388 close(fd);
diff --git a/scripts/basic/hash.c b/scripts/basic/hash.c
deleted file mode 100644
index 2ef5d3f666b8..000000000000
--- a/scripts/basic/hash.c
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com>
3 *
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10#define DYNAMIC_DEBUG_HASH_BITS 6
11
12static const char *program;
13
14static void usage(void)
15{
16 printf("Usage: %s <djb2|r5> <modname>\n", program);
17 exit(1);
18}
19
20/* djb2 hashing algorithm by Dan Bernstein. From:
21 * http://www.cse.yorku.ca/~oz/hash.html
22 */
23
24static unsigned int djb2_hash(char *str)
25{
26 unsigned long hash = 5381;
27 int c;
28
29 c = *str;
30 while (c) {
31 hash = ((hash << 5) + hash) + c;
32 c = *++str;
33 }
34 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
35}
36
37static unsigned int r5_hash(char *str)
38{
39 unsigned long hash = 0;
40 int c;
41
42 c = *str;
43 while (c) {
44 hash = (hash + (c << 4) + (c >> 4)) * 11;
45 c = *++str;
46 }
47 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
48}
49
50int main(int argc, char *argv[])
51{
52 program = argv[0];
53
54 if (argc != 3)
55 usage();
56 if (!strcmp(argv[1], "djb2"))
57 printf("%d\n", djb2_hash(argv[2]));
58 else if (!strcmp(argv[1], "r5"))
59 printf("%d\n", r5_hash(argv[2]));
60 else
61 usage();
62 exit(0);
63}
64
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 6501a50e17f0..6129020c41a9 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -17,7 +17,9 @@ def getsizes(file):
17 sym = {} 17 sym = {}
18 for l in os.popen("nm --size-sort " + file).readlines(): 18 for l in os.popen("nm --size-sort " + file).readlines():
19 size, type, name = l[:-1].split() 19 size, type, name = l[:-1].split()
20 if type in "tTdDbB": 20 if type in "tTdDbBrR":
21 # strip generated symbols
22 if name[:6] == "__mod_": continue
21 # function names begin with '.' on 64-bit powerpc 23 # function names begin with '.' on 64-bit powerpc
22 if "." in name[1:]: name = "static." + name.split(".")[0] 24 if "." in name[1:]: name = "static." + name.split(".")[0]
23 sym[name] = sym.get(name, 0) + int(size, 16) 25 sym[name] = sym.get(name, 0) + int(size, 16)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2039acdf5122..b0aa2c680593 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2,7 +2,7 @@
2# (c) 2001, Dave Jones. (the file handling bit) 2# (c) 2001, Dave Jones. (the file handling bit)
3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) 3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) 4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
5# (c) 2008,2009, Andy Whitcroft <apw@canonical.com> 5# (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
6# Licensed under the terms of the GNU GPL License version 2 6# Licensed under the terms of the GNU GPL License version 2
7 7
8use strict; 8use strict;
@@ -10,7 +10,7 @@ use strict;
10my $P = $0; 10my $P = $0;
11$P =~ s@.*/@@g; 11$P =~ s@.*/@@g;
12 12
13my $V = '0.30'; 13my $V = '0.31';
14 14
15use Getopt::Long qw(:config no_auto_abbrev); 15use Getopt::Long qw(:config no_auto_abbrev);
16 16
@@ -103,6 +103,8 @@ for my $key (keys %debug) {
103 die "$@" if ($@); 103 die "$@" if ($@);
104} 104}
105 105
106my $rpt_cleaners = 0;
107
106if ($terse) { 108if ($terse) {
107 $emacs = 1; 109 $emacs = 1;
108 $quiet++; 110 $quiet++;
@@ -150,6 +152,20 @@ our $Sparse = qr{
150# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check 152# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
151our $Attribute = qr{ 153our $Attribute = qr{
152 const| 154 const|
155 __percpu|
156 __nocast|
157 __safe|
158 __bitwise__|
159 __packed__|
160 __packed2__|
161 __naked|
162 __maybe_unused|
163 __always_unused|
164 __noreturn|
165 __used|
166 __cold|
167 __noclone|
168 __deprecated|
153 __read_mostly| 169 __read_mostly|
154 __kprobes| 170 __kprobes|
155 __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)| 171 __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
@@ -194,10 +210,10 @@ our $typeTypedefs = qr{(?x:
194 210
195our $logFunctions = qr{(?x: 211our $logFunctions = qr{(?x:
196 printk| 212 printk|
197 pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| 213 [a-z]+_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)|
198 (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
199 WARN| 214 WARN|
200 panic 215 panic|
216 MODULE_[A-Z_]+
201)}; 217)};
202 218
203our @typeList = ( 219our @typeList = (
@@ -675,15 +691,15 @@ sub ctx_block_get {
675 $blk .= $rawlines[$line]; 691 $blk .= $rawlines[$line];
676 692
677 # Handle nested #if/#else. 693 # Handle nested #if/#else.
678 if ($rawlines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) { 694 if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
679 push(@stack, $level); 695 push(@stack, $level);
680 } elsif ($rawlines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) { 696 } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
681 $level = $stack[$#stack - 1]; 697 $level = $stack[$#stack - 1];
682 } elsif ($rawlines[$line] =~ /^.\s*#\s*endif\b/) { 698 } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
683 $level = pop(@stack); 699 $level = pop(@stack);
684 } 700 }
685 701
686 foreach my $c (split(//, $rawlines[$line])) { 702 foreach my $c (split(//, $lines[$line])) {
687 ##print "C<$c>L<$level><$open$close>O<$off>\n"; 703 ##print "C<$c>L<$level><$open$close>O<$off>\n";
688 if ($off > 0) { 704 if ($off > 0) {
689 $off--; 705 $off--;
@@ -843,7 +859,12 @@ sub annotate_values {
843 $av_preprocessor = 0; 859 $av_preprocessor = 0;
844 } 860 }
845 861
846 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\()/) { 862 } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
863 print "CAST($1)\n" if ($dbg_values > 1);
864 push(@av_paren_type, $type);
865 $type = 'C';
866
867 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
847 print "DECLARE($1)\n" if ($dbg_values > 1); 868 print "DECLARE($1)\n" if ($dbg_values > 1);
848 $type = 'T'; 869 $type = 'T';
849 870
@@ -1308,7 +1329,11 @@ sub process {
1308 $here = "#$realline: " if ($file); 1329 $here = "#$realline: " if ($file);
1309 1330
1310 # extract the filename as it passes 1331 # extract the filename as it passes
1311 if ($line=~/^\+\+\+\s+(\S+)/) { 1332 if ($line =~ /^diff --git.*?(\S+)$/) {
1333 $realfile = $1;
1334 $realfile =~ s@^([^/]*)/@@;
1335
1336 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1312 $realfile = $1; 1337 $realfile = $1;
1313 $realfile =~ s@^([^/]*)/@@; 1338 $realfile =~ s@^([^/]*)/@@;
1314 1339
@@ -1332,6 +1357,14 @@ sub process {
1332 1357
1333 $cnt_lines++ if ($realcnt != 0); 1358 $cnt_lines++ if ($realcnt != 0);
1334 1359
1360# Check for incorrect file permissions
1361 if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
1362 my $permhere = $here . "FILE: $realfile\n";
1363 if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
1364 ERROR("do not set execute permissions for source files\n" . $permhere);
1365 }
1366 }
1367
1335#check the patch for a signoff: 1368#check the patch for a signoff:
1336 if ($line =~ /^\s*signed-off-by:/i) { 1369 if ($line =~ /^\s*signed-off-by:/i) {
1337 # This is a signoff, if ugly, so do not double report. 1370 # This is a signoff, if ugly, so do not double report.
@@ -1389,21 +1422,38 @@ sub process {
1389 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { 1422 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
1390 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1423 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1391 ERROR("trailing whitespace\n" . $herevet); 1424 ERROR("trailing whitespace\n" . $herevet);
1425 $rpt_cleaners = 1;
1392 } 1426 }
1393 1427
1394# check for Kconfig help text having a real description 1428# check for Kconfig help text having a real description
1429# Only applies when adding the entry originally, after that we do not have
1430# sufficient context to determine whether it is indeed long enough.
1395 if ($realfile =~ /Kconfig/ && 1431 if ($realfile =~ /Kconfig/ &&
1396 $line =~ /\+?\s*(---)?help(---)?$/) { 1432 $line =~ /\+\s*(?:---)?help(?:---)?$/) {
1397 my $length = 0; 1433 my $length = 0;
1398 for (my $l = $linenr; defined($lines[$l]); $l++) { 1434 my $cnt = $realcnt;
1399 my $f = $lines[$l]; 1435 my $ln = $linenr + 1;
1436 my $f;
1437 my $is_end = 0;
1438 while ($cnt > 0 && defined $lines[$ln - 1]) {
1439 $f = $lines[$ln - 1];
1440 $cnt-- if ($lines[$ln - 1] !~ /^-/);
1441 $is_end = $lines[$ln - 1] =~ /^\+/;
1442 $ln++;
1443
1444 next if ($f =~ /^-/);
1445 $f =~ s/^.//;
1400 $f =~ s/#.*//; 1446 $f =~ s/#.*//;
1401 $f =~ s/^\s+//; 1447 $f =~ s/^\s+//;
1402 next if ($f =~ /^$/); 1448 next if ($f =~ /^$/);
1403 last if ($f =~ /^\s*config\s/); 1449 if ($f =~ /^\s*config\s/) {
1450 $is_end = 1;
1451 last;
1452 }
1404 $length++; 1453 $length++;
1405 } 1454 }
1406 WARN("please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($length < 4); 1455 WARN("please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_end && $length < 4);
1456 #print "is_end<$is_end> length<$length>\n";
1407 } 1457 }
1408 1458
1409# check we are in a valid source file if not then ignore this hunk 1459# check we are in a valid source file if not then ignore this hunk
@@ -1412,7 +1462,7 @@ sub process {
1412#80 column limit 1462#80 column limit
1413 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1463 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1414 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1464 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1415 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ || 1465 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1416 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && 1466 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1417 $length > 80) 1467 $length > 80)
1418 { 1468 {
@@ -1450,6 +1500,7 @@ sub process {
1450 $rawline =~ /^\+\s* \s*/) { 1500 $rawline =~ /^\+\s* \s*/) {
1451 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1501 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1452 ERROR("code indent should use tabs where possible\n" . $herevet); 1502 ERROR("code indent should use tabs where possible\n" . $herevet);
1503 $rpt_cleaners = 1;
1453 } 1504 }
1454 1505
1455# check for space before tabs. 1506# check for space before tabs.
@@ -1459,10 +1510,13 @@ sub process {
1459 } 1510 }
1460 1511
1461# check for spaces at the beginning of a line. 1512# check for spaces at the beginning of a line.
1462 if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) { 1513# Exceptions:
1514# 1) within comments
1515# 2) indented preprocessor commands
1516# 3) hanging labels
1517 if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) {
1463 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1518 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1464 WARN("please, no space for starting a line, \ 1519 WARN("please, no spaces at the start of a line\n" . $herevet);
1465 excluding comments\n" . $herevet);
1466 } 1520 }
1467 1521
1468# check we are in a valid C source file if not then ignore this hunk 1522# check we are in a valid C source file if not then ignore this hunk
@@ -1598,7 +1652,7 @@ sub process {
1598 1652
1599 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { 1653 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
1600 ERROR("that open brace { should be on the previous line\n" . 1654 ERROR("that open brace { should be on the previous line\n" .
1601 "$here\n$ctx\n$lines[$ctx_ln - 1]\n"); 1655 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
1602 } 1656 }
1603 if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ && 1657 if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
1604 $ctx =~ /\)\s*\;\s*$/ && 1658 $ctx =~ /\)\s*\;\s*$/ &&
@@ -1607,7 +1661,7 @@ sub process {
1607 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]); 1661 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
1608 if ($nindent > $indent) { 1662 if ($nindent > $indent) {
1609 WARN("trailing semicolon indicates no statements, indent implies otherwise\n" . 1663 WARN("trailing semicolon indicates no statements, indent implies otherwise\n" .
1610 "$here\n$ctx\n$lines[$ctx_ln - 1]\n"); 1664 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
1611 } 1665 }
1612 } 1666 }
1613 } 1667 }
@@ -1768,8 +1822,17 @@ sub process {
1768 !defined $suppress_export{$realline_next} && 1822 !defined $suppress_export{$realline_next} &&
1769 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ || 1823 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
1770 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { 1824 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1825 # Handle definitions which produce identifiers with
1826 # a prefix:
1827 # XXX(foo);
1828 # EXPORT_SYMBOL(something_foo);
1771 my $name = $1; 1829 my $name = $1;
1772 if ($stat !~ /(?: 1830 if ($stat =~ /^.([A-Z_]+)\s*\(\s*($Ident)/ &&
1831 $name =~ /^${Ident}_$2/) {
1832#print "FOO C name<$name>\n";
1833 $suppress_export{$realline_next} = 1;
1834
1835 } elsif ($stat !~ /(?:
1773 \n.}\s*$| 1836 \n.}\s*$|
1774 ^.DEFINE_$Ident\(\Q$name\E\)| 1837 ^.DEFINE_$Ident\(\Q$name\E\)|
1775 ^.DECLARE_$Ident\(\Q$name\E\)| 1838 ^.DECLARE_$Ident\(\Q$name\E\)|
@@ -1806,6 +1869,23 @@ sub process {
1806 $herecurr); 1869 $herecurr);
1807 } 1870 }
1808 1871
1872# check for static const char * arrays.
1873 if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
1874 WARN("static const char * array should probably be static const char * const\n" .
1875 $herecurr);
1876 }
1877
1878# check for static char foo[] = "bar" declarations.
1879 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
1880 WARN("static char array declaration should probably be static const char\n" .
1881 $herecurr);
1882 }
1883
1884# check for declarations of struct pci_device_id
1885 if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) {
1886 WARN("Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr);
1887 }
1888
1809# check for new typedefs, only function parameters and sparse annotations 1889# check for new typedefs, only function parameters and sparse annotations
1810# make sense. 1890# make sense.
1811 if ($line =~ /\btypedef\s/ && 1891 if ($line =~ /\btypedef\s/ &&
@@ -1863,16 +1943,21 @@ sub process {
1863 WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); 1943 WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
1864 } 1944 }
1865 1945
1946# check for uses of printk_ratelimit
1947 if ($line =~ /\bprintk_ratelimit\s*\(/) {
1948 WARN("Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
1949 }
1950
1866# printk should use KERN_* levels. Note that follow on printk's on the 1951# printk should use KERN_* levels. Note that follow on printk's on the
1867# same line do not need a level, so we use the current block context 1952# same line do not need a level, so we use the current block context
1868# to try and find and validate the current printk. In summary the current 1953# to try and find and validate the current printk. In summary the current
1869# printk includes all preceeding printk's which have no newline on the end. 1954# printk includes all preceding printk's which have no newline on the end.
1870# we assume the first bad printk is the one to report. 1955# we assume the first bad printk is the one to report.
1871 if ($line =~ /\bprintk\((?!KERN_)\s*"/) { 1956 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
1872 my $ok = 0; 1957 my $ok = 0;
1873 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { 1958 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
1874 #print "CHECK<$lines[$ln - 1]\n"; 1959 #print "CHECK<$lines[$ln - 1]\n";
1875 # we have a preceeding printk if it ends 1960 # we have a preceding printk if it ends
1876 # with "\n" ignore it, else it is to blame 1961 # with "\n" ignore it, else it is to blame
1877 if ($lines[$ln - 1] =~ m{\bprintk\(}) { 1962 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
1878 if ($rawlines[$ln - 1] !~ m{\\n"}) { 1963 if ($rawlines[$ln - 1] !~ m{\\n"}) {
@@ -1899,6 +1984,11 @@ sub process {
1899 ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); 1984 ERROR("open brace '{' following $1 go on the same line\n" . $hereprev);
1900 } 1985 }
1901 1986
1987# missing space after union, struct or enum definition
1988 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
1989 WARN("missing space after $1 definition\n" . $herecurr);
1990 }
1991
1902# check for spacing round square brackets; allowed: 1992# check for spacing round square brackets; allowed:
1903# 1. with a type on the left -- int [] a; 1993# 1. with a type on the left -- int [] a;
1904# 2. at the beginning of a line for slice initialisers -- [0...10] = 5, 1994# 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
@@ -1959,7 +2049,7 @@ sub process {
1959 for (my $n = 0; $n < $#elements; $n += 2) { 2049 for (my $n = 0; $n < $#elements; $n += 2) {
1960 $off += length($elements[$n]); 2050 $off += length($elements[$n]);
1961 2051
1962 # Pick up the preceeding and succeeding characters. 2052 # Pick up the preceding and succeeding characters.
1963 my $ca = substr($opline, 0, $off); 2053 my $ca = substr($opline, 0, $off);
1964 my $cc = ''; 2054 my $cc = '';
1965 if (length($opline) >= ($off + length($elements[$n + 1]))) { 2055 if (length($opline) >= ($off + length($elements[$n + 1]))) {
@@ -2176,21 +2266,29 @@ sub process {
2176 my $value = $2; 2266 my $value = $2;
2177 2267
2178 # Flatten any parentheses 2268 # Flatten any parentheses
2179 $value =~ s/\)\(/\) \(/g; 2269 $value =~ s/\(/ \(/g;
2270 $value =~ s/\)/\) /g;
2180 while ($value =~ s/\[[^\{\}]*\]/1/ || 2271 while ($value =~ s/\[[^\{\}]*\]/1/ ||
2181 $value !~ /(?:$Ident|-?$Constant)\s* 2272 $value !~ /(?:$Ident|-?$Constant)\s*
2182 $Compare\s* 2273 $Compare\s*
2183 (?:$Ident|-?$Constant)/x && 2274 (?:$Ident|-?$Constant)/x &&
2184 $value =~ s/\([^\(\)]*\)/1/) { 2275 $value =~ s/\([^\(\)]*\)/1/) {
2185 } 2276 }
2186 2277#print "value<$value>\n";
2187 if ($value =~ /^(?:$Ident|-?$Constant)$/) { 2278 if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
2188 ERROR("return is not a function, parentheses are not required\n" . $herecurr); 2279 ERROR("return is not a function, parentheses are not required\n" . $herecurr);
2189 2280
2190 } elsif ($spacing !~ /\s+/) { 2281 } elsif ($spacing !~ /\s+/) {
2191 ERROR("space required before the open parenthesis '('\n" . $herecurr); 2282 ERROR("space required before the open parenthesis '('\n" . $herecurr);
2192 } 2283 }
2193 } 2284 }
2285# Return of what appears to be an errno should normally be -'ve
2286 if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
2287 my $name = $1;
2288 if ($name ne 'EOF' && $name ne 'ERROR') {
2289 WARN("return of an errno should typically be -ve (return -$1)\n" . $herecurr);
2290 }
2291 }
2194 2292
2195# Need a space before open parenthesis after if, while etc 2293# Need a space before open parenthesis after if, while etc
2196 if ($line=~/\b(if|while|for|switch)\(/) { 2294 if ($line=~/\b(if|while|for|switch)\(/) {
@@ -2409,8 +2507,8 @@ sub process {
2409 \.$Ident\s*=\s*| 2507 \.$Ident\s*=\s*|
2410 ^\"|\"$ 2508 ^\"|\"$
2411 }x; 2509 }x;
2412 #print "REST<$rest> dstat<$dstat>\n"; 2510 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
2413 if ($rest ne '') { 2511 if ($rest ne '' && $rest ne ',') {
2414 if ($rest !~ /while\s*\(/ && 2512 if ($rest !~ /while\s*\(/ &&
2415 $dstat !~ /$exceptions/) 2513 $dstat !~ /$exceptions/)
2416 { 2514 {
@@ -2561,11 +2659,6 @@ sub process {
2561 WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); 2659 WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
2562 } 2660 }
2563 2661
2564# SPIN_LOCK_UNLOCKED & RW_LOCK_UNLOCKED are deprecated
2565 if ($line =~ /\b(SPIN_LOCK_UNLOCKED|RW_LOCK_UNLOCKED)/) {
2566 ERROR("Use of $1 is deprecated: see Documentation/spinlocks.txt\n" . $herecurr);
2567 }
2568
2569# warn about #if 0 2662# warn about #if 0
2570 if ($line =~ /^.\s*\#\s*if\s+0\b/) { 2663 if ($line =~ /^.\s*\#\s*if\s+0\b/) {
2571 CHK("if this code is redundant consider removing it\n" . 2664 CHK("if this code is redundant consider removing it\n" .
@@ -2650,11 +2743,21 @@ sub process {
2650 WARN("plain inline is preferred over $1\n" . $herecurr); 2743 WARN("plain inline is preferred over $1\n" . $herecurr);
2651 } 2744 }
2652 2745
2746# Check for __attribute__ packed, prefer __packed
2747 if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
2748 WARN("__packed is preferred over __attribute__((packed))\n" . $herecurr);
2749 }
2750
2653# check for sizeof(&) 2751# check for sizeof(&)
2654 if ($line =~ /\bsizeof\s*\(\s*\&/) { 2752 if ($line =~ /\bsizeof\s*\(\s*\&/) {
2655 WARN("sizeof(& should be avoided\n" . $herecurr); 2753 WARN("sizeof(& should be avoided\n" . $herecurr);
2656 } 2754 }
2657 2755
2756# check for line continuations in quoted strings with odd counts of "
2757 if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
2758 WARN("Avoid line continuations in quoted strings\n" . $herecurr);
2759 }
2760
2658# check for new externs in .c files. 2761# check for new externs in .c files.
2659 if ($realfile =~ /\.c$/ && defined $stat && 2762 if ($realfile =~ /\.c$/ && defined $stat &&
2660 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 2763 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -2692,27 +2795,28 @@ sub process {
2692 } 2795 }
2693 2796
2694# check for pointless casting of kmalloc return 2797# check for pointless casting of kmalloc return
2695 if ($line =~ /\*\s*\)\s*k[czm]alloc\b/) { 2798 if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) {
2696 WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); 2799 WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
2697 } 2800 }
2698 2801
2802# check for multiple semicolons
2803 if ($line =~ /;\s*;\s*$/) {
2804 WARN("Statements terminations use 1 semicolon\n" . $herecurr);
2805 }
2806
2699# check for gcc specific __FUNCTION__ 2807# check for gcc specific __FUNCTION__
2700 if ($line =~ /__FUNCTION__/) { 2808 if ($line =~ /__FUNCTION__/) {
2701 WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); 2809 WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
2702 } 2810 }
2703 2811
2704# check for semaphores used as mutexes 2812# check for semaphores initialized locked
2705 if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) { 2813 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
2706 WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
2707 }
2708# check for semaphores used as mutexes
2709 if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
2710 WARN("consider using a completion\n" . $herecurr); 2814 WARN("consider using a completion\n" . $herecurr);
2711 2815
2712 } 2816 }
2713# recommend strict_strto* over simple_strto* 2817# recommend kstrto* over simple_strto*
2714 if ($line =~ /\bsimple_(strto.*?)\s*\(/) { 2818 if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
2715 WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); 2819 WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr);
2716 } 2820 }
2717# check for __initcall(), use device_initcall() explicitly please 2821# check for __initcall(), use device_initcall() explicitly please
2718 if ($line =~ /^.\s*__initcall\s*\(/) { 2822 if ($line =~ /^.\s*__initcall\s*\(/) {
@@ -2803,6 +2907,16 @@ sub process {
2803 ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); 2907 ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
2804 } 2908 }
2805 } 2909 }
2910
2911 if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
2912 $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
2913 WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
2914 }
2915
2916 # Check for memset with swapped arguments
2917 if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) {
2918 ERROR("memset size is 3rd argument, not the second.\n" . $herecurr);
2919 }
2806 } 2920 }
2807 2921
2808 # If we have no input at all, then there is nothing to report on 2922 # If we have no input at all, then there is nothing to report on
@@ -2839,6 +2953,16 @@ sub process {
2839 print "\n" if ($quiet == 0); 2953 print "\n" if ($quiet == 0);
2840 } 2954 }
2841 2955
2956 if ($quiet == 0) {
2957 # If there were whitespace errors which cleanpatch can fix
2958 # then suggest that.
2959 if ($rpt_cleaners) {
2960 print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n";
2961 print " scripts/cleanfile\n\n";
2962 $rpt_cleaners = 0;
2963 }
2964 }
2965
2842 if ($clean == 1 && $quiet == 0) { 2966 if ($clean == 1 && $quiet == 0) {
2843 print "$vname has no obvious style problems and is ready for submission.\n" 2967 print "$vname has no obvious style problems and is ready for submission.\n"
2844 } 2968 }
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 1afff6658a7d..17e384396705 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -12,7 +12,7 @@
12# sh64 port by Paul Mundt 12# sh64 port by Paul Mundt
13# Random bits by Matt Mackall <mpm@selenic.com> 13# Random bits by Matt Mackall <mpm@selenic.com>
14# M68k port by Geert Uytterhoeven and Andreas Schwab 14# M68k port by Geert Uytterhoeven and Andreas Schwab
15# AVR32 port by Haavard Skinnemoen <hskinnemoen@atmel.com> 15# AVR32 port by Haavard Skinnemoen (Atmel)
16# PARISC port by Kyle McMartin <kyle@parisc-linux.org> 16# PARISC port by Kyle McMartin <kyle@parisc-linux.org>
17# sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk> 17# sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk>
18# 18#
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index 6bb42e72e0e5..3ab316e52313 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -6,7 +6,7 @@
6# and listed below so they are ignored. 6# and listed below so they are ignored.
7# 7#
8# Usage: 8# Usage:
9# syscallchk gcc gcc-options 9# checksyscalls.sh gcc gcc-options
10# 10#
11 11
12ignore_list() { 12ignore_list() {
@@ -204,5 +204,5 @@ sed -n -e '/^\#define/ s/[^_]*__NR_\([^[:space:]]*\).*/\
204\#endif/p' $1 204\#endif/p' $1
205} 205}
206 206
207(ignore_list && syscall_list ${srctree}/arch/x86/include/asm/unistd_32.h) | \ 207(ignore_list && syscall_list $(dirname $0)/../arch/x86/include/asm/unistd_32.h) | \
208$* -E -x c - > /dev/null 208$* -E -x c - > /dev/null
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl
index b444e89a0095..5e490a8ceca5 100755
--- a/scripts/checkversion.pl
+++ b/scripts/checkversion.pl
@@ -12,6 +12,7 @@ $| = 1;
12my $debugging; 12my $debugging;
13 13
14foreach my $file (@ARGV) { 14foreach my $file (@ARGV) {
15 next if $file =~ "include/linux/version\.h";
15 # Open this file. 16 # Open this file.
16 open( my $f, '<', $file ) 17 open( my $f, '<', $file )
17 or die "Can't open $file: $!\n"; 18 or die "Can't open $file: $!\n";
diff --git a/scripts/coccicheck b/scripts/coccicheck
index b8bcf1f7bed7..1bb1a1bd2daa 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -16,6 +16,7 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
16else 16else
17 ONLINE=0 17 ONLINE=0
18 FLAGS="-very_quiet" 18 FLAGS="-very_quiet"
19 OPTIONS="-dir $srctree"
19fi 20fi
20 21
21if [ ! -x "$SPATCH" ]; then 22if [ ! -x "$SPATCH" ]; then
@@ -25,11 +26,13 @@ fi
25 26
26if [ "$MODE" = "" ] ; then 27if [ "$MODE" = "" ] ; then
27 if [ "$ONLINE" = "0" ] ; then 28 if [ "$ONLINE" = "0" ] ; then
28 echo 'You have not explicitly specify the mode to use. Fallback to "report".' 29 echo 'You have not explicitly specified the mode to use. Using default "chain" mode.'
30 echo 'All available modes will be tried (in that order): patch, report, context, org'
29 echo 'You can specify the mode with "make coccicheck MODE=<mode>"' 31 echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
30 echo 'Available modes are: report, patch, context, org'
31 fi 32 fi
32 MODE="report" 33 MODE="chain"
34elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
35 FLAGS="$FLAGS -no_show_diff"
33fi 36fi
34 37
35if [ "$ONLINE" = "0" ] ; then 38if [ "$ONLINE" = "0" ] ; then
@@ -44,7 +47,7 @@ coccinelle () {
44 47
45 OPT=`grep "Option" $COCCI | cut -d':' -f2` 48 OPT=`grep "Option" $COCCI | cut -d':' -f2`
46 49
47# The option '-parse_cocci' can be used to syntaxically check the SmPL files. 50# The option '-parse_cocci' can be used to syntactically check the SmPL files.
48# 51#
49# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null 52# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
50 53
@@ -52,21 +55,44 @@ coccinelle () {
52 55
53 FILE=`echo $COCCI | sed "s|$srctree/||"` 56 FILE=`echo $COCCI | sed "s|$srctree/||"`
54 57
55 echo "Processing `basename $COCCI` with option(s) \"$OPT\"" 58 echo "Processing `basename $COCCI`"
59 echo "with option(s) \"$OPT\""
60 echo ''
56 echo 'Message example to submit a patch:' 61 echo 'Message example to submit a patch:'
57 62
58 sed -e '/\/\/\//!d' -e 's|^///||' $COCCI 63 sed -ne 's|^///||p' $COCCI
59 64
60 echo ' The semantic patch that makes this change is available' 65 if [ "$MODE" = "patch" ] ; then
66 echo ' The semantic patch that makes this change is available'
67 elif [ "$MODE" = "report" ] ; then
68 echo ' The semantic patch that makes this report is available'
69 elif [ "$MODE" = "context" ] ; then
70 echo ' The semantic patch that spots this code is available'
71 elif [ "$MODE" = "org" ] ; then
72 echo ' The semantic patch that makes this Org report is available'
73 else
74 echo ' The semantic patch that makes this output is available'
75 fi
61 echo " in $FILE." 76 echo " in $FILE."
62 echo '' 77 echo ''
63 echo ' More information about semantic patching is available at' 78 echo ' More information about semantic patching is available at'
64 echo ' http://coccinelle.lip6.fr/' 79 echo ' http://coccinelle.lip6.fr/'
65 echo '' 80 echo ''
66 81
67 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 82 if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
83 echo 'Semantic patch information:'
84 sed -ne 's|^//#||p' $COCCI
85 echo ''
86 fi
87 fi
88
89 if [ "$MODE" = "chain" ] ; then
90 $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
91 $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
92 $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \
93 $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
68 else 94 else
69 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 95 $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
70 fi 96 fi
71 97
72} 98}
diff --git a/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
index 7d4771d449c3..7d4771d449c3 100644
--- a/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci
+++ b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
diff --git a/scripts/coccinelle/alloc/kzalloc-simple.cocci b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci
index 2eae828fc657..046b9b16f8f9 100644
--- a/scripts/coccinelle/alloc/kzalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci
@@ -1,5 +1,9 @@
1/// 1///
2/// kzalloc should be used rather than kmalloc followed by memset 0 2/// Use kzalloc rather than kmalloc followed by memset with 0
3///
4/// This considers some simple cases that are common and easy to validate
5/// Note in particular that there are no ...s in the rule, so all of the
6/// matched code has to be contiguous
3/// 7///
4// Confidence: High 8// Confidence: High
5// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. 9// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2.
diff --git a/scripts/coccinelle/err_cast.cocci b/scripts/coccinelle/api/err_cast.cocci
index 2ce115000af6..2ce115000af6 100644
--- a/scripts/coccinelle/err_cast.cocci
+++ b/scripts/coccinelle/api/err_cast.cocci
diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci
new file mode 100644
index 000000000000..e0805ad08d39
--- /dev/null
+++ b/scripts/coccinelle/api/kstrdup.cocci
@@ -0,0 +1,39 @@
1/// Use kstrdup rather than duplicating its implementation
2///
3// Confidence: High
4// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
5// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
6// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/
8// Comments:
9// Options: -no_includes -include_headers
10
11virtual patch
12
13@@
14expression from,to;
15expression flag,E1,E2;
16statement S;
17@@
18
19- to = kmalloc(strlen(from) + 1,flag);
20+ to = kstrdup(from, flag);
21 ... when != \(from = E1 \| to = E1 \)
22 if (to==NULL || ...) S
23 ... when != \(from = E2 \| to = E2 \)
24- strcpy(to, from);
25
26@@
27expression x,from,to;
28expression flag,E1,E2,E3;
29statement S;
30@@
31
32- x = strlen(from) + 1;
33 ... when != \( x = E1 \| from = E1 \)
34- to = \(kmalloc\|kzalloc\)(x,flag);
35+ to = kstrdup(from, flag);
36 ... when != \(x = E2 \| from = E2 \| to = E2 \)
37 if (to==NULL || ...) S
38 ... when != \(x = E3 \| from = E3 \| to = E3 \)
39- memcpy(to, from, x);
diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci
new file mode 100644
index 000000000000..b5d722077dc1
--- /dev/null
+++ b/scripts/coccinelle/api/memdup.cocci
@@ -0,0 +1,40 @@
1/// Use kmemdup rather than duplicating its implementation
2///
3// Confidence: High
4// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
5// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
6// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/
8// Comments:
9// Options: -no_includes -include_headers
10
11virtual patch
12
13@r1@
14expression from,to;
15expression flag;
16position p;
17@@
18
19 to = \(kmalloc@p\|kzalloc@p\)(strlen(from) + 1,flag);
20
21@r2@
22expression x,from,to;
23expression flag,E1;
24position p;
25@@
26
27 x = strlen(from) + 1;
28 ... when != \( x = E1 \| from = E1 \)
29 to = \(kmalloc@p\|kzalloc@p\)(x,flag);
30
31@@
32expression from,to,size,flag;
33position p != {r1.p,r2.p};
34statement S;
35@@
36
37- to = \(kmalloc@p\|kzalloc@p\)(size,flag);
38+ to = kmemdup(from,size,flag);
39 if (to==NULL || ...) S
40- memcpy(to, from, size);
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
new file mode 100644
index 000000000000..72ce012e878a
--- /dev/null
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -0,0 +1,35 @@
1/// Use kmemdup_user rather than duplicating its implementation
2/// This is a little bit restricted to reduce false positives
3///
4// Confidence: High
5// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
6// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
7// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/
9// Comments:
10// Options: -no_includes -include_headers
11
12virtual patch
13
14@@
15expression from,to,size,flag;
16position p;
17identifier l1,l2;
18@@
19
20- to = \(kmalloc@p\|kzalloc@p\)(size,flag);
21+ to = memdup_user(from,size);
22 if (
23- to==NULL
24+ IS_ERR(to)
25 || ...) {
26 <+... when != goto l1;
27- -ENOMEM
28+ PTR_ERR(to)
29 ...+>
30 }
31- if (copy_from_user(to, from, size) != 0) {
32- <+... when != goto l2;
33- -EFAULT
34- ...+>
35- }
diff --git a/scripts/coccinelle/resource_size.cocci b/scripts/coccinelle/api/resource_size.cocci
index 1935a58b39d9..1935a58b39d9 100644
--- a/scripts/coccinelle/resource_size.cocci
+++ b/scripts/coccinelle/api/resource_size.cocci
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci
new file mode 100644
index 000000000000..f9f79d9245ee
--- /dev/null
+++ b/scripts/coccinelle/free/kfree.cocci
@@ -0,0 +1,117 @@
1/// Find a use after free.
2//# Values of variables may imply that some
3//# execution paths are not possible, resulting in false positives.
4//# Another source of false positives are macros such as
5//# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument
6///
7// Confidence: Moderate
8// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/
12// Comments:
13// Options: -no_includes -include_headers
14
15virtual org
16virtual report
17
18@free@
19expression E;
20position p1;
21@@
22
23kfree@p1(E)
24
25@print expression@
26constant char *c;
27expression free.E,E2;
28type T;
29position p;
30identifier f;
31@@
32
33(
34 f(...,c,...,(T)E@p,...)
35|
36 E@p == E2
37|
38 E@p != E2
39|
40 !E@p
41|
42 E@p || ...
43)
44
45@sz@
46expression free.E;
47position p;
48@@
49
50 sizeof(<+...E@p...+>)
51
52@loop exists@
53expression E;
54identifier l;
55position ok;
56@@
57
58while (1) { ...
59 kfree@ok(E)
60 ... when != break;
61 when != goto l;
62 when forall
63}
64
65@r exists@
66expression free.E, subE<=free.E, E2;
67expression E1;
68iterator iter;
69statement S;
70position free.p1!=loop.ok,p2!={print.p,sz.p};
71@@
72
73kfree@p1(E,...)
74...
75(
76 iter(...,subE,...) S // no use
77|
78 list_remove_head(E1,subE,...)
79|
80 subE = E2
81|
82 subE++
83|
84 ++subE
85|
86 --subE
87|
88 subE--
89|
90 &subE
91|
92 BUG(...)
93|
94 BUG_ON(...)
95|
96 return_VALUE(...)
97|
98 return_ACPI_STATUS(...)
99|
100 E@p2 // bad use
101)
102
103@script:python depends on org@
104p1 << free.p1;
105p2 << r.p2;
106@@
107
108cocci.print_main("kfree",p1)
109cocci.print_secs("ref",p2)
110
111@script:python depends on report@
112p1 << free.p1;
113p2 << r.p2;
114@@
115
116msg = "reference preceded by free on line %s" % (p1[0].line)
117coccilib.report.print_report(p2[0],msg)
diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
new file mode 100644
index 000000000000..77bc108c3f59
--- /dev/null
+++ b/scripts/coccinelle/iterators/fen.cocci
@@ -0,0 +1,64 @@
1/// These iterators only exit normally when the loop cursor is NULL, so there
2/// is no point to call of_node_put on the final value.
3///
4// Confidence: High
5// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
6// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
7// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/
9// Comments:
10// Options: -no_includes -include_headers
11
12virtual patch
13
14@@
15iterator name for_each_node_by_name;
16expression np,E;
17identifier l;
18@@
19
20for_each_node_by_name(np,...) {
21 ... when != break;
22 when != goto l;
23}
24... when != np = E
25- of_node_put(np);
26
27@@
28iterator name for_each_node_by_type;
29expression np,E;
30identifier l;
31@@
32
33for_each_node_by_type(np,...) {
34 ... when != break;
35 when != goto l;
36}
37... when != np = E
38- of_node_put(np);
39
40@@
41iterator name for_each_compatible_node;
42expression np,E;
43identifier l;
44@@
45
46for_each_compatible_node(np,...) {
47 ... when != break;
48 when != goto l;
49}
50... when != np = E
51- of_node_put(np);
52
53@@
54iterator name for_each_matching_node;
55expression np,E;
56identifier l;
57@@
58
59for_each_matching_node(np,...) {
60 ... when != break;
61 when != goto l;
62}
63... when != np = E
64- of_node_put(np);
diff --git a/scripts/coccinelle/iterators/itnull.cocci b/scripts/coccinelle/iterators/itnull.cocci
new file mode 100644
index 000000000000..baa4297a4ed1
--- /dev/null
+++ b/scripts/coccinelle/iterators/itnull.cocci
@@ -0,0 +1,58 @@
1/// Many iterators have the property that the first argument is always bound
2/// to a real list element, never NULL. False positives arise for some
3/// iterators that do not have this property, or in cases when the loop
4/// cursor is reassigned. The latter should only happen when the matched
5/// code is on the way to a loop exit (break, goto, or return).
6///
7// Confidence: Moderate
8// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/
12// Comments:
13// Options: -no_includes -include_headers
14
15virtual patch
16
17@@
18iterator I;
19expression x,E,E1,E2;
20statement S,S1,S2;
21@@
22
23I(x,...) { <...
24(
25- if (x == NULL && ...) S
26|
27- if (x != NULL || ...)
28 S
29|
30- (x == NULL) ||
31 E
32|
33- (x != NULL) &&
34 E
35|
36- (x == NULL && ...) ? E1 :
37 E2
38|
39- (x != NULL || ...) ?
40 E1
41- : E2
42|
43- if (x == NULL && ...) S1 else
44 S2
45|
46- if (x != NULL || ...)
47 S1
48- else S2
49|
50+ BAD(
51 x == NULL
52+ )
53|
54+ BAD(
55 x != NULL
56+ )
57)
58 ...> } \ No newline at end of file
diff --git a/scripts/coccinelle/iterators/list_entry_update.cocci b/scripts/coccinelle/iterators/list_entry_update.cocci
new file mode 100644
index 000000000000..b2967475679b
--- /dev/null
+++ b/scripts/coccinelle/iterators/list_entry_update.cocci
@@ -0,0 +1,62 @@
1/// list_for_each_entry uses its first argument to get from one element of
2/// the list to the next, so it is usually not a good idea to reassign it.
3/// The first rule finds such a reassignment and the second rule checks
4/// that there is a path from the reassignment back to the top of the loop.
5///
6// Confidence: High
7// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
8// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options: -no_includes -include_headers
13
14virtual context
15virtual org
16virtual report
17
18@r@
19iterator name list_for_each_entry;
20expression x,E;
21position p1,p2;
22@@
23
24list_for_each_entry@p1(x,...) { <... x =@p2 E ...> }
25
26@depends on context && !org && !report@
27expression x,E;
28position r.p1,r.p2;
29statement S;
30@@
31
32*x =@p2 E
33...
34list_for_each_entry@p1(x,...) S
35
36// ------------------------------------------------------------------------
37
38@back depends on (org || report) && !context exists@
39expression x,E;
40position r.p1,r.p2;
41statement S;
42@@
43
44x =@p2 E
45...
46list_for_each_entry@p1(x,...) S
47
48@script:python depends on back && org@
49p1 << r.p1;
50p2 << r.p2;
51@@
52
53cocci.print_main("iterator",p1)
54cocci.print_secs("update",p2)
55
56@script:python depends on back && report@
57p1 << r.p1;
58p2 << r.p2;
59@@
60
61msg = "iterator with update on line %s" % (p2[0].line)
62coccilib.report.print_report(p1[0],msg)
diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci
new file mode 100644
index 000000000000..00af5344a68f
--- /dev/null
+++ b/scripts/coccinelle/locks/call_kern.cocci
@@ -0,0 +1,74 @@
1/// Find functions that refer to GFP_KERNEL but are called with locks held.
2/// The proposed change of converting the GFP_KERNEL is not necessarily the
3/// correct one. It may be desired to unlock the lock, or to not call the
4/// function under the lock in the first place.
5///
6// Confidence: Moderate
7// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
8// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options: -no_includes -include_headers
13
14virtual patch
15
16@gfp exists@
17identifier fn;
18position p;
19@@
20
21fn(...) {
22 ... when != read_unlock_irq(...)
23 when != write_unlock_irq(...)
24 when != read_unlock_irqrestore(...)
25 when != write_unlock_irqrestore(...)
26 when != spin_unlock(...)
27 when != spin_unlock_irq(...)
28 when != spin_unlock_irqrestore(...)
29 when != local_irq_enable(...)
30 when any
31 GFP_KERNEL@p
32 ... when any
33}
34
35@locked@
36identifier gfp.fn;
37@@
38
39(
40read_lock_irq
41|
42write_lock_irq
43|
44read_lock_irqsave
45|
46write_lock_irqsave
47|
48spin_lock
49|
50spin_trylock
51|
52spin_lock_irq
53|
54spin_lock_irqsave
55|
56local_irq_disable
57)
58 (...)
59... when != read_unlock_irq(...)
60 when != write_unlock_irq(...)
61 when != read_unlock_irqrestore(...)
62 when != write_unlock_irqrestore(...)
63 when != spin_unlock(...)
64 when != spin_unlock_irq(...)
65 when != spin_unlock_irqrestore(...)
66 when != local_irq_enable(...)
67fn(...)
68
69@depends on locked@
70position gfp.p;
71@@
72
73- GFP_KERNEL@p
74+ GFP_ATOMIC
diff --git a/scripts/coccinelle/locks/double_lock.cocci b/scripts/coccinelle/locks/double_lock.cocci
new file mode 100644
index 000000000000..63b24e682fad
--- /dev/null
+++ b/scripts/coccinelle/locks/double_lock.cocci
@@ -0,0 +1,92 @@
1/// Find double locks. False positives may occur when some paths cannot
2/// occur at execution, due to the values of variables, and when there is
3/// an intervening function call that releases the lock.
4///
5// Confidence: Moderate
6// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
7// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/
10// Comments:
11// Options: -no_includes -include_headers
12
13virtual org
14virtual report
15
16@locked@
17position p1;
18expression E1;
19position p;
20@@
21
22(
23mutex_lock@p1
24|
25mutex_trylock@p1
26|
27spin_lock@p1
28|
29spin_trylock@p1
30|
31read_lock@p1
32|
33read_trylock@p1
34|
35write_lock@p1
36|
37write_trylock@p1
38) (E1@p,...);
39
40@balanced@
41position p1 != locked.p1;
42position locked.p;
43identifier lock,unlock;
44expression x <= locked.E1;
45expression E,locked.E1;
46expression E2;
47@@
48
49if (E) {
50 <+... when != E1
51 lock(E1@p,...)
52 ...+>
53}
54... when != E1
55 when != \(x = E2\|&x\)
56 when forall
57if (E) {
58 <+... when != E1
59 unlock@p1(E1,...)
60 ...+>
61}
62
63@r depends on !balanced exists@
64expression x <= locked.E1;
65expression locked.E1;
66expression E2;
67identifier lock;
68position locked.p,p1,p2;
69@@
70
71lock@p1 (E1@p,...);
72... when != E1
73 when != \(x = E2\|&x\)
74lock@p2 (E1,...);
75
76@script:python depends on org@
77p1 << r.p1;
78p2 << r.p2;
79lock << r.lock;
80@@
81
82cocci.print_main(lock,p1)
83cocci.print_secs("second lock",p2)
84
85@script:python depends on report@
86p1 << r.p1;
87p2 << r.p2;
88lock << r.lock;
89@@
90
91msg = "second lock on line %s" % (p2[0].line)
92coccilib.report.print_report(p1[0],msg)
diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci
new file mode 100644
index 000000000000..b4344d838097
--- /dev/null
+++ b/scripts/coccinelle/locks/flags.cocci
@@ -0,0 +1,80 @@
1/// Find nested lock+irqsave functions that use the same flags variables
2///
3// Confidence: High
4// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
5// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
6// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/
8// Comments:
9// Options: -no_includes -include_headers
10
11virtual context
12virtual org
13virtual report
14
15@r@
16expression lock1,lock2,flags;
17position p1,p2;
18@@
19
20(
21spin_lock_irqsave@p1(lock1,flags)
22|
23read_lock_irqsave@p1(lock1,flags)
24|
25write_lock_irqsave@p1(lock1,flags)
26)
27... when != flags
28(
29spin_lock_irqsave(lock1,flags)
30|
31read_lock_irqsave(lock1,flags)
32|
33write_lock_irqsave(lock1,flags)
34|
35spin_lock_irqsave@p2(lock2,flags)
36|
37read_lock_irqsave@p2(lock2,flags)
38|
39write_lock_irqsave@p2(lock2,flags)
40)
41
42@d@
43expression f <= r.flags;
44expression lock1,lock2,flags;
45position r.p1, r.p2;
46@@
47
48(
49*spin_lock_irqsave@p1(lock1,flags)
50|
51*read_lock_irqsave@p1(lock1,flags)
52|
53*write_lock_irqsave@p1(lock1,flags)
54)
55... when != f
56(
57*spin_lock_irqsave@p2(lock2,flags)
58|
59*read_lock_irqsave@p2(lock2,flags)
60|
61*write_lock_irqsave@p2(lock2,flags)
62)
63
64// ----------------------------------------------------------------------
65
66@script:python depends on d && org@
67p1 << r.p1;
68p2 << r.p2;
69@@
70
71cocci.print_main("original lock",p1)
72cocci.print_secs("nested lock+irqsave that reuses flags",p2)
73
74@script:python depends on d && report@
75p1 << r.p1;
76p2 << r.p2;
77@@
78
79msg="ERROR: nested lock+irqsave that reuses flags from %s." % (p1[0].line)
80coccilib.report.print_report(p2[0], msg)
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci
new file mode 100644
index 000000000000..7641a2925434
--- /dev/null
+++ b/scripts/coccinelle/locks/mini_lock.cocci
@@ -0,0 +1,95 @@
1/// Find missing unlocks. This semantic match considers the specific case
2/// where the unlock is missing from an if branch, and there is a lock
3/// before the if and an unlock after the if. False positives are due to
4/// cases where the if branch represents a case where the function is
5/// supposed to exit with the lock held, or where there is some preceding
6/// function call that releases the lock.
7///
8// Confidence: Moderate
9// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
10// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
11// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/
13// Comments:
14// Options: -no_includes -include_headers
15
16virtual org
17virtual report
18
19@prelocked@
20position p1,p;
21expression E1;
22@@
23
24(
25mutex_lock@p1
26|
27mutex_trylock@p1
28|
29spin_lock@p1
30|
31spin_trylock@p1
32|
33read_lock@p1
34|
35read_trylock@p1
36|
37write_lock@p1
38|
39write_trylock@p1
40|
41read_lock_irq@p1
42|
43write_lock_irq@p1
44|
45read_lock_irqsave@p1
46|
47write_lock_irqsave@p1
48|
49spin_lock_irq@p1
50|
51spin_lock_irqsave@p1
52) (E1@p,...);
53
54@looped@
55position r;
56@@
57
58for(...;...;...) { <+... return@r ...; ...+> }
59
60@err@
61expression E1;
62position prelocked.p;
63position up != prelocked.p1;
64position r!=looped.r;
65identifier lock,unlock;
66@@
67
68lock(E1@p,...);
69<+... when != E1
70if (...) {
71 ... when != E1
72 return@r ...;
73}
74...+>
75unlock@up(E1,...);
76
77@script:python depends on org@
78p << prelocked.p1;
79lock << err.lock;
80unlock << err.unlock;
81p2 << err.r;
82@@
83
84cocci.print_main(lock,p)
85cocci.print_secs(unlock,p2)
86
87@script:python depends on report@
88p << prelocked.p1;
89lock << err.lock;
90unlock << err.unlock;
91p2 << err.r;
92@@
93
94msg = "preceding lock on line %s" % (p[0].line)
95coccilib.report.print_report(p2[0],msg)
diff --git a/scripts/coccinelle/misc/doubleinit.cocci b/scripts/coccinelle/misc/doubleinit.cocci
new file mode 100644
index 000000000000..156b20adb351
--- /dev/null
+++ b/scripts/coccinelle/misc/doubleinit.cocci
@@ -0,0 +1,53 @@
1/// Find duplicate field initializations. This has a high rate of false
2/// positives due to #ifdefs, which Coccinelle is not aware of in a structure
3/// initialization.
4///
5// Confidence: Low
6// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
7// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/
10// Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
11// Options: -no_includes -include_headers
12
13virtual org
14virtual report
15
16@r@
17identifier I, s, fld;
18position p0,p;
19expression E;
20@@
21
22struct I s =@p0 { ..., .fld@p = E, ...};
23
24@s@
25identifier I, s, r.fld;
26position r.p0,p;
27expression E;
28@@
29
30struct I s =@p0 { ..., .fld@p = E, ...};
31
32@script:python depends on org@
33p0 << r.p0;
34fld << r.fld;
35ps << s.p;
36pr << r.p;
37@@
38
39if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)):
40 cocci.print_main(fld,p0)
41 cocci.print_secs("s",ps)
42 cocci.print_secs("r",pr)
43
44@script:python depends on report@
45p0 << r.p0;
46fld << r.fld;
47ps << s.p;
48pr << r.p;
49@@
50
51if int(ps[0].line) < int(pr[0].line) or (int(ps[0].line) == int(pr[0].line) and int(ps[0].column) < int(pr[0].column)):
52 msg = "%s: first occurrence %s, second occurrence %s" % (fld,ps[0].line,pr[0].line)
53 coccilib.report.print_report(p0[0],msg)
diff --git a/scripts/coccinelle/misc/ifcol.cocci b/scripts/coccinelle/misc/ifcol.cocci
new file mode 100644
index 000000000000..b7ed91dbeb95
--- /dev/null
+++ b/scripts/coccinelle/misc/ifcol.cocci
@@ -0,0 +1,48 @@
1/// Find confusingly indented code in or after an if. An if branch should
2/// be indented. The code following an if should not be indented.
3/// Sometimes, code after an if that is indented is actually intended to be
4/// part of the if branch.
5///
6/// This has a high rate of false positives, because Coccinelle's column
7/// calculation does not distinguish between spaces and tabs, so code that
8/// is not visually aligned may be considered to be in the same column.
9///
10// Confidence: Low
11// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
12// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
13// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
14// URL: http://coccinelle.lip6.fr/
15// Comments:
16// Options: -no_includes -include_headers
17
18virtual org
19virtual report
20
21@r disable braces4@
22position p1,p2;
23statement S1,S2;
24@@
25
26(
27if (...) { ... }
28|
29if (...) S1@p1 S2@p2
30)
31
32@script:python depends on org@
33p1 << r.p1;
34p2 << r.p2;
35@@
36
37if (p1[0].column == p2[0].column):
38 cocci.print_main("branch",p1)
39 cocci.print_secs("after",p2)
40
41@script:python depends on report@
42p1 << r.p1;
43p2 << r.p2;
44@@
45
46if (p1[0].column == p2[0].column):
47 msg = "code aligned with following code on line %s" % (p2[0].line)
48 coccilib.report.print_report(p1[0],msg)
diff --git a/scripts/coccinelle/deref_null.cocci b/scripts/coccinelle/null/deref_null.cocci
index 9969d76d0f4b..cdac6cfcce92 100644
--- a/scripts/coccinelle/deref_null.cocci
+++ b/scripts/coccinelle/null/deref_null.cocci
@@ -11,21 +11,10 @@
11// Options: 11// Options:
12 12
13virtual context 13virtual context
14virtual patch
15virtual org 14virtual org
16virtual report 15virtual report
17 16
18@initialize:python depends on !context && patch && !org && !report@ 17@ifm@
19
20import sys
21print >> sys.stderr, "This semantic patch does not support the 'patch' mode."
22
23@depends on patch@
24@@
25
26this_rule_should_never_matches();
27
28@ifm depends on !patch@
29expression *E; 18expression *E;
30statement S1,S2; 19statement S1,S2;
31position p1; 20position p1;
@@ -35,7 +24,7 @@ if@p1 ((E == NULL && ...) || ...) S1 else S2
35 24
36// The following two rules are separate, because both can match a single 25// The following two rules are separate, because both can match a single
37// expression in different ways 26// expression in different ways
38@pr1 depends on !patch expression@ 27@pr1 expression@
39expression *ifm.E; 28expression *ifm.E;
40identifier f; 29identifier f;
41position p1; 30position p1;
@@ -43,7 +32,7 @@ position p1;
43 32
44 (E != NULL && ...) ? <+...E->f@p1...+> : ... 33 (E != NULL && ...) ? <+...E->f@p1...+> : ...
45 34
46@pr2 depends on !patch expression@ 35@pr2 expression@
47expression *ifm.E; 36expression *ifm.E;
48identifier f; 37identifier f;
49position p2; 38position p2;
@@ -59,7 +48,7 @@ position p2;
59 48
60// For org and report modes 49// For org and report modes
61 50
62@r depends on !context && !patch && (org || report) exists@ 51@r depends on !context && (org || report) exists@
63expression subE <= ifm.E; 52expression subE <= ifm.E;
64expression *ifm.E; 53expression *ifm.E;
65expression E1,E2; 54expression E1,E2;
@@ -99,7 +88,7 @@ if@p1 ((E == NULL && ...) || ...)
99} 88}
100else S3 89else S3
101 90
102@script:python depends on !context && !patch && !org && report@ 91@script:python depends on !context && !org && report@
103p << r.p; 92p << r.p;
104p1 << ifm.p1; 93p1 << ifm.p1;
105x << ifm.E; 94x << ifm.E;
@@ -109,7 +98,7 @@ msg="ERROR: %s is NULL but dereferenced." % (x)
109coccilib.report.print_report(p[0], msg) 98coccilib.report.print_report(p[0], msg)
110cocci.include_match(False) 99cocci.include_match(False)
111 100
112@script:python depends on !context && !patch && org && !report@ 101@script:python depends on !context && org && !report@
113p << r.p; 102p << r.p;
114p1 << ifm.p1; 103p1 << ifm.p1;
115x << ifm.E; 104x << ifm.E;
@@ -120,7 +109,7 @@ msg_safe=msg.replace("[","@(").replace("]",")")
120cocci.print_main(msg_safe,p) 109cocci.print_main(msg_safe,p)
121cocci.include_match(False) 110cocci.include_match(False)
122 111
123@s depends on !context && !patch && (org || report) exists@ 112@s depends on !context && (org || report) exists@
124expression subE <= ifm.E; 113expression subE <= ifm.E;
125expression *ifm.E; 114expression *ifm.E;
126expression E1,E2; 115expression E1,E2;
@@ -159,7 +148,7 @@ if@p1 ((E == NULL && ...) || ...)
159} 148}
160else S3 149else S3
161 150
162@script:python depends on !context && !patch && !org && report@ 151@script:python depends on !context && !org && report@
163p << s.p; 152p << s.p;
164p1 << ifm.p1; 153p1 << ifm.p1;
165x << ifm.E; 154x << ifm.E;
@@ -168,7 +157,7 @@ x << ifm.E;
168msg="ERROR: %s is NULL but dereferenced." % (x) 157msg="ERROR: %s is NULL but dereferenced." % (x)
169coccilib.report.print_report(p[0], msg) 158coccilib.report.print_report(p[0], msg)
170 159
171@script:python depends on !context && !patch && org && !report@ 160@script:python depends on !context && org && !report@
172p << s.p; 161p << s.p;
173p1 << ifm.p1; 162p1 << ifm.p1;
174x << ifm.E; 163x << ifm.E;
@@ -180,7 +169,7 @@ cocci.print_main(msg_safe,p)
180 169
181// For context mode 170// For context mode
182 171
183@depends on context && !patch && !org && !report exists@ 172@depends on context && !org && !report exists@
184expression subE <= ifm.E; 173expression subE <= ifm.E;
185expression *ifm.E; 174expression *ifm.E;
186expression E1,E2; 175expression E1,E2;
@@ -223,7 +212,7 @@ else S3
223// The following three rules are duplicates of ifm, pr1 and pr2 respectively. 212// The following three rules are duplicates of ifm, pr1 and pr2 respectively.
224// It is need because the previous rule as already made a "change". 213// It is need because the previous rule as already made a "change".
225 214
226@ifm1 depends on !patch@ 215@ifm1@
227expression *E; 216expression *E;
228statement S1,S2; 217statement S1,S2;
229position p1; 218position p1;
@@ -231,7 +220,7 @@ position p1;
231 220
232if@p1 ((E == NULL && ...) || ...) S1 else S2 221if@p1 ((E == NULL && ...) || ...) S1 else S2
233 222
234@pr11 depends on !patch expression@ 223@pr11 expression@
235expression *ifm1.E; 224expression *ifm1.E;
236identifier f; 225identifier f;
237position p1; 226position p1;
@@ -239,7 +228,7 @@ position p1;
239 228
240 (E != NULL && ...) ? <+...E->f@p1...+> : ... 229 (E != NULL && ...) ? <+...E->f@p1...+> : ...
241 230
242@pr12 depends on !patch expression@ 231@pr12 expression@
243expression *ifm1.E; 232expression *ifm1.E;
244identifier f; 233identifier f;
245position p2; 234position p2;
@@ -253,7 +242,7 @@ position p2;
253 sizeof(<+...E->f@p2...+>) 242 sizeof(<+...E->f@p2...+>)
254) 243)
255 244
256@depends on context && !patch && !org && !report exists@ 245@depends on context && !org && !report exists@
257expression subE <= ifm1.E; 246expression subE <= ifm1.E;
258expression *ifm1.E; 247expression *ifm1.E;
259expression E1,E2; 248expression E1,E2;
diff --git a/scripts/coccinelle/null/eno.cocci b/scripts/coccinelle/null/eno.cocci
new file mode 100644
index 000000000000..4c9c52b9c413
--- /dev/null
+++ b/scripts/coccinelle/null/eno.cocci
@@ -0,0 +1,20 @@
1/// The various basic memory allocation functions don't return ERR_PTR
2///
3// Confidence: High
4// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
5// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
6// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/
8// Comments:
9// Options: -no_includes -include_headers
10
11virtual patch
12
13@@
14expression x,E;
15@@
16
17x = \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
18... when != x = E
19- IS_ERR(x)
20+ !x
diff --git a/scripts/coccinelle/null/kmerr.cocci b/scripts/coccinelle/null/kmerr.cocci
new file mode 100644
index 000000000000..949bf656c64c
--- /dev/null
+++ b/scripts/coccinelle/null/kmerr.cocci
@@ -0,0 +1,72 @@
1/// This semantic patch looks for kmalloc etc that are not followed by a
2/// NULL check. It only gives a report in the case where there is some
3/// error handling code later in the function, which may be helpful
4/// in determining what the error handling code for the call to kmalloc etc
5/// should be.
6///
7// Confidence: High
8// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/
12// Comments:
13// Options: -no_includes -include_headers
14
15virtual context
16virtual org
17virtual report
18
19@withtest@
20expression x;
21position p;
22identifier f,fld;
23@@
24
25x@p = f(...);
26... when != x->fld
27\(x == NULL \| x != NULL\)
28
29@fixed depends on context && !org && !report@
30expression x,x1;
31position p1 != withtest.p;
32statement S;
33position any withtest.p;
34identifier f;
35@@
36
37*x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
38...
39*x1@p = f(...);
40if (!x1) S
41
42// ------------------------------------------------------------------------
43
44@rfixed depends on (org || report) && !context exists@
45expression x,x1;
46position p1 != withtest.p;
47position p2;
48statement S;
49position any withtest.p;
50identifier f;
51@@
52
53x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
54...
55x1@p = f@p2(...);
56if (!x1) S
57
58@script:python depends on org@
59p1 << rfixed.p1;
60p2 << rfixed.p2;
61@@
62
63cocci.print_main("alloc call",p1)
64cocci.print_secs("possible model",p2)
65
66@script:python depends on report@
67p1 << rfixed.p1;
68p2 << rfixed.p2;
69@@
70
71msg = "alloc with no test, possible model on line %s" % (p2[0].line)
72coccilib.report.print_report(p1[0],msg)
diff --git a/scripts/coccinelle/tests/doublebitand.cocci b/scripts/coccinelle/tests/doublebitand.cocci
new file mode 100644
index 000000000000..9ba73d05a77e
--- /dev/null
+++ b/scripts/coccinelle/tests/doublebitand.cocci
@@ -0,0 +1,54 @@
1/// Find bit operations that include the same argument more than once
2//# One source of false positives is when the argument performs a side
3//# effect. Another source of false positives is when a neutral value
4//# such as 0 for | is used to indicate no information, to maintain the
5//# same structure as other similar expressions
6///
7// Confidence: Moderate
8// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/
12// Comments:
13// Options: -no_includes -include_headers
14
15virtual context
16virtual org
17virtual report
18
19@r expression@
20expression E;
21position p;
22@@
23
24(
25* E@p
26 & ... & E
27|
28* E@p
29 | ... | E
30|
31* E@p
32 & ... & !E
33|
34* E@p
35 | ... | !E
36|
37* !E@p
38 & ... & E
39|
40* !E@p
41 | ... | E
42)
43
44@script:python depends on org@
45p << r.p;
46@@
47
48cocci.print_main("duplicated argument to & or |",p)
49
50@script:python depends on report@
51p << r.p;
52@@
53
54coccilib.report.print_report(p[0],"duplicated argument to & or |")
diff --git a/scripts/coccinelle/tests/doubletest.cocci b/scripts/coccinelle/tests/doubletest.cocci
new file mode 100644
index 000000000000..13a2c0e8a4bf
--- /dev/null
+++ b/scripts/coccinelle/tests/doubletest.cocci
@@ -0,0 +1,40 @@
1/// Find &&/|| operations that include the same argument more than once
2//# A common source of false positives is when the argument performs a side
3//# effect.
4///
5// Confidence: Moderate
6// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
7// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/
10// Comments:
11// Options: -no_includes -include_headers
12
13virtual context
14virtual org
15virtual report
16
17@r expression@
18expression E;
19position p;
20@@
21
22(
23* E@p
24 || ... || E
25|
26* E@p
27 && ... && E
28)
29
30@script:python depends on org@
31p << r.p;
32@@
33
34cocci.print_main("duplicated argument to && or ||",p)
35
36@script:python depends on report@
37p << r.p;
38@@
39
40coccilib.report.print_report(p[0],"duplicated argument to && or ||")
diff --git a/scripts/config b/scripts/config
index 608d7fdb13e8..a7c7c4b8e957 100755
--- a/scripts/config
+++ b/scripts/config
@@ -10,8 +10,10 @@ commands:
10 --enable|-e option Enable option 10 --enable|-e option Enable option
11 --disable|-d option Disable option 11 --disable|-d option Disable option
12 --module|-m option Turn option into a module 12 --module|-m option Turn option into a module
13 --set-str option value 13 --set-str option string
14 Set option to "value" 14 Set option to "string"
15 --set-val option value
16 Set option to value
15 --state|-s option Print state of option (n,y,m,undef) 17 --state|-s option Print state of option (n,y,m,undef)
16 18
17 --enable-after|-E beforeopt option 19 --enable-after|-E beforeopt option
@@ -86,7 +88,7 @@ while [ "$1" != "" ] ; do
86 B=$ARG 88 B=$ARG
87 shift 2 89 shift 2
88 ;; 90 ;;
89 --*) 91 -*)
90 checkarg "$1" 92 checkarg "$1"
91 shift 93 shift
92 ;; 94 ;;
@@ -109,6 +111,11 @@ while [ "$1" != "" ] ; do
109 shift 111 shift
110 ;; 112 ;;
111 113
114 --set-val)
115 set_var "CONFIG_$ARG" "CONFIG_$ARG=$1"
116 shift
117 ;;
118
112 --state|-s) 119 --state|-s)
113 if grep -q "# CONFIG_$ARG is not set" $FN ; then 120 if grep -q "# CONFIG_$ARG is not set" $FN ; then
114 echo n 121 echo n
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
new file mode 100755
index 000000000000..a27235685949
--- /dev/null
+++ b/scripts/depmod.sh
@@ -0,0 +1,50 @@
1#!/bin/sh
2#
3# A depmod wrapper used by the toplevel Makefile
4
5if test $# -ne 2; then
6 echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
7 exit 1
8fi
9DEPMOD=$1
10KERNELRELEASE=$2
11
12if ! "$DEPMOD" -V 2>/dev/null | grep -q module-init-tools; then
13 echo "Warning: you may need to install module-init-tools" >&2
14 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt" >&2
15 sleep 1
16fi
17
18if ! test -r System.map -a -x "$DEPMOD"; then
19 exit 0
20fi
21# older versions of depmod require the version string to start with three
22# numbers, so we cheat with a symlink here
23depmod_hack_needed=true
24tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
25mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
26if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
27 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
28 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
29 depmod_hack_needed=false
30 fi
31fi
32rm -rf "$tmp_dir"
33if $depmod_hack_needed; then
34 symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
35 ln -s "$KERNELRELEASE" "$symlink"
36 KERNELRELEASE=99.98.$KERNELRELEASE
37fi
38
39set -- -ae -F System.map
40if test -n "$INSTALL_MOD_PATH"; then
41 set -- "$@" -b "$INSTALL_MOD_PATH"
42fi
43"$DEPMOD" "$@" "$KERNELRELEASE"
44ret=$?
45
46if $depmod_hack_needed; then
47 rm -f "$symlink"
48fi
49
50exit $ret
diff --git a/scripts/basic/docproc.c b/scripts/docproc.c
index fc3b18d844af..98dec87974d0 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/docproc.c
@@ -333,7 +333,10 @@ static void docsect(char *filename, char *line)
333 if (*s == '\n') 333 if (*s == '\n')
334 *s = '\0'; 334 *s = '\0';
335 335
336 asprintf(&s, "DOC: %s", line); 336 if (asprintf(&s, "DOC: %s", line) < 0) {
337 perror("asprintf");
338 exit(1);
339 }
337 consume_symbol(s); 340 consume_symbol(s);
338 free(s); 341 free(s);
339 342
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 01cdb36fc583..04a31c17639f 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -4,7 +4,7 @@ hostprogs-y := dtc
4always := $(hostprogs-y) 4always := $(hostprogs-y)
5 5
6dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ 6dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
7 srcpos.o checks.o 7 srcpos.o checks.o util.o
8dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o 8dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
9 9
10# Source files need to get at the userspace version of libfdt_env.h to compile 10# Source files need to get at the userspace version of libfdt_env.h to compile
@@ -19,6 +19,7 @@ HOSTCFLAGS_fstree.o := $(HOSTCFLAGS_DTC)
19HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC) 19HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
20HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC) 20HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
21HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC) 21HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
22HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
22 23
23HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) 24HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC)
24HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) 25HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 95485796f253..a662a0044798 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -278,32 +278,112 @@ static void check_property_name_chars(struct check *c, struct node *dt,
278} 278}
279PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR); 279PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
280 280
281#define DESCLABEL_FMT "%s%s%s%s%s"
282#define DESCLABEL_ARGS(node,prop,mark) \
283 ((mark) ? "value of " : ""), \
284 ((prop) ? "'" : ""), \
285 ((prop) ? (prop)->name : ""), \
286 ((prop) ? "' in " : ""), (node)->fullpath
287
288static void check_duplicate_label(struct check *c, struct node *dt,
289 const char *label, struct node *node,
290 struct property *prop, struct marker *mark)
291{
292 struct node *othernode = NULL;
293 struct property *otherprop = NULL;
294 struct marker *othermark = NULL;
295
296 othernode = get_node_by_label(dt, label);
297
298 if (!othernode)
299 otherprop = get_property_by_label(dt, label, &othernode);
300 if (!othernode)
301 othermark = get_marker_label(dt, label, &othernode,
302 &otherprop);
303
304 if (!othernode)
305 return;
306
307 if ((othernode != node) || (otherprop != prop) || (othermark != mark))
308 FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
309 " and " DESCLABEL_FMT,
310 label, DESCLABEL_ARGS(node, prop, mark),
311 DESCLABEL_ARGS(othernode, otherprop, othermark));
312}
313
314static void check_duplicate_label_node(struct check *c, struct node *dt,
315 struct node *node)
316{
317 struct label *l;
318
319 for_each_label(node->labels, l)
320 check_duplicate_label(c, dt, l->label, node, NULL, NULL);
321}
322static void check_duplicate_label_prop(struct check *c, struct node *dt,
323 struct node *node, struct property *prop)
324{
325 struct marker *m = prop->val.markers;
326 struct label *l;
327
328 for_each_label(prop->labels, l)
329 check_duplicate_label(c, dt, l->label, node, prop, NULL);
330
331 for_each_marker_of_type(m, LABEL)
332 check_duplicate_label(c, dt, m->ref, node, prop, m);
333}
334CHECK(duplicate_label, NULL, check_duplicate_label_node,
335 check_duplicate_label_prop, NULL, ERROR);
336
281static void check_explicit_phandles(struct check *c, struct node *root, 337static void check_explicit_phandles(struct check *c, struct node *root,
282 struct node *node) 338 struct node *node, struct property *prop)
283{ 339{
284 struct property *prop; 340 struct marker *m;
285 struct node *other; 341 struct node *other;
286 cell_t phandle; 342 cell_t phandle;
287 343
288 prop = get_property(node, "linux,phandle"); 344 if (!streq(prop->name, "phandle")
289 if (! prop) 345 && !streq(prop->name, "linux,phandle"))
290 return; /* No phandle, that's fine */ 346 return;
291 347
292 if (prop->val.len != sizeof(cell_t)) { 348 if (prop->val.len != sizeof(cell_t)) {
293 FAIL(c, "%s has bad length (%d) linux,phandle property", 349 FAIL(c, "%s has bad length (%d) %s property",
294 node->fullpath, prop->val.len); 350 node->fullpath, prop->val.len, prop->name);
351 return;
352 }
353
354 m = prop->val.markers;
355 for_each_marker_of_type(m, REF_PHANDLE) {
356 assert(m->offset == 0);
357 if (node != get_node_by_ref(root, m->ref))
358 /* "Set this node's phandle equal to some
359 * other node's phandle". That's nonsensical
360 * by construction. */ {
361 FAIL(c, "%s in %s is a reference to another node",
362 prop->name, node->fullpath);
363 return;
364 }
365 /* But setting this node's phandle equal to its own
366 * phandle is allowed - that means allocate a unique
367 * phandle for this node, even if it's not otherwise
368 * referenced. The value will be filled in later, so
369 * no further checking for now. */
295 return; 370 return;
296 } 371 }
297 372
298 phandle = propval_cell(prop); 373 phandle = propval_cell(prop);
374
299 if ((phandle == 0) || (phandle == -1)) { 375 if ((phandle == 0) || (phandle == -1)) {
300 FAIL(c, "%s has invalid linux,phandle value 0x%x", 376 FAIL(c, "%s has bad value (0x%x) in %s property",
301 node->fullpath, phandle); 377 node->fullpath, phandle, prop->name);
302 return; 378 return;
303 } 379 }
304 380
381 if (node->phandle && (node->phandle != phandle))
382 FAIL(c, "%s has %s property which replaces existing phandle information",
383 node->fullpath, prop->name);
384
305 other = get_node_by_phandle(root, phandle); 385 other = get_node_by_phandle(root, phandle);
306 if (other) { 386 if (other && (other != node)) {
307 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", 387 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
308 node->fullpath, phandle, other->fullpath); 388 node->fullpath, phandle, other->fullpath);
309 return; 389 return;
@@ -311,7 +391,7 @@ static void check_explicit_phandles(struct check *c, struct node *root,
311 391
312 node->phandle = phandle; 392 node->phandle = phandle;
313} 393}
314NODE_CHECK(explicit_phandles, NULL, ERROR); 394PROP_CHECK(explicit_phandles, NULL, ERROR);
315 395
316static void check_name_properties(struct check *c, struct node *root, 396static void check_name_properties(struct check *c, struct node *root,
317 struct node *node) 397 struct node *node)
@@ -549,6 +629,9 @@ static struct check *check_table[] = {
549 &duplicate_node_names, &duplicate_property_names, 629 &duplicate_node_names, &duplicate_property_names,
550 &node_name_chars, &node_name_format, &property_name_chars, 630 &node_name_chars, &node_name_format, &property_name_chars,
551 &name_is_string, &name_properties, 631 &name_is_string, &name_properties,
632
633 &duplicate_label,
634
552 &explicit_phandles, 635 &explicit_phandles,
553 &phandle_references, &path_references, 636 &phandle_references, &path_references,
554 637
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index a627bbee91d4..e866ea5166ac 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -18,7 +18,7 @@
18 * USA 18 * USA
19 */ 19 */
20 20
21%option noyywrap noinput nounput yylineno 21%option noyywrap nounput noinput never-interactive
22 22
23%x INCLUDE 23%x INCLUDE
24%x BYTESTRING 24%x BYTESTRING
@@ -38,6 +38,13 @@ LINECOMMENT "//".*\n
38#include "srcpos.h" 38#include "srcpos.h"
39#include "dtc-parser.tab.h" 39#include "dtc-parser.tab.h"
40 40
41YYLTYPE yylloc;
42
43/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
44#define YY_USER_ACTION \
45 { \
46 srcpos_update(&yylloc, yytext, yyleng); \
47 }
41 48
42/*#define LEXDEBUG 1*/ 49/*#define LEXDEBUG 1*/
43 50
@@ -47,15 +54,10 @@ LINECOMMENT "//".*\n
47#define DPRINT(fmt, ...) do { } while (0) 54#define DPRINT(fmt, ...) do { } while (0)
48#endif 55#endif
49 56
50static int dts_version; /* = 0 */ 57static int dts_version = 1;
51 58
52#define BEGIN_DEFAULT() if (dts_version == 0) { \ 59#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
53 DPRINT("<INITIAL>\n"); \
54 BEGIN(INITIAL); \
55 } else { \
56 DPRINT("<V1>\n"); \
57 BEGIN(V1); \ 60 BEGIN(V1); \
58 }
59 61
60static void push_input_file(const char *filename); 62static void push_input_file(const char *filename);
61static int pop_input_file(void); 63static int pop_input_file(void);
@@ -75,18 +77,13 @@ static int pop_input_file(void);
75 } 77 }
76 78
77<*>{STRING} { 79<*>{STRING} {
78 yylloc.file = srcpos_file;
79 yylloc.first_line = yylineno;
80 DPRINT("String: %s\n", yytext); 80 DPRINT("String: %s\n", yytext);
81 yylval.data = data_copy_escape_string(yytext+1, 81 yylval.data = data_copy_escape_string(yytext+1,
82 yyleng-2); 82 yyleng-2);
83 yylloc.first_line = yylineno;
84 return DT_STRING; 83 return DT_STRING;
85 } 84 }
86 85
87<*>"/dts-v1/" { 86<*>"/dts-v1/" {
88 yylloc.file = srcpos_file;
89 yylloc.first_line = yylineno;
90 DPRINT("Keyword: /dts-v1/\n"); 87 DPRINT("Keyword: /dts-v1/\n");
91 dts_version = 1; 88 dts_version = 1;
92 BEGIN_DEFAULT(); 89 BEGIN_DEFAULT();
@@ -94,106 +91,57 @@ static int pop_input_file(void);
94 } 91 }
95 92
96<*>"/memreserve/" { 93<*>"/memreserve/" {
97 yylloc.file = srcpos_file;
98 yylloc.first_line = yylineno;
99 DPRINT("Keyword: /memreserve/\n"); 94 DPRINT("Keyword: /memreserve/\n");
100 BEGIN_DEFAULT(); 95 BEGIN_DEFAULT();
101 return DT_MEMRESERVE; 96 return DT_MEMRESERVE;
102 } 97 }
103 98
104<*>{LABEL}: { 99<*>{LABEL}: {
105 yylloc.file = srcpos_file;
106 yylloc.first_line = yylineno;
107 DPRINT("Label: %s\n", yytext); 100 DPRINT("Label: %s\n", yytext);
108 yylval.labelref = strdup(yytext); 101 yylval.labelref = xstrdup(yytext);
109 yylval.labelref[yyleng-1] = '\0'; 102 yylval.labelref[yyleng-1] = '\0';
110 return DT_LABEL; 103 return DT_LABEL;
111 } 104 }
112 105
113<INITIAL>[bodh]# {
114 yylloc.file = srcpos_file;
115 yylloc.first_line = yylineno;
116 if (*yytext == 'b')
117 yylval.cbase = 2;
118 else if (*yytext == 'o')
119 yylval.cbase = 8;
120 else if (*yytext == 'd')
121 yylval.cbase = 10;
122 else
123 yylval.cbase = 16;
124 DPRINT("Base: %d\n", yylval.cbase);
125 return DT_BASE;
126 }
127
128<INITIAL>[0-9a-fA-F]+ {
129 yylloc.file = srcpos_file;
130 yylloc.first_line = yylineno;
131 yylval.literal = strdup(yytext);
132 DPRINT("Literal: '%s'\n", yylval.literal);
133 return DT_LEGACYLITERAL;
134 }
135
136<V1>[0-9]+|0[xX][0-9a-fA-F]+ { 106<V1>[0-9]+|0[xX][0-9a-fA-F]+ {
137 yylloc.file = srcpos_file; 107 yylval.literal = xstrdup(yytext);
138 yylloc.first_line = yylineno;
139 yylval.literal = strdup(yytext);
140 DPRINT("Literal: '%s'\n", yylval.literal); 108 DPRINT("Literal: '%s'\n", yylval.literal);
141 return DT_LITERAL; 109 return DT_LITERAL;
142 } 110 }
143 111
144\&{LABEL} { /* label reference */ 112<*>\&{LABEL} { /* label reference */
145 yylloc.file = srcpos_file;
146 yylloc.first_line = yylineno;
147 DPRINT("Ref: %s\n", yytext+1); 113 DPRINT("Ref: %s\n", yytext+1);
148 yylval.labelref = strdup(yytext+1); 114 yylval.labelref = xstrdup(yytext+1);
149 return DT_REF; 115 return DT_REF;
150 } 116 }
151 117
152"&{/"{PATHCHAR}+\} { /* new-style path reference */ 118<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
153 yylloc.file = srcpos_file;
154 yylloc.first_line = yylineno;
155 yytext[yyleng-1] = '\0'; 119 yytext[yyleng-1] = '\0';
156 DPRINT("Ref: %s\n", yytext+2); 120 DPRINT("Ref: %s\n", yytext+2);
157 yylval.labelref = strdup(yytext+2); 121 yylval.labelref = xstrdup(yytext+2);
158 return DT_REF;
159 }
160
161<INITIAL>"&/"{PATHCHAR}+ { /* old-style path reference */
162 yylloc.file = srcpos_file;
163 yylloc.first_line = yylineno;
164 DPRINT("Ref: %s\n", yytext+1);
165 yylval.labelref = strdup(yytext+1);
166 return DT_REF; 122 return DT_REF;
167 } 123 }
168 124
169<BYTESTRING>[0-9a-fA-F]{2} { 125<BYTESTRING>[0-9a-fA-F]{2} {
170 yylloc.file = srcpos_file;
171 yylloc.first_line = yylineno;
172 yylval.byte = strtol(yytext, NULL, 16); 126 yylval.byte = strtol(yytext, NULL, 16);
173 DPRINT("Byte: %02x\n", (int)yylval.byte); 127 DPRINT("Byte: %02x\n", (int)yylval.byte);
174 return DT_BYTE; 128 return DT_BYTE;
175 } 129 }
176 130
177<BYTESTRING>"]" { 131<BYTESTRING>"]" {
178 yylloc.file = srcpos_file;
179 yylloc.first_line = yylineno;
180 DPRINT("/BYTESTRING\n"); 132 DPRINT("/BYTESTRING\n");
181 BEGIN_DEFAULT(); 133 BEGIN_DEFAULT();
182 return ']'; 134 return ']';
183 } 135 }
184 136
185<PROPNODENAME>{PROPNODECHAR}+ { 137<PROPNODENAME>{PROPNODECHAR}+ {
186 yylloc.file = srcpos_file;
187 yylloc.first_line = yylineno;
188 DPRINT("PropNodeName: %s\n", yytext); 138 DPRINT("PropNodeName: %s\n", yytext);
189 yylval.propnodename = strdup(yytext); 139 yylval.propnodename = xstrdup(yytext);
190 BEGIN_DEFAULT(); 140 BEGIN_DEFAULT();
191 return DT_PROPNODENAME; 141 return DT_PROPNODENAME;
192 } 142 }
193 143
194"/incbin/" { 144"/incbin/" {
195 yylloc.file = srcpos_file;
196 yylloc.first_line = yylineno;
197 DPRINT("Binary Include\n"); 145 DPRINT("Binary Include\n");
198 return DT_INCBIN; 146 return DT_INCBIN;
199 } 147 }
@@ -203,8 +151,6 @@ static int pop_input_file(void);
203<*>{LINECOMMENT}+ /* eat C++-style comments */ 151<*>{LINECOMMENT}+ /* eat C++-style comments */
204 152
205<*>. { 153<*>. {
206 yylloc.file = srcpos_file;
207 yylloc.first_line = yylineno;
208 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 154 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
209 (unsigned)yytext[0]); 155 (unsigned)yytext[0]);
210 if (yytext[0] == '[') { 156 if (yytext[0] == '[') {
@@ -221,100 +167,25 @@ static int pop_input_file(void);
221 167
222%% 168%%
223 169
224
225/*
226 * Stack of nested include file contexts.
227 */
228
229struct incl_file {
230 struct dtc_file *file;
231 YY_BUFFER_STATE yy_prev_buf;
232 int yy_prev_lineno;
233 struct incl_file *prev;
234};
235
236static struct incl_file *incl_file_stack;
237
238
239/*
240 * Detect infinite include recursion.
241 */
242#define MAX_INCLUDE_DEPTH (100)
243
244static int incl_depth = 0;
245
246
247static void push_input_file(const char *filename) 170static void push_input_file(const char *filename)
248{ 171{
249 struct incl_file *incl_file;
250 struct dtc_file *newfile;
251 struct search_path search, *searchptr = NULL;
252
253 assert(filename); 172 assert(filename);
254 173
255 if (incl_depth++ >= MAX_INCLUDE_DEPTH) 174 srcfile_push(filename);
256 die("Includes nested too deeply");
257
258 if (srcpos_file) {
259 search.dir = srcpos_file->dir;
260 search.next = NULL;
261 search.prev = NULL;
262 searchptr = &search;
263 }
264
265 newfile = dtc_open_file(filename, searchptr);
266 175
267 incl_file = xmalloc(sizeof(struct incl_file)); 176 yyin = current_srcfile->f;
268 177
269 /* 178 yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
270 * Save current context.
271 */
272 incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
273 incl_file->yy_prev_lineno = yylineno;
274 incl_file->file = srcpos_file;
275 incl_file->prev = incl_file_stack;
276
277 incl_file_stack = incl_file;
278
279 /*
280 * Establish new context.
281 */
282 srcpos_file = newfile;
283 yylineno = 1;
284 yyin = newfile->file;
285 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
286} 179}
287 180
288 181
289static int pop_input_file(void) 182static int pop_input_file(void)
290{ 183{
291 struct incl_file *incl_file; 184 if (srcfile_pop() == 0)
292
293 if (incl_file_stack == 0)
294 return 0; 185 return 0;
295 186
296 dtc_close_file(srcpos_file); 187 yypop_buffer_state();
297 188 yyin = current_srcfile->f;
298 /*
299 * Pop.
300 */
301 --incl_depth;
302 incl_file = incl_file_stack;
303 incl_file_stack = incl_file->prev;
304
305 /*
306 * Recover old context.
307 */
308 yy_delete_buffer(YY_CURRENT_BUFFER);
309 yy_switch_to_buffer(incl_file->yy_prev_buf);
310 yylineno = incl_file->yy_prev_lineno;
311 srcpos_file = incl_file->file;
312 yyin = incl_file->file ? incl_file->file->file : NULL;
313
314 /*
315 * Free old state.
316 */
317 free(incl_file);
318 189
319 return 1; 190 return 1;
320} 191}
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index e27cc636e326..50c4420b4b2c 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -170,20 +170,7 @@ extern FILE *yyin, *yyout;
170#define EOB_ACT_END_OF_FILE 1 170#define EOB_ACT_END_OF_FILE 1
171#define EOB_ACT_LAST_MATCH 2 171#define EOB_ACT_LAST_MATCH 2
172 172
173 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires 173 #define YY_LESS_LINENO(n)
174 * access to the local variable yy_act. Since yyless() is a macro, it would break
175 * existing scanners that call yyless() from OUTSIDE yylex.
176 * One obvious solution it to make yy_act a global. I tried that, and saw
177 * a 5% performance hit in a non-yylineno scanner, because yy_act is
178 * normally declared as a register variable-- so it is not worth it.
179 */
180 #define YY_LESS_LINENO(n) \
181 do { \
182 int yyl;\
183 for ( yyl = n; yyl < yyleng; ++yyl )\
184 if ( yytext[yyl] == '\n' )\
185 --yylineno;\
186 }while(0)
187 174
188/* Return all but the first "n" matched characters back to the input stream. */ 175/* Return all but the first "n" matched characters back to the input stream. */
189#define yyless(n) \ 176#define yyless(n) \
@@ -385,8 +372,8 @@ static void yy_fatal_error (yyconst char msg[] );
385 *yy_cp = '\0'; \ 372 *yy_cp = '\0'; \
386 (yy_c_buf_p) = yy_cp; 373 (yy_c_buf_p) = yy_cp;
387 374
388#define YY_NUM_RULES 20 375#define YY_NUM_RULES 17
389#define YY_END_OF_BUFFER 21 376#define YY_END_OF_BUFFER 18
390/* This struct is not used in this scanner, 377/* This struct is not used in this scanner,
391 but its presence is necessary. */ 378 but its presence is necessary. */
392struct yy_trans_info 379struct yy_trans_info
@@ -394,20 +381,19 @@ struct yy_trans_info
394 flex_int32_t yy_verify; 381 flex_int32_t yy_verify;
395 flex_int32_t yy_nxt; 382 flex_int32_t yy_nxt;
396 }; 383 };
397static yyconst flex_int16_t yy_accept[104] = 384static yyconst flex_int16_t yy_accept[94] =
398 { 0, 385 { 0,
399 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
400 21, 19, 16, 16, 19, 19, 19, 7, 7, 19, 387 18, 16, 13, 13, 16, 16, 16, 16, 16, 16,
401 7, 19, 19, 19, 19, 13, 14, 14, 19, 8, 388 16, 10, 11, 11, 6, 6, 13, 0, 2, 0,
402 8, 16, 0, 2, 0, 0, 9, 0, 0, 0, 389 7, 0, 0, 0, 0, 0, 0, 0, 5, 0,
403 0, 0, 0, 7, 7, 5, 0, 6, 0, 12, 390 9, 9, 11, 11, 6, 0, 7, 0, 0, 0,
404 12, 14, 14, 8, 0, 11, 9, 0, 0, 0, 391 0, 15, 0, 0, 0, 0, 6, 0, 14, 0,
405 0, 18, 0, 0, 0, 0, 8, 0, 17, 0, 392 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
406 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 393 0, 0, 0, 0, 0, 0, 0, 0, 3, 12,
407 0, 0, 0, 0, 0, 0, 0, 0, 3, 15,
408 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 394 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
409
410 0, 4, 0 395 0, 4, 0
396
411 } ; 397 } ;
412 398
413static yyconst flex_int32_t yy_ec[256] = 399static yyconst flex_int32_t yy_ec[256] =
@@ -416,16 +402,16 @@ static yyconst flex_int32_t yy_ec[256] =
416 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 402 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 2, 1, 4, 5, 1, 1, 6, 1, 1, 404 1, 2, 1, 4, 5, 1, 1, 6, 1, 1,
419 1, 7, 8, 8, 9, 8, 10, 11, 12, 13, 405 1, 7, 5, 5, 8, 5, 9, 10, 11, 12,
420 13, 13, 13, 13, 13, 13, 13, 14, 1, 1, 406 12, 12, 12, 12, 12, 12, 12, 13, 1, 1,
421 1, 1, 8, 8, 15, 15, 15, 15, 15, 15, 407 1, 1, 5, 5, 14, 14, 14, 14, 14, 14,
422 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 408 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
423 16, 16, 16, 16, 16, 16, 16, 17, 16, 16, 409 15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
424 1, 18, 19, 1, 16, 1, 15, 20, 21, 22, 410 1, 17, 18, 1, 15, 1, 14, 19, 20, 21,
425 411
426 23, 15, 16, 24, 25, 16, 16, 26, 27, 28, 412 22, 14, 15, 15, 23, 15, 15, 24, 25, 26,
427 24, 16, 16, 29, 30, 31, 32, 33, 16, 17, 413 15, 15, 15, 27, 28, 29, 30, 31, 15, 16,
428 16, 16, 34, 1, 35, 1, 1, 1, 1, 1, 414 15, 15, 32, 1, 33, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -442,136 +428,114 @@ static yyconst flex_int32_t yy_ec[256] =
442 1, 1, 1, 1, 1 428 1, 1, 1, 1, 1
443 } ; 429 } ;
444 430
445static yyconst flex_int32_t yy_meta[36] = 431static yyconst flex_int32_t yy_meta[34] =
446 { 0, 432 { 0,
447 1, 1, 1, 1, 2, 1, 2, 2, 2, 3, 433 1, 1, 1, 1, 2, 1, 2, 2, 3, 4,
448 4, 4, 4, 5, 6, 7, 7, 1, 1, 6, 434 4, 4, 5, 6, 7, 7, 1, 1, 6, 6,
449 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 435 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
450 7, 7, 7, 8, 1 436 7, 8, 1
451 } ; 437 } ;
452 438
453static yyconst flex_int16_t yy_base[117] = 439static yyconst flex_int16_t yy_base[106] =
454 { 0, 440 { 0,
455 0, 0, 30, 0, 44, 0, 67, 0, 97, 105, 441 0, 0, 237, 236, 25, 0, 47, 0, 30, 71,
456 302, 303, 35, 44, 40, 94, 112, 0, 129, 152, 442 244, 247, 82, 84, 84, 211, 95, 229, 218, 0,
457 296, 295, 159, 0, 176, 303, 0, 116, 95, 165, 443 111, 247, 0, 84, 83, 95, 106, 86, 247, 237,
458 49, 46, 102, 303, 296, 0, 0, 288, 290, 293, 444 0, 230, 231, 234, 207, 209, 212, 220, 247, 206,
459 264, 266, 270, 0, 0, 303, 0, 303, 264, 303, 445 247, 218, 0, 106, 116, 0, 0, 0, 223, 89,
460 0, 0, 195, 101, 0, 0, 0, 0, 284, 125, 446 226, 219, 199, 206, 200, 204, 0, 190, 213, 212,
461 277, 265, 225, 230, 216, 218, 0, 202, 224, 221, 447 202, 91, 178, 161, 247, 172, 144, 150, 140, 130,
462 217, 107, 196, 188, 303, 206, 179, 186, 178, 185, 448 140, 124, 128, 120, 138, 137, 123, 122, 247, 247,
463 183, 162, 161, 150, 169, 160, 145, 125, 303, 303, 449 134, 114, 132, 86, 135, 125, 90, 136, 247, 97,
464 137, 109, 190, 103, 203, 167, 108, 197, 303, 123, 450 29, 247, 247, 153, 156, 161, 165, 170, 176, 180,
465 451
466 29, 303, 303, 215, 221, 226, 229, 234, 240, 246, 452 187, 195, 200, 205, 212
467 250, 257, 265, 270, 275, 282
468 } ; 453 } ;
469 454
470static yyconst flex_int16_t yy_def[117] = 455static yyconst flex_int16_t yy_def[106] =
471 { 0, 456 { 0,
472 103, 1, 1, 3, 3, 5, 103, 7, 3, 3, 457 93, 1, 1, 1, 1, 5, 93, 7, 1, 1,
473 103, 103, 103, 103, 104, 105, 103, 106, 103, 19, 458 93, 93, 93, 93, 94, 95, 93, 96, 17, 97,
474 19, 20, 103, 107, 20, 103, 108, 109, 105, 103, 459 96, 93, 98, 99, 93, 93, 93, 94, 93, 94,
475 103, 103, 104, 103, 104, 110, 111, 103, 112, 113, 460 100, 93, 101, 102, 93, 93, 93, 96, 93, 93,
476 103, 103, 103, 106, 19, 103, 20, 103, 103, 103, 461 93, 96, 98, 99, 93, 103, 100, 104, 101, 101,
477 20, 108, 109, 103, 114, 110, 111, 115, 112, 112, 462 102, 93, 93, 93, 93, 93, 103, 104, 93, 93,
478 113, 103, 103, 103, 103, 103, 114, 115, 103, 103, 463 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
479 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 464 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
480 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 465 93, 93, 93, 93, 93, 105, 93, 105, 93, 105,
481 103, 103, 103, 103, 103, 116, 103, 116, 103, 116, 466 93, 93, 0, 93, 93, 93, 93, 93, 93, 93,
482 467
483 103, 103, 0, 103, 103, 103, 103, 103, 103, 103, 468 93, 93, 93, 93, 93
484 103, 103, 103, 103, 103, 103
485 } ; 469 } ;
486 470
487static yyconst flex_int16_t yy_nxt[339] = 471static yyconst flex_int16_t yy_nxt[281] =
488 { 0, 472 { 0,
489 12, 13, 14, 15, 12, 16, 12, 12, 12, 17, 473 12, 13, 14, 15, 12, 16, 12, 12, 17, 12,
490 18, 18, 18, 12, 19, 20, 20, 12, 12, 21, 474 12, 12, 12, 18, 18, 18, 12, 12, 18, 18,
491 19, 21, 19, 22, 20, 20, 20, 20, 20, 20, 475 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
492 20, 20, 20, 12, 12, 12, 32, 32, 102, 23, 476 18, 12, 12, 19, 20, 20, 20, 92, 21, 25,
493 12, 12, 12, 34, 20, 32, 32, 32, 32, 20, 477 26, 26, 22, 21, 21, 21, 21, 12, 13, 14,
494 20, 20, 20, 20, 24, 24, 24, 35, 25, 54, 478 15, 23, 16, 23, 23, 19, 23, 23, 23, 12,
495 54, 54, 26, 25, 25, 25, 25, 12, 13, 14, 479 24, 24, 24, 12, 12, 24, 24, 24, 24, 24,
496 15, 27, 12, 27, 27, 27, 23, 27, 27, 27, 480 24, 24, 24, 24, 24, 24, 24, 24, 12, 12,
497 12, 28, 28, 28, 12, 12, 28, 28, 28, 28, 481 25, 26, 26, 27, 27, 27, 27, 29, 43, 29,
498 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 482 43, 43, 45, 45, 45, 50, 39, 59, 46, 93,
499 483
500 12, 12, 29, 36, 103, 34, 17, 30, 31, 31, 484 30, 33, 30, 34, 45, 45, 45, 27, 27, 68,
501 29, 54, 54, 54, 17, 30, 31, 31, 39, 35, 485 43, 91, 43, 43, 69, 35, 87, 36, 39, 37,
502 52, 40, 52, 52, 52, 103, 78, 38, 38, 46, 486 42, 42, 42, 39, 42, 45, 45, 45, 89, 42,
503 101, 60, 79, 41, 69, 97, 42, 94, 43, 45, 487 42, 42, 42, 85, 85, 86, 85, 85, 86, 89,
504 45, 45, 46, 45, 47, 47, 93, 92, 45, 45, 488 84, 90, 83, 82, 81, 80, 79, 78, 77, 76,
505 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, 489 75, 74, 90, 28, 28, 28, 28, 28, 28, 28,
506 47, 47, 47, 47, 47, 39, 47, 91, 40, 90, 490 28, 31, 31, 31, 38, 38, 38, 38, 41, 73,
507 99, 47, 47, 47, 47, 54, 54, 54, 89, 88, 491 41, 43, 72, 43, 71, 43, 43, 44, 33, 44,
508 41, 55, 87, 49, 100, 43, 51, 51, 51, 86, 492 44, 44, 44, 47, 69, 47, 47, 49, 49, 49,
509 51, 95, 95, 96, 85, 51, 51, 51, 51, 52, 493 49, 49, 49, 49, 49, 51, 51, 51, 51, 51,
510 494
511 99, 52, 52, 52, 95, 95, 96, 84, 46, 83, 495 51, 51, 51, 57, 70, 57, 58, 58, 58, 67,
512 82, 81, 39, 79, 100, 33, 33, 33, 33, 33, 496 58, 58, 88, 88, 88, 88, 88, 88, 88, 88,
513 33, 33, 33, 37, 80, 77, 37, 37, 37, 44, 497 34, 66, 65, 64, 63, 62, 61, 60, 52, 50,
514 40, 44, 50, 76, 50, 52, 75, 52, 74, 52, 498 39, 56, 39, 55, 54, 53, 52, 50, 48, 93,
515 52, 53, 73, 53, 53, 53, 53, 56, 56, 56, 499 40, 39, 32, 93, 19, 19, 11, 93, 93, 93,
516 72, 56, 56, 57, 71, 57, 57, 59, 59, 59, 500 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
517 59, 59, 59, 59, 59, 61, 61, 61, 61, 61, 501 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
518 61, 61, 61, 67, 70, 67, 68, 68, 68, 62, 502 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
519 68, 68, 98, 98, 98, 98, 98, 98, 98, 98,
520 60, 66, 65, 64, 63, 62, 60, 58, 103, 48,
521
522 48, 103, 11, 103, 103, 103, 103, 103, 103, 103,
523 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
524 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
525 103, 103, 103, 103, 103, 103, 103, 103
526 } ; 503 } ;
527 504
528static yyconst flex_int16_t yy_chk[339] = 505static yyconst flex_int16_t yy_chk[281] =
529 { 0, 506 { 0,
530 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 507 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
531 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 508 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
532 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 509 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
533 1, 1, 1, 1, 1, 3, 13, 13, 101, 3, 510 1, 1, 1, 5, 5, 5, 5, 91, 5, 9,
534 3, 3, 3, 15, 3, 14, 14, 32, 32, 3, 511 9, 9, 5, 5, 5, 5, 5, 7, 7, 7,
535 3, 3, 3, 3, 5, 5, 5, 15, 5, 31,
536 31, 31, 5, 5, 5, 5, 5, 7, 7, 7,
537 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 512 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
538 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 513 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
539 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 514 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
540 515 10, 10, 10, 13, 13, 14, 14, 15, 24, 28,
541 7, 7, 9, 16, 29, 33, 9, 9, 9, 9, 516 24, 24, 25, 25, 25, 50, 24, 50, 25, 90,
542 10, 54, 54, 54, 10, 10, 10, 10, 17, 33, 517
543 28, 17, 28, 28, 28, 100, 72, 16, 29, 28, 518 15, 17, 28, 17, 26, 26, 26, 27, 27, 62,
544 97, 60, 72, 17, 60, 94, 17, 92, 17, 19, 519 44, 87, 44, 44, 62, 17, 84, 17, 44, 17,
545 19, 19, 19, 19, 19, 19, 91, 88, 19, 19, 520 21, 21, 21, 21, 21, 45, 45, 45, 86, 21,
546 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 521 21, 21, 21, 83, 83, 83, 85, 85, 85, 88,
547 19, 19, 20, 20, 20, 23, 20, 87, 23, 86, 522 82, 86, 81, 78, 77, 76, 75, 74, 73, 72,
548 96, 20, 20, 20, 20, 30, 30, 30, 85, 84, 523 71, 70, 88, 94, 94, 94, 94, 94, 94, 94,
549 23, 30, 83, 23, 96, 23, 25, 25, 25, 82, 524 94, 95, 95, 95, 96, 96, 96, 96, 97, 69,
550 25, 93, 93, 93, 81, 25, 25, 25, 25, 53, 525 97, 98, 68, 98, 67, 98, 98, 99, 66, 99,
551 526 99, 99, 99, 100, 64, 100, 100, 101, 101, 101,
552 98, 53, 53, 53, 95, 95, 95, 80, 53, 79, 527 101, 101, 101, 101, 101, 102, 102, 102, 102, 102,
553 78, 77, 76, 74, 98, 104, 104, 104, 104, 104, 528
554 104, 104, 104, 105, 73, 71, 105, 105, 105, 106, 529 102, 102, 102, 103, 63, 103, 104, 104, 104, 61,
555 70, 106, 107, 69, 107, 108, 68, 108, 66, 108, 530 104, 104, 105, 105, 105, 105, 105, 105, 105, 105,
556 108, 109, 65, 109, 109, 109, 109, 110, 110, 110, 531 60, 59, 58, 56, 55, 54, 53, 52, 51, 49,
557 64, 110, 110, 111, 63, 111, 111, 112, 112, 112, 532 42, 40, 38, 37, 36, 35, 34, 33, 32, 30,
558 112, 112, 112, 112, 112, 113, 113, 113, 113, 113, 533 19, 18, 16, 11, 4, 3, 93, 93, 93, 93,
559 113, 113, 113, 114, 62, 114, 115, 115, 115, 61, 534 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
560 115, 115, 116, 116, 116, 116, 116, 116, 116, 116, 535 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
561 59, 49, 43, 42, 41, 40, 39, 38, 35, 22, 536 93, 93, 93, 93, 93, 93, 93, 93, 93, 93
562
563 21, 11, 103, 103, 103, 103, 103, 103, 103, 103,
564 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
565 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
566 103, 103, 103, 103, 103, 103, 103, 103
567 } ; 537 } ;
568 538
569/* Table of booleans, true if rule could match eol. */
570static yyconst flex_int32_t yy_rule_can_match_eol[21] =
571 { 0,
5721, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
573 0, };
574
575static yy_state_type yy_last_accepting_state; 539static yy_state_type yy_last_accepting_state;
576static char *yy_last_accepting_cpos; 540static char *yy_last_accepting_cpos;
577 541
@@ -616,6 +580,13 @@ char *yytext;
616#include "srcpos.h" 580#include "srcpos.h"
617#include "dtc-parser.tab.h" 581#include "dtc-parser.tab.h"
618 582
583YYLTYPE yylloc;
584
585/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
586#define YY_USER_ACTION \
587 { \
588 srcpos_update(&yylloc, yytext, yyleng); \
589 }
619 590
620/*#define LEXDEBUG 1*/ 591/*#define LEXDEBUG 1*/
621 592
@@ -625,19 +596,14 @@ char *yytext;
625#define DPRINT(fmt, ...) do { } while (0) 596#define DPRINT(fmt, ...) do { } while (0)
626#endif 597#endif
627 598
628static int dts_version; /* = 0 */ 599static int dts_version = 1;
629 600
630#define BEGIN_DEFAULT() if (dts_version == 0) { \ 601#define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
631 DPRINT("<INITIAL>\n"); \
632 BEGIN(INITIAL); \
633 } else { \
634 DPRINT("<V1>\n"); \
635 BEGIN(V1); \ 602 BEGIN(V1); \
636 }
637 603
638static void push_input_file(const char *filename); 604static void push_input_file(const char *filename);
639static int pop_input_file(void); 605static int pop_input_file(void);
640#line 641 "dtc-lexer.lex.c" 606#line 607 "dtc-lexer.lex.c"
641 607
642#define INITIAL 0 608#define INITIAL 0
643#define INCLUDE 1 609#define INCLUDE 1
@@ -826,9 +792,9 @@ YY_DECL
826 register char *yy_cp, *yy_bp; 792 register char *yy_cp, *yy_bp;
827 register int yy_act; 793 register int yy_act;
828 794
829#line 64 "dtc-lexer.l" 795#line 66 "dtc-lexer.l"
830 796
831#line 832 "dtc-lexer.lex.c" 797#line 798 "dtc-lexer.lex.c"
832 798
833 if ( !(yy_init) ) 799 if ( !(yy_init) )
834 { 800 {
@@ -881,35 +847,21 @@ yy_match:
881 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 847 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
882 { 848 {
883 yy_current_state = (int) yy_def[yy_current_state]; 849 yy_current_state = (int) yy_def[yy_current_state];
884 if ( yy_current_state >= 104 ) 850 if ( yy_current_state >= 94 )
885 yy_c = yy_meta[(unsigned int) yy_c]; 851 yy_c = yy_meta[(unsigned int) yy_c];
886 } 852 }
887 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 853 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
888 ++yy_cp; 854 ++yy_cp;
889 } 855 }
890 while ( yy_base[yy_current_state] != 303 ); 856 while ( yy_current_state != 93 );
857 yy_cp = (yy_last_accepting_cpos);
858 yy_current_state = (yy_last_accepting_state);
891 859
892yy_find_action: 860yy_find_action:
893 yy_act = yy_accept[yy_current_state]; 861 yy_act = yy_accept[yy_current_state];
894 if ( yy_act == 0 )
895 { /* have to back up */
896 yy_cp = (yy_last_accepting_cpos);
897 yy_current_state = (yy_last_accepting_state);
898 yy_act = yy_accept[yy_current_state];
899 }
900 862
901 YY_DO_BEFORE_ACTION; 863 YY_DO_BEFORE_ACTION;
902 864
903 if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
904 {
905 int yyl;
906 for ( yyl = 0; yyl < yyleng; ++yyl )
907 if ( yytext[yyl] == '\n' )
908
909 yylineno++;
910;
911 }
912
913do_action: /* This label is used only to access EOF actions. */ 865do_action: /* This label is used only to access EOF actions. */
914 866
915 switch ( yy_act ) 867 switch ( yy_act )
@@ -924,7 +876,7 @@ do_action: /* This label is used only to access EOF actions. */
924case 1: 876case 1:
925/* rule 1 can match eol */ 877/* rule 1 can match eol */
926YY_RULE_SETUP 878YY_RULE_SETUP
927#line 65 "dtc-lexer.l" 879#line 67 "dtc-lexer.l"
928{ 880{
929 char *name = strchr(yytext, '\"') + 1; 881 char *name = strchr(yytext, '\"') + 1;
930 yytext[yyleng-1] = '\0'; 882 yytext[yyleng-1] = '\0';
@@ -936,7 +888,7 @@ case YY_STATE_EOF(INCLUDE):
936case YY_STATE_EOF(BYTESTRING): 888case YY_STATE_EOF(BYTESTRING):
937case YY_STATE_EOF(PROPNODENAME): 889case YY_STATE_EOF(PROPNODENAME):
938case YY_STATE_EOF(V1): 890case YY_STATE_EOF(V1):
939#line 71 "dtc-lexer.l" 891#line 73 "dtc-lexer.l"
940{ 892{
941 if (!pop_input_file()) { 893 if (!pop_input_file()) {
942 yyterminate(); 894 yyterminate();
@@ -946,23 +898,18 @@ case YY_STATE_EOF(V1):
946case 2: 898case 2:
947/* rule 2 can match eol */ 899/* rule 2 can match eol */
948YY_RULE_SETUP 900YY_RULE_SETUP
949#line 77 "dtc-lexer.l" 901#line 79 "dtc-lexer.l"
950{ 902{
951 yylloc.file = srcpos_file;
952 yylloc.first_line = yylineno;
953 DPRINT("String: %s\n", yytext); 903 DPRINT("String: %s\n", yytext);
954 yylval.data = data_copy_escape_string(yytext+1, 904 yylval.data = data_copy_escape_string(yytext+1,
955 yyleng-2); 905 yyleng-2);
956 yylloc.first_line = yylineno;
957 return DT_STRING; 906 return DT_STRING;
958 } 907 }
959 YY_BREAK 908 YY_BREAK
960case 3: 909case 3:
961YY_RULE_SETUP 910YY_RULE_SETUP
962#line 87 "dtc-lexer.l" 911#line 86 "dtc-lexer.l"
963{ 912{
964 yylloc.file = srcpos_file;
965 yylloc.first_line = yylineno;
966 DPRINT("Keyword: /dts-v1/\n"); 913 DPRINT("Keyword: /dts-v1/\n");
967 dts_version = 1; 914 dts_version = 1;
968 BEGIN_DEFAULT(); 915 BEGIN_DEFAULT();
@@ -971,10 +918,8 @@ YY_RULE_SETUP
971 YY_BREAK 918 YY_BREAK
972case 4: 919case 4:
973YY_RULE_SETUP 920YY_RULE_SETUP
974#line 96 "dtc-lexer.l" 921#line 93 "dtc-lexer.l"
975{ 922{
976 yylloc.file = srcpos_file;
977 yylloc.first_line = yylineno;
978 DPRINT("Keyword: /memreserve/\n"); 923 DPRINT("Keyword: /memreserve/\n");
979 BEGIN_DEFAULT(); 924 BEGIN_DEFAULT();
980 return DT_MEMRESERVE; 925 return DT_MEMRESERVE;
@@ -982,158 +927,100 @@ YY_RULE_SETUP
982 YY_BREAK 927 YY_BREAK
983case 5: 928case 5:
984YY_RULE_SETUP 929YY_RULE_SETUP
985#line 104 "dtc-lexer.l" 930#line 99 "dtc-lexer.l"
986{ 931{
987 yylloc.file = srcpos_file;
988 yylloc.first_line = yylineno;
989 DPRINT("Label: %s\n", yytext); 932 DPRINT("Label: %s\n", yytext);
990 yylval.labelref = strdup(yytext); 933 yylval.labelref = xstrdup(yytext);
991 yylval.labelref[yyleng-1] = '\0'; 934 yylval.labelref[yyleng-1] = '\0';
992 return DT_LABEL; 935 return DT_LABEL;
993 } 936 }
994 YY_BREAK 937 YY_BREAK
995case 6: 938case 6:
996YY_RULE_SETUP 939YY_RULE_SETUP
997#line 113 "dtc-lexer.l" 940#line 106 "dtc-lexer.l"
998{
999 yylloc.file = srcpos_file;
1000 yylloc.first_line = yylineno;
1001 if (*yytext == 'b')
1002 yylval.cbase = 2;
1003 else if (*yytext == 'o')
1004 yylval.cbase = 8;
1005 else if (*yytext == 'd')
1006 yylval.cbase = 10;
1007 else
1008 yylval.cbase = 16;
1009 DPRINT("Base: %d\n", yylval.cbase);
1010 return DT_BASE;
1011 }
1012 YY_BREAK
1013case 7:
1014YY_RULE_SETUP
1015#line 128 "dtc-lexer.l"
1016{ 941{
1017 yylloc.file = srcpos_file; 942 yylval.literal = xstrdup(yytext);
1018 yylloc.first_line = yylineno;
1019 yylval.literal = strdup(yytext);
1020 DPRINT("Literal: '%s'\n", yylval.literal);
1021 return DT_LEGACYLITERAL;
1022 }
1023 YY_BREAK
1024case 8:
1025YY_RULE_SETUP
1026#line 136 "dtc-lexer.l"
1027{
1028 yylloc.file = srcpos_file;
1029 yylloc.first_line = yylineno;
1030 yylval.literal = strdup(yytext);
1031 DPRINT("Literal: '%s'\n", yylval.literal); 943 DPRINT("Literal: '%s'\n", yylval.literal);
1032 return DT_LITERAL; 944 return DT_LITERAL;
1033 } 945 }
1034 YY_BREAK 946 YY_BREAK
1035case 9: 947case 7:
1036YY_RULE_SETUP 948YY_RULE_SETUP
1037#line 144 "dtc-lexer.l" 949#line 112 "dtc-lexer.l"
1038{ /* label reference */ 950{ /* label reference */
1039 yylloc.file = srcpos_file;
1040 yylloc.first_line = yylineno;
1041 DPRINT("Ref: %s\n", yytext+1); 951 DPRINT("Ref: %s\n", yytext+1);
1042 yylval.labelref = strdup(yytext+1); 952 yylval.labelref = xstrdup(yytext+1);
1043 return DT_REF; 953 return DT_REF;
1044 } 954 }
1045 YY_BREAK 955 YY_BREAK
1046case 10: 956case 8:
1047YY_RULE_SETUP 957YY_RULE_SETUP
1048#line 152 "dtc-lexer.l" 958#line 118 "dtc-lexer.l"
1049{ /* new-style path reference */ 959{ /* new-style path reference */
1050 yylloc.file = srcpos_file;
1051 yylloc.first_line = yylineno;
1052 yytext[yyleng-1] = '\0'; 960 yytext[yyleng-1] = '\0';
1053 DPRINT("Ref: %s\n", yytext+2); 961 DPRINT("Ref: %s\n", yytext+2);
1054 yylval.labelref = strdup(yytext+2); 962 yylval.labelref = xstrdup(yytext+2);
1055 return DT_REF; 963 return DT_REF;
1056 } 964 }
1057 YY_BREAK 965 YY_BREAK
1058case 11: 966case 9:
1059YY_RULE_SETUP
1060#line 161 "dtc-lexer.l"
1061{ /* old-style path reference */
1062 yylloc.file = srcpos_file;
1063 yylloc.first_line = yylineno;
1064 DPRINT("Ref: %s\n", yytext+1);
1065 yylval.labelref = strdup(yytext+1);
1066 return DT_REF;
1067 }
1068 YY_BREAK
1069case 12:
1070YY_RULE_SETUP 967YY_RULE_SETUP
1071#line 169 "dtc-lexer.l" 968#line 125 "dtc-lexer.l"
1072{ 969{
1073 yylloc.file = srcpos_file;
1074 yylloc.first_line = yylineno;
1075 yylval.byte = strtol(yytext, NULL, 16); 970 yylval.byte = strtol(yytext, NULL, 16);
1076 DPRINT("Byte: %02x\n", (int)yylval.byte); 971 DPRINT("Byte: %02x\n", (int)yylval.byte);
1077 return DT_BYTE; 972 return DT_BYTE;
1078 } 973 }
1079 YY_BREAK 974 YY_BREAK
1080case 13: 975case 10:
1081YY_RULE_SETUP 976YY_RULE_SETUP
1082#line 177 "dtc-lexer.l" 977#line 131 "dtc-lexer.l"
1083{ 978{
1084 yylloc.file = srcpos_file;
1085 yylloc.first_line = yylineno;
1086 DPRINT("/BYTESTRING\n"); 979 DPRINT("/BYTESTRING\n");
1087 BEGIN_DEFAULT(); 980 BEGIN_DEFAULT();
1088 return ']'; 981 return ']';
1089 } 982 }
1090 YY_BREAK 983 YY_BREAK
1091case 14: 984case 11:
1092YY_RULE_SETUP 985YY_RULE_SETUP
1093#line 185 "dtc-lexer.l" 986#line 137 "dtc-lexer.l"
1094{ 987{
1095 yylloc.file = srcpos_file;
1096 yylloc.first_line = yylineno;
1097 DPRINT("PropNodeName: %s\n", yytext); 988 DPRINT("PropNodeName: %s\n", yytext);
1098 yylval.propnodename = strdup(yytext); 989 yylval.propnodename = xstrdup(yytext);
1099 BEGIN_DEFAULT(); 990 BEGIN_DEFAULT();
1100 return DT_PROPNODENAME; 991 return DT_PROPNODENAME;
1101 } 992 }
1102 YY_BREAK 993 YY_BREAK
1103case 15: 994case 12:
1104YY_RULE_SETUP 995YY_RULE_SETUP
1105#line 194 "dtc-lexer.l" 996#line 144 "dtc-lexer.l"
1106{ 997{
1107 yylloc.file = srcpos_file;
1108 yylloc.first_line = yylineno;
1109 DPRINT("Binary Include\n"); 998 DPRINT("Binary Include\n");
1110 return DT_INCBIN; 999 return DT_INCBIN;
1111 } 1000 }
1112 YY_BREAK 1001 YY_BREAK
1113case 16: 1002case 13:
1114/* rule 16 can match eol */ 1003/* rule 13 can match eol */
1115YY_RULE_SETUP 1004YY_RULE_SETUP
1116#line 201 "dtc-lexer.l" 1005#line 149 "dtc-lexer.l"
1117/* eat whitespace */ 1006/* eat whitespace */
1118 YY_BREAK 1007 YY_BREAK
1119case 17: 1008case 14:
1120/* rule 17 can match eol */ 1009/* rule 14 can match eol */
1121YY_RULE_SETUP 1010YY_RULE_SETUP
1122#line 202 "dtc-lexer.l" 1011#line 150 "dtc-lexer.l"
1123/* eat C-style comments */ 1012/* eat C-style comments */
1124 YY_BREAK 1013 YY_BREAK
1125case 18: 1014case 15:
1126/* rule 18 can match eol */ 1015/* rule 15 can match eol */
1127YY_RULE_SETUP 1016YY_RULE_SETUP
1128#line 203 "dtc-lexer.l" 1017#line 151 "dtc-lexer.l"
1129/* eat C++-style comments */ 1018/* eat C++-style comments */
1130 YY_BREAK 1019 YY_BREAK
1131case 19: 1020case 16:
1132YY_RULE_SETUP 1021YY_RULE_SETUP
1133#line 205 "dtc-lexer.l" 1022#line 153 "dtc-lexer.l"
1134{ 1023{
1135 yylloc.file = srcpos_file;
1136 yylloc.first_line = yylineno;
1137 DPRINT("Char: %c (\\x%02x)\n", yytext[0], 1024 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
1138 (unsigned)yytext[0]); 1025 (unsigned)yytext[0]);
1139 if (yytext[0] == '[') { 1026 if (yytext[0] == '[') {
@@ -1148,12 +1035,12 @@ YY_RULE_SETUP
1148 return yytext[0]; 1035 return yytext[0];
1149 } 1036 }
1150 YY_BREAK 1037 YY_BREAK
1151case 20: 1038case 17:
1152YY_RULE_SETUP 1039YY_RULE_SETUP
1153#line 222 "dtc-lexer.l" 1040#line 168 "dtc-lexer.l"
1154ECHO; 1041ECHO;
1155 YY_BREAK 1042 YY_BREAK
1156#line 1157 "dtc-lexer.lex.c" 1043#line 1044 "dtc-lexer.lex.c"
1157 1044
1158 case YY_END_OF_BUFFER: 1045 case YY_END_OF_BUFFER:
1159 { 1046 {
@@ -1218,7 +1105,8 @@ ECHO;
1218 1105
1219 else 1106 else
1220 { 1107 {
1221 yy_cp = (yy_c_buf_p); 1108 yy_cp = (yy_last_accepting_cpos);
1109 yy_current_state = (yy_last_accepting_state);
1222 goto yy_find_action; 1110 goto yy_find_action;
1223 } 1111 }
1224 } 1112 }
@@ -1443,7 +1331,7 @@ static int yy_get_next_buffer (void)
1443 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1331 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1444 { 1332 {
1445 yy_current_state = (int) yy_def[yy_current_state]; 1333 yy_current_state = (int) yy_def[yy_current_state];
1446 if ( yy_current_state >= 104 ) 1334 if ( yy_current_state >= 94 )
1447 yy_c = yy_meta[(unsigned int) yy_c]; 1335 yy_c = yy_meta[(unsigned int) yy_c];
1448 } 1336 }
1449 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1337 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1471,11 +1359,11 @@ static int yy_get_next_buffer (void)
1471 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1359 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1472 { 1360 {
1473 yy_current_state = (int) yy_def[yy_current_state]; 1361 yy_current_state = (int) yy_def[yy_current_state];
1474 if ( yy_current_state >= 104 ) 1362 if ( yy_current_state >= 94 )
1475 yy_c = yy_meta[(unsigned int) yy_c]; 1363 yy_c = yy_meta[(unsigned int) yy_c];
1476 } 1364 }
1477 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1365 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1478 yy_is_jam = (yy_current_state == 103); 1366 yy_is_jam = (yy_current_state == 93);
1479 1367
1480 return yy_is_jam ? 0 : yy_current_state; 1368 return yy_is_jam ? 0 : yy_current_state;
1481} 1369}
@@ -1550,11 +1438,6 @@ static int yy_get_next_buffer (void)
1550 *(yy_c_buf_p) = '\0'; /* preserve yytext */ 1438 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1551 (yy_hold_char) = *++(yy_c_buf_p); 1439 (yy_hold_char) = *++(yy_c_buf_p);
1552 1440
1553 if ( c == '\n' )
1554
1555 yylineno++;
1556;
1557
1558 return c; 1441 return c;
1559} 1442}
1560#endif /* ifndef YY_NO_INPUT */ 1443#endif /* ifndef YY_NO_INPUT */
@@ -1669,10 +1552,6 @@ static void yy_load_buffer_state (void)
1669 yyfree((void *) b ); 1552 yyfree((void *) b );
1670} 1553}
1671 1554
1672#ifndef __cplusplus
1673extern int isatty (int );
1674#endif /* __cplusplus */
1675
1676/* Initializes or reinitializes a buffer. 1555/* Initializes or reinitializes a buffer.
1677 * This function is sometimes called more than once on the same buffer, 1556 * This function is sometimes called more than once on the same buffer,
1678 * such as during a yyrestart() or at EOF. 1557 * such as during a yyrestart() or at EOF.
@@ -1696,7 +1575,7 @@ extern int isatty (int );
1696 b->yy_bs_column = 0; 1575 b->yy_bs_column = 0;
1697 } 1576 }
1698 1577
1699 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 1578 b->yy_is_interactive = 0;
1700 1579
1701 errno = oerrno; 1580 errno = oerrno;
1702} 1581}
@@ -2025,9 +1904,6 @@ static int yy_init_globals (void)
2025 * This function is called from yylex_destroy(), so don't allocate here. 1904 * This function is called from yylex_destroy(), so don't allocate here.
2026 */ 1905 */
2027 1906
2028 /* We do not touch yylineno unless the option is enabled. */
2029 yylineno = 1;
2030
2031 (yy_buffer_stack) = 0; 1907 (yy_buffer_stack) = 0;
2032 (yy_buffer_stack_top) = 0; 1908 (yy_buffer_stack_top) = 0;
2033 (yy_buffer_stack_max) = 0; 1909 (yy_buffer_stack_max) = 0;
@@ -2120,104 +1996,29 @@ void yyfree (void * ptr )
2120 1996
2121#define YYTABLES_NAME "yytables" 1997#define YYTABLES_NAME "yytables"
2122 1998
2123#line 222 "dtc-lexer.l" 1999#line 168 "dtc-lexer.l"
2124
2125
2126
2127
2128/*
2129 * Stack of nested include file contexts.
2130 */
2131
2132struct incl_file {
2133 struct dtc_file *file;
2134 YY_BUFFER_STATE yy_prev_buf;
2135 int yy_prev_lineno;
2136 struct incl_file *prev;
2137};
2138
2139static struct incl_file *incl_file_stack;
2140 2000
2141 2001
2142/*
2143 * Detect infinite include recursion.
2144 */
2145#define MAX_INCLUDE_DEPTH (100)
2146
2147static int incl_depth = 0;
2148
2149 2002
2150static void push_input_file(const char *filename) 2003static void push_input_file(const char *filename)
2151{ 2004{
2152 struct incl_file *incl_file;
2153 struct dtc_file *newfile;
2154 struct search_path search, *searchptr = NULL;
2155
2156 assert(filename); 2005 assert(filename);
2157 2006
2158 if (incl_depth++ >= MAX_INCLUDE_DEPTH) 2007 srcfile_push(filename);
2159 die("Includes nested too deeply");
2160
2161 if (srcpos_file) {
2162 search.dir = srcpos_file->dir;
2163 search.next = NULL;
2164 search.prev = NULL;
2165 searchptr = &search;
2166 }
2167
2168 newfile = dtc_open_file(filename, searchptr);
2169 2008
2170 incl_file = xmalloc(sizeof(struct incl_file)); 2009 yyin = current_srcfile->f;
2171 2010
2172 /* 2011 yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE));
2173 * Save current context.
2174 */
2175 incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
2176 incl_file->yy_prev_lineno = yylineno;
2177 incl_file->file = srcpos_file;
2178 incl_file->prev = incl_file_stack;
2179
2180 incl_file_stack = incl_file;
2181
2182 /*
2183 * Establish new context.
2184 */
2185 srcpos_file = newfile;
2186 yylineno = 1;
2187 yyin = newfile->file;
2188 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
2189} 2012}
2190 2013
2191 2014
2192static int pop_input_file(void) 2015static int pop_input_file(void)
2193{ 2016{
2194 struct incl_file *incl_file; 2017 if (srcfile_pop() == 0)
2195
2196 if (incl_file_stack == 0)
2197 return 0; 2018 return 0;
2198 2019
2199 dtc_close_file(srcpos_file); 2020 yypop_buffer_state();
2200 2021 yyin = current_srcfile->f;
2201 /*
2202 * Pop.
2203 */
2204 --incl_depth;
2205 incl_file = incl_file_stack;
2206 incl_file_stack = incl_file->prev;
2207
2208 /*
2209 * Recover old context.
2210 */
2211 yy_delete_buffer(YY_CURRENT_BUFFER);
2212 yy_switch_to_buffer(incl_file->yy_prev_buf);
2213 yylineno = incl_file->yy_prev_lineno;
2214 srcpos_file = incl_file->file;
2215 yyin = incl_file->file ? incl_file->file->file : NULL;
2216
2217 /*
2218 * Free old state.
2219 */
2220 free(incl_file);
2221 2022
2222 return 1; 2023 return 1;
2223} 2024}
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 27129377e5d2..9be2eea18a30 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1,24 +1,23 @@
1/* A Bison parser, made by GNU Bison 2.3. */
2 1
3/* Skeleton implementation for Bison's Yacc-like parsers in C 2/* A Bison parser, made by GNU Bison 2.4.1. */
4 3
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc. 7 Free Software Foundation, Inc.
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation, either version 3 of the License, or
11 any later version. 12 (at your option) any later version.
12 13
13 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 17 GNU General Public License for more details.
17 18
18 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22 21
23/* As a special exception, you may create a larger work that contains 22/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work 23 part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
29 special exception, which will cause the skeleton and the resulting 28 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public 29 Bison output files to be licensed under the GNU General Public
31 License without this special exception. 30 License without this special exception.
32 31
33 This special exception was added by the Free Software Foundation in 32 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */ 33 version 2.2 of Bison. */
35 34
@@ -47,7 +46,7 @@
47#define YYBISON 1 46#define YYBISON 1
48 47
49/* Bison version. */ 48/* Bison version. */
50#define YYBISON_VERSION "2.3" 49#define YYBISON_VERSION "2.4.1"
51 50
52/* Skeleton name. */ 51/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c" 52#define YYSKELETON_NAME "yacc.c"
@@ -55,55 +54,32 @@
55/* Pure parsers. */ 54/* Pure parsers. */
56#define YYPURE 0 55#define YYPURE 0
57 56
58/* Using locations. */ 57/* Push parsers. */
59#define YYLSP_NEEDED 1 58#define YYPUSH 0
60
61 59
60/* Pull parsers. */
61#define YYPULL 1
62 62
63/* Tokens. */ 63/* Using locations. */
64#ifndef YYTOKENTYPE 64#define YYLSP_NEEDED 0
65# define YYTOKENTYPE
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
67 know about them. */
68 enum yytokentype {
69 DT_V1 = 258,
70 DT_MEMRESERVE = 259,
71 DT_PROPNODENAME = 260,
72 DT_LITERAL = 261,
73 DT_LEGACYLITERAL = 262,
74 DT_BASE = 263,
75 DT_BYTE = 264,
76 DT_STRING = 265,
77 DT_LABEL = 266,
78 DT_REF = 267,
79 DT_INCBIN = 268
80 };
81#endif
82/* Tokens. */
83#define DT_V1 258
84#define DT_MEMRESERVE 259
85#define DT_PROPNODENAME 260
86#define DT_LITERAL 261
87#define DT_LEGACYLITERAL 262
88#define DT_BASE 263
89#define DT_BYTE 264
90#define DT_STRING 265
91#define DT_LABEL 266
92#define DT_REF 267
93#define DT_INCBIN 268
94
95 65
96 66
97 67
98/* Copy the first part of user declarations. */ 68/* Copy the first part of user declarations. */
99#line 23 "dtc-parser.y" 69
70/* Line 189 of yacc.c */
71#line 21 "dtc-parser.y"
100 72
101#include <stdio.h> 73#include <stdio.h>
102 74
103#include "dtc.h" 75#include "dtc.h"
104#include "srcpos.h" 76#include "srcpos.h"
105 77
78YYLTYPE yylloc;
79
106extern int yylex(void); 80extern int yylex(void);
81extern void print_error(char const *fmt, ...);
82extern void yyerror(char const *s);
107 83
108extern struct boot_info *the_boot_info; 84extern struct boot_info *the_boot_info;
109extern int treesource_error; 85extern int treesource_error;
@@ -111,6 +87,9 @@ extern int treesource_error;
111static unsigned long long eval_literal(const char *s, int base, int bits); 87static unsigned long long eval_literal(const char *s, int base, int bits);
112 88
113 89
90/* Line 189 of yacc.c */
91#line 92 "dtc-parser.tab.c"
92
114/* Enabling traces. */ 93/* Enabling traces. */
115#ifndef YYDEBUG 94#ifndef YYDEBUG
116# define YYDEBUG 0 95# define YYDEBUG 0
@@ -129,10 +108,35 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
129# define YYTOKEN_TABLE 0 108# define YYTOKEN_TABLE 0
130#endif 109#endif
131 110
111
112/* Tokens. */
113#ifndef YYTOKENTYPE
114# define YYTOKENTYPE
115 /* Put the tokens into the symbol table, so that GDB and other debuggers
116 know about them. */
117 enum yytokentype {
118 DT_V1 = 258,
119 DT_MEMRESERVE = 259,
120 DT_PROPNODENAME = 260,
121 DT_LITERAL = 261,
122 DT_BASE = 262,
123 DT_BYTE = 263,
124 DT_STRING = 264,
125 DT_LABEL = 265,
126 DT_REF = 266,
127 DT_INCBIN = 267
128 };
129#endif
130
131
132
132#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 133#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
133typedef union YYSTYPE 134typedef union YYSTYPE
134#line 37 "dtc-parser.y"
135{ 135{
136
137/* Line 214 of yacc.c */
138#line 39 "dtc-parser.y"
139
136 char *propnodename; 140 char *propnodename;
137 char *literal; 141 char *literal;
138 char *labelref; 142 char *labelref;
@@ -147,34 +151,23 @@ typedef union YYSTYPE
147 struct node *node; 151 struct node *node;
148 struct node *nodelist; 152 struct node *nodelist;
149 struct reserve_info *re; 153 struct reserve_info *re;
150} 154
151/* Line 187 of yacc.c. */ 155
152#line 153 "dtc-parser.tab.c" 156
153 YYSTYPE; 157/* Line 214 of yacc.c */
158#line 159 "dtc-parser.tab.c"
159} YYSTYPE;
160# define YYSTYPE_IS_TRIVIAL 1
154# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 161# define yystype YYSTYPE /* obsolescent; will be withdrawn */
155# define YYSTYPE_IS_DECLARED 1 162# define YYSTYPE_IS_DECLARED 1
156# define YYSTYPE_IS_TRIVIAL 1
157#endif
158
159#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
160typedef struct YYLTYPE
161{
162 int first_line;
163 int first_column;
164 int last_line;
165 int last_column;
166} YYLTYPE;
167# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
168# define YYLTYPE_IS_DECLARED 1
169# define YYLTYPE_IS_TRIVIAL 1
170#endif 163#endif
171 164
172 165
173/* Copy the second part of user declarations. */ 166/* Copy the second part of user declarations. */
174 167
175 168
176/* Line 216 of yacc.c. */ 169/* Line 264 of yacc.c */
177#line 178 "dtc-parser.tab.c" 170#line 171 "dtc-parser.tab.c"
178 171
179#ifdef short 172#ifdef short
180# undef short 173# undef short
@@ -249,14 +242,14 @@ typedef short int yytype_int16;
249#if (defined __STDC__ || defined __C99__FUNC__ \ 242#if (defined __STDC__ || defined __C99__FUNC__ \
250 || defined __cplusplus || defined _MSC_VER) 243 || defined __cplusplus || defined _MSC_VER)
251static int 244static int
252YYID (int i) 245YYID (int yyi)
253#else 246#else
254static int 247static int
255YYID (i) 248YYID (yyi)
256 int i; 249 int yyi;
257#endif 250#endif
258{ 251{
259 return i; 252 return yyi;
260} 253}
261#endif 254#endif
262 255
@@ -332,15 +325,13 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
332 325
333#if (! defined yyoverflow \ 326#if (! defined yyoverflow \
334 && (! defined __cplusplus \ 327 && (! defined __cplusplus \
335 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ 328 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
336 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
337 329
338/* A type that is properly aligned for any stack member. */ 330/* A type that is properly aligned for any stack member. */
339union yyalloc 331union yyalloc
340{ 332{
341 yytype_int16 yyss; 333 yytype_int16 yyss_alloc;
342 YYSTYPE yyvs; 334 YYSTYPE yyvs_alloc;
343 YYLTYPE yyls;
344}; 335};
345 336
346/* The size of the maximum gap between one aligned stack and the next. */ 337/* The size of the maximum gap between one aligned stack and the next. */
@@ -349,8 +340,8 @@ union yyalloc
349/* The size of an array large to enough to hold all stacks, each with 340/* The size of an array large to enough to hold all stacks, each with
350 N elements. */ 341 N elements. */
351# define YYSTACK_BYTES(N) \ 342# define YYSTACK_BYTES(N) \
352 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ 343 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
353 + 2 * YYSTACK_GAP_MAXIMUM) 344 + YYSTACK_GAP_MAXIMUM)
354 345
355/* Copy COUNT objects from FROM to TO. The source and destination do 346/* Copy COUNT objects from FROM to TO. The source and destination do
356 not overlap. */ 347 not overlap. */
@@ -375,12 +366,12 @@ union yyalloc
375 elements in the stack, and YYPTR gives the new location of the 366 elements in the stack, and YYPTR gives the new location of the
376 stack. Advance YYPTR to a properly aligned location for the next 367 stack. Advance YYPTR to a properly aligned location for the next
377 stack. */ 368 stack. */
378# define YYSTACK_RELOCATE(Stack) \ 369# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
379 do \ 370 do \
380 { \ 371 { \
381 YYSIZE_T yynewbytes; \ 372 YYSIZE_T yynewbytes; \
382 YYCOPY (&yyptr->Stack, Stack, yysize); \ 373 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
383 Stack = &yyptr->Stack; \ 374 Stack = &yyptr->Stack_alloc; \
384 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 375 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
385 yyptr += yynewbytes / sizeof (*yyptr); \ 376 yyptr += yynewbytes / sizeof (*yyptr); \
386 } \ 377 } \
@@ -389,22 +380,22 @@ union yyalloc
389#endif 380#endif
390 381
391/* YYFINAL -- State number of the termination state. */ 382/* YYFINAL -- State number of the termination state. */
392#define YYFINAL 9 383#define YYFINAL 4
393/* YYLAST -- Last index in YYTABLE. */ 384/* YYLAST -- Last index in YYTABLE. */
394#define YYLAST 73 385#define YYLAST 56
395 386
396/* YYNTOKENS -- Number of terminals. */ 387/* YYNTOKENS -- Number of terminals. */
397#define YYNTOKENS 27 388#define YYNTOKENS 25
398/* YYNNTS -- Number of nonterminals. */ 389/* YYNNTS -- Number of nonterminals. */
399#define YYNNTS 20 390#define YYNNTS 16
400/* YYNRULES -- Number of rules. */ 391/* YYNRULES -- Number of rules. */
401#define YYNRULES 45 392#define YYNRULES 39
402/* YYNRULES -- Number of states. */ 393/* YYNRULES -- Number of states. */
403#define YYNSTATES 76 394#define YYNSTATES 67
404 395
405/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 396/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
406#define YYUNDEFTOK 2 397#define YYUNDEFTOK 2
407#define YYMAXUTOK 268 398#define YYMAXUTOK 267
408 399
409#define YYTRANSLATE(YYX) \ 400#define YYTRANSLATE(YYX) \
410 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 401 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -416,15 +407,15 @@ static const yytype_uint8 yytranslate[] =
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 24, 26, 2, 2, 25, 15, 2, 16, 2, 2, 410 22, 24, 2, 2, 23, 2, 2, 14, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 411 2, 2, 2, 2, 2, 2, 2, 2, 2, 13,
421 20, 19, 21, 2, 2, 2, 2, 2, 2, 2, 412 18, 17, 19, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 22, 2, 23, 2, 2, 2, 2, 2, 2, 415 2, 20, 2, 21, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 17, 2, 18, 2, 2, 2, 2, 418 2, 2, 2, 15, 2, 16, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -438,7 +429,7 @@ static const yytype_uint8 yytranslate[] =
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 431 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
441 5, 6, 7, 8, 9, 10, 11, 12, 13 432 5, 6, 7, 8, 9, 10, 11, 12
442}; 433};
443 434
444#if YYDEBUG 435#if YYDEBUG
@@ -446,41 +437,37 @@ static const yytype_uint8 yytranslate[] =
446 YYRHS. */ 437 YYRHS. */
447static const yytype_uint8 yyprhs[] = 438static const yytype_uint8 yyprhs[] =
448{ 439{
449 0, 0, 3, 8, 11, 12, 15, 21, 22, 25, 440 0, 0, 3, 8, 9, 12, 17, 20, 22, 25,
450 27, 34, 36, 38, 41, 47, 48, 51, 57, 61, 441 29, 33, 39, 40, 43, 48, 51, 54, 57, 62,
451 64, 69, 74, 77, 87, 93, 96, 97, 100, 103, 442 67, 70, 80, 86, 89, 90, 93, 96, 97, 100,
452 104, 107, 110, 113, 114, 116, 118, 121, 122, 125, 443 103, 106, 108, 109, 112, 115, 116, 119, 122, 125
453 128, 129, 132, 135, 139, 140
454}; 444};
455 445
456/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 446/* YYRHS -- A `-1'-separated list of the rules' RHS. */
457static const yytype_int8 yyrhs[] = 447static const yytype_int8 yyrhs[] =
458{ 448{
459 28, 0, -1, 3, 14, 29, 34, -1, 31, 34, 449 26, 0, -1, 3, 13, 27, 30, -1, -1, 28,
460 -1, -1, 30, 29, -1, 46, 4, 33, 33, 14, 450 27, -1, 4, 29, 29, 13, -1, 10, 28, -1,
461 -1, -1, 32, 31, -1, 30, -1, 46, 4, 33, 451 6, -1, 14, 31, -1, 30, 14, 31, -1, 30,
462 15, 33, 14, -1, 6, -1, 7, -1, 16, 35, 452 11, 31, -1, 15, 32, 39, 16, 13, -1, -1,
463 -1, 17, 36, 44, 18, 14, -1, -1, 36, 37, 453 32, 33, -1, 5, 17, 34, 13, -1, 5, 13,
464 -1, 46, 5, 19, 38, 14, -1, 46, 5, 14, 454 -1, 10, 33, -1, 35, 9, -1, 35, 18, 36,
465 -1, 39, 10, -1, 39, 20, 40, 21, -1, 39, 455 19, -1, 35, 20, 38, 21, -1, 35, 11, -1,
466 22, 43, 23, -1, 39, 12, -1, 39, 13, 24, 456 35, 12, 22, 9, 23, 29, 23, 29, 24, -1,
467 10, 25, 33, 25, 33, 26, -1, 39, 13, 24, 457 35, 12, 22, 9, 24, -1, 34, 10, -1, -1,
468 10, 26, -1, 38, 11, -1, -1, 38, 25, -1, 458 34, 23, -1, 35, 10, -1, -1, 36, 37, -1,
469 39, 11, -1, -1, 40, 42, -1, 40, 12, -1, 459 36, 11, -1, 36, 10, -1, 6, -1, -1, 38,
470 40, 11, -1, -1, 8, -1, 6, -1, 41, 7, 460 8, -1, 38, 10, -1, -1, 40, 39, -1, 40,
471 -1, -1, 43, 9, -1, 43, 11, -1, -1, 45, 461 33, -1, 5, 31, -1, 10, 40, -1
472 44, -1, 45, 37, -1, 46, 5, 35, -1, -1,
473 11, -1
474}; 462};
475 463
476/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 464/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
477static const yytype_uint16 yyrline[] = 465static const yytype_uint16 yyrline[] =
478{ 466{
479 0, 89, 89, 93, 101, 104, 111, 119, 122, 129, 467 0, 86, 86, 95, 98, 105, 109, 117, 124, 128,
480 133, 140, 144, 151, 158, 166, 169, 176, 180, 187, 468 132, 145, 153, 156, 163, 167, 171, 179, 183, 187,
481 191, 195, 199, 203, 220, 231, 239, 242, 246, 254, 469 191, 195, 212, 222, 230, 233, 237, 245, 248, 252,
482 257, 261, 266, 274, 277, 281, 285, 293, 296, 300, 470 257, 264, 272, 275, 279, 287, 290, 294, 302, 306
483 308, 311, 315, 323, 331, 334
484}; 471};
485#endif 472#endif
486 473
@@ -490,13 +477,12 @@ static const yytype_uint16 yyrline[] =
490static const char *const yytname[] = 477static const char *const yytname[] =
491{ 478{
492 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE", 479 "$end", "error", "$undefined", "DT_V1", "DT_MEMRESERVE",
493 "DT_PROPNODENAME", "DT_LITERAL", "DT_LEGACYLITERAL", "DT_BASE", 480 "DT_PROPNODENAME", "DT_LITERAL", "DT_BASE", "DT_BYTE", "DT_STRING",
494 "DT_BYTE", "DT_STRING", "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'-'", 481 "DT_LABEL", "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='",
495 "'/'", "'{'", "'}'", "'='", "'<'", "'>'", "'['", "']'", "'('", "','", 482 "'<'", "'>'", "'['", "']'", "'('", "','", "')'", "$accept", "sourcefile",
496 "')'", "$accept", "sourcefile", "memreserves", "memreserve", 483 "memreserves", "memreserve", "addr", "devicetree", "nodedef", "proplist",
497 "v0_memreserves", "v0_memreserve", "addr", "devicetree", "nodedef", 484 "propdef", "propdata", "propdataprefix", "celllist", "cellval",
498 "proplist", "propdef", "propdata", "propdataprefix", "celllist", 485 "bytestring", "subnodes", "subnode", 0
499 "cellbase", "cellval", "bytestring", "subnodes", "subnode", "label", 0
500}; 486};
501#endif 487#endif
502 488
@@ -506,29 +492,27 @@ static const char *const yytname[] =
506static const yytype_uint16 yytoknum[] = 492static const yytype_uint16 yytoknum[] =
507{ 493{
508 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 494 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
509 265, 266, 267, 268, 59, 45, 47, 123, 125, 61, 495 265, 266, 267, 59, 47, 123, 125, 61, 60, 62,
510 60, 62, 91, 93, 40, 44, 41 496 91, 93, 40, 44, 41
511}; 497};
512# endif 498# endif
513 499
514/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 500/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
515static const yytype_uint8 yyr1[] = 501static const yytype_uint8 yyr1[] =
516{ 502{
517 0, 27, 28, 28, 29, 29, 30, 31, 31, 32, 503 0, 25, 26, 27, 27, 28, 28, 29, 30, 30,
518 32, 33, 33, 34, 35, 36, 36, 37, 37, 38, 504 30, 31, 32, 32, 33, 33, 33, 34, 34, 34,
519 38, 38, 38, 38, 38, 38, 39, 39, 39, 40, 505 34, 34, 34, 34, 35, 35, 35, 36, 36, 36,
520 40, 40, 40, 41, 41, 42, 42, 43, 43, 43, 506 36, 37, 38, 38, 38, 39, 39, 39, 40, 40
521 44, 44, 44, 45, 46, 46
522}; 507};
523 508
524/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 509/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
525static const yytype_uint8 yyr2[] = 510static const yytype_uint8 yyr2[] =
526{ 511{
527 0, 2, 4, 2, 0, 2, 5, 0, 2, 1, 512 0, 2, 4, 0, 2, 4, 2, 1, 2, 3,
528 6, 1, 1, 2, 5, 0, 2, 5, 3, 2, 513 3, 5, 0, 2, 4, 2, 2, 2, 4, 4,
529 4, 4, 2, 9, 5, 2, 0, 2, 2, 0, 514 2, 9, 5, 2, 0, 2, 2, 0, 2, 2,
530 2, 2, 2, 0, 1, 1, 2, 0, 2, 2, 515 2, 1, 0, 2, 2, 0, 2, 2, 2, 2
531 0, 2, 2, 3, 0, 1
532}; 516};
533 517
534/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 518/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -536,86 +520,79 @@ static const yytype_uint8 yyr2[] =
536 means the default is an error. */ 520 means the default is an error. */
537static const yytype_uint8 yydefact[] = 521static const yytype_uint8 yydefact[] =
538{ 522{
539 7, 0, 45, 0, 9, 0, 7, 0, 4, 1, 523 0, 0, 0, 3, 1, 0, 0, 0, 3, 7,
540 0, 3, 8, 0, 0, 4, 0, 15, 13, 11, 524 0, 6, 0, 2, 4, 0, 12, 8, 0, 0,
541 12, 0, 2, 5, 0, 40, 0, 0, 0, 16, 525 5, 35, 10, 9, 0, 0, 13, 0, 35, 15,
542 0, 40, 0, 0, 6, 0, 42, 41, 0, 10, 526 24, 38, 16, 39, 0, 37, 36, 0, 0, 11,
543 14, 18, 26, 43, 0, 0, 25, 17, 27, 19, 527 23, 14, 25, 17, 26, 20, 0, 27, 32, 0,
544 28, 22, 0, 29, 37, 0, 33, 0, 0, 35, 528 0, 0, 0, 31, 30, 29, 18, 28, 33, 34,
545 34, 32, 31, 20, 0, 30, 38, 39, 21, 0, 529 19, 0, 22, 0, 0, 0, 21
546 24, 36, 0, 0, 0, 23
547}; 530};
548 531
549/* YYDEFGOTO[NTERM-NUM]. */ 532/* YYDEFGOTO[NTERM-NUM]. */
550static const yytype_int8 yydefgoto[] = 533static const yytype_int8 yydefgoto[] =
551{ 534{
552 -1, 3, 14, 4, 5, 6, 27, 11, 18, 25, 535 -1, 2, 7, 8, 10, 13, 17, 21, 26, 37,
553 29, 44, 45, 56, 64, 65, 57, 30, 31, 7 536 38, 50, 57, 51, 27, 28
554}; 537};
555 538
556/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 539/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
557 STATE-NUM. */ 540 STATE-NUM. */
558#define YYPACT_NINF -14 541#define YYPACT_NINF -12
559static const yytype_int8 yypact[] = 542static const yytype_int8 yypact[] =
560{ 543{
561 30, -11, -14, 7, -14, -1, 27, 13, 27, -14, 544 10, -11, 18, -1, -12, 22, -1, 15, -1, -12,
562 8, -14, -14, 40, -1, 27, 35, -14, -14, -14, 545 22, -12, 20, 1, -12, 17, -12, -12, 20, 20,
563 -14, 21, -14, -14, 40, 24, 40, 28, 40, -14, 546 -12, 6, -12, -12, 21, 6, -12, 23, 6, -12,
564 32, 24, 46, 38, -14, 39, -14, -14, 26, -14, 547 -12, -12, -12, -12, 28, -12, -12, -6, 13, -12,
565 -14, -14, -14, -14, -9, 10, -14, -14, -14, -14, 548 -12, -12, -12, -12, -12, -12, 24, -12, -12, 33,
566 -14, -14, 31, -14, -14, 44, -2, 3, 23, -14, 549 -5, 0, -4, -12, -12, -12, -12, -12, -12, -12,
567 -14, -14, -14, -14, 50, -14, -14, -14, -14, 40, 550 -12, 22, -12, 25, 22, 19, -12
568 -14, -14, 33, 40, 36, -14
569}; 551};
570 552
571/* YYPGOTO[NTERM-NUM]. */ 553/* YYPGOTO[NTERM-NUM]. */
572static const yytype_int8 yypgoto[] = 554static const yytype_int8 yypgoto[] =
573{ 555{
574 -14, -14, 48, 29, 53, -14, -13, 47, 34, -14, 556 -12, -12, 36, 39, -10, -12, 8, -12, 12, -12,
575 37, -14, -14, -14, -14, -14, -14, 42, -14, -7 557 -12, -12, -12, -12, 27, 31
576}; 558};
577 559
578/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 560/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
579 positive, shift that token. If negative, reduce the rule which 561 positive, shift that token. If negative, reduce the rule which
580 number is the opposite. If zero, do what YYDEFACT says. 562 number is the opposite. If zero, do what YYDEFACT says.
581 If YYTABLE_NINF, syntax error. */ 563 If YYTABLE_NINF, syntax error. */
582#define YYTABLE_NINF -45 564#define YYTABLE_NINF -1
583static const yytype_int8 yytable[] = 565static const yytype_uint8 yytable[] =
584{ 566{
585 21, 16, 46, 8, 59, 47, 60, 9, 16, 61, 567 15, 53, 3, 5, 40, 54, 55, 41, 58, 6,
586 62, 28, 66, 33, 67, 10, 48, 13, 32, 63, 568 59, 24, 18, 1, 56, 19, 25, 42, 4, 61,
587 49, 50, 51, 52, 32, 17, 68, 19, 20, -44, 569 62, 60, 43, 44, 45, 46, 22, 23, 9, 12,
588 53, -44, 54, 1, -44, 2, 26, 15, 2, 24, 570 20, 47, 31, 48, 29, 16, 16, 32, 30, 34,
589 41, 2, 34, 17, 15, 42, 19, 20, 69, 70, 571 35, 39, 52, 66, 14, 11, 49, 0, 64, 0,
590 35, 38, 39, 40, 58, 55, 72, 71, 73, 12, 572 0, 63, 0, 0, 65, 36, 33
591 74, 22, 75, 23, 0, 0, 0, 0, 36, 0,
592 0, 0, 43, 37
593}; 573};
594 574
595static const yytype_int8 yycheck[] = 575static const yytype_int8 yycheck[] =
596{ 576{
597 13, 8, 11, 14, 6, 14, 8, 0, 15, 11, 577 10, 6, 13, 4, 10, 10, 11, 13, 8, 10,
598 12, 24, 9, 26, 11, 16, 25, 4, 25, 21, 578 10, 5, 11, 3, 19, 14, 10, 23, 0, 23,
599 10, 11, 12, 13, 31, 17, 23, 6, 7, 5, 579 24, 21, 9, 10, 11, 12, 18, 19, 6, 14,
600 20, 4, 22, 3, 4, 11, 15, 8, 11, 4, 580 13, 18, 24, 20, 13, 15, 15, 25, 17, 16,
601 14, 11, 14, 17, 15, 19, 6, 7, 25, 26, 581 28, 13, 9, 24, 8, 6, 22, -1, 23, -1,
602 18, 5, 14, 14, 10, 24, 69, 7, 25, 6, 582 -1, 61, -1, -1, 64, 28, 25
603 73, 14, 26, 15, -1, -1, -1, -1, 31, -1,
604 -1, -1, 38, 31
605}; 583};
606 584
607/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 585/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
608 symbol of state STATE-NUM. */ 586 symbol of state STATE-NUM. */
609static const yytype_uint8 yystos[] = 587static const yytype_uint8 yystos[] =
610{ 588{
611 0, 3, 11, 28, 30, 31, 32, 46, 14, 0, 589 0, 3, 26, 13, 0, 4, 10, 27, 28, 6,
612 16, 34, 31, 4, 29, 30, 46, 17, 35, 6, 590 29, 28, 14, 30, 27, 29, 15, 31, 11, 14,
613 7, 33, 34, 29, 4, 36, 15, 33, 33, 37, 591 13, 32, 31, 31, 5, 10, 33, 39, 40, 13,
614 44, 45, 46, 33, 14, 18, 37, 44, 5, 14, 592 17, 31, 33, 40, 16, 33, 39, 34, 35, 13,
615 14, 14, 19, 35, 38, 39, 11, 14, 25, 10, 593 10, 13, 23, 9, 10, 11, 12, 18, 20, 22,
616 11, 12, 13, 20, 22, 24, 40, 43, 10, 6, 594 36, 38, 9, 6, 10, 11, 19, 37, 8, 10,
617 8, 11, 12, 21, 41, 42, 9, 11, 23, 25, 595 21, 23, 24, 29, 23, 29, 24
618 26, 7, 33, 25, 33, 26
619}; 596};
620 597
621#define yyerrok (yyerrstatus = 0) 598#define yyerrok (yyerrstatus = 0)
@@ -728,7 +705,7 @@ do { \
728 { \ 705 { \
729 YYFPRINTF (stderr, "%s ", Title); \ 706 YYFPRINTF (stderr, "%s ", Title); \
730 yy_symbol_print (stderr, \ 707 yy_symbol_print (stderr, \
731 Type, Value, Location); \ 708 Type, Value); \
732 YYFPRINTF (stderr, "\n"); \ 709 YYFPRINTF (stderr, "\n"); \
733 } \ 710 } \
734} while (YYID (0)) 711} while (YYID (0))
@@ -742,19 +719,17 @@ do { \
742#if (defined __STDC__ || defined __C99__FUNC__ \ 719#if (defined __STDC__ || defined __C99__FUNC__ \
743 || defined __cplusplus || defined _MSC_VER) 720 || defined __cplusplus || defined _MSC_VER)
744static void 721static void
745yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) 722yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
746#else 723#else
747static void 724static void
748yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) 725yy_symbol_value_print (yyoutput, yytype, yyvaluep)
749 FILE *yyoutput; 726 FILE *yyoutput;
750 int yytype; 727 int yytype;
751 YYSTYPE const * const yyvaluep; 728 YYSTYPE const * const yyvaluep;
752 YYLTYPE const * const yylocationp;
753#endif 729#endif
754{ 730{
755 if (!yyvaluep) 731 if (!yyvaluep)
756 return; 732 return;
757 YYUSE (yylocationp);
758# ifdef YYPRINT 733# ifdef YYPRINT
759 if (yytype < YYNTOKENS) 734 if (yytype < YYNTOKENS)
760 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 735 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
@@ -776,14 +751,13 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
776#if (defined __STDC__ || defined __C99__FUNC__ \ 751#if (defined __STDC__ || defined __C99__FUNC__ \
777 || defined __cplusplus || defined _MSC_VER) 752 || defined __cplusplus || defined _MSC_VER)
778static void 753static void
779yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) 754yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
780#else 755#else
781static void 756static void
782yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) 757yy_symbol_print (yyoutput, yytype, yyvaluep)
783 FILE *yyoutput; 758 FILE *yyoutput;
784 int yytype; 759 int yytype;
785 YYSTYPE const * const yyvaluep; 760 YYSTYPE const * const yyvaluep;
786 YYLTYPE const * const yylocationp;
787#endif 761#endif
788{ 762{
789 if (yytype < YYNTOKENS) 763 if (yytype < YYNTOKENS)
@@ -791,9 +765,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
791 else 765 else
792 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 766 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
793 767
794 YY_LOCATION_PRINT (yyoutput, *yylocationp); 768 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
795 YYFPRINTF (yyoutput, ": ");
796 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
797 YYFPRINTF (yyoutput, ")"); 769 YYFPRINTF (yyoutput, ")");
798} 770}
799 771
@@ -805,17 +777,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
805#if (defined __STDC__ || defined __C99__FUNC__ \ 777#if (defined __STDC__ || defined __C99__FUNC__ \
806 || defined __cplusplus || defined _MSC_VER) 778 || defined __cplusplus || defined _MSC_VER)
807static void 779static void
808yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 780yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
809#else 781#else
810static void 782static void
811yy_stack_print (bottom, top) 783yy_stack_print (yybottom, yytop)
812 yytype_int16 *bottom; 784 yytype_int16 *yybottom;
813 yytype_int16 *top; 785 yytype_int16 *yytop;
814#endif 786#endif
815{ 787{
816 YYFPRINTF (stderr, "Stack now"); 788 YYFPRINTF (stderr, "Stack now");
817 for (; bottom <= top; ++bottom) 789 for (; yybottom <= yytop; yybottom++)
818 YYFPRINTF (stderr, " %d", *bottom); 790 {
791 int yybot = *yybottom;
792 YYFPRINTF (stderr, " %d", yybot);
793 }
819 YYFPRINTF (stderr, "\n"); 794 YYFPRINTF (stderr, "\n");
820} 795}
821 796
@@ -833,12 +808,11 @@ do { \
833#if (defined __STDC__ || defined __C99__FUNC__ \ 808#if (defined __STDC__ || defined __C99__FUNC__ \
834 || defined __cplusplus || defined _MSC_VER) 809 || defined __cplusplus || defined _MSC_VER)
835static void 810static void
836yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) 811yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
837#else 812#else
838static void 813static void
839yy_reduce_print (yyvsp, yylsp, yyrule) 814yy_reduce_print (yyvsp, yyrule)
840 YYSTYPE *yyvsp; 815 YYSTYPE *yyvsp;
841 YYLTYPE *yylsp;
842 int yyrule; 816 int yyrule;
843#endif 817#endif
844{ 818{
@@ -850,18 +824,18 @@ yy_reduce_print (yyvsp, yylsp, yyrule)
850 /* The symbols being reduced. */ 824 /* The symbols being reduced. */
851 for (yyi = 0; yyi < yynrhs; yyi++) 825 for (yyi = 0; yyi < yynrhs; yyi++)
852 { 826 {
853 fprintf (stderr, " $%d = ", yyi + 1); 827 YYFPRINTF (stderr, " $%d = ", yyi + 1);
854 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 828 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
855 &(yyvsp[(yyi + 1) - (yynrhs)]) 829 &(yyvsp[(yyi + 1) - (yynrhs)])
856 , &(yylsp[(yyi + 1) - (yynrhs)]) ); 830 );
857 fprintf (stderr, "\n"); 831 YYFPRINTF (stderr, "\n");
858 } 832 }
859} 833}
860 834
861# define YY_REDUCE_PRINT(Rule) \ 835# define YY_REDUCE_PRINT(Rule) \
862do { \ 836do { \
863 if (yydebug) \ 837 if (yydebug) \
864 yy_reduce_print (yyvsp, yylsp, Rule); \ 838 yy_reduce_print (yyvsp, Rule); \
865} while (YYID (0)) 839} while (YYID (0))
866 840
867/* Nonzero means print parse trace. It is left uninitialized so that 841/* Nonzero means print parse trace. It is left uninitialized so that
@@ -1112,18 +1086,16 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
1112#if (defined __STDC__ || defined __C99__FUNC__ \ 1086#if (defined __STDC__ || defined __C99__FUNC__ \
1113 || defined __cplusplus || defined _MSC_VER) 1087 || defined __cplusplus || defined _MSC_VER)
1114static void 1088static void
1115yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) 1089yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1116#else 1090#else
1117static void 1091static void
1118yydestruct (yymsg, yytype, yyvaluep, yylocationp) 1092yydestruct (yymsg, yytype, yyvaluep)
1119 const char *yymsg; 1093 const char *yymsg;
1120 int yytype; 1094 int yytype;
1121 YYSTYPE *yyvaluep; 1095 YYSTYPE *yyvaluep;
1122 YYLTYPE *yylocationp;
1123#endif 1096#endif
1124{ 1097{
1125 YYUSE (yyvaluep); 1098 YYUSE (yyvaluep);
1126 YYUSE (yylocationp);
1127 1099
1128 if (!yymsg) 1100 if (!yymsg)
1129 yymsg = "Deleting"; 1101 yymsg = "Deleting";
@@ -1136,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
1136 break; 1108 break;
1137 } 1109 }
1138} 1110}
1139
1140 1111
1141/* Prevent warnings from -Wmissing-prototypes. */ 1112/* Prevent warnings from -Wmissing-prototypes. */
1142
1143#ifdef YYPARSE_PARAM 1113#ifdef YYPARSE_PARAM
1144#if defined __STDC__ || defined __cplusplus 1114#if defined __STDC__ || defined __cplusplus
1145int yyparse (void *YYPARSE_PARAM); 1115int yyparse (void *YYPARSE_PARAM);
@@ -1155,23 +1125,20 @@ int yyparse ();
1155#endif /* ! YYPARSE_PARAM */ 1125#endif /* ! YYPARSE_PARAM */
1156 1126
1157 1127
1158 1128/* The lookahead symbol. */
1159/* The look-ahead symbol. */
1160int yychar; 1129int yychar;
1161 1130
1162/* The semantic value of the look-ahead symbol. */ 1131/* The semantic value of the lookahead symbol. */
1163YYSTYPE yylval; 1132YYSTYPE yylval;
1164 1133
1165/* Number of syntax errors so far. */ 1134/* Number of syntax errors so far. */
1166int yynerrs; 1135int yynerrs;
1167/* Location data for the look-ahead symbol. */
1168YYLTYPE yylloc;
1169 1136
1170 1137
1171 1138
1172/*----------. 1139/*-------------------------.
1173| yyparse. | 1140| yyparse or yypush_parse. |
1174`----------*/ 1141`-------------------------*/
1175 1142
1176#ifdef YYPARSE_PARAM 1143#ifdef YYPARSE_PARAM
1177#if (defined __STDC__ || defined __C99__FUNC__ \ 1144#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1195,79 +1162,70 @@ yyparse ()
1195#endif 1162#endif
1196#endif 1163#endif
1197{ 1164{
1198
1199 int yystate;
1200 int yyn;
1201 int yyresult;
1202 /* Number of tokens to shift before error messages enabled. */
1203 int yyerrstatus;
1204 /* Look-ahead token as an internal (translated) token number. */
1205 int yytoken = 0;
1206#if YYERROR_VERBOSE
1207 /* Buffer for error messages, and its allocated size. */
1208 char yymsgbuf[128];
1209 char *yymsg = yymsgbuf;
1210 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1211#endif
1212 1165
1213 /* Three stacks and their tools:
1214 `yyss': related to states,
1215 `yyvs': related to semantic values,
1216 `yyls': related to locations.
1217 1166
1218 Refer to the stacks thru separate pointers, to allow yyoverflow 1167 int yystate;
1219 to reallocate them elsewhere. */ 1168 /* Number of tokens to shift before error messages enabled. */
1169 int yyerrstatus;
1220 1170
1221 /* The state stack. */ 1171 /* The stacks and their tools:
1222 yytype_int16 yyssa[YYINITDEPTH]; 1172 `yyss': related to states.
1223 yytype_int16 *yyss = yyssa; 1173 `yyvs': related to semantic values.
1224 yytype_int16 *yyssp;
1225 1174
1226 /* The semantic value stack. */ 1175 Refer to the stacks thru separate pointers, to allow yyoverflow
1227 YYSTYPE yyvsa[YYINITDEPTH]; 1176 to reallocate them elsewhere. */
1228 YYSTYPE *yyvs = yyvsa;
1229 YYSTYPE *yyvsp;
1230 1177
1231 /* The location stack. */ 1178 /* The state stack. */
1232 YYLTYPE yylsa[YYINITDEPTH]; 1179 yytype_int16 yyssa[YYINITDEPTH];
1233 YYLTYPE *yyls = yylsa; 1180 yytype_int16 *yyss;
1234 YYLTYPE *yylsp; 1181 yytype_int16 *yyssp;
1235 /* The locations where the error started and ended. */
1236 YYLTYPE yyerror_range[2];
1237 1182
1238#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) 1183 /* The semantic value stack. */
1184 YYSTYPE yyvsa[YYINITDEPTH];
1185 YYSTYPE *yyvs;
1186 YYSTYPE *yyvsp;
1239 1187
1240 YYSIZE_T yystacksize = YYINITDEPTH; 1188 YYSIZE_T yystacksize;
1241 1189
1190 int yyn;
1191 int yyresult;
1192 /* Lookahead token as an internal (translated) token number. */
1193 int yytoken;
1242 /* The variables used to return semantic value and location from the 1194 /* The variables used to return semantic value and location from the
1243 action routines. */ 1195 action routines. */
1244 YYSTYPE yyval; 1196 YYSTYPE yyval;
1245 YYLTYPE yyloc; 1197
1198#if YYERROR_VERBOSE
1199 /* Buffer for error messages, and its allocated size. */
1200 char yymsgbuf[128];
1201 char *yymsg = yymsgbuf;
1202 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1203#endif
1204
1205#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1246 1206
1247 /* The number of symbols on the RHS of the reduced rule. 1207 /* The number of symbols on the RHS of the reduced rule.
1248 Keep to zero when no symbol should be popped. */ 1208 Keep to zero when no symbol should be popped. */
1249 int yylen = 0; 1209 int yylen = 0;
1250 1210
1211 yytoken = 0;
1212 yyss = yyssa;
1213 yyvs = yyvsa;
1214 yystacksize = YYINITDEPTH;
1215
1251 YYDPRINTF ((stderr, "Starting parse\n")); 1216 YYDPRINTF ((stderr, "Starting parse\n"));
1252 1217
1253 yystate = 0; 1218 yystate = 0;
1254 yyerrstatus = 0; 1219 yyerrstatus = 0;
1255 yynerrs = 0; 1220 yynerrs = 0;
1256 yychar = YYEMPTY; /* Cause a token to be read. */ 1221 yychar = YYEMPTY; /* Cause a token to be read. */
1257 1222
1258 /* Initialize stack pointers. 1223 /* Initialize stack pointers.
1259 Waste one element of value and location stack 1224 Waste one element of value and location stack
1260 so that they stay on the same level as the state stack. 1225 so that they stay on the same level as the state stack.
1261 The wasted elements are never initialized. */ 1226 The wasted elements are never initialized. */
1262
1263 yyssp = yyss; 1227 yyssp = yyss;
1264 yyvsp = yyvs; 1228 yyvsp = yyvs;
1265 yylsp = yyls;
1266#if YYLTYPE_IS_TRIVIAL
1267 /* Initialize the default location before parsing starts. */
1268 yylloc.first_line = yylloc.last_line = 1;
1269 yylloc.first_column = yylloc.last_column = 0;
1270#endif
1271 1229
1272 goto yysetstate; 1230 goto yysetstate;
1273 1231
@@ -1294,7 +1252,6 @@ yyparse ()
1294 memory. */ 1252 memory. */
1295 YYSTYPE *yyvs1 = yyvs; 1253 YYSTYPE *yyvs1 = yyvs;
1296 yytype_int16 *yyss1 = yyss; 1254 yytype_int16 *yyss1 = yyss;
1297 YYLTYPE *yyls1 = yyls;
1298 1255
1299 /* Each stack pointer address is followed by the size of the 1256 /* Each stack pointer address is followed by the size of the
1300 data in use in that stack, in bytes. This used to be a 1257 data in use in that stack, in bytes. This used to be a
@@ -1303,9 +1260,8 @@ yyparse ()
1303 yyoverflow (YY_("memory exhausted"), 1260 yyoverflow (YY_("memory exhausted"),
1304 &yyss1, yysize * sizeof (*yyssp), 1261 &yyss1, yysize * sizeof (*yyssp),
1305 &yyvs1, yysize * sizeof (*yyvsp), 1262 &yyvs1, yysize * sizeof (*yyvsp),
1306 &yyls1, yysize * sizeof (*yylsp),
1307 &yystacksize); 1263 &yystacksize);
1308 yyls = yyls1; 1264
1309 yyss = yyss1; 1265 yyss = yyss1;
1310 yyvs = yyvs1; 1266 yyvs = yyvs1;
1311 } 1267 }
@@ -1326,9 +1282,8 @@ yyparse ()
1326 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1282 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1327 if (! yyptr) 1283 if (! yyptr)
1328 goto yyexhaustedlab; 1284 goto yyexhaustedlab;
1329 YYSTACK_RELOCATE (yyss); 1285 YYSTACK_RELOCATE (yyss_alloc, yyss);
1330 YYSTACK_RELOCATE (yyvs); 1286 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1331 YYSTACK_RELOCATE (yyls);
1332# undef YYSTACK_RELOCATE 1287# undef YYSTACK_RELOCATE
1333 if (yyss1 != yyssa) 1288 if (yyss1 != yyssa)
1334 YYSTACK_FREE (yyss1); 1289 YYSTACK_FREE (yyss1);
@@ -1338,7 +1293,6 @@ yyparse ()
1338 1293
1339 yyssp = yyss + yysize - 1; 1294 yyssp = yyss + yysize - 1;
1340 yyvsp = yyvs + yysize - 1; 1295 yyvsp = yyvs + yysize - 1;
1341 yylsp = yyls + yysize - 1;
1342 1296
1343 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1297 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1344 (unsigned long int) yystacksize)); 1298 (unsigned long int) yystacksize));
@@ -1349,6 +1303,9 @@ yyparse ()
1349 1303
1350 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1304 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1351 1305
1306 if (yystate == YYFINAL)
1307 YYACCEPT;
1308
1352 goto yybackup; 1309 goto yybackup;
1353 1310
1354/*-----------. 1311/*-----------.
@@ -1357,16 +1314,16 @@ yyparse ()
1357yybackup: 1314yybackup:
1358 1315
1359 /* Do appropriate processing given the current state. Read a 1316 /* Do appropriate processing given the current state. Read a
1360 look-ahead token if we need one and don't already have one. */ 1317 lookahead token if we need one and don't already have one. */
1361 1318
1362 /* First try to decide what to do without reference to look-ahead token. */ 1319 /* First try to decide what to do without reference to lookahead token. */
1363 yyn = yypact[yystate]; 1320 yyn = yypact[yystate];
1364 if (yyn == YYPACT_NINF) 1321 if (yyn == YYPACT_NINF)
1365 goto yydefault; 1322 goto yydefault;
1366 1323
1367 /* Not known => get a look-ahead token if don't already have one. */ 1324 /* Not known => get a lookahead token if don't already have one. */
1368 1325
1369 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1326 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1370 if (yychar == YYEMPTY) 1327 if (yychar == YYEMPTY)
1371 { 1328 {
1372 YYDPRINTF ((stderr, "Reading a token: ")); 1329 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1398,24 +1355,20 @@ yybackup:
1398 goto yyreduce; 1355 goto yyreduce;
1399 } 1356 }
1400 1357
1401 if (yyn == YYFINAL)
1402 YYACCEPT;
1403
1404 /* Count tokens shifted since error; after three, turn off error 1358 /* Count tokens shifted since error; after three, turn off error
1405 status. */ 1359 status. */
1406 if (yyerrstatus) 1360 if (yyerrstatus)
1407 yyerrstatus--; 1361 yyerrstatus--;
1408 1362
1409 /* Shift the look-ahead token. */ 1363 /* Shift the lookahead token. */
1410 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1364 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1411 1365
1412 /* Discard the shifted token unless it is eof. */ 1366 /* Discard the shifted token. */
1413 if (yychar != YYEOF) 1367 yychar = YYEMPTY;
1414 yychar = YYEMPTY;
1415 1368
1416 yystate = yyn; 1369 yystate = yyn;
1417 *++yyvsp = yylval; 1370 *++yyvsp = yylval;
1418 *++yylsp = yylloc; 1371
1419 goto yynewstate; 1372 goto yynewstate;
1420 1373
1421 1374
@@ -1446,337 +1399,387 @@ yyreduce:
1446 GCC warning that YYVAL may be used uninitialized. */ 1399 GCC warning that YYVAL may be used uninitialized. */
1447 yyval = yyvsp[1-yylen]; 1400 yyval = yyvsp[1-yylen];
1448 1401
1449 /* Default location. */ 1402
1450 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1451 YY_REDUCE_PRINT (yyn); 1403 YY_REDUCE_PRINT (yyn);
1452 switch (yyn) 1404 switch (yyn)
1453 { 1405 {
1454 case 2: 1406 case 2:
1455#line 90 "dtc-parser.y" 1407
1408/* Line 1455 of yacc.c */
1409#line 87 "dtc-parser.y"
1456 { 1410 {
1457 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 0); 1411 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
1412 guess_boot_cpuid((yyvsp[(4) - (4)].node)));
1458 ;} 1413 ;}
1459 break; 1414 break;
1460 1415
1461 case 3: 1416 case 3:
1462#line 94 "dtc-parser.y" 1417
1418/* Line 1455 of yacc.c */
1419#line 95 "dtc-parser.y"
1463 { 1420 {
1464 the_boot_info = build_boot_info((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].node), 0); 1421 (yyval.re) = NULL;
1465 ;} 1422 ;}
1466 break; 1423 break;
1467 1424
1468 case 4: 1425 case 4:
1469#line 101 "dtc-parser.y" 1426
1427/* Line 1455 of yacc.c */
1428#line 99 "dtc-parser.y"
1470 { 1429 {
1471 (yyval.re) = NULL; 1430 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1472 ;} 1431 ;}
1473 break; 1432 break;
1474 1433
1475 case 5: 1434 case 5:
1476#line 105 "dtc-parser.y" 1435
1436/* Line 1455 of yacc.c */
1437#line 106 "dtc-parser.y"
1477 { 1438 {
1478 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1439 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr));
1479 ;} 1440 ;}
1480 break; 1441 break;
1481 1442
1482 case 6: 1443 case 6:
1483#line 112 "dtc-parser.y" 1444
1445/* Line 1455 of yacc.c */
1446#line 110 "dtc-parser.y"
1484 { 1447 {
1485 (yyval.re) = build_reserve_entry((yyvsp[(3) - (5)].addr), (yyvsp[(4) - (5)].addr), (yyvsp[(1) - (5)].labelref)); 1448 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
1449 (yyval.re) = (yyvsp[(2) - (2)].re);
1486 ;} 1450 ;}
1487 break; 1451 break;
1488 1452
1489 case 7: 1453 case 7:
1490#line 119 "dtc-parser.y" 1454
1455/* Line 1455 of yacc.c */
1456#line 118 "dtc-parser.y"
1491 { 1457 {
1492 (yyval.re) = NULL; 1458 (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
1493 ;} 1459 ;}
1494 break; 1460 break;
1495 1461
1496 case 8: 1462 case 8:
1497#line 123 "dtc-parser.y" 1463
1464/* Line 1455 of yacc.c */
1465#line 125 "dtc-parser.y"
1498 { 1466 {
1499 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1467 (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
1500 ;} 1468 ;}
1501 break; 1469 break;
1502 1470
1503 case 9: 1471 case 9:
1504#line 130 "dtc-parser.y" 1472
1473/* Line 1455 of yacc.c */
1474#line 129 "dtc-parser.y"
1505 { 1475 {
1506 (yyval.re) = (yyvsp[(1) - (1)].re); 1476 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
1507 ;} 1477 ;}
1508 break; 1478 break;
1509 1479
1510 case 10: 1480 case 10:
1511#line 134 "dtc-parser.y" 1481
1482/* Line 1455 of yacc.c */
1483#line 133 "dtc-parser.y"
1512 { 1484 {
1513 (yyval.re) = build_reserve_entry((yyvsp[(3) - (6)].addr), (yyvsp[(5) - (6)].addr) - (yyvsp[(3) - (6)].addr) + 1, (yyvsp[(1) - (6)].labelref)); 1485 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
1486
1487 if (target)
1488 merge_nodes(target, (yyvsp[(3) - (3)].node));
1489 else
1490 print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref));
1491 (yyval.node) = (yyvsp[(1) - (3)].node);
1514 ;} 1492 ;}
1515 break; 1493 break;
1516 1494
1517 case 11: 1495 case 11:
1518#line 141 "dtc-parser.y" 1496
1497/* Line 1455 of yacc.c */
1498#line 146 "dtc-parser.y"
1519 { 1499 {
1520 (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); 1500 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
1521 ;} 1501 ;}
1522 break; 1502 break;
1523 1503
1524 case 12: 1504 case 12:
1525#line 145 "dtc-parser.y" 1505
1506/* Line 1455 of yacc.c */
1507#line 153 "dtc-parser.y"
1526 { 1508 {
1527 (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 16, 64); 1509 (yyval.proplist) = NULL;
1528 ;} 1510 ;}
1529 break; 1511 break;
1530 1512
1531 case 13: 1513 case 13:
1532#line 152 "dtc-parser.y" 1514
1515/* Line 1455 of yacc.c */
1516#line 157 "dtc-parser.y"
1533 { 1517 {
1534 (yyval.node) = name_node((yyvsp[(2) - (2)].node), "", NULL); 1518 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
1535 ;} 1519 ;}
1536 break; 1520 break;
1537 1521
1538 case 14: 1522 case 14:
1539#line 159 "dtc-parser.y" 1523
1524/* Line 1455 of yacc.c */
1525#line 164 "dtc-parser.y"
1540 { 1526 {
1541 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); 1527 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
1542 ;} 1528 ;}
1543 break; 1529 break;
1544 1530
1545 case 15: 1531 case 15:
1546#line 166 "dtc-parser.y" 1532
1533/* Line 1455 of yacc.c */
1534#line 168 "dtc-parser.y"
1547 { 1535 {
1548 (yyval.proplist) = NULL; 1536 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
1549 ;} 1537 ;}
1550 break; 1538 break;
1551 1539
1552 case 16: 1540 case 16:
1553#line 170 "dtc-parser.y" 1541
1542/* Line 1455 of yacc.c */
1543#line 172 "dtc-parser.y"
1554 { 1544 {
1555 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); 1545 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
1546 (yyval.prop) = (yyvsp[(2) - (2)].prop);
1556 ;} 1547 ;}
1557 break; 1548 break;
1558 1549
1559 case 17: 1550 case 17:
1560#line 177 "dtc-parser.y" 1551
1552/* Line 1455 of yacc.c */
1553#line 180 "dtc-parser.y"
1561 { 1554 {
1562 (yyval.prop) = build_property((yyvsp[(2) - (5)].propnodename), (yyvsp[(4) - (5)].data), (yyvsp[(1) - (5)].labelref)); 1555 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
1563 ;} 1556 ;}
1564 break; 1557 break;
1565 1558
1566 case 18: 1559 case 18:
1567#line 181 "dtc-parser.y" 1560
1561/* Line 1455 of yacc.c */
1562#line 184 "dtc-parser.y"
1568 { 1563 {
1569 (yyval.prop) = build_property((yyvsp[(2) - (3)].propnodename), empty_data, (yyvsp[(1) - (3)].labelref)); 1564 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1570 ;} 1565 ;}
1571 break; 1566 break;
1572 1567
1573 case 19: 1568 case 19:
1569
1570/* Line 1455 of yacc.c */
1574#line 188 "dtc-parser.y" 1571#line 188 "dtc-parser.y"
1575 { 1572 {
1576 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); 1573 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1577 ;} 1574 ;}
1578 break; 1575 break;
1579 1576
1580 case 20: 1577 case 20:
1578
1579/* Line 1455 of yacc.c */
1581#line 192 "dtc-parser.y" 1580#line 192 "dtc-parser.y"
1582 { 1581 {
1583 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1582 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1584 ;} 1583 ;}
1585 break; 1584 break;
1586 1585
1587 case 21: 1586 case 21:
1588#line 196 "dtc-parser.y"
1589 {
1590 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1591 ;}
1592 break;
1593
1594 case 22:
1595#line 200 "dtc-parser.y"
1596 {
1597 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1598 ;}
1599 break;
1600 1587
1601 case 23: 1588/* Line 1455 of yacc.c */
1602#line 204 "dtc-parser.y" 1589#line 196 "dtc-parser.y"
1603 { 1590 {
1604 struct search_path path = { srcpos_file->dir, NULL, NULL }; 1591 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
1605 struct dtc_file *file = dtc_open_file((yyvsp[(4) - (9)].data).val, &path); 1592 struct data d;
1606 struct data d = empty_data;
1607 1593
1608 if ((yyvsp[(6) - (9)].addr) != 0) 1594 if ((yyvsp[(6) - (9)].addr) != 0)
1609 if (fseek(file->file, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0) 1595 if (fseek(f, (yyvsp[(6) - (9)].addr), SEEK_SET) != 0)
1610 yyerrorf("Couldn't seek to offset %llu in \"%s\": %s", 1596 print_error("Couldn't seek to offset %llu in \"%s\": %s",
1611 (unsigned long long)(yyvsp[(6) - (9)].addr), 1597 (unsigned long long)(yyvsp[(6) - (9)].addr),
1612 (yyvsp[(4) - (9)].data).val, strerror(errno)); 1598 (yyvsp[(4) - (9)].data).val,
1599 strerror(errno));
1613 1600
1614 d = data_copy_file(file->file, (yyvsp[(8) - (9)].addr)); 1601 d = data_copy_file(f, (yyvsp[(8) - (9)].addr));
1615 1602
1616 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); 1603 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d);
1617 dtc_close_file(file); 1604 fclose(f);
1618 ;} 1605 ;}
1619 break; 1606 break;
1620 1607
1621 case 24: 1608 case 22:
1622#line 221 "dtc-parser.y" 1609
1610/* Line 1455 of yacc.c */
1611#line 213 "dtc-parser.y"
1623 { 1612 {
1624 struct search_path path = { srcpos_file->dir, NULL, NULL }; 1613 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
1625 struct dtc_file *file = dtc_open_file((yyvsp[(4) - (5)].data).val, &path);
1626 struct data d = empty_data; 1614 struct data d = empty_data;
1627 1615
1628 d = data_copy_file(file->file, -1); 1616 d = data_copy_file(f, -1);
1629 1617
1630 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); 1618 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d);
1631 dtc_close_file(file); 1619 fclose(f);
1632 ;} 1620 ;}
1633 break; 1621 break;
1634 1622
1635 case 25: 1623 case 23:
1636#line 232 "dtc-parser.y" 1624
1625/* Line 1455 of yacc.c */
1626#line 223 "dtc-parser.y"
1637 { 1627 {
1638 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1628 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1639 ;} 1629 ;}
1640 break; 1630 break;
1641 1631
1642 case 26: 1632 case 24:
1643#line 239 "dtc-parser.y" 1633
1634/* Line 1455 of yacc.c */
1635#line 230 "dtc-parser.y"
1644 { 1636 {
1645 (yyval.data) = empty_data; 1637 (yyval.data) = empty_data;
1646 ;} 1638 ;}
1647 break; 1639 break;
1648 1640
1649 case 27: 1641 case 25:
1650#line 243 "dtc-parser.y" 1642
1643/* Line 1455 of yacc.c */
1644#line 234 "dtc-parser.y"
1651 { 1645 {
1652 (yyval.data) = (yyvsp[(1) - (2)].data); 1646 (yyval.data) = (yyvsp[(1) - (2)].data);
1653 ;} 1647 ;}
1654 break; 1648 break;
1655 1649
1656 case 28: 1650 case 26:
1657#line 247 "dtc-parser.y" 1651
1652/* Line 1455 of yacc.c */
1653#line 238 "dtc-parser.y"
1658 { 1654 {
1659 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1655 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1660 ;} 1656 ;}
1661 break; 1657 break;
1662 1658
1663 case 29: 1659 case 27:
1664#line 254 "dtc-parser.y" 1660
1661/* Line 1455 of yacc.c */
1662#line 245 "dtc-parser.y"
1665 { 1663 {
1666 (yyval.data) = empty_data; 1664 (yyval.data) = empty_data;
1667 ;} 1665 ;}
1668 break; 1666 break;
1669 1667
1670 case 30: 1668 case 28:
1671#line 258 "dtc-parser.y" 1669
1670/* Line 1455 of yacc.c */
1671#line 249 "dtc-parser.y"
1672 { 1672 {
1673 (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell)); 1673 (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell));
1674 ;} 1674 ;}
1675 break; 1675 break;
1676 1676
1677 case 31: 1677 case 29:
1678#line 262 "dtc-parser.y" 1678
1679/* Line 1455 of yacc.c */
1680#line 253 "dtc-parser.y"
1679 { 1681 {
1680 (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE, 1682 (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE,
1681 (yyvsp[(2) - (2)].labelref)), -1); 1683 (yyvsp[(2) - (2)].labelref)), -1);
1682 ;} 1684 ;}
1683 break; 1685 break;
1684 1686
1685 case 32: 1687 case 30:
1686#line 267 "dtc-parser.y" 1688
1689/* Line 1455 of yacc.c */
1690#line 258 "dtc-parser.y"
1687 { 1691 {
1688 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1692 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1689 ;} 1693 ;}
1690 break; 1694 break;
1691 1695
1692 case 33: 1696 case 31:
1693#line 274 "dtc-parser.y"
1694 {
1695 (yyval.cbase) = 16;
1696 ;}
1697 break;
1698 1697
1699 case 35: 1698/* Line 1455 of yacc.c */
1700#line 282 "dtc-parser.y" 1699#line 265 "dtc-parser.y"
1701 { 1700 {
1702 (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32); 1701 (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32);
1703 ;} 1702 ;}
1704 break; 1703 break;
1705 1704
1706 case 36: 1705 case 32:
1707#line 286 "dtc-parser.y"
1708 {
1709 (yyval.cell) = eval_literal((yyvsp[(2) - (2)].literal), (yyvsp[(1) - (2)].cbase), 32);
1710 ;}
1711 break;
1712 1706
1713 case 37: 1707/* Line 1455 of yacc.c */
1714#line 293 "dtc-parser.y" 1708#line 272 "dtc-parser.y"
1715 { 1709 {
1716 (yyval.data) = empty_data; 1710 (yyval.data) = empty_data;
1717 ;} 1711 ;}
1718 break; 1712 break;
1719 1713
1720 case 38: 1714 case 33:
1721#line 297 "dtc-parser.y" 1715
1716/* Line 1455 of yacc.c */
1717#line 276 "dtc-parser.y"
1722 { 1718 {
1723 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); 1719 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
1724 ;} 1720 ;}
1725 break; 1721 break;
1726 1722
1727 case 39: 1723 case 34:
1728#line 301 "dtc-parser.y" 1724
1725/* Line 1455 of yacc.c */
1726#line 280 "dtc-parser.y"
1729 { 1727 {
1730 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1728 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1731 ;} 1729 ;}
1732 break; 1730 break;
1733 1731
1734 case 40: 1732 case 35:
1735#line 308 "dtc-parser.y" 1733
1734/* Line 1455 of yacc.c */
1735#line 287 "dtc-parser.y"
1736 { 1736 {
1737 (yyval.nodelist) = NULL; 1737 (yyval.nodelist) = NULL;
1738 ;} 1738 ;}
1739 break; 1739 break;
1740 1740
1741 case 41: 1741 case 36:
1742#line 312 "dtc-parser.y" 1742
1743/* Line 1455 of yacc.c */
1744#line 291 "dtc-parser.y"
1743 { 1745 {
1744 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); 1746 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
1745 ;} 1747 ;}
1746 break; 1748 break;
1747 1749
1748 case 42: 1750 case 37:
1749#line 316 "dtc-parser.y" 1751
1752/* Line 1455 of yacc.c */
1753#line 295 "dtc-parser.y"
1750 { 1754 {
1751 yyerror("syntax error: properties must precede subnodes"); 1755 print_error("syntax error: properties must precede subnodes");
1752 YYERROR; 1756 YYERROR;
1753 ;} 1757 ;}
1754 break; 1758 break;
1755 1759
1756 case 43: 1760 case 38:
1757#line 324 "dtc-parser.y"
1758 {
1759 (yyval.node) = name_node((yyvsp[(3) - (3)].node), (yyvsp[(2) - (3)].propnodename), (yyvsp[(1) - (3)].labelref));
1760 ;}
1761 break;
1762 1761
1763 case 44: 1762/* Line 1455 of yacc.c */
1764#line 331 "dtc-parser.y" 1763#line 303 "dtc-parser.y"
1765 { 1764 {
1766 (yyval.labelref) = NULL; 1765 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
1767 ;} 1766 ;}
1768 break; 1767 break;
1769 1768
1770 case 45: 1769 case 39:
1771#line 335 "dtc-parser.y" 1770
1771/* Line 1455 of yacc.c */
1772#line 307 "dtc-parser.y"
1772 { 1773 {
1773 (yyval.labelref) = (yyvsp[(1) - (1)].labelref); 1774 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
1775 (yyval.node) = (yyvsp[(2) - (2)].node);
1774 ;} 1776 ;}
1775 break; 1777 break;
1776 1778
1777 1779
1778/* Line 1267 of yacc.c. */ 1780
1779#line 1780 "dtc-parser.tab.c" 1781/* Line 1455 of yacc.c */
1782#line 1783 "dtc-parser.tab.c"
1780 default: break; 1783 default: break;
1781 } 1784 }
1782 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 1785 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1786,7 +1789,6 @@ yyreduce:
1786 YY_STACK_PRINT (yyss, yyssp); 1789 YY_STACK_PRINT (yyss, yyssp);
1787 1790
1788 *++yyvsp = yyval; 1791 *++yyvsp = yyval;
1789 *++yylsp = yyloc;
1790 1792
1791 /* Now `shift' the result of the reduction. Determine what state 1793 /* Now `shift' the result of the reduction. Determine what state
1792 that goes to, based on the state we popped back to and the rule 1794 that goes to, based on the state we popped back to and the rule
@@ -1848,11 +1850,11 @@ yyerrlab:
1848#endif 1850#endif
1849 } 1851 }
1850 1852
1851 yyerror_range[0] = yylloc; 1853
1852 1854
1853 if (yyerrstatus == 3) 1855 if (yyerrstatus == 3)
1854 { 1856 {
1855 /* If just tried and failed to reuse look-ahead token after an 1857 /* If just tried and failed to reuse lookahead token after an
1856 error, discard it. */ 1858 error, discard it. */
1857 1859
1858 if (yychar <= YYEOF) 1860 if (yychar <= YYEOF)
@@ -1864,12 +1866,12 @@ yyerrlab:
1864 else 1866 else
1865 { 1867 {
1866 yydestruct ("Error: discarding", 1868 yydestruct ("Error: discarding",
1867 yytoken, &yylval, &yylloc); 1869 yytoken, &yylval);
1868 yychar = YYEMPTY; 1870 yychar = YYEMPTY;
1869 } 1871 }
1870 } 1872 }
1871 1873
1872 /* Else will try to reuse look-ahead token after shifting the error 1874 /* Else will try to reuse lookahead token after shifting the error
1873 token. */ 1875 token. */
1874 goto yyerrlab1; 1876 goto yyerrlab1;
1875 1877
@@ -1885,7 +1887,6 @@ yyerrorlab:
1885 if (/*CONSTCOND*/ 0) 1887 if (/*CONSTCOND*/ 0)
1886 goto yyerrorlab; 1888 goto yyerrorlab;
1887 1889
1888 yyerror_range[0] = yylsp[1-yylen];
1889 /* Do not reclaim the symbols of the rule which action triggered 1890 /* Do not reclaim the symbols of the rule which action triggered
1890 this YYERROR. */ 1891 this YYERROR. */
1891 YYPOPSTACK (yylen); 1892 YYPOPSTACK (yylen);
@@ -1919,24 +1920,16 @@ yyerrlab1:
1919 if (yyssp == yyss) 1920 if (yyssp == yyss)
1920 YYABORT; 1921 YYABORT;
1921 1922
1922 yyerror_range[0] = *yylsp; 1923
1923 yydestruct ("Error: popping", 1924 yydestruct ("Error: popping",
1924 yystos[yystate], yyvsp, yylsp); 1925 yystos[yystate], yyvsp);
1925 YYPOPSTACK (1); 1926 YYPOPSTACK (1);
1926 yystate = *yyssp; 1927 yystate = *yyssp;
1927 YY_STACK_PRINT (yyss, yyssp); 1928 YY_STACK_PRINT (yyss, yyssp);
1928 } 1929 }
1929 1930
1930 if (yyn == YYFINAL)
1931 YYACCEPT;
1932
1933 *++yyvsp = yylval; 1931 *++yyvsp = yylval;
1934 1932
1935 yyerror_range[1] = yylloc;
1936 /* Using YYLLOC is tempting, but would change the location of
1937 the look-ahead. YYLOC is available though. */
1938 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
1939 *++yylsp = yyloc;
1940 1933
1941 /* Shift the error token. */ 1934 /* Shift the error token. */
1942 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 1935 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
@@ -1959,7 +1952,7 @@ yyabortlab:
1959 yyresult = 1; 1952 yyresult = 1;
1960 goto yyreturn; 1953 goto yyreturn;
1961 1954
1962#ifndef yyoverflow 1955#if !defined(yyoverflow) || YYERROR_VERBOSE
1963/*-------------------------------------------------. 1956/*-------------------------------------------------.
1964| yyexhaustedlab -- memory exhaustion comes here. | 1957| yyexhaustedlab -- memory exhaustion comes here. |
1965`-------------------------------------------------*/ 1958`-------------------------------------------------*/
@@ -1970,9 +1963,9 @@ yyexhaustedlab:
1970#endif 1963#endif
1971 1964
1972yyreturn: 1965yyreturn:
1973 if (yychar != YYEOF && yychar != YYEMPTY) 1966 if (yychar != YYEMPTY)
1974 yydestruct ("Cleanup: discarding lookahead", 1967 yydestruct ("Cleanup: discarding lookahead",
1975 yytoken, &yylval, &yylloc); 1968 yytoken, &yylval);
1976 /* Do not reclaim the symbols of the rule which action triggered 1969 /* Do not reclaim the symbols of the rule which action triggered
1977 this YYABORT or YYACCEPT. */ 1970 this YYABORT or YYACCEPT. */
1978 YYPOPSTACK (yylen); 1971 YYPOPSTACK (yylen);
@@ -1980,7 +1973,7 @@ yyreturn:
1980 while (yyssp != yyss) 1973 while (yyssp != yyss)
1981 { 1974 {
1982 yydestruct ("Cleanup: popping", 1975 yydestruct ("Cleanup: popping",
1983 yystos[*yyssp], yyvsp, yylsp); 1976 yystos[*yyssp], yyvsp);
1984 YYPOPSTACK (1); 1977 YYPOPSTACK (1);
1985 } 1978 }
1986#ifndef yyoverflow 1979#ifndef yyoverflow
@@ -1996,29 +1989,24 @@ yyreturn:
1996} 1989}
1997 1990
1998 1991
1999#line 340 "dtc-parser.y" 1992
1993/* Line 1675 of yacc.c */
1994#line 313 "dtc-parser.y"
2000 1995
2001 1996
2002void yyerrorf(char const *s, ...) 1997void print_error(char const *fmt, ...)
2003{ 1998{
2004 const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
2005 va_list va; 1999 va_list va;
2006 va_start(va, s);
2007
2008 if (strcmp(fname, "-") == 0)
2009 fname = "stdin";
2010 2000
2011 fprintf(stderr, "%s:%d ", fname, yylloc.first_line); 2001 va_start(va, fmt);
2012 vfprintf(stderr, s, va); 2002 srcpos_verror(&yylloc, fmt, va);
2013 fprintf(stderr, "\n"); 2003 va_end(va);
2014 2004
2015 treesource_error = 1; 2005 treesource_error = 1;
2016 va_end(va);
2017} 2006}
2018 2007
2019void yyerror (char const *s) 2008void yyerror(char const *s) {
2020{ 2009 print_error("%s", s);
2021 yyerrorf("%s", s);
2022} 2010}
2023 2011
2024static unsigned long long eval_literal(const char *s, int base, int bits) 2012static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -2029,12 +2017,12 @@ static unsigned long long eval_literal(const char *s, int base, int bits)
2029 errno = 0; 2017 errno = 0;
2030 val = strtoull(s, &e, base); 2018 val = strtoull(s, &e, base);
2031 if (*e) 2019 if (*e)
2032 yyerror("bad characters in literal"); 2020 print_error("bad characters in literal");
2033 else if ((errno == ERANGE) 2021 else if ((errno == ERANGE)
2034 || ((bits < 64) && (val >= (1ULL << bits)))) 2022 || ((bits < 64) && (val >= (1ULL << bits))))
2035 yyerror("literal out of range"); 2023 print_error("literal out of range");
2036 else if (errno != 0) 2024 else if (errno != 0)
2037 yyerror("bad literal"); 2025 print_error("bad literal");
2038 return val; 2026 return val;
2039} 2027}
2040 2028
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped
index ba99100d55c9..95c9547adea5 100644
--- a/scripts/dtc/dtc-parser.tab.h_shipped
+++ b/scripts/dtc/dtc-parser.tab.h_shipped
@@ -1,24 +1,23 @@
1/* A Bison parser, made by GNU Bison 2.3. */
2 1
3/* Skeleton interface for Bison's Yacc-like parsers in C 2/* A Bison parser, made by GNU Bison 2.4.1. */
4 3
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 4/* Skeleton interface for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc. 7 Free Software Foundation, Inc.
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation, either version 3 of the License, or
11 any later version. 12 (at your option) any later version.
12 13
13 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 17 GNU General Public License for more details.
17 18
18 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22 21
23/* As a special exception, you may create a larger work that contains 22/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work 23 part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
29 special exception, which will cause the skeleton and the resulting 28 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public 29 Bison output files to be licensed under the GNU General Public
31 License without this special exception. 30 License without this special exception.
32 31
33 This special exception was added by the Free Software Foundation in 32 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */ 33 version 2.2 of Bison. */
35 34
35
36/* Tokens. */ 36/* Tokens. */
37#ifndef YYTOKENTYPE 37#ifndef YYTOKENTYPE
38# define YYTOKENTYPE 38# define YYTOKENTYPE
@@ -43,35 +43,24 @@
43 DT_MEMRESERVE = 259, 43 DT_MEMRESERVE = 259,
44 DT_PROPNODENAME = 260, 44 DT_PROPNODENAME = 260,
45 DT_LITERAL = 261, 45 DT_LITERAL = 261,
46 DT_LEGACYLITERAL = 262, 46 DT_BASE = 262,
47 DT_BASE = 263, 47 DT_BYTE = 263,
48 DT_BYTE = 264, 48 DT_STRING = 264,
49 DT_STRING = 265, 49 DT_LABEL = 265,
50 DT_LABEL = 266, 50 DT_REF = 266,
51 DT_REF = 267, 51 DT_INCBIN = 267
52 DT_INCBIN = 268
53 }; 52 };
54#endif 53#endif
55/* Tokens. */
56#define DT_V1 258
57#define DT_MEMRESERVE 259
58#define DT_PROPNODENAME 260
59#define DT_LITERAL 261
60#define DT_LEGACYLITERAL 262
61#define DT_BASE 263
62#define DT_BYTE 264
63#define DT_STRING 265
64#define DT_LABEL 266
65#define DT_REF 267
66#define DT_INCBIN 268
67
68 54
69 55
70 56
71#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 57#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
72typedef union YYSTYPE 58typedef union YYSTYPE
73#line 37 "dtc-parser.y"
74{ 59{
60
61/* Line 1676 of yacc.c */
62#line 39 "dtc-parser.y"
63
75 char *propnodename; 64 char *propnodename;
76 char *literal; 65 char *literal;
77 char *labelref; 66 char *labelref;
@@ -86,28 +75,17 @@ typedef union YYSTYPE
86 struct node *node; 75 struct node *node;
87 struct node *nodelist; 76 struct node *nodelist;
88 struct reserve_info *re; 77 struct reserve_info *re;
89} 78
90/* Line 1489 of yacc.c. */ 79
91#line 92 "dtc-parser.tab.h" 80
92 YYSTYPE; 81/* Line 1676 of yacc.c */
82#line 83 "dtc-parser.tab.h"
83} YYSTYPE;
84# define YYSTYPE_IS_TRIVIAL 1
93# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 85# define yystype YYSTYPE /* obsolescent; will be withdrawn */
94# define YYSTYPE_IS_DECLARED 1 86# define YYSTYPE_IS_DECLARED 1
95# define YYSTYPE_IS_TRIVIAL 1
96#endif 87#endif
97 88
98extern YYSTYPE yylval; 89extern YYSTYPE yylval;
99 90
100#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
101typedef struct YYLTYPE
102{
103 int first_line;
104 int first_column;
105 int last_line;
106 int last_column;
107} YYLTYPE;
108# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
109# define YYLTYPE_IS_DECLARED 1
110# define YYLTYPE_IS_TRIVIAL 1
111#endif
112 91
113extern YYLTYPE yylloc;
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index b2ab562420ea..5e84a67fc1d2 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -18,15 +18,17 @@
18 * USA 18 * USA
19 */ 19 */
20 20
21%locations
22
23%{ 21%{
24#include <stdio.h> 22#include <stdio.h>
25 23
26#include "dtc.h" 24#include "dtc.h"
27#include "srcpos.h" 25#include "srcpos.h"
28 26
27YYLTYPE yylloc;
28
29extern int yylex(void); 29extern int yylex(void);
30extern void print_error(char const *fmt, ...);
31extern void yyerror(char const *s);
30 32
31extern struct boot_info *the_boot_info; 33extern struct boot_info *the_boot_info;
32extern int treesource_error; 34extern int treesource_error;
@@ -55,7 +57,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
55%token DT_MEMRESERVE 57%token DT_MEMRESERVE
56%token <propnodename> DT_PROPNODENAME 58%token <propnodename> DT_PROPNODENAME
57%token <literal> DT_LITERAL 59%token <literal> DT_LITERAL
58%token <literal> DT_LEGACYLITERAL
59%token <cbase> DT_BASE 60%token <cbase> DT_BASE
60%token <byte> DT_BYTE 61%token <byte> DT_BYTE
61%token <data> DT_STRING 62%token <data> DT_STRING
@@ -67,11 +68,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
67%type <data> propdataprefix 68%type <data> propdataprefix
68%type <re> memreserve 69%type <re> memreserve
69%type <re> memreserves 70%type <re> memreserves
70%type <re> v0_memreserve
71%type <re> v0_memreserves
72%type <addr> addr 71%type <addr> addr
73%type <data> celllist 72%type <data> celllist
74%type <cbase> cellbase
75%type <cell> cellval 73%type <cell> cellval
76%type <data> bytestring 74%type <data> bytestring
77%type <prop> propdef 75%type <prop> propdef
@@ -81,18 +79,14 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
81%type <node> nodedef 79%type <node> nodedef
82%type <node> subnode 80%type <node> subnode
83%type <nodelist> subnodes 81%type <nodelist> subnodes
84%type <labelref> label
85 82
86%% 83%%
87 84
88sourcefile: 85sourcefile:
89 DT_V1 ';' memreserves devicetree 86 DT_V1 ';' memreserves devicetree
90 { 87 {
91 the_boot_info = build_boot_info($3, $4, 0); 88 the_boot_info = build_boot_info($3, $4,
92 } 89 guess_boot_cpuid($4));
93 | v0_memreserves devicetree
94 {
95 the_boot_info = build_boot_info($1, $2, 0);
96 } 90 }
97 ; 91 ;
98 92
@@ -108,31 +102,14 @@ memreserves:
108 ; 102 ;
109 103
110memreserve: 104memreserve:
111 label DT_MEMRESERVE addr addr ';' 105 DT_MEMRESERVE addr addr ';'
112 { 106 {
113 $$ = build_reserve_entry($3, $4, $1); 107 $$ = build_reserve_entry($2, $3);
114 } 108 }
115 ; 109 | DT_LABEL memreserve
116
117v0_memreserves:
118 /* empty */
119 { 110 {
120 $$ = NULL; 111 add_label(&$2->labels, $1);
121 } 112 $$ = $2;
122 | v0_memreserve v0_memreserves
123 {
124 $$ = chain_reserve_entry($1, $2);
125 };
126 ;
127
128v0_memreserve:
129 memreserve
130 {
131 $$ = $1;
132 }
133 | label DT_MEMRESERVE addr '-' addr ';'
134 {
135 $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
136 } 113 }
137 ; 114 ;
138 115
@@ -141,16 +118,26 @@ addr:
141 { 118 {
142 $$ = eval_literal($1, 0, 64); 119 $$ = eval_literal($1, 0, 64);
143 } 120 }
144 | DT_LEGACYLITERAL
145 {
146 $$ = eval_literal($1, 16, 64);
147 }
148 ; 121 ;
149 122
150devicetree: 123devicetree:
151 '/' nodedef 124 '/' nodedef
152 { 125 {
153 $$ = name_node($2, "", NULL); 126 $$ = name_node($2, "");
127 }
128 | devicetree '/' nodedef
129 {
130 $$ = merge_nodes($1, $3);
131 }
132 | devicetree DT_REF nodedef
133 {
134 struct node *target = get_node_by_ref($1, $2);
135
136 if (target)
137 merge_nodes(target, $3);
138 else
139 print_error("label or path, '%s', not found", $2);
140 $$ = $1;
154 } 141 }
155 ; 142 ;
156 143
@@ -173,13 +160,18 @@ proplist:
173 ; 160 ;
174 161
175propdef: 162propdef:
176 label DT_PROPNODENAME '=' propdata ';' 163 DT_PROPNODENAME '=' propdata ';'
164 {
165 $$ = build_property($1, $3);
166 }
167 | DT_PROPNODENAME ';'
177 { 168 {
178 $$ = build_property($2, $4, $1); 169 $$ = build_property($1, empty_data);
179 } 170 }
180 | label DT_PROPNODENAME ';' 171 | DT_LABEL propdef
181 { 172 {
182 $$ = build_property($2, empty_data, $1); 173 add_label(&$2->labels, $1);
174 $$ = $2;
183 } 175 }
184 ; 176 ;
185 177
@@ -202,31 +194,30 @@ propdata:
202 } 194 }
203 | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')' 195 | propdataprefix DT_INCBIN '(' DT_STRING ',' addr ',' addr ')'
204 { 196 {
205 struct search_path path = { srcpos_file->dir, NULL, NULL }; 197 FILE *f = srcfile_relative_open($4.val, NULL);
206 struct dtc_file *file = dtc_open_file($4.val, &path); 198 struct data d;
207 struct data d = empty_data;
208 199
209 if ($6 != 0) 200 if ($6 != 0)
210 if (fseek(file->file, $6, SEEK_SET) != 0) 201 if (fseek(f, $6, SEEK_SET) != 0)
211 yyerrorf("Couldn't seek to offset %llu in \"%s\": %s", 202 print_error("Couldn't seek to offset %llu in \"%s\": %s",
212 (unsigned long long)$6, 203 (unsigned long long)$6,
213 $4.val, strerror(errno)); 204 $4.val,
205 strerror(errno));
214 206
215 d = data_copy_file(file->file, $8); 207 d = data_copy_file(f, $8);
216 208
217 $$ = data_merge($1, d); 209 $$ = data_merge($1, d);
218 dtc_close_file(file); 210 fclose(f);
219 } 211 }
220 | propdataprefix DT_INCBIN '(' DT_STRING ')' 212 | propdataprefix DT_INCBIN '(' DT_STRING ')'
221 { 213 {
222 struct search_path path = { srcpos_file->dir, NULL, NULL }; 214 FILE *f = srcfile_relative_open($4.val, NULL);
223 struct dtc_file *file = dtc_open_file($4.val, &path);
224 struct data d = empty_data; 215 struct data d = empty_data;
225 216
226 d = data_copy_file(file->file, -1); 217 d = data_copy_file(f, -1);
227 218
228 $$ = data_merge($1, d); 219 $$ = data_merge($1, d);
229 dtc_close_file(file); 220 fclose(f);
230 } 221 }
231 | propdata DT_LABEL 222 | propdata DT_LABEL
232 { 223 {
@@ -269,23 +260,11 @@ celllist:
269 } 260 }
270 ; 261 ;
271 262
272cellbase:
273 /* empty */
274 {
275 $$ = 16;
276 }
277 | DT_BASE
278 ;
279
280cellval: 263cellval:
281 DT_LITERAL 264 DT_LITERAL
282 { 265 {
283 $$ = eval_literal($1, 0, 32); 266 $$ = eval_literal($1, 0, 32);
284 } 267 }
285 | cellbase DT_LEGACYLITERAL
286 {
287 $$ = eval_literal($2, $1, 32);
288 }
289 ; 268 ;
290 269
291bytestring: 270bytestring:
@@ -308,57 +287,44 @@ subnodes:
308 { 287 {
309 $$ = NULL; 288 $$ = NULL;
310 } 289 }
311 | subnode subnodes 290 | subnode subnodes
312 { 291 {
313 $$ = chain_node($1, $2); 292 $$ = chain_node($1, $2);
314 } 293 }
315 | subnode propdef 294 | subnode propdef
316 { 295 {
317 yyerror("syntax error: properties must precede subnodes"); 296 print_error("syntax error: properties must precede subnodes");
318 YYERROR; 297 YYERROR;
319 } 298 }
320 ; 299 ;
321 300
322subnode: 301subnode:
323 label DT_PROPNODENAME nodedef 302 DT_PROPNODENAME nodedef
324 { 303 {
325 $$ = name_node($3, $2, $1); 304 $$ = name_node($2, $1);
326 } 305 }
327 ; 306 | DT_LABEL subnode
328
329label:
330 /* empty */
331 { 307 {
332 $$ = NULL; 308 add_label(&$2->labels, $1);
333 } 309 $$ = $2;
334 | DT_LABEL
335 {
336 $$ = $1;
337 } 310 }
338 ; 311 ;
339 312
340%% 313%%
341 314
342void yyerrorf(char const *s, ...) 315void print_error(char const *fmt, ...)
343{ 316{
344 const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
345 va_list va; 317 va_list va;
346 va_start(va, s);
347
348 if (strcmp(fname, "-") == 0)
349 fname = "stdin";
350 318
351 fprintf(stderr, "%s:%d ", fname, yylloc.first_line); 319 va_start(va, fmt);
352 vfprintf(stderr, s, va); 320 srcpos_verror(&yylloc, fmt, va);
353 fprintf(stderr, "\n"); 321 va_end(va);
354 322
355 treesource_error = 1; 323 treesource_error = 1;
356 va_end(va);
357} 324}
358 325
359void yyerror (char const *s) 326void yyerror(char const *s) {
360{ 327 print_error("%s", s);
361 yyerrorf("%s", s);
362} 328}
363 329
364static unsigned long long eval_literal(const char *s, int base, int bits) 330static unsigned long long eval_literal(const char *s, int base, int bits)
@@ -369,11 +335,11 @@ static unsigned long long eval_literal(const char *s, int base, int bits)
369 errno = 0; 335 errno = 0;
370 val = strtoull(s, &e, base); 336 val = strtoull(s, &e, base);
371 if (*e) 337 if (*e)
372 yyerror("bad characters in literal"); 338 print_error("bad characters in literal");
373 else if ((errno == ERANGE) 339 else if ((errno == ERANGE)
374 || ((bits < 64) && (val >= (1ULL << bits)))) 340 || ((bits < 64) && (val >= (1ULL << bits))))
375 yyerror("literal out of range"); 341 print_error("literal out of range");
376 else if (errno != 0) 342 else if (errno != 0)
377 yyerror("bad literal"); 343 print_error("bad literal");
378 return val; 344 return val;
379} 345}
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index d8fd43b4ac1a..cbc0193098e4 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -30,30 +30,7 @@ int quiet; /* Level of quietness */
30int reservenum; /* Number of memory reservation slots */ 30int reservenum; /* Number of memory reservation slots */
31int minsize; /* Minimum blob size */ 31int minsize; /* Minimum blob size */
32int padsize; /* Additional padding to blob */ 32int padsize; /* Additional padding to blob */
33 33int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
34char *join_path(const char *path, const char *name)
35{
36 int lenp = strlen(path);
37 int lenn = strlen(name);
38 int len;
39 int needslash = 1;
40 char *str;
41
42 len = lenp + lenn + 2;
43 if ((lenp > 0) && (path[lenp-1] == '/')) {
44 needslash = 0;
45 len--;
46 }
47
48 str = xmalloc(len);
49 memcpy(str, path, lenp);
50 if (needslash) {
51 str[lenp] = '/';
52 lenp++;
53 }
54 memcpy(str+lenp, name, lenn+1);
55 return str;
56}
57 34
58static void fill_fullpaths(struct node *tree, const char *prefix) 35static void fill_fullpaths(struct node *tree, const char *prefix)
59{ 36{
@@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void)
104 fprintf(stderr, "\t\tSet the physical boot cpu\n"); 81 fprintf(stderr, "\t\tSet the physical boot cpu\n");
105 fprintf(stderr, "\t-f\n"); 82 fprintf(stderr, "\t-f\n");
106 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); 83 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
84 fprintf(stderr, "\t-s\n");
85 fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
107 fprintf(stderr, "\t-v\n"); 86 fprintf(stderr, "\t-v\n");
108 fprintf(stderr, "\t\tPrint DTC version and exit\n"); 87 fprintf(stderr, "\t\tPrint DTC version and exit\n");
88 fprintf(stderr, "\t-H <phandle format>\n");
89 fprintf(stderr, "\t\tphandle formats are:\n");
90 fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
91 fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
92 fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
109 exit(3); 93 exit(3);
110} 94}
111 95
@@ -115,7 +99,7 @@ int main(int argc, char *argv[])
115 const char *inform = "dts"; 99 const char *inform = "dts";
116 const char *outform = "dts"; 100 const char *outform = "dts";
117 const char *outname = "-"; 101 const char *outname = "-";
118 int force = 0, check = 0; 102 int force = 0, check = 0, sort = 0;
119 const char *arg; 103 const char *arg;
120 int opt; 104 int opt;
121 FILE *outf = NULL; 105 FILE *outf = NULL;
@@ -127,7 +111,7 @@ int main(int argc, char *argv[])
127 minsize = 0; 111 minsize = 0;
128 padsize = 0; 112 padsize = 0;
129 113
130 while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) { 114 while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
131 switch (opt) { 115 switch (opt) {
132 case 'I': 116 case 'I':
133 inform = optarg; 117 inform = optarg;
@@ -165,6 +149,22 @@ int main(int argc, char *argv[])
165 case 'v': 149 case 'v':
166 printf("Version: %s\n", DTC_VERSION); 150 printf("Version: %s\n", DTC_VERSION);
167 exit(0); 151 exit(0);
152 case 'H':
153 if (streq(optarg, "legacy"))
154 phandle_format = PHANDLE_LEGACY;
155 else if (streq(optarg, "epapr"))
156 phandle_format = PHANDLE_EPAPR;
157 else if (streq(optarg, "both"))
158 phandle_format = PHANDLE_BOTH;
159 else
160 die("Invalid argument \"%s\" to -H option\n",
161 optarg);
162 break;
163
164 case 's':
165 sort = 1;
166 break;
167
168 case 'h': 168 case 'h':
169 default: 169 default:
170 usage(); 170 usage();
@@ -182,6 +182,9 @@ int main(int argc, char *argv[])
182 if (minsize && padsize) 182 if (minsize && padsize)
183 die("Can't set both -p and -S\n"); 183 die("Can't set both -p and -S\n");
184 184
185 if (minsize)
186 fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
187
185 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", 188 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
186 inform, outform, arg); 189 inform, outform, arg);
187 190
@@ -200,6 +203,8 @@ int main(int argc, char *argv[])
200 fill_fullpaths(bi->dt, ""); 203 fill_fullpaths(bi->dt, "");
201 process_checks(force, bi); 204 process_checks(force, bi);
202 205
206 if (sort)
207 sort_tree(bi);
203 208
204 if (streq(outname, "-")) { 209 if (streq(outname, "-")) {
205 outf = stdout; 210 outf = stdout;
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index 08d54c870086..f37c97eb3dfc 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -34,7 +34,17 @@
34#include <libfdt_env.h> 34#include <libfdt_env.h>
35#include <fdt.h> 35#include <fdt.h>
36 36
37#include "util.h"
38
39#ifdef DEBUG
40#define debug(fmt,args...) printf(fmt, ##args)
41#else
42#define debug(fmt,args...)
43#endif
44
45
37#define DEFAULT_FDT_VERSION 17 46#define DEFAULT_FDT_VERSION 17
47
38/* 48/*
39 * Command line options 49 * Command line options
40 */ 50 */
@@ -42,36 +52,11 @@ extern int quiet; /* Level of quietness */
42extern int reservenum; /* Number of memory reservation slots */ 52extern int reservenum; /* Number of memory reservation slots */
43extern int minsize; /* Minimum blob size */ 53extern int minsize; /* Minimum blob size */
44extern int padsize; /* Additional padding to blob */ 54extern int padsize; /* Additional padding to blob */
55extern int phandle_format; /* Use linux,phandle or phandle properties */
45 56
46static inline void __attribute__((noreturn)) die(char * str, ...) 57#define PHANDLE_LEGACY 0x1
47{ 58#define PHANDLE_EPAPR 0x2
48 va_list ap; 59#define PHANDLE_BOTH 0x3
49
50 va_start(ap, str);
51 fprintf(stderr, "FATAL ERROR: ");
52 vfprintf(stderr, str, ap);
53 exit(1);
54}
55
56static inline void *xmalloc(size_t len)
57{
58 void *new = malloc(len);
59
60 if (! new)
61 die("malloc() failed\n");
62
63 return new;
64}
65
66static inline void *xrealloc(void *p, size_t len)
67{
68 void *new = realloc(p, len);
69
70 if (! new)
71 die("realloc() failed (len=%d)\n", len);
72
73 return new;
74}
75 60
76typedef uint32_t cell_t; 61typedef uint32_t cell_t;
77 62
@@ -140,13 +125,18 @@ int data_is_one_string(struct data d);
140#define MAX_NODENAME_LEN 31 125#define MAX_NODENAME_LEN 31
141 126
142/* Live trees */ 127/* Live trees */
128struct label {
129 char *label;
130 struct label *next;
131};
132
143struct property { 133struct property {
144 char *name; 134 char *name;
145 struct data val; 135 struct data val;
146 136
147 struct property *next; 137 struct property *next;
148 138
149 char *label; 139 struct label *labels;
150}; 140};
151 141
152struct node { 142struct node {
@@ -163,22 +153,28 @@ struct node {
163 cell_t phandle; 153 cell_t phandle;
164 int addr_cells, size_cells; 154 int addr_cells, size_cells;
165 155
166 char *label; 156 struct label *labels;
167}; 157};
168 158
159#define for_each_label(l0, l) \
160 for ((l) = (l0); (l); (l) = (l)->next)
161
169#define for_each_property(n, p) \ 162#define for_each_property(n, p) \
170 for ((p) = (n)->proplist; (p); (p) = (p)->next) 163 for ((p) = (n)->proplist; (p); (p) = (p)->next)
171 164
172#define for_each_child(n, c) \ 165#define for_each_child(n, c) \
173 for ((c) = (n)->children; (c); (c) = (c)->next_sibling) 166 for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
174 167
175struct property *build_property(char *name, struct data val, char *label); 168void add_label(struct label **labels, char *label);
169
170struct property *build_property(char *name, struct data val);
176struct property *chain_property(struct property *first, struct property *list); 171struct property *chain_property(struct property *first, struct property *list);
177struct property *reverse_properties(struct property *first); 172struct property *reverse_properties(struct property *first);
178 173
179struct node *build_node(struct property *proplist, struct node *children); 174struct node *build_node(struct property *proplist, struct node *children);
180struct node *name_node(struct node *node, char *name, char *label); 175struct node *name_node(struct node *node, char *name);
181struct node *chain_node(struct node *first, struct node *list); 176struct node *chain_node(struct node *first, struct node *list);
177struct node *merge_nodes(struct node *old_node, struct node *new_node);
182 178
183void add_property(struct node *node, struct property *prop); 179void add_property(struct node *node, struct property *prop);
184void add_child(struct node *parent, struct node *child); 180void add_child(struct node *parent, struct node *child);
@@ -186,6 +182,10 @@ void add_child(struct node *parent, struct node *child);
186const char *get_unitname(struct node *node); 182const char *get_unitname(struct node *node);
187struct property *get_property(struct node *node, const char *propname); 183struct property *get_property(struct node *node, const char *propname);
188cell_t propval_cell(struct property *prop); 184cell_t propval_cell(struct property *prop);
185struct property *get_property_by_label(struct node *tree, const char *label,
186 struct node **node);
187struct marker *get_marker_label(struct node *tree, const char *label,
188 struct node **node, struct property **prop);
189struct node *get_subnode(struct node *node, const char *nodename); 189struct node *get_subnode(struct node *node, const char *nodename);
190struct node *get_node_by_path(struct node *tree, const char *path); 190struct node *get_node_by_path(struct node *tree, const char *path);
191struct node *get_node_by_label(struct node *tree, const char *label); 191struct node *get_node_by_label(struct node *tree, const char *label);
@@ -193,6 +193,8 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle);
193struct node *get_node_by_ref(struct node *tree, const char *ref); 193struct node *get_node_by_ref(struct node *tree, const char *ref);
194cell_t get_node_phandle(struct node *root, struct node *node); 194cell_t get_node_phandle(struct node *root, struct node *node);
195 195
196uint32_t guess_boot_cpuid(struct node *tree);
197
196/* Boot info (tree plus memreserve information */ 198/* Boot info (tree plus memreserve information */
197 199
198struct reserve_info { 200struct reserve_info {
@@ -200,10 +202,10 @@ struct reserve_info {
200 202
201 struct reserve_info *next; 203 struct reserve_info *next;
202 204
203 char *label; 205 struct label *labels;
204}; 206};
205 207
206struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label); 208struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len);
207struct reserve_info *chain_reserve_entry(struct reserve_info *first, 209struct reserve_info *chain_reserve_entry(struct reserve_info *first,
208 struct reserve_info *list); 210 struct reserve_info *list);
209struct reserve_info *add_reserve_entry(struct reserve_info *list, 211struct reserve_info *add_reserve_entry(struct reserve_info *list,
@@ -218,6 +220,7 @@ struct boot_info {
218 220
219struct boot_info *build_boot_info(struct reserve_info *reservelist, 221struct boot_info *build_boot_info(struct reserve_info *reservelist,
220 struct node *tree, uint32_t boot_cpuid_phys); 222 struct node *tree, uint32_t boot_cpuid_phys);
223void sort_tree(struct boot_info *bi);
221 224
222/* Checks */ 225/* Checks */
223 226
@@ -239,8 +242,4 @@ struct boot_info *dt_from_source(const char *f);
239 242
240struct boot_info *dt_from_fs(const char *dirname); 243struct boot_info *dt_from_fs(const char *dirname);
241 244
242/* misc */
243
244char *join_path(const char *path, const char *name);
245
246#endif /* _DTC_H */ 245#endif /* _DTC_H */
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c
index 76acd28c068d..ead0332c87e1 100644
--- a/scripts/dtc/flattree.c
+++ b/scripts/dtc/flattree.c
@@ -52,9 +52,9 @@ struct emitter {
52 void (*string)(void *, char *, int); 52 void (*string)(void *, char *, int);
53 void (*align)(void *, int); 53 void (*align)(void *, int);
54 void (*data)(void *, struct data); 54 void (*data)(void *, struct data);
55 void (*beginnode)(void *, const char *); 55 void (*beginnode)(void *, struct label *labels);
56 void (*endnode)(void *, const char *); 56 void (*endnode)(void *, struct label *labels);
57 void (*property)(void *, const char *); 57 void (*property)(void *, struct label *labels);
58}; 58};
59 59
60static void bin_emit_cell(void *e, cell_t val) 60static void bin_emit_cell(void *e, cell_t val)
@@ -89,17 +89,17 @@ static void bin_emit_data(void *e, struct data d)
89 *dtbuf = data_append_data(*dtbuf, d.val, d.len); 89 *dtbuf = data_append_data(*dtbuf, d.val, d.len);
90} 90}
91 91
92static void bin_emit_beginnode(void *e, const char *label) 92static void bin_emit_beginnode(void *e, struct label *labels)
93{ 93{
94 bin_emit_cell(e, FDT_BEGIN_NODE); 94 bin_emit_cell(e, FDT_BEGIN_NODE);
95} 95}
96 96
97static void bin_emit_endnode(void *e, const char *label) 97static void bin_emit_endnode(void *e, struct label *labels)
98{ 98{
99 bin_emit_cell(e, FDT_END_NODE); 99 bin_emit_cell(e, FDT_END_NODE);
100} 100}
101 101
102static void bin_emit_property(void *e, const char *label) 102static void bin_emit_property(void *e, struct label *labels)
103{ 103{
104 bin_emit_cell(e, FDT_PROP); 104 bin_emit_cell(e, FDT_PROP);
105} 105}
@@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, const char *label, int offset)
127 fprintf(f, "%s\t= . + %d\n", label, offset); 127 fprintf(f, "%s\t= . + %d\n", label, offset);
128} 128}
129 129
130#define ASM_EMIT_BELONG(f, fmt, ...) \
131 { \
132 fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \
133 fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \
134 fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
135 fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
136 }
137
130static void asm_emit_cell(void *e, cell_t val) 138static void asm_emit_cell(void *e, cell_t val)
131{ 139{
132 FILE *f = e; 140 FILE *f = e;
133 141
134 fprintf(f, "\t.long\t0x%x\n", val); 142 fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
143 (val >> 24) & 0xff, (val >> 16) & 0xff,
144 (val >> 8) & 0xff, val & 0xff);
135} 145}
136 146
137static void asm_emit_string(void *e, char *str, int len) 147static void asm_emit_string(void *e, char *str, int len)
@@ -156,7 +166,7 @@ static void asm_emit_align(void *e, int a)
156{ 166{
157 FILE *f = e; 167 FILE *f = e;
158 168
159 fprintf(f, "\t.balign\t%d\n", a); 169 fprintf(f, "\t.balign\t%d, 0\n", a);
160} 170}
161 171
162static void asm_emit_data(void *e, struct data d) 172static void asm_emit_data(void *e, struct data d)
@@ -169,8 +179,7 @@ static void asm_emit_data(void *e, struct data d)
169 emit_offset_label(f, m->ref, m->offset); 179 emit_offset_label(f, m->ref, m->offset);
170 180
171 while ((d.len - off) >= sizeof(uint32_t)) { 181 while ((d.len - off) >= sizeof(uint32_t)) {
172 fprintf(f, "\t.long\t0x%x\n", 182 asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off))));
173 fdt32_to_cpu(*((uint32_t *)(d.val+off))));
174 off += sizeof(uint32_t); 183 off += sizeof(uint32_t);
175 } 184 }
176 185
@@ -182,37 +191,43 @@ static void asm_emit_data(void *e, struct data d)
182 assert(off == d.len); 191 assert(off == d.len);
183} 192}
184 193
185static void asm_emit_beginnode(void *e, const char *label) 194static void asm_emit_beginnode(void *e, struct label *labels)
186{ 195{
187 FILE *f = e; 196 FILE *f = e;
197 struct label *l;
188 198
189 if (label) { 199 for_each_label(labels, l) {
190 fprintf(f, "\t.globl\t%s\n", label); 200 fprintf(f, "\t.globl\t%s\n", l->label);
191 fprintf(f, "%s:\n", label); 201 fprintf(f, "%s:\n", l->label);
192 } 202 }
193 fprintf(f, "\t.long\tFDT_BEGIN_NODE\n"); 203 fprintf(f, "\t/* FDT_BEGIN_NODE */\n");
204 asm_emit_cell(e, FDT_BEGIN_NODE);
194} 205}
195 206
196static void asm_emit_endnode(void *e, const char *label) 207static void asm_emit_endnode(void *e, struct label *labels)
197{ 208{
198 FILE *f = e; 209 FILE *f = e;
210 struct label *l;
199 211
200 fprintf(f, "\t.long\tFDT_END_NODE\n"); 212 fprintf(f, "\t/* FDT_END_NODE */\n");
201 if (label) { 213 asm_emit_cell(e, FDT_END_NODE);
202 fprintf(f, "\t.globl\t%s_end\n", label); 214 for_each_label(labels, l) {
203 fprintf(f, "%s_end:\n", label); 215 fprintf(f, "\t.globl\t%s_end\n", l->label);
216 fprintf(f, "%s_end:\n", l->label);
204 } 217 }
205} 218}
206 219
207static void asm_emit_property(void *e, const char *label) 220static void asm_emit_property(void *e, struct label *labels)
208{ 221{
209 FILE *f = e; 222 FILE *f = e;
223 struct label *l;
210 224
211 if (label) { 225 for_each_label(labels, l) {
212 fprintf(f, "\t.globl\t%s\n", label); 226 fprintf(f, "\t.globl\t%s\n", l->label);
213 fprintf(f, "%s:\n", label); 227 fprintf(f, "%s:\n", l->label);
214 } 228 }
215 fprintf(f, "\t.long\tFDT_PROP\n"); 229 fprintf(f, "\t/* FDT_PROP */\n");
230 asm_emit_cell(e, FDT_PROP);
216} 231}
217 232
218static struct emitter asm_emitter = { 233static struct emitter asm_emitter = {
@@ -248,7 +263,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
248 struct node *child; 263 struct node *child;
249 int seen_name_prop = 0; 264 int seen_name_prop = 0;
250 265
251 emit->beginnode(etarget, tree->label); 266 emit->beginnode(etarget, tree->labels);
252 267
253 if (vi->flags & FTF_FULLPATH) 268 if (vi->flags & FTF_FULLPATH)
254 emit->string(etarget, tree->fullpath, 0); 269 emit->string(etarget, tree->fullpath, 0);
@@ -265,7 +280,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
265 280
266 nameoff = stringtable_insert(strbuf, prop->name); 281 nameoff = stringtable_insert(strbuf, prop->name);
267 282
268 emit->property(etarget, prop->label); 283 emit->property(etarget, prop->labels);
269 emit->cell(etarget, prop->val.len); 284 emit->cell(etarget, prop->val.len);
270 emit->cell(etarget, nameoff); 285 emit->cell(etarget, nameoff);
271 286
@@ -292,7 +307,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit,
292 flatten_tree(child, emit, etarget, strbuf, vi); 307 flatten_tree(child, emit, etarget, strbuf, vi);
293 } 308 }
294 309
295 emit->endnode(etarget, tree->label); 310 emit->endnode(etarget, tree->labels);
296} 311}
297 312
298static struct data flatten_reserve_list(struct reserve_info *reservelist, 313static struct data flatten_reserve_list(struct reserve_info *reservelist,
@@ -413,10 +428,13 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
413 if (padlen > 0) 428 if (padlen > 0)
414 blob = data_append_zeroes(blob, padlen); 429 blob = data_append_zeroes(blob, padlen);
415 430
416 fwrite(blob.val, blob.len, 1, f); 431 if (fwrite(blob.val, blob.len, 1, f) != 1) {
417 432 if (ferror(f))
418 if (ferror(f)) 433 die("Error writing device tree blob: %s\n",
419 die("Error writing device tree blob: %s\n", strerror(errno)); 434 strerror(errno));
435 else
436 die("Short write on device tree blob\n");
437 }
420 438
421 /* 439 /*
422 * data_merge() frees the right-hand element so only the blob 440 * data_merge() frees the right-hand element so only the blob
@@ -455,39 +473,44 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
455 die("Unknown device tree blob version %d\n", version); 473 die("Unknown device tree blob version %d\n", version);
456 474
457 fprintf(f, "/* autogenerated by dtc, do not edit */\n\n"); 475 fprintf(f, "/* autogenerated by dtc, do not edit */\n\n");
458 fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC);
459 fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE);
460 fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE);
461 fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP);
462 fprintf(f, "#define FDT_END 0x%x\n", FDT_END);
463 fprintf(f, "\n");
464 476
465 emit_label(f, symprefix, "blob_start"); 477 emit_label(f, symprefix, "blob_start");
466 emit_label(f, symprefix, "header"); 478 emit_label(f, symprefix, "header");
467 fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n"); 479 fprintf(f, "\t/* magic */\n");
468 fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n", 480 asm_emit_cell(f, FDT_MAGIC);
469 symprefix, symprefix); 481 fprintf(f, "\t/* totalsize */\n");
470 fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n", 482 ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start",
483 symprefix, symprefix);
484 fprintf(f, "\t/* off_dt_struct */\n");
485 ASM_EMIT_BELONG(f, "_%s_struct_start - _%s_blob_start",
471 symprefix, symprefix); 486 symprefix, symprefix);
472 fprintf(f, "\t.long\t_%s_strings_start - _%s_blob_start\t/* off_dt_strings */\n", 487 fprintf(f, "\t/* off_dt_strings */\n");
488 ASM_EMIT_BELONG(f, "_%s_strings_start - _%s_blob_start",
473 symprefix, symprefix); 489 symprefix, symprefix);
474 fprintf(f, "\t.long\t_%s_reserve_map - _%s_blob_start\t/* off_dt_strings */\n", 490 fprintf(f, "\t/* off_mem_rsvmap */\n");
491 ASM_EMIT_BELONG(f, "_%s_reserve_map - _%s_blob_start",
475 symprefix, symprefix); 492 symprefix, symprefix);
476 fprintf(f, "\t.long\t%d\t\t\t\t\t/* version */\n", vi->version); 493 fprintf(f, "\t/* version */\n");
477 fprintf(f, "\t.long\t%d\t\t\t\t\t/* last_comp_version */\n", 494 asm_emit_cell(f, vi->version);
478 vi->last_comp_version); 495 fprintf(f, "\t/* last_comp_version */\n");
479 496 asm_emit_cell(f, vi->last_comp_version);
480 if (vi->flags & FTF_BOOTCPUID) 497
481 fprintf(f, "\t.long\t%i\t\t\t\t\t/* boot_cpuid_phys */\n", 498 if (vi->flags & FTF_BOOTCPUID) {
482 bi->boot_cpuid_phys); 499 fprintf(f, "\t/* boot_cpuid_phys */\n");
500 asm_emit_cell(f, bi->boot_cpuid_phys);
501 }
483 502
484 if (vi->flags & FTF_STRTABSIZE) 503 if (vi->flags & FTF_STRTABSIZE) {
485 fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n", 504 fprintf(f, "\t/* size_dt_strings */\n");
486 symprefix, symprefix); 505 ASM_EMIT_BELONG(f, "_%s_strings_end - _%s_strings_start",
506 symprefix, symprefix);
507 }
487 508
488 if (vi->flags & FTF_STRUCTSIZE) 509 if (vi->flags & FTF_STRUCTSIZE) {
489 fprintf(f, "\t.long\t_%s_struct_end - _%s_struct_start\t/* size_dt_struct */\n", 510 fprintf(f, "\t/* size_dt_struct */\n");
511 ASM_EMIT_BELONG(f, "_%s_struct_end - _%s_struct_start",
490 symprefix, symprefix); 512 symprefix, symprefix);
513 }
491 514
492 /* 515 /*
493 * Reserve map entries. 516 * Reserve map entries.
@@ -505,16 +528,17 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
505 * as it appears .quad isn't available in some assemblers. 528 * as it appears .quad isn't available in some assemblers.
506 */ 529 */
507 for (re = bi->reservelist; re; re = re->next) { 530 for (re = bi->reservelist; re; re = re->next) {
508 if (re->label) { 531 struct label *l;
509 fprintf(f, "\t.globl\t%s\n", re->label); 532
510 fprintf(f, "%s:\n", re->label); 533 for_each_label(re->labels, l) {
534 fprintf(f, "\t.globl\t%s\n", l->label);
535 fprintf(f, "%s:\n", l->label);
511 } 536 }
512 fprintf(f, "\t.long\t0x%08x, 0x%08x\n", 537 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32));
513 (unsigned int)(re->re.address >> 32), 538 ASM_EMIT_BELONG(f, "0x%08x",
514 (unsigned int)(re->re.address & 0xffffffff)); 539 (unsigned int)(re->re.address & 0xffffffff));
515 fprintf(f, "\t.long\t0x%08x, 0x%08x\n", 540 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32));
516 (unsigned int)(re->re.size >> 32), 541 ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff));
517 (unsigned int)(re->re.size & 0xffffffff));
518 } 542 }
519 for (i = 0; i < reservenum; i++) { 543 for (i = 0; i < reservenum; i++) {
520 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); 544 fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -524,7 +548,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
524 548
525 emit_label(f, symprefix, "struct_start"); 549 emit_label(f, symprefix, "struct_start");
526 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi); 550 flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi);
527 fprintf(f, "\t.long\tFDT_END\n"); 551
552 fprintf(f, "\t/* FDT_END */\n");
553 asm_emit_cell(f, FDT_END);
528 emit_label(f, symprefix, "struct_end"); 554 emit_label(f, symprefix, "struct_end");
529 555
530 emit_label(f, symprefix, "strings_start"); 556 emit_label(f, symprefix, "strings_start");
@@ -601,7 +627,7 @@ static char *flat_read_string(struct inbuf *inb)
601 len++; 627 len++;
602 } while ((*p++) != '\0'); 628 } while ((*p++) != '\0');
603 629
604 str = strdup(inb->ptr); 630 str = xstrdup(inb->ptr);
605 631
606 inb->ptr += len; 632 inb->ptr += len;
607 633
@@ -643,7 +669,7 @@ static char *flat_read_stringtable(struct inbuf *inb, int offset)
643 p++; 669 p++;
644 } 670 }
645 671
646 return strdup(inb->base + offset); 672 return xstrdup(inb->base + offset);
647} 673}
648 674
649static struct property *flat_read_property(struct inbuf *dtbuf, 675static struct property *flat_read_property(struct inbuf *dtbuf,
@@ -663,7 +689,7 @@ static struct property *flat_read_property(struct inbuf *dtbuf,
663 689
664 val = flat_read_data(dtbuf, proplen); 690 val = flat_read_data(dtbuf, proplen);
665 691
666 return build_property(name, val, NULL); 692 return build_property(name, val);
667} 693}
668 694
669 695
@@ -688,7 +714,7 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb)
688 if (re.size == 0) 714 if (re.size == 0)
689 break; 715 break;
690 716
691 new = build_reserve_entry(re.address, re.size, NULL); 717 new = build_reserve_entry(re.address, re.size);
692 reservelist = add_reserve_entry(reservelist, new); 718 reservelist = add_reserve_entry(reservelist, new);
693 } 719 }
694 720
@@ -710,7 +736,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath)
710 if (!streq(ppath, "/")) 736 if (!streq(ppath, "/"))
711 plen++; 737 plen++;
712 738
713 return strdup(cpath + plen); 739 return xstrdup(cpath + plen);
714} 740}
715 741
716static struct node *unflatten_tree(struct inbuf *dtbuf, 742static struct node *unflatten_tree(struct inbuf *dtbuf,
@@ -776,7 +802,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
776 802
777struct boot_info *dt_from_blob(const char *fname) 803struct boot_info *dt_from_blob(const char *fname)
778{ 804{
779 struct dtc_file *dtcf; 805 FILE *f;
780 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; 806 uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
781 uint32_t off_dt, off_str, off_mem_rsvmap; 807 uint32_t off_dt, off_str, off_mem_rsvmap;
782 int rc; 808 int rc;
@@ -791,14 +817,14 @@ struct boot_info *dt_from_blob(const char *fname)
791 uint32_t val; 817 uint32_t val;
792 int flags = 0; 818 int flags = 0;
793 819
794 dtcf = dtc_open_file(fname, NULL); 820 f = srcfile_relative_open(fname, NULL);
795 821
796 rc = fread(&magic, sizeof(magic), 1, dtcf->file); 822 rc = fread(&magic, sizeof(magic), 1, f);
797 if (ferror(dtcf->file)) 823 if (ferror(f))
798 die("Error reading DT blob magic number: %s\n", 824 die("Error reading DT blob magic number: %s\n",
799 strerror(errno)); 825 strerror(errno));
800 if (rc < 1) { 826 if (rc < 1) {
801 if (feof(dtcf->file)) 827 if (feof(f))
802 die("EOF reading DT blob magic number\n"); 828 die("EOF reading DT blob magic number\n");
803 else 829 else
804 die("Mysterious short read reading magic number\n"); 830 die("Mysterious short read reading magic number\n");
@@ -808,11 +834,11 @@ struct boot_info *dt_from_blob(const char *fname)
808 if (magic != FDT_MAGIC) 834 if (magic != FDT_MAGIC)
809 die("Blob has incorrect magic number\n"); 835 die("Blob has incorrect magic number\n");
810 836
811 rc = fread(&totalsize, sizeof(totalsize), 1, dtcf->file); 837 rc = fread(&totalsize, sizeof(totalsize), 1, f);
812 if (ferror(dtcf->file)) 838 if (ferror(f))
813 die("Error reading DT blob size: %s\n", strerror(errno)); 839 die("Error reading DT blob size: %s\n", strerror(errno));
814 if (rc < 1) { 840 if (rc < 1) {
815 if (feof(dtcf->file)) 841 if (feof(f))
816 die("EOF reading DT blob size\n"); 842 die("EOF reading DT blob size\n");
817 else 843 else
818 die("Mysterious short read reading blob size\n"); 844 die("Mysterious short read reading blob size\n");
@@ -832,12 +858,12 @@ struct boot_info *dt_from_blob(const char *fname)
832 p = blob + sizeof(magic) + sizeof(totalsize); 858 p = blob + sizeof(magic) + sizeof(totalsize);
833 859
834 while (sizeleft) { 860 while (sizeleft) {
835 if (feof(dtcf->file)) 861 if (feof(f))
836 die("EOF before reading %d bytes of DT blob\n", 862 die("EOF before reading %d bytes of DT blob\n",
837 totalsize); 863 totalsize);
838 864
839 rc = fread(p, 1, sizeleft, dtcf->file); 865 rc = fread(p, 1, sizeleft, f);
840 if (ferror(dtcf->file)) 866 if (ferror(f))
841 die("Error reading DT blob: %s\n", 867 die("Error reading DT blob: %s\n",
842 strerror(errno)); 868 strerror(errno));
843 869
@@ -900,7 +926,7 @@ struct boot_info *dt_from_blob(const char *fname)
900 926
901 free(blob); 927 free(blob);
902 928
903 dtc_close_file(dtcf); 929 fclose(f);
904 930
905 return build_boot_info(reservelist, tree, boot_cpuid_phys); 931 return build_boot_info(reservelist, tree, boot_cpuid_phys);
906} 932}
diff --git a/scripts/dtc/fstree.c b/scripts/dtc/fstree.c
index 8fe1bdf239f0..f3774530170a 100644
--- a/scripts/dtc/fstree.c
+++ b/scripts/dtc/fstree.c
@@ -58,10 +58,9 @@ static struct node *read_fstree(const char *dirname)
58 "WARNING: Cannot open %s: %s\n", 58 "WARNING: Cannot open %s: %s\n",
59 tmpnam, strerror(errno)); 59 tmpnam, strerror(errno));
60 } else { 60 } else {
61 prop = build_property(strdup(de->d_name), 61 prop = build_property(xstrdup(de->d_name),
62 data_copy_file(pfile, 62 data_copy_file(pfile,
63 st.st_size), 63 st.st_size));
64 NULL);
65 add_property(tree, prop); 64 add_property(tree, prop);
66 fclose(pfile); 65 fclose(pfile);
67 } 66 }
@@ -69,8 +68,7 @@ static struct node *read_fstree(const char *dirname)
69 struct node *newchild; 68 struct node *newchild;
70 69
71 newchild = read_fstree(tmpnam); 70 newchild = read_fstree(tmpnam);
72 newchild = name_node(newchild, strdup(de->d_name), 71 newchild = name_node(newchild, xstrdup(de->d_name));
73 NULL);
74 add_child(tree, newchild); 72 add_child(tree, newchild);
75 } 73 }
76 74
@@ -86,8 +84,8 @@ struct boot_info *dt_from_fs(const char *dirname)
86 struct node *tree; 84 struct node *tree;
87 85
88 tree = read_fstree(dirname); 86 tree = read_fstree(dirname);
89 tree = name_node(tree, "", NULL); 87 tree = name_node(tree, "");
90 88
91 return build_boot_info(NULL, tree, 0); 89 return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
92} 90}
93 91
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index ce80e4fb41b2..ff6246f000ce 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -61,7 +61,7 @@
61#define FDT_ERR_NOTFOUND 1 61#define FDT_ERR_NOTFOUND 1
62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ 62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
63#define FDT_ERR_EXISTS 2 63#define FDT_ERR_EXISTS 2
64 /* FDT_ERR_EXISTS: Attemped to create a node or property which 64 /* FDT_ERR_EXISTS: Attempted to create a node or property which
65 * already exists */ 65 * already exists */
66#define FDT_ERR_NOSPACE 3 66#define FDT_ERR_NOSPACE 3
67 /* FDT_ERR_NOSPACE: Operation needed to expand the device 67 /* FDT_ERR_NOSPACE: Operation needed to expand the device
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index 0ca3de550b3f..26d0e1e60c0c 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -24,17 +24,30 @@
24 * Tree building functions 24 * Tree building functions
25 */ 25 */
26 26
27struct property *build_property(char *name, struct data val, char *label) 27void add_label(struct label **labels, char *label)
28{
29 struct label *new;
30
31 /* Make sure the label isn't already there */
32 for_each_label(*labels, new)
33 if (streq(new->label, label))
34 return;
35
36 new = xmalloc(sizeof(*new));
37 new->label = label;
38 new->next = *labels;
39 *labels = new;
40}
41
42struct property *build_property(char *name, struct data val)
28{ 43{
29 struct property *new = xmalloc(sizeof(*new)); 44 struct property *new = xmalloc(sizeof(*new));
30 45
46 memset(new, 0, sizeof(*new));
47
31 new->name = name; 48 new->name = name;
32 new->val = val; 49 new->val = val;
33 50
34 new->next = NULL;
35
36 new->label = label;
37
38 return new; 51 return new;
39} 52}
40 53
@@ -78,17 +91,82 @@ struct node *build_node(struct property *proplist, struct node *children)
78 return new; 91 return new;
79} 92}
80 93
81struct node *name_node(struct node *node, char *name, char * label) 94struct node *name_node(struct node *node, char *name)
82{ 95{
83 assert(node->name == NULL); 96 assert(node->name == NULL);
84 97
85 node->name = name; 98 node->name = name;
86 99
87 node->label = label;
88
89 return node; 100 return node;
90} 101}
91 102
103struct node *merge_nodes(struct node *old_node, struct node *new_node)
104{
105 struct property *new_prop, *old_prop;
106 struct node *new_child, *old_child;
107 struct label *l;
108
109 /* Add new node labels to old node */
110 for_each_label(new_node->labels, l)
111 add_label(&old_node->labels, l->label);
112
113 /* Move properties from the new node to the old node. If there
114 * is a collision, replace the old value with the new */
115 while (new_node->proplist) {
116 /* Pop the property off the list */
117 new_prop = new_node->proplist;
118 new_node->proplist = new_prop->next;
119 new_prop->next = NULL;
120
121 /* Look for a collision, set new value if there is */
122 for_each_property(old_node, old_prop) {
123 if (streq(old_prop->name, new_prop->name)) {
124 /* Add new labels to old property */
125 for_each_label(new_prop->labels, l)
126 add_label(&old_prop->labels, l->label);
127
128 old_prop->val = new_prop->val;
129 free(new_prop);
130 new_prop = NULL;
131 break;
132 }
133 }
134
135 /* if no collision occurred, add property to the old node. */
136 if (new_prop)
137 add_property(old_node, new_prop);
138 }
139
140 /* Move the override child nodes into the primary node. If
141 * there is a collision, then merge the nodes. */
142 while (new_node->children) {
143 /* Pop the child node off the list */
144 new_child = new_node->children;
145 new_node->children = new_child->next_sibling;
146 new_child->parent = NULL;
147 new_child->next_sibling = NULL;
148
149 /* Search for a collision. Merge if there is */
150 for_each_child(old_node, old_child) {
151 if (streq(old_child->name, new_child->name)) {
152 merge_nodes(old_child, new_child);
153 new_child = NULL;
154 break;
155 }
156 }
157
158 /* if no collision occurred, add child to the old node. */
159 if (new_child)
160 add_child(old_node, new_child);
161 }
162
163 /* The new node contents are now merged into the old node. Free
164 * the new node. */
165 free(new_node);
166
167 return old_node;
168}
169
92struct node *chain_node(struct node *first, struct node *list) 170struct node *chain_node(struct node *first, struct node *list)
93{ 171{
94 assert(first->next_sibling == NULL); 172 assert(first->next_sibling == NULL);
@@ -124,18 +202,15 @@ void add_child(struct node *parent, struct node *child)
124 *p = child; 202 *p = child;
125} 203}
126 204
127struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size, 205struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
128 char *label)
129{ 206{
130 struct reserve_info *new = xmalloc(sizeof(*new)); 207 struct reserve_info *new = xmalloc(sizeof(*new));
131 208
209 memset(new, 0, sizeof(*new));
210
132 new->re.address = address; 211 new->re.address = address;
133 new->re.size = size; 212 new->re.size = size;
134 213
135 new->next = NULL;
136
137 new->label = label;
138
139 return new; 214 return new;
140} 215}
141 216
@@ -208,6 +283,60 @@ cell_t propval_cell(struct property *prop)
208 return fdt32_to_cpu(*((cell_t *)prop->val.val)); 283 return fdt32_to_cpu(*((cell_t *)prop->val.val));
209} 284}
210 285
286struct property *get_property_by_label(struct node *tree, const char *label,
287 struct node **node)
288{
289 struct property *prop;
290 struct node *c;
291
292 *node = tree;
293
294 for_each_property(tree, prop) {
295 struct label *l;
296
297 for_each_label(prop->labels, l)
298 if (streq(l->label, label))
299 return prop;
300 }
301
302 for_each_child(tree, c) {
303 prop = get_property_by_label(c, label, node);
304 if (prop)
305 return prop;
306 }
307
308 *node = NULL;
309 return NULL;
310}
311
312struct marker *get_marker_label(struct node *tree, const char *label,
313 struct node **node, struct property **prop)
314{
315 struct marker *m;
316 struct property *p;
317 struct node *c;
318
319 *node = tree;
320
321 for_each_property(tree, p) {
322 *prop = p;
323 m = p->val.markers;
324 for_each_marker_of_type(m, LABEL)
325 if (streq(m->ref, label))
326 return m;
327 }
328
329 for_each_child(tree, c) {
330 m = get_marker_label(c, label, node, prop);
331 if (m)
332 return m;
333 }
334
335 *prop = NULL;
336 *node = NULL;
337 return NULL;
338}
339
211struct node *get_subnode(struct node *node, const char *nodename) 340struct node *get_subnode(struct node *node, const char *nodename)
212{ 341{
213 struct node *child; 342 struct node *child;
@@ -245,11 +374,13 @@ struct node *get_node_by_path(struct node *tree, const char *path)
245struct node *get_node_by_label(struct node *tree, const char *label) 374struct node *get_node_by_label(struct node *tree, const char *label)
246{ 375{
247 struct node *child, *node; 376 struct node *child, *node;
377 struct label *l;
248 378
249 assert(label && (strlen(label) > 0)); 379 assert(label && (strlen(label) > 0));
250 380
251 if (tree->label && streq(tree->label, label)) 381 for_each_label(tree->labels, l)
252 return tree; 382 if (streq(l->label, label))
383 return tree;
253 384
254 for_each_child(tree, child) { 385 for_each_child(tree, child) {
255 node = get_node_by_label(child, label); 386 node = get_node_by_label(child, label);
@@ -293,16 +424,186 @@ cell_t get_node_phandle(struct node *root, struct node *node)
293 if ((node->phandle != 0) && (node->phandle != -1)) 424 if ((node->phandle != 0) && (node->phandle != -1))
294 return node->phandle; 425 return node->phandle;
295 426
296 assert(! get_property(node, "linux,phandle"));
297
298 while (get_node_by_phandle(root, phandle)) 427 while (get_node_by_phandle(root, phandle))
299 phandle++; 428 phandle++;
300 429
301 node->phandle = phandle; 430 node->phandle = phandle;
302 add_property(node, 431
303 build_property("linux,phandle", 432 if (!get_property(node, "linux,phandle")
304 data_append_cell(empty_data, phandle), 433 && (phandle_format & PHANDLE_LEGACY))
305 NULL)); 434 add_property(node,
435 build_property("linux,phandle",
436 data_append_cell(empty_data, phandle)));
437
438 if (!get_property(node, "phandle")
439 && (phandle_format & PHANDLE_EPAPR))
440 add_property(node,
441 build_property("phandle",
442 data_append_cell(empty_data, phandle)));
443
444 /* If the node *does* have a phandle property, we must
445 * be dealing with a self-referencing phandle, which will be
446 * fixed up momentarily in the caller */
306 447
307 return node->phandle; 448 return node->phandle;
308} 449}
450
451uint32_t guess_boot_cpuid(struct node *tree)
452{
453 struct node *cpus, *bootcpu;
454 struct property *reg;
455
456 cpus = get_node_by_path(tree, "/cpus");
457 if (!cpus)
458 return 0;
459
460
461 bootcpu = cpus->children;
462 if (!bootcpu)
463 return 0;
464
465 reg = get_property(bootcpu, "reg");
466 if (!reg || (reg->val.len != sizeof(uint32_t)))
467 return 0;
468
469 /* FIXME: Sanity check node? */
470
471 return propval_cell(reg);
472}
473
474static int cmp_reserve_info(const void *ax, const void *bx)
475{
476 const struct reserve_info *a, *b;
477
478 a = *((const struct reserve_info * const *)ax);
479 b = *((const struct reserve_info * const *)bx);
480
481 if (a->re.address < b->re.address)
482 return -1;
483 else if (a->re.address > b->re.address)
484 return 1;
485 else if (a->re.size < b->re.size)
486 return -1;
487 else if (a->re.size > b->re.size)
488 return 1;
489 else
490 return 0;
491}
492
493static void sort_reserve_entries(struct boot_info *bi)
494{
495 struct reserve_info *ri, **tbl;
496 int n = 0, i = 0;
497
498 for (ri = bi->reservelist;
499 ri;
500 ri = ri->next)
501 n++;
502
503 if (n == 0)
504 return;
505
506 tbl = xmalloc(n * sizeof(*tbl));
507
508 for (ri = bi->reservelist;
509 ri;
510 ri = ri->next)
511 tbl[i++] = ri;
512
513 qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
514
515 bi->reservelist = tbl[0];
516 for (i = 0; i < (n-1); i++)
517 tbl[i]->next = tbl[i+1];
518 tbl[n-1]->next = NULL;
519
520 free(tbl);
521}
522
523static int cmp_prop(const void *ax, const void *bx)
524{
525 const struct property *a, *b;
526
527 a = *((const struct property * const *)ax);
528 b = *((const struct property * const *)bx);
529
530 return strcmp(a->name, b->name);
531}
532
533static void sort_properties(struct node *node)
534{
535 int n = 0, i = 0;
536 struct property *prop, **tbl;
537
538 for_each_property(node, prop)
539 n++;
540
541 if (n == 0)
542 return;
543
544 tbl = xmalloc(n * sizeof(*tbl));
545
546 for_each_property(node, prop)
547 tbl[i++] = prop;
548
549 qsort(tbl, n, sizeof(*tbl), cmp_prop);
550
551 node->proplist = tbl[0];
552 for (i = 0; i < (n-1); i++)
553 tbl[i]->next = tbl[i+1];
554 tbl[n-1]->next = NULL;
555
556 free(tbl);
557}
558
559static int cmp_subnode(const void *ax, const void *bx)
560{
561 const struct node *a, *b;
562
563 a = *((const struct node * const *)ax);
564 b = *((const struct node * const *)bx);
565
566 return strcmp(a->name, b->name);
567}
568
569static void sort_subnodes(struct node *node)
570{
571 int n = 0, i = 0;
572 struct node *subnode, **tbl;
573
574 for_each_child(node, subnode)
575 n++;
576
577 if (n == 0)
578 return;
579
580 tbl = xmalloc(n * sizeof(*tbl));
581
582 for_each_child(node, subnode)
583 tbl[i++] = subnode;
584
585 qsort(tbl, n, sizeof(*tbl), cmp_subnode);
586
587 node->children = tbl[0];
588 for (i = 0; i < (n-1); i++)
589 tbl[i]->next_sibling = tbl[i+1];
590 tbl[n-1]->next_sibling = NULL;
591
592 free(tbl);
593}
594
595static void sort_node(struct node *node)
596{
597 struct node *c;
598
599 sort_properties(node);
600 sort_subnodes(node);
601 for_each_child(node, c)
602 sort_node(c);
603}
604
605void sort_tree(struct boot_info *bi)
606{
607 sort_reserve_entries(bi);
608 sort_node(bi->dt);
609}
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c
index 9641b7628b4d..2dbc874288ca 100644
--- a/scripts/dtc/srcpos.c
+++ b/scripts/dtc/srcpos.c
@@ -17,100 +17,232 @@
17 * USA 17 * USA
18 */ 18 */
19 19
20#define _GNU_SOURCE
21
22#include <stdio.h>
23
20#include "dtc.h" 24#include "dtc.h"
21#include "srcpos.h" 25#include "srcpos.h"
22 26
23/*
24 * Like yylineno, this is the current open file pos.
25 */
26 27
27struct dtc_file *srcpos_file; 28static char *dirname(const char *path)
29{
30 const char *slash = strrchr(path, '/');
31
32 if (slash) {
33 int len = slash - path;
34 char *dir = xmalloc(len + 1);
35
36 memcpy(dir, path, len);
37 dir[len] = '\0';
38 return dir;
39 }
40 return NULL;
41}
42
43struct srcfile_state *current_srcfile; /* = NULL */
28 44
29static int dtc_open_one(struct dtc_file *file, 45/* Detect infinite include recursion. */
30 const char *search, 46#define MAX_SRCFILE_DEPTH (100)
31 const char *fname) 47static int srcfile_depth; /* = 0 */
48
49FILE *srcfile_relative_open(const char *fname, char **fullnamep)
32{ 50{
51 FILE *f;
33 char *fullname; 52 char *fullname;
34 53
35 if (search) { 54 if (streq(fname, "-")) {
36 fullname = xmalloc(strlen(search) + strlen(fname) + 2); 55 f = stdin;
37 56 fullname = xstrdup("<stdin>");
38 strcpy(fullname, search);
39 strcat(fullname, "/");
40 strcat(fullname, fname);
41 } else { 57 } else {
42 fullname = strdup(fname); 58 if (!current_srcfile || !current_srcfile->dir
59 || (fname[0] == '/'))
60 fullname = xstrdup(fname);
61 else
62 fullname = join_path(current_srcfile->dir, fname);
63
64 f = fopen(fullname, "r");
65 if (!f)
66 die("Couldn't open \"%s\": %s\n", fname,
67 strerror(errno));
43 } 68 }
44 69
45 file->file = fopen(fullname, "r"); 70 if (fullnamep)
46 if (!file->file) { 71 *fullnamep = fullname;
72 else
47 free(fullname); 73 free(fullname);
48 return 0;
49 }
50 74
51 file->name = fullname; 75 return f;
52 return 1;
53} 76}
54 77
78void srcfile_push(const char *fname)
79{
80 struct srcfile_state *srcfile;
81
82 if (srcfile_depth++ >= MAX_SRCFILE_DEPTH)
83 die("Includes nested too deeply");
84
85 srcfile = xmalloc(sizeof(*srcfile));
86
87 srcfile->f = srcfile_relative_open(fname, &srcfile->name);
88 srcfile->dir = dirname(srcfile->name);
89 srcfile->prev = current_srcfile;
90
91 srcfile->lineno = 1;
92 srcfile->colno = 1;
93
94 current_srcfile = srcfile;
95}
55 96
56struct dtc_file *dtc_open_file(const char *fname, 97int srcfile_pop(void)
57 const struct search_path *search)
58{ 98{
59 static const struct search_path default_search = { NULL, NULL, NULL }; 99 struct srcfile_state *srcfile = current_srcfile;
60 100
61 struct dtc_file *file; 101 assert(srcfile);
62 const char *slash;
63 102
64 file = xmalloc(sizeof(struct dtc_file)); 103 current_srcfile = srcfile->prev;
65 104
66 slash = strrchr(fname, '/'); 105 if (fclose(srcfile->f))
67 if (slash) { 106 die("Error closing \"%s\": %s\n", srcfile->name,
68 char *dir = xmalloc(slash - fname + 1); 107 strerror(errno));
69 108
70 memcpy(dir, fname, slash - fname); 109 /* FIXME: We allow the srcfile_state structure to leak,
71 dir[slash - fname] = 0; 110 * because it could still be referenced from a location
72 file->dir = dir; 111 * variable being carried through the parser somewhere. To
73 } else { 112 * fix this we could either allocate all the files from a
74 file->dir = NULL; 113 * table, or use a pool allocator. */
75 }
76 114
77 if (streq(fname, "-")) { 115 return current_srcfile ? 1 : 0;
78 file->name = "stdin"; 116}
79 file->file = stdin;
80 return file;
81 }
82 117
83 if (fname[0] == '/') { 118/*
84 file->file = fopen(fname, "r"); 119 * The empty source position.
85 if (!file->file) 120 */
86 goto fail;
87 121
88 file->name = strdup(fname); 122struct srcpos srcpos_empty = {
89 return file; 123 .first_line = 0,
90 } 124 .first_column = 0,
125 .last_line = 0,
126 .last_column = 0,
127 .file = NULL,
128};
91 129
92 if (!search) 130#define TAB_SIZE 8
93 search = &default_search;
94 131
95 while (search) { 132void srcpos_update(struct srcpos *pos, const char *text, int len)
96 if (dtc_open_one(file, search->dir, fname)) 133{
97 return file; 134 int i;
135
136 pos->file = current_srcfile;
137
138 pos->first_line = current_srcfile->lineno;
139 pos->first_column = current_srcfile->colno;
140
141 for (i = 0; i < len; i++)
142 if (text[i] == '\n') {
143 current_srcfile->lineno++;
144 current_srcfile->colno = 1;
145 } else if (text[i] == '\t') {
146 current_srcfile->colno =
147 ALIGN(current_srcfile->colno, TAB_SIZE);
148 } else {
149 current_srcfile->colno++;
150 }
151
152 pos->last_line = current_srcfile->lineno;
153 pos->last_column = current_srcfile->colno;
154}
98 155
99 if (errno != ENOENT) 156struct srcpos *
100 goto fail; 157srcpos_copy(struct srcpos *pos)
158{
159 struct srcpos *pos_new;
101 160
102 search = search->next; 161 pos_new = xmalloc(sizeof(struct srcpos));
103 } 162 memcpy(pos_new, pos, sizeof(struct srcpos));
163
164 return pos_new;
165}
166
167
168
169void
170srcpos_dump(struct srcpos *pos)
171{
172 printf("file : \"%s\"\n",
173 pos->file ? (char *) pos->file : "<no file>");
174 printf("first_line : %d\n", pos->first_line);
175 printf("first_column: %d\n", pos->first_column);
176 printf("last_line : %d\n", pos->last_line);
177 printf("last_column : %d\n", pos->last_column);
178 printf("file : %s\n", pos->file->name);
179}
104 180
105fail: 181
106 die("Couldn't open \"%s\": %s\n", fname, strerror(errno)); 182char *
183srcpos_string(struct srcpos *pos)
184{
185 const char *fname = "<no-file>";
186 char *pos_str;
187 int rc;
188
189 if (pos)
190 fname = pos->file->name;
191
192
193 if (pos->first_line != pos->last_line)
194 rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
195 pos->first_line, pos->first_column,
196 pos->last_line, pos->last_column);
197 else if (pos->first_column != pos->last_column)
198 rc = asprintf(&pos_str, "%s:%d.%d-%d", fname,
199 pos->first_line, pos->first_column,
200 pos->last_column);
201 else
202 rc = asprintf(&pos_str, "%s:%d.%d", fname,
203 pos->first_line, pos->first_column);
204
205 if (rc == -1)
206 die("Couldn't allocate in srcpos string");
207
208 return pos_str;
209}
210
211void
212srcpos_verror(struct srcpos *pos, char const *fmt, va_list va)
213{
214 const char *srcstr;
215
216 srcstr = srcpos_string(pos);
217
218 fprintf(stdout, "Error: %s ", srcstr);
219 vfprintf(stdout, fmt, va);
220 fprintf(stdout, "\n");
107} 221}
108 222
109void dtc_close_file(struct dtc_file *file) 223void
224srcpos_error(struct srcpos *pos, char const *fmt, ...)
110{ 225{
111 if (fclose(file->file)) 226 va_list va;
112 die("Error closing \"%s\": %s\n", file->name, strerror(errno)); 227
228 va_start(va, fmt);
229 srcpos_verror(pos, fmt, va);
230 va_end(va);
231}
232
233
234void
235srcpos_warn(struct srcpos *pos, char const *fmt, ...)
236{
237 const char *srcstr;
238 va_list va;
239 va_start(va, fmt);
240
241 srcstr = srcpos_string(pos);
242
243 fprintf(stderr, "Warning: %s ", srcstr);
244 vfprintf(stderr, fmt, va);
245 fprintf(stderr, "\n");
113 246
114 free(file->dir); 247 va_end(va);
115 free(file);
116} 248}
diff --git a/scripts/dtc/srcpos.h b/scripts/dtc/srcpos.h
index e17c7c04db8e..bd7966e56a53 100644
--- a/scripts/dtc/srcpos.h
+++ b/scripts/dtc/srcpos.h
@@ -17,69 +17,70 @@
17 * USA 17 * USA
18 */ 18 */
19 19
20/* 20#ifndef _SRCPOS_H_
21 * Augment the standard YYLTYPE with a filenum index into an 21#define _SRCPOS_H_
22 * array of all opened filenames.
23 */
24 22
25#include <stdio.h> 23#include <stdio.h>
26 24
27struct dtc_file { 25struct srcfile_state {
26 FILE *f;
27 char *name;
28 char *dir; 28 char *dir;
29 const char *name; 29 int lineno, colno;
30 FILE *file; 30 struct srcfile_state *prev;
31}; 31};
32 32
33#if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED) 33extern struct srcfile_state *current_srcfile; /* = NULL */
34typedef struct YYLTYPE { 34
35FILE *srcfile_relative_open(const char *fname, char **fullnamep);
36void srcfile_push(const char *fname);
37int srcfile_pop(void);
38
39struct srcpos {
35 int first_line; 40 int first_line;
36 int first_column; 41 int first_column;
37 int last_line; 42 int last_line;
38 int last_column; 43 int last_column;
39 struct dtc_file *file; 44 struct srcfile_state *file;
40} YYLTYPE; 45};
41
42#define YYLTYPE_IS_DECLARED 1
43#define YYLTYPE_IS_TRIVIAL 1
44#endif
45
46/* Cater to old parser templates. */
47#ifndef YYID
48#define YYID(n) (n)
49#endif
50 46
51#define YYLLOC_DEFAULT(Current, Rhs, N) \ 47#define YYLTYPE struct srcpos
52 do \
53 if (YYID (N)) \
54 { \
55 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
56 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
57 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
58 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
59 (Current).file = YYRHSLOC (Rhs, N).file; \
60 } \
61 else \
62 { \
63 (Current).first_line = (Current).last_line = \
64 YYRHSLOC (Rhs, 0).last_line; \
65 (Current).first_column = (Current).last_column = \
66 YYRHSLOC (Rhs, 0).last_column; \
67 (Current).file = YYRHSLOC (Rhs, 0).file; \
68 } \
69 while (YYID (0))
70 48
49#define YYLLOC_DEFAULT(Current, Rhs, N) \
50 do { \
51 if (N) { \
52 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
53 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
54 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
55 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
56 (Current).file = YYRHSLOC(Rhs, N).file; \
57 } else { \
58 (Current).first_line = (Current).last_line = \
59 YYRHSLOC(Rhs, 0).last_line; \
60 (Current).first_column = (Current).last_column = \
61 YYRHSLOC(Rhs, 0).last_column; \
62 (Current).file = YYRHSLOC (Rhs, 0).file; \
63 } \
64 } while (0)
71 65
72 66
73extern void yyerror(char const *); 67/*
74extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2))); 68 * Fictional source position used for IR nodes that are
69 * created without otherwise knowing a true source position.
70 * For example,constant definitions from the command line.
71 */
72extern struct srcpos srcpos_empty;
75 73
76extern struct dtc_file *srcpos_file; 74extern void srcpos_update(struct srcpos *pos, const char *text, int len);
75extern struct srcpos *srcpos_copy(struct srcpos *pos);
76extern char *srcpos_string(struct srcpos *pos);
77extern void srcpos_dump(struct srcpos *pos);
77 78
78struct search_path { 79extern void srcpos_verror(struct srcpos *pos, char const *, va_list va)
79 const char *dir; /* NULL for current directory */ 80 __attribute__((format(printf, 2, 0)));
80 struct search_path *prev, *next; 81extern void srcpos_error(struct srcpos *pos, char const *, ...)
81}; 82 __attribute__((format(printf, 2, 3)));
83extern void srcpos_warn(struct srcpos *pos, char const *, ...)
84 __attribute__((format(printf, 2, 3)));
82 85
83extern struct dtc_file *dtc_open_file(const char *fname, 86#endif /* _SRCPOS_H_ */
84 const struct search_path *search);
85extern void dtc_close_file(struct dtc_file *file);
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
index 1521ff11bb97..c09aafade313 100644
--- a/scripts/dtc/treesource.c
+++ b/scripts/dtc/treesource.c
@@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname)
32 the_boot_info = NULL; 32 the_boot_info = NULL;
33 treesource_error = 0; 33 treesource_error = 0;
34 34
35 srcpos_file = dtc_open_file(fname, NULL); 35 srcfile_push(fname);
36 yyin = srcpos_file->file; 36 yyin = current_srcfile->f;
37 37
38 if (yyparse() != 0) 38 if (yyparse() != 0)
39 die("Unable to parse input tree\n"); 39 die("Unable to parse input tree\n");
@@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val)
63{ 63{
64 const char *str = val.val; 64 const char *str = val.val;
65 int i; 65 int i;
66 int newchunk = 1;
67 struct marker *m = val.markers; 66 struct marker *m = val.markers;
68 67
69 assert(str[val.len-1] == '\0'); 68 assert(str[val.len-1] == '\0');
70 69
70 while (m && (m->offset == 0)) {
71 if (m->type == LABEL)
72 fprintf(f, "%s: ", m->ref);
73 m = m->next;
74 }
75 fprintf(f, "\"");
76
71 for (i = 0; i < (val.len-1); i++) { 77 for (i = 0; i < (val.len-1); i++) {
72 char c = str[i]; 78 char c = str[i];
73 79
74 if (newchunk) {
75 while (m && (m->offset <= i)) {
76 if (m->type == LABEL) {
77 assert(m->offset == i);
78 fprintf(f, "%s: ", m->ref);
79 }
80 m = m->next;
81 }
82 fprintf(f, "\"");
83 newchunk = 0;
84 }
85
86 switch (c) { 80 switch (c) {
87 case '\a': 81 case '\a':
88 fprintf(f, "\\a"); 82 fprintf(f, "\\a");
@@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val)
113 break; 107 break;
114 case '\0': 108 case '\0':
115 fprintf(f, "\", "); 109 fprintf(f, "\", ");
116 newchunk = 1; 110 while (m && (m->offset < i)) {
111 if (m->type == LABEL) {
112 assert(m->offset == (i+1));
113 fprintf(f, "%s: ", m->ref);
114 }
115 m = m->next;
116 }
117 fprintf(f, "\"");
117 break; 118 break;
118 default: 119 default:
119 if (isprint(c)) 120 if (isprint(c))
@@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
234{ 235{
235 struct property *prop; 236 struct property *prop;
236 struct node *child; 237 struct node *child;
238 struct label *l;
237 239
238 write_prefix(f, level); 240 write_prefix(f, level);
239 if (tree->label) 241 for_each_label(tree->labels, l)
240 fprintf(f, "%s: ", tree->label); 242 fprintf(f, "%s: ", l->label);
241 if (tree->name && (*tree->name)) 243 if (tree->name && (*tree->name))
242 fprintf(f, "%s {\n", tree->name); 244 fprintf(f, "%s {\n", tree->name);
243 else 245 else
@@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
245 247
246 for_each_property(tree, prop) { 248 for_each_property(tree, prop) {
247 write_prefix(f, level+1); 249 write_prefix(f, level+1);
248 if (prop->label) 250 for_each_label(prop->labels, l)
249 fprintf(f, "%s: ", prop->label); 251 fprintf(f, "%s: ", l->label);
250 fprintf(f, "%s", prop->name); 252 fprintf(f, "%s", prop->name);
251 write_propval(f, prop); 253 write_propval(f, prop);
252 } 254 }
@@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi)
266 fprintf(f, "/dts-v1/;\n\n"); 268 fprintf(f, "/dts-v1/;\n\n");
267 269
268 for (re = bi->reservelist; re; re = re->next) { 270 for (re = bi->reservelist; re; re = re->next) {
269 if (re->label) 271 struct label *l;
270 fprintf(f, "%s: ", re->label); 272
273 for_each_label(re->labels, l)
274 fprintf(f, "%s: ", l->label);
271 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", 275 fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
272 (unsigned long long)re->re.address, 276 (unsigned long long)re->re.address,
273 (unsigned long long)re->re.size); 277 (unsigned long long)re->re.size);
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
new file mode 100644
index 000000000000..d7ac27d2ae15
--- /dev/null
+++ b/scripts/dtc/util.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 * USA
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <stdarg.h>
23#include <string.h>
24
25#include "util.h"
26
27char *xstrdup(const char *s)
28{
29 int len = strlen(s) + 1;
30 char *dup = xmalloc(len);
31
32 memcpy(dup, s, len);
33
34 return dup;
35}
36
37char *join_path(const char *path, const char *name)
38{
39 int lenp = strlen(path);
40 int lenn = strlen(name);
41 int len;
42 int needslash = 1;
43 char *str;
44
45 len = lenp + lenn + 2;
46 if ((lenp > 0) && (path[lenp-1] == '/')) {
47 needslash = 0;
48 len--;
49 }
50
51 str = xmalloc(len);
52 memcpy(str, path, lenp);
53 if (needslash) {
54 str[lenp] = '/';
55 lenp++;
56 }
57 memcpy(str+lenp, name, lenn+1);
58 return str;
59}
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h
new file mode 100644
index 000000000000..9cead842c11e
--- /dev/null
+++ b/scripts/dtc/util.h
@@ -0,0 +1,56 @@
1#ifndef _UTIL_H
2#define _UTIL_H
3
4/*
5 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23static inline void __attribute__((noreturn)) die(char * str, ...)
24{
25 va_list ap;
26
27 va_start(ap, str);
28 fprintf(stderr, "FATAL ERROR: ");
29 vfprintf(stderr, str, ap);
30 exit(1);
31}
32
33static inline void *xmalloc(size_t len)
34{
35 void *new = malloc(len);
36
37 if (!new)
38 die("malloc() failed\n");
39
40 return new;
41}
42
43static inline void *xrealloc(void *p, size_t len)
44{
45 void *new = realloc(p, len);
46
47 if (!new)
48 die("realloc() failed (len=%d)\n", len);
49
50 return new;
51}
52
53extern char *xstrdup(const char *s);
54extern char *join_path(const char *path, const char *name);
55
56#endif /* _UTIL_H */
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index 658ff42429d6..6158b867df99 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
#define DTC_VERSION "DTC 1.2.0" #define DTC_VERSION "DTC 1.2.0-g37c0b6a0"
diff --git a/scripts/export_report.pl b/scripts/export_report.pl
index 04dce7c15f83..8f79b701de87 100644
--- a/scripts/export_report.pl
+++ b/scripts/export_report.pl
@@ -25,11 +25,12 @@ sub alphabetically {
25sub print_depends_on { 25sub print_depends_on {
26 my ($href) = @_; 26 my ($href) = @_;
27 print "\n"; 27 print "\n";
28 while (my ($mod, $list) = each %$href) { 28 for my $mod (sort keys %$href) {
29 my $list = $href->{$mod};
29 print "\t$mod:\n"; 30 print "\t$mod:\n";
30 foreach my $sym (sort numerically @{$list}) { 31 foreach my $sym (sort numerically @{$list}) {
31 my ($symbol, $no) = split /\s+/, $sym; 32 my ($symbol, $no) = split /\s+/, $sym;
32 printf("\t\t%-25s\t%-25d\n", $symbol, $no); 33 printf("\t\t%-25s\n", $symbol);
33 } 34 }
34 print "\n"; 35 print "\n";
35 } 36 }
@@ -49,8 +50,14 @@ sub usage {
49} 50}
50 51
51sub collectcfiles { 52sub collectcfiles {
52 my @file 53 my @file;
53 = `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`; 54 while (<.tmp_versions/*.mod>) {
55 open my $fh, '<', $_ or die "cannot open $_: $!\n";
56 push (@file,
57 grep s/\.ko/.mod.c/, # change the suffix
58 grep m/.+\.ko/, # find the .ko path
59 <$fh>); # lines in opened file
60 }
54 chomp @file; 61 chomp @file;
55 return @file; 62 return @file;
56} 63}
@@ -95,6 +102,8 @@ close($module_symvers);
95# 102#
96# collect the usage count of each symbol. 103# collect the usage count of each symbol.
97# 104#
105my $modversion_warnings = 0;
106
98foreach my $thismod (@allcfiles) { 107foreach my $thismod (@allcfiles) {
99 my $module; 108 my $module;
100 109
@@ -125,7 +134,8 @@ foreach my $thismod (@allcfiles) {
125 } 134 }
126 } 135 }
127 if ($state != 2) { 136 if ($state != 2) {
128 print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n"; 137 warn "WARNING:$thismod is not built with CONFIG_MODVERSIONS enabled\n";
138 $modversion_warnings++;
129 } 139 }
130 close($module); 140 close($module);
131} 141}
@@ -159,8 +169,12 @@ printf("SECTION 2:\n\tThis section reports export-symbol-usage of in-kernel
159modules. Each module lists the modules, and the symbols from that module that 169modules. Each module lists the modules, and the symbols from that module that
160it uses. Each listed symbol reports the number of modules using it\n"); 170it uses. Each listed symbol reports the number of modules using it\n");
161 171
172print "\nNOTE: Got $modversion_warnings CONFIG_MODVERSIONS warnings\n\n"
173 if $modversion_warnings;
174
162print "~"x80 , "\n"; 175print "~"x80 , "\n";
163while (my ($thismod, $list) = each %MODULE) { 176for my $thismod (sort keys %MODULE) {
177 my $list = $MODULE{$thismod};
164 my %depends; 178 my %depends;
165 $thismod =~ s/\.mod\.c/.ko/; 179 $thismod =~ s/\.mod\.c/.ko/;
166 print "\t\t\t$thismod\n"; 180 print "\t\t\t$thismod\n";
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 37f30d36c944..e1862429ccda 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -7,12 +7,10 @@
7# The obscure use of the "tr" filter is to work around older versions of 7# The obscure use of the "tr" filter is to work around older versions of
8# "grep" that report the byte offset of the line instead of the pattern. 8# "grep" that report the byte offset of the line instead of the pattern.
9# 9#
10# (c) 2009, Dick Streefland <dick@streefland.net> 10# (c) 2009,2010 Dick Streefland <dick@streefland.net>
11# Licensed under the terms of the GNU General Public License. 11# Licensed under the terms of the GNU General Public License.
12# ---------------------------------------------------------------------- 12# ----------------------------------------------------------------------
13 13
14gz1='\037\213\010'
15gz2='01'
16cf1='IKCFG_ST\037\213\010' 14cf1='IKCFG_ST\037\213\010'
17cf2='0123456789' 15cf2='0123456789'
18 16
@@ -21,11 +19,25 @@ dump_config()
21 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"` 19 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
22 then 20 then
23 pos=${pos%%:*} 21 pos=${pos%%:*}
24 tail -c+$(($pos+8)) "$1" | zcat -q 22 tail -c+$(($pos+8)) "$1" | zcat > $tmp1 2> /dev/null
25 exit 0 23 if [ $? != 1 ]
24 then # exit status must be 0 or 2 (trailing garbage warning)
25 cat $tmp1
26 exit 0
27 fi
26 fi 28 fi
27} 29}
28 30
31try_decompress()
32{
33 for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
34 do
35 pos=${pos%%:*}
36 tail -c+$pos "$img" | $3 > $tmp2 2> /dev/null
37 dump_config $tmp2
38 done
39}
40
29# Check invocation: 41# Check invocation:
30me=${0##*/} 42me=${0##*/}
31img=$1 43img=$1
@@ -35,18 +47,20 @@ then
35 exit 2 47 exit 2
36fi 48fi
37 49
50# Prepare temp files:
51tmp1=/tmp/ikconfig$$.1
52tmp2=/tmp/ikconfig$$.2
53trap "rm -f $tmp1 $tmp2" 0
54
38# Initial attempt for uncompressed images or objects: 55# Initial attempt for uncompressed images or objects:
39dump_config "$img" 56dump_config "$img"
40 57
41# That didn't work, so decompress and try again: 58# That didn't work, so retry after decompression.
42tmp=/tmp/ikconfig$$ 59try_decompress '\037\213\010' xy gunzip
43trap "rm -f $tmp" 0 60try_decompress '\3757zXZ\000' abcde unxz
44for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"` 61try_decompress 'BZh' xy bunzip2
45do 62try_decompress '\135\0\0\0' xxx unlzma
46 pos=${pos%%:*} 63try_decompress '\211\114\132' xy 'lzop -d'
47 tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
48 dump_config $tmp
49done
50 64
51# Bail out: 65# Bail out:
52echo "$me: Cannot find kernel config." >&2 66echo "$me: Cannot find kernel config." >&2
diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh
new file mode 100644
index 000000000000..520d16b1ffaf
--- /dev/null
+++ b/scripts/gcc-goto.sh
@@ -0,0 +1,5 @@
1#!/bin/sh
2# Test for gcc 'asm goto' suport
3# Copyright (C) 2010, Jason Baron <jbaron@redhat.com>
4
5echo "int main(void) { entry: asm goto (\"\"::::entry); return 0; }" | $@ -x c - -c -o /dev/null >/dev/null 2>&1 && echo "y"
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 5958fffb2114..b482f162a18a 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -1,4 +1,4 @@
1#!/bin/bash 1#!/bin/sh
2# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org> 2# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
3# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org> 3# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
4# 4#
@@ -105,9 +105,9 @@ list_parse() {
105# for links, devices etc the format differs. See gen_init_cpio for details 105# for links, devices etc the format differs. See gen_init_cpio for details
106parse() { 106parse() {
107 local location="$1" 107 local location="$1"
108 local name="${location/${srcdir}//}" 108 local name="/${location#${srcdir}}"
109 # change '//' into '/' 109 # change '//' into '/'
110 name="${name//\/\///}" 110 name=$(echo "$name" | sed -e 's://*:/:g')
111 local mode="$2" 111 local mode="$2"
112 local uid="$3" 112 local uid="$3"
113 local gid="$4" 113 local gid="$4"
@@ -117,8 +117,8 @@ parse() {
117 [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 117 [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
118 local str="${mode} ${uid} ${gid}" 118 local str="${mode} ${uid} ${gid}"
119 119
120 [ "${ftype}" == "invalid" ] && return 0 120 [ "${ftype}" = "invalid" ] && return 0
121 [ "${location}" == "${srcdir}" ] && return 0 121 [ "${location}" = "${srcdir}" ] && return 0
122 122
123 case "${ftype}" in 123 case "${ftype}" in
124 "file") 124 "file")
@@ -192,7 +192,7 @@ input_file() {
192 if [ -f "$1" ]; then 192 if [ -f "$1" ]; then
193 ${dep_list}header "$1" 193 ${dep_list}header "$1"
194 is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" 194 is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')"
195 if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then 195 if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then
196 cpio_file=$1 196 cpio_file=$1
197 echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" 197 echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed"
198 [ ! -z ${dep_list} ] && echo "$1" 198 [ ! -z ${dep_list} ] && echo "$1"
@@ -204,7 +204,7 @@ input_file() {
204 else 204 else
205 echo "$1 \\" 205 echo "$1 \\"
206 cat "$1" | while read type dir file perm ; do 206 cat "$1" | while read type dir file perm ; do
207 if [ "$type" == "file" ]; then 207 if [ "$type" = "file" ]; then
208 echo "$file \\"; 208 echo "$file \\";
209 fi 209 fi
210 done 210 done
@@ -226,7 +226,7 @@ cpio_list=
226output="/dev/stdout" 226output="/dev/stdout"
227output_file="" 227output_file=""
228is_cpio_compressed= 228is_cpio_compressed=
229compr="gzip -9 -f" 229compr="gzip -n -9 -f"
230 230
231arg="$1" 231arg="$1"
232case "$arg" in 232case "$arg" in
@@ -240,9 +240,11 @@ case "$arg" in
240 output_file="$1" 240 output_file="$1"
241 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" 241 cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
242 output=${cpio_list} 242 output=${cpio_list}
243 echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f" 243 echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f"
244 echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" 244 echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
245 echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" 245 echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
246 echo "$output_file" | grep -q "\.xz$" && \
247 compr="xz --check=crc32 --lzma2=dict=1MiB"
246 echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f" 248 echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
247 echo "$output_file" | grep -q "\.cpio$" && compr="cat" 249 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
248 shift 250 shift
@@ -282,11 +284,18 @@ while [ $# -gt 0 ]; do
282done 284done
283 285
284# If output_file is set we will generate cpio archive and compress it 286# If output_file is set we will generate cpio archive and compress it
285# we are carefull to delete tmp files 287# we are careful to delete tmp files
286if [ ! -z ${output_file} ]; then 288if [ ! -z ${output_file} ]; then
287 if [ -z ${cpio_file} ]; then 289 if [ -z ${cpio_file} ]; then
290 timestamp=
291 if test -n "$KBUILD_BUILD_TIMESTAMP"; then
292 timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)"
293 if test -n "$timestamp"; then
294 timestamp="-t $timestamp"
295 fi
296 fi
288 cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" 297 cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)"
289 usr/gen_init_cpio ${cpio_list} > ${cpio_tfile} 298 usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile}
290 else 299 else
291 cpio_tfile=${cpio_file} 300 cpio_tfile=${cpio_file}
292 fi 301 fi
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index e420fe440019..13d03cf05d95 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -28,9 +28,9 @@ $(obj)/keywords.c: $(obj)/keywords.gperf FORCE
28# flex 28# flex
29 29
30quiet_cmd_lex.c = FLEX $@ 30quiet_cmd_lex.c = FLEX $@
31 cmd_lex.c = flex -o$@ -d $< $(obj)/parse.h 31 cmd_lex.c = flex -o$@ -d $<
32 32
33$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h $(obj)/keywords.c FORCE 33$(obj)/lex.c: $(obj)/lex.l $(obj)/keywords.c FORCE
34 $(call if_changed,lex.c) 34 $(call if_changed,lex.c)
35 cp $@ $@_shipped 35 cp $@ $@_shipped
36 36
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index f99115ebe925..f9e75531ea03 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -53,12 +53,22 @@ static int nsyms;
53static struct symbol *expansion_trail; 53static struct symbol *expansion_trail;
54static struct symbol *visited_symbols; 54static struct symbol *visited_symbols;
55 55
56static const char *const symbol_type_name[] = { 56static const struct {
57 "normal", "typedef", "enum", "struct", "union" 57 int n;
58 const char *name;
59} symbol_types[] = {
60 [SYM_NORMAL] = { 0, NULL},
61 [SYM_TYPEDEF] = {'t', "typedef"},
62 [SYM_ENUM] = {'e', "enum"},
63 [SYM_STRUCT] = {'s', "struct"},
64 [SYM_UNION] = {'u', "union"},
65 [SYM_ENUM_CONST] = {'E', "enum constant"},
58}; 66};
59 67
60static int equal_list(struct string_list *a, struct string_list *b); 68static int equal_list(struct string_list *a, struct string_list *b);
61static void print_list(FILE * f, struct string_list *list); 69static void print_list(FILE * f, struct string_list *list);
70static struct string_list *concat_list(struct string_list *start, ...);
71static struct string_list *mk_node(const char *string);
62static void print_location(void); 72static void print_location(void);
63static void print_type_name(enum symbol_type type, const char *name); 73static void print_type_name(enum symbol_type type, const char *name);
64 74
@@ -140,14 +150,20 @@ static unsigned long crc32(const char *s)
140 150
141static enum symbol_type map_to_ns(enum symbol_type t) 151static enum symbol_type map_to_ns(enum symbol_type t)
142{ 152{
143 if (t == SYM_TYPEDEF) 153 switch (t) {
144 t = SYM_NORMAL; 154 case SYM_ENUM_CONST:
145 else if (t == SYM_UNION) 155 case SYM_NORMAL:
146 t = SYM_STRUCT; 156 case SYM_TYPEDEF:
157 return SYM_NORMAL;
158 case SYM_ENUM:
159 case SYM_STRUCT:
160 case SYM_UNION:
161 return SYM_STRUCT;
162 }
147 return t; 163 return t;
148} 164}
149 165
150struct symbol *find_symbol(const char *name, enum symbol_type ns) 166struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact)
151{ 167{
152 unsigned long h = crc32(name) % HASH_BUCKETS; 168 unsigned long h = crc32(name) % HASH_BUCKETS;
153 struct symbol *sym; 169 struct symbol *sym;
@@ -158,6 +174,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns)
158 sym->is_declared) 174 sym->is_declared)
159 break; 175 break;
160 176
177 if (exact && sym && sym->type != ns)
178 return NULL;
161 return sym; 179 return sym;
162} 180}
163 181
@@ -180,10 +198,47 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,
180 struct string_list *defn, int is_extern, 198 struct string_list *defn, int is_extern,
181 int is_reference) 199 int is_reference)
182{ 200{
183 unsigned long h = crc32(name) % HASH_BUCKETS; 201 unsigned long h;
184 struct symbol *sym; 202 struct symbol *sym;
185 enum symbol_status status = STATUS_UNCHANGED; 203 enum symbol_status status = STATUS_UNCHANGED;
204 /* The parser adds symbols in the order their declaration completes,
205 * so it is safe to store the value of the previous enum constant in
206 * a static variable.
207 */
208 static int enum_counter;
209 static struct string_list *last_enum_expr;
210
211 if (type == SYM_ENUM_CONST) {
212 if (defn) {
213 free_list(last_enum_expr, NULL);
214 last_enum_expr = copy_list_range(defn, NULL);
215 enum_counter = 1;
216 } else {
217 struct string_list *expr;
218 char buf[20];
219
220 snprintf(buf, sizeof(buf), "%d", enum_counter++);
221 if (last_enum_expr) {
222 expr = copy_list_range(last_enum_expr, NULL);
223 defn = concat_list(mk_node("("),
224 expr,
225 mk_node(")"),
226 mk_node("+"),
227 mk_node(buf), NULL);
228 } else {
229 defn = mk_node(buf);
230 }
231 }
232 } else if (type == SYM_ENUM) {
233 free_list(last_enum_expr, NULL);
234 last_enum_expr = NULL;
235 enum_counter = 0;
236 if (!name)
237 /* Anonymous enum definition, nothing more to do */
238 return NULL;
239 }
186 240
241 h = crc32(name) % HASH_BUCKETS;
187 for (sym = symtab[h]; sym; sym = sym->hash_next) { 242 for (sym = symtab[h]; sym; sym = sym->hash_next) {
188 if (map_to_ns(sym->type) == map_to_ns(type) && 243 if (map_to_ns(sym->type) == map_to_ns(type) &&
189 strcmp(name, sym->name) == 0) { 244 strcmp(name, sym->name) == 0) {
@@ -247,8 +302,12 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,
247 sym->is_override = 0; 302 sym->is_override = 0;
248 303
249 if (flag_debug) { 304 if (flag_debug) {
250 fprintf(debugfile, "Defn for %s %s == <", 305 if (symbol_types[type].name)
251 symbol_type_name[type], name); 306 fprintf(debugfile, "Defn for %s %s == <",
307 symbol_types[type].name, name);
308 else
309 fprintf(debugfile, "Defn for type%d %s == <",
310 type, name);
252 if (is_extern) 311 if (is_extern)
253 fputs("extern ", debugfile); 312 fputs("extern ", debugfile);
254 print_list(debugfile, defn); 313 print_list(debugfile, defn);
@@ -288,6 +347,35 @@ void free_list(struct string_list *s, struct string_list *e)
288 } 347 }
289} 348}
290 349
350static struct string_list *mk_node(const char *string)
351{
352 struct string_list *newnode;
353
354 newnode = xmalloc(sizeof(*newnode));
355 newnode->string = xstrdup(string);
356 newnode->tag = SYM_NORMAL;
357 newnode->next = NULL;
358
359 return newnode;
360}
361
362static struct string_list *concat_list(struct string_list *start, ...)
363{
364 va_list ap;
365 struct string_list *n, *n2;
366
367 if (!start)
368 return NULL;
369 for (va_start(ap, start); (n = va_arg(ap, struct string_list *));) {
370 for (n2 = n; n2->next; n2 = n2->next)
371 ;
372 n2->next = start;
373 start = n;
374 }
375 va_end(ap);
376 return start;
377}
378
291struct string_list *copy_node(struct string_list *node) 379struct string_list *copy_node(struct string_list *node)
292{ 380{
293 struct string_list *newnode; 381 struct string_list *newnode;
@@ -299,6 +387,22 @@ struct string_list *copy_node(struct string_list *node)
299 return newnode; 387 return newnode;
300} 388}
301 389
390struct string_list *copy_list_range(struct string_list *start,
391 struct string_list *end)
392{
393 struct string_list *res, *n;
394
395 if (start == end)
396 return NULL;
397 n = res = copy_node(start);
398 for (start = start->next; start != end; start = start->next) {
399 n->next = copy_node(start);
400 n = n->next;
401 }
402 n->next = NULL;
403 return res;
404}
405
302static int equal_list(struct string_list *a, struct string_list *b) 406static int equal_list(struct string_list *a, struct string_list *b)
303{ 407{
304 while (a && b) { 408 while (a && b) {
@@ -346,8 +450,8 @@ static struct string_list *read_node(FILE *f)
346 if (node.string[1] == '#') { 450 if (node.string[1] == '#') {
347 int n; 451 int n;
348 452
349 for (n = 0; n < ARRAY_SIZE(symbol_type_name); n++) { 453 for (n = 0; n < ARRAY_SIZE(symbol_types); n++) {
350 if (node.string[0] == symbol_type_name[n][0]) { 454 if (node.string[0] == symbol_types[n].n) {
351 node.tag = n; 455 node.tag = n;
352 node.string += 2; 456 node.string += 2;
353 return copy_node(&node); 457 return copy_node(&node);
@@ -397,8 +501,8 @@ static void read_reference(FILE *f)
397 501
398static void print_node(FILE * f, struct string_list *list) 502static void print_node(FILE * f, struct string_list *list)
399{ 503{
400 if (list->tag != SYM_NORMAL) { 504 if (symbol_types[list->tag].n) {
401 putc(symbol_type_name[list->tag][0], f); 505 putc(symbol_types[list->tag].n, f);
402 putc('#', f); 506 putc('#', f);
403 } 507 }
404 fputs(list->string, f); 508 fputs(list->string, f);
@@ -468,8 +572,9 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
468 crc = partial_crc32_one(' ', crc); 572 crc = partial_crc32_one(' ', crc);
469 break; 573 break;
470 574
575 case SYM_ENUM_CONST:
471 case SYM_TYPEDEF: 576 case SYM_TYPEDEF:
472 subsym = find_symbol(cur->string, cur->tag); 577 subsym = find_symbol(cur->string, cur->tag, 0);
473 /* FIXME: Bad reference files can segfault here. */ 578 /* FIXME: Bad reference files can segfault here. */
474 if (subsym->expansion_trail) { 579 if (subsym->expansion_trail) {
475 if (flag_dump_defs) 580 if (flag_dump_defs)
@@ -486,55 +591,30 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
486 case SYM_STRUCT: 591 case SYM_STRUCT:
487 case SYM_UNION: 592 case SYM_UNION:
488 case SYM_ENUM: 593 case SYM_ENUM:
489 subsym = find_symbol(cur->string, cur->tag); 594 subsym = find_symbol(cur->string, cur->tag, 0);
490 if (!subsym) { 595 if (!subsym) {
491 struct string_list *n, *t = NULL; 596 struct string_list *n;
492 597
493 error_with_pos("expand undefined %s %s", 598 error_with_pos("expand undefined %s %s",
494 symbol_type_name[cur->tag], 599 symbol_types[cur->tag].name,
495 cur->string); 600 cur->string);
496 601 n = concat_list(mk_node
497 n = xmalloc(sizeof(*n)); 602 (symbol_types[cur->tag].name),
498 n->string = xstrdup(symbol_type_name[cur->tag]); 603 mk_node(cur->string),
499 n->tag = SYM_NORMAL; 604 mk_node("{"),
500 n->next = t; 605 mk_node("UNKNOWN"),
501 t = n; 606 mk_node("}"), NULL);
502
503 n = xmalloc(sizeof(*n));
504 n->string = xstrdup(cur->string);
505 n->tag = SYM_NORMAL;
506 n->next = t;
507 t = n;
508
509 n = xmalloc(sizeof(*n));
510 n->string = xstrdup("{");
511 n->tag = SYM_NORMAL;
512 n->next = t;
513 t = n;
514
515 n = xmalloc(sizeof(*n));
516 n->string = xstrdup("UNKNOWN");
517 n->tag = SYM_NORMAL;
518 n->next = t;
519 t = n;
520
521 n = xmalloc(sizeof(*n));
522 n->string = xstrdup("}");
523 n->tag = SYM_NORMAL;
524 n->next = t;
525 t = n;
526
527 subsym = 607 subsym =
528 add_symbol(cur->string, cur->tag, n, 0); 608 add_symbol(cur->string, cur->tag, n, 0);
529 } 609 }
530 if (subsym->expansion_trail) { 610 if (subsym->expansion_trail) {
531 if (flag_dump_defs) { 611 if (flag_dump_defs) {
532 fprintf(debugfile, "%s %s ", 612 fprintf(debugfile, "%s %s ",
533 symbol_type_name[cur->tag], 613 symbol_types[cur->tag].name,
534 cur->string); 614 cur->string);
535 } 615 }
536 616
537 crc = partial_crc32(symbol_type_name[cur->tag], 617 crc = partial_crc32(symbol_types[cur->tag].name,
538 crc); 618 crc);
539 crc = partial_crc32_one(' ', crc); 619 crc = partial_crc32_one(' ', crc);
540 crc = partial_crc32(cur->string, crc); 620 crc = partial_crc32(cur->string, crc);
@@ -565,7 +645,7 @@ void export_symbol(const char *name)
565{ 645{
566 struct symbol *sym; 646 struct symbol *sym;
567 647
568 sym = find_symbol(name, SYM_NORMAL); 648 sym = find_symbol(name, SYM_NORMAL, 0);
569 if (!sym) 649 if (!sym)
570 error_with_pos("export undefined symbol %s", name); 650 error_with_pos("export undefined symbol %s", name);
571 else { 651 else {
@@ -624,8 +704,8 @@ static void print_location(void)
624 704
625static void print_type_name(enum symbol_type type, const char *name) 705static void print_type_name(enum symbol_type type, const char *name)
626{ 706{
627 if (type != SYM_NORMAL) 707 if (symbol_types[type].name)
628 fprintf(stderr, "%s %s", symbol_type_name[type], name); 708 fprintf(stderr, "%s %s", symbol_types[type].name, name);
629 else 709 else
630 fprintf(stderr, "%s", name); 710 fprintf(stderr, "%s", name);
631} 711}
@@ -771,8 +851,8 @@ int main(int argc, char **argv)
771 851
772 if (sym->is_override) 852 if (sym->is_override)
773 fputs("override ", dumpfile); 853 fputs("override ", dumpfile);
774 if (sym->type != SYM_NORMAL) { 854 if (symbol_types[sym->type].n) {
775 putc(symbol_type_name[sym->type][0], dumpfile); 855 putc(symbol_types[sym->type].n, dumpfile);
776 putc('#', dumpfile); 856 putc('#', dumpfile);
777 } 857 }
778 fputs(sym->name, dumpfile); 858 fputs(sym->name, dumpfile);
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index 25c4d40cefc1..7ec52ae3846a 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -26,7 +26,8 @@
26#include <stdio.h> 26#include <stdio.h>
27 27
28enum symbol_type { 28enum symbol_type {
29 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION 29 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION,
30 SYM_ENUM_CONST
30}; 31};
31 32
32enum symbol_status { 33enum symbol_status {
@@ -58,7 +59,7 @@ typedef struct string_list **yystype;
58extern int cur_line; 59extern int cur_line;
59extern char *cur_filename; 60extern char *cur_filename;
60 61
61struct symbol *find_symbol(const char *name, enum symbol_type ns); 62struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
62struct symbol *add_symbol(const char *name, enum symbol_type type, 63struct symbol *add_symbol(const char *name, enum symbol_type type,
63 struct string_list *defn, int is_extern); 64 struct string_list *defn, int is_extern);
64void export_symbol(const char *); 65void export_symbol(const char *);
@@ -66,6 +67,8 @@ void export_symbol(const char *);
66void free_node(struct string_list *list); 67void free_node(struct string_list *list);
67void free_list(struct string_list *s, struct string_list *e); 68void free_list(struct string_list *s, struct string_list *e);
68struct string_list *copy_node(struct string_list *); 69struct string_list *copy_node(struct string_list *);
70struct string_list *copy_list_range(struct string_list *start,
71 struct string_list *end);
69 72
70int yylex(void); 73int yylex(void);
71int yyparse(void); 74int yyparse(void);
diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.c_shipped
index 2ac23bcca5b5..af4939041e4b 100644
--- a/scripts/genksyms/lex.c_shipped
+++ b/scripts/genksyms/lex.c_shipped
@@ -79,6 +79,7 @@ typedef int flex_int32_t;
79typedef unsigned char flex_uint8_t; 79typedef unsigned char flex_uint8_t;
80typedef unsigned short int flex_uint16_t; 80typedef unsigned short int flex_uint16_t;
81typedef unsigned int flex_uint32_t; 81typedef unsigned int flex_uint32_t;
82#endif /* ! C99 */
82 83
83/* Limits of integral types. */ 84/* Limits of integral types. */
84#ifndef INT8_MIN 85#ifndef INT8_MIN
@@ -109,8 +110,6 @@ typedef unsigned int flex_uint32_t;
109#define UINT32_MAX (4294967295U) 110#define UINT32_MAX (4294967295U)
110#endif 111#endif
111 112
112#endif /* ! C99 */
113
114#endif /* ! FLEXINT_H */ 113#endif /* ! FLEXINT_H */
115 114
116/* %endif */ 115/* %endif */
@@ -456,16 +455,16 @@ struct yy_trans_info
456 flex_int32_t yy_verify; 455 flex_int32_t yy_verify;
457 flex_int32_t yy_nxt; 456 flex_int32_t yy_nxt;
458 }; 457 };
459static yyconst flex_int16_t yy_accept[76] = 458static yyconst flex_int16_t yy_accept[73] =
460 { 0, 459 { 0,
461 0, 0, 0, 0, 14, 12, 4, 3, 12, 7, 460 0, 0, 14, 12, 4, 3, 12, 7, 12, 12,
462 12, 12, 7, 12, 12, 12, 12, 12, 9, 9, 461 12, 12, 12, 9, 9, 12, 12, 7, 12, 12,
463 12, 12, 12, 4, 0, 5, 0, 7, 0, 6, 462 4, 0, 5, 0, 7, 8, 0, 6, 0, 0,
464 0, 0, 0, 0, 0, 0, 2, 8, 10, 10, 463 10, 10, 9, 0, 0, 9, 9, 0, 9, 0,
465 9, 0, 0, 9, 9, 0, 9, 0, 0, 11, 464 0, 0, 0, 2, 0, 0, 11, 0, 10, 0,
466 0, 0, 0, 10, 0, 10, 9, 9, 0, 0, 465 10, 9, 9, 0, 0, 0, 10, 10, 0, 0,
467 0, 0, 0, 0, 0, 10, 10, 0, 0, 0, 466 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
468 0, 0, 0, 1, 0 467 1, 0
469 } ; 468 } ;
470 469
471static yyconst flex_int32_t yy_ec[256] = 470static yyconst flex_int32_t yy_ec[256] =
@@ -507,108 +506,104 @@ static yyconst flex_int32_t yy_meta[29] =
507 8, 7, 3, 3, 3, 1, 3, 1 506 8, 7, 3, 3, 3, 1, 3, 1
508 } ; 507 } ;
509 508
510static yyconst flex_int16_t yy_base[88] = 509static yyconst flex_int16_t yy_base[85] =
511 { 0, 510 { 0,
512 0, 147, 21, 140, 145, 284, 39, 284, 26, 0, 511 0, 145, 150, 266, 27, 266, 25, 0, 131, 23,
513 32, 126, 40, 44, 115, 35, 36, 46, 50, 53, 512 23, 16, 23, 39, 31, 25, 39, 60, 22, 65,
514 39, 61, 54, 79, 65, 284, 0, 0, 66, 284, 513 57, 43, 266, 0, 0, 266, 61, 266, 0, 128,
515 0, 119, 79, 75, 123, 104, 284, 284, 107, 0, 514 74, 0, 113, 59, 62, 113, 52, 0, 0, 72,
516 79, 73, 76, 76, 66, 0, 0, 85, 86, 284, 515 66, 110, 100, 266, 73, 74, 266, 70, 266, 90,
517 133, 83, 91, 284, 99, 147, 284, 114, 122, 70, 516 103, 266, 84, 129, 108, 113, 143, 266, 107, 66,
518 107, 141, 172, 151, 135, 181, 284, 137, 114, 157, 517 118, 137, 168, 120, 80, 91, 145, 143, 83, 41,
519 149, 48, 45, 284, 284, 208, 214, 222, 230, 238, 518 266, 266, 190, 196, 204, 212, 220, 228, 232, 237,
520 246, 250, 255, 256, 261, 267, 275 519 238, 243, 249, 257
521 } ; 520 } ;
522 521
523static yyconst flex_int16_t yy_def[88] = 522static yyconst flex_int16_t yy_def[85] =
524 { 0, 523 { 0,
525 75, 1, 1, 3, 75, 75, 75, 75, 76, 77, 524 72, 1, 72, 72, 72, 72, 73, 74, 72, 72,
526 78, 75, 77, 79, 75, 75, 75, 75, 75, 19, 525 75, 72, 72, 72, 14, 72, 72, 74, 72, 76,
527 75, 75, 75, 75, 76, 75, 80, 77, 78, 75, 526 72, 73, 72, 77, 74, 72, 75, 72, 78, 72,
528 81, 75, 76, 78, 79, 79, 75, 75, 75, 39, 527 72, 31, 14, 79, 80, 72, 72, 81, 15, 73,
529 19, 82, 83, 75, 75, 84, 20, 76, 78, 75, 528 75, 76, 76, 72, 73, 75, 72, 82, 72, 72,
530 79, 51, 85, 75, 75, 75, 75, 84, 79, 51, 529 72, 72, 81, 76, 54, 72, 72, 72, 76, 54,
531 79, 79, 79, 51, 75, 75, 75, 86, 79, 63, 530 76, 76, 76, 54, 83, 76, 63, 83, 84, 84,
532 86, 87, 87, 75, 0, 75, 75, 75, 75, 75, 531 72, 0, 72, 72, 72, 72, 72, 72, 72, 72,
533 75, 75, 75, 75, 75, 75, 75 532 72, 72, 72, 72
534 } ; 533 } ;
535 534
536static yyconst flex_int16_t yy_nxt[313] = 535static yyconst flex_int16_t yy_nxt[295] =
537 { 0, 536 { 0,
538 6, 7, 8, 7, 9, 6, 10, 6, 6, 11, 537 4, 5, 6, 5, 7, 4, 8, 9, 10, 11,
539 6, 6, 12, 6, 6, 6, 6, 6, 6, 10, 538 9, 12, 13, 14, 15, 15, 16, 9, 17, 8,
540 10, 10, 13, 10, 10, 6, 10, 6, 15, 16, 539 8, 8, 18, 8, 8, 4, 8, 19, 21, 23,
541 26, 15, 17, 18, 19, 20, 20, 21, 15, 22, 540 21, 26, 28, 26, 26, 30, 31, 31, 31, 26,
542 24, 30, 24, 38, 33, 36, 37, 74, 23, 34, 541 26, 26, 26, 71, 39, 39, 39, 23, 29, 26,
543 74, 27, 38, 38, 38, 38, 38, 31, 32, 39, 542 24, 32, 33, 33, 34, 72, 26, 26, 21, 35,
544 39, 39, 40, 41, 41, 42, 47, 47, 47, 26, 543 21, 36, 37, 38, 40, 36, 43, 44, 24, 41,
545 43, 38, 44, 45, 46, 30, 44, 75, 38, 38, 544 28, 32, 50, 50, 52, 28, 23, 23, 52, 35,
546 24, 38, 24, 26, 30, 40, 55, 55, 57, 26, 545 56, 56, 44, 28, 42, 71, 29, 31, 31, 31,
547 27, 31, 57, 43, 35, 30, 64, 64, 64, 57, 546 42, 29, 59, 44, 48, 49, 49, 24, 24, 29,
548 547
549 31, 65, 65, 75, 27, 36, 37, 35, 59, 37, 548 49, 43, 44, 51, 51, 51, 36, 37, 59, 44,
550 27, 31, 56, 56, 56, 59, 37, 51, 52, 52, 549 36, 65, 44, 54, 55, 55, 51, 51, 51, 59,
551 39, 39, 39, 59, 37, 37, 68, 53, 54, 54, 550 44, 64, 64, 64, 58, 58, 57, 57, 57, 58,
552 69, 50, 38, 54, 59, 37, 44, 45, 32, 37, 551 59, 44, 42, 64, 64, 64, 52, 72, 59, 44,
553 44, 35, 59, 37, 75, 14, 60, 60, 66, 66, 552 47, 66, 60, 60, 42, 44, 59, 69, 26, 72,
554 66, 37, 14, 72, 75, 61, 62, 63, 59, 61, 553 20, 61, 62, 63, 72, 61, 57, 57, 57, 66,
555 56, 56, 56, 69, 64, 64, 64, 69, 67, 67, 554 72, 72, 72, 66, 49, 49, 72, 61, 62, 49,
556 75, 75, 75, 67, 37, 35, 75, 75, 75, 61, 555 44, 61, 72, 72, 72, 72, 72, 72, 72, 72,
557 62, 75, 75, 61, 75, 70, 70, 70, 75, 75, 556 72, 67, 67, 67, 72, 72, 72, 67, 67, 67,
558 75, 70, 70, 70, 66, 66, 66, 75, 75, 75, 557 22, 22, 22, 22, 22, 22, 22, 22, 25, 72,
559 558
560 75, 75, 54, 54, 75, 75, 75, 54, 25, 25, 559 72, 25, 25, 25, 27, 27, 27, 27, 27, 27,
561 25, 25, 25, 25, 25, 25, 28, 75, 75, 28, 560 27, 27, 42, 42, 42, 42, 42, 42, 42, 42,
562 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 561 45, 72, 45, 45, 45, 45, 45, 45, 46, 72,
563 35, 35, 35, 35, 35, 35, 35, 35, 48, 75, 562 46, 46, 46, 46, 46, 46, 34, 34, 72, 34,
564 48, 48, 48, 48, 48, 48, 49, 75, 49, 49, 563 51, 72, 51, 53, 53, 53, 57, 72, 57, 68,
565 49, 49, 49, 49, 42, 42, 75, 42, 56, 75, 564 68, 68, 68, 68, 68, 68, 68, 70, 70, 70,
566 56, 58, 58, 58, 66, 75, 66, 71, 71, 71, 565 70, 70, 70, 70, 70, 3, 72, 72, 72, 72,
567 71, 71, 71, 71, 71, 73, 73, 73, 73, 73, 566 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
568 73, 73, 73, 5, 75, 75, 75, 75, 75, 75, 567 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
569 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 568 72, 72, 72, 72
570 569
571 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
572 75, 75
573 } ; 570 } ;
574 571
575static yyconst flex_int16_t yy_chk[313] = 572static yyconst flex_int16_t yy_chk[295] =
576 { 0, 573 { 0,
577 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 574 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
578 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 575 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
579 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 576 1, 1, 1, 1, 1, 1, 1, 1, 5, 7,
580 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 577 5, 10, 11, 12, 12, 13, 13, 13, 13, 19,
581 7, 11, 7, 16, 13, 14, 14, 73, 3, 13, 578 10, 16, 16, 70, 15, 15, 15, 22, 11, 19,
582 72, 9, 16, 17, 17, 21, 21, 11, 18, 18, 579 7, 14, 14, 14, 14, 15, 17, 17, 21, 14,
583 18, 18, 19, 19, 19, 19, 20, 20, 20, 25, 580 21, 14, 14, 14, 18, 14, 20, 20, 22, 18,
584 19, 23, 19, 19, 19, 29, 19, 20, 22, 22, 581 27, 34, 35, 35, 37, 41, 40, 45, 37, 34,
585 24, 23, 24, 33, 34, 42, 43, 43, 45, 48, 582 48, 48, 65, 46, 65, 69, 27, 31, 31, 31,
586 25, 29, 45, 42, 60, 49, 52, 52, 52, 44, 583 60, 41, 66, 66, 31, 31, 31, 40, 45, 46,
587 584
588 34, 53, 53, 41, 33, 36, 36, 52, 61, 61, 585 31, 43, 43, 50, 50, 50, 53, 53, 59, 59,
589 48, 49, 55, 55, 55, 69, 69, 36, 36, 36, 586 53, 59, 42, 43, 43, 43, 51, 51, 51, 61,
590 39, 39, 39, 59, 59, 35, 59, 39, 39, 39, 587 61, 55, 55, 55, 51, 51, 56, 56, 56, 51,
591 61, 32, 15, 39, 51, 51, 58, 58, 12, 68, 588 54, 54, 55, 64, 64, 64, 36, 33, 62, 62,
592 58, 68, 62, 62, 5, 4, 51, 51, 65, 65, 589 30, 61, 54, 54, 64, 68, 67, 68, 9, 3,
593 65, 71, 2, 71, 0, 51, 51, 51, 70, 51, 590 2, 54, 54, 54, 0, 54, 57, 57, 57, 62,
594 56, 56, 56, 62, 64, 64, 64, 62, 56, 56, 591 0, 0, 0, 62, 57, 57, 0, 67, 67, 57,
595 0, 0, 0, 56, 63, 64, 0, 0, 0, 70, 592 63, 67, 0, 0, 0, 0, 0, 0, 0, 0,
596 70, 0, 0, 70, 0, 63, 63, 63, 0, 0, 593 0, 63, 63, 63, 0, 0, 0, 63, 63, 63,
597 0, 63, 63, 63, 66, 66, 66, 0, 0, 0, 594 73, 73, 73, 73, 73, 73, 73, 73, 74, 0,
598 595
599 0, 0, 66, 66, 0, 0, 0, 66, 76, 76, 596 0, 74, 74, 74, 75, 75, 75, 75, 75, 75,
600 76, 76, 76, 76, 76, 76, 77, 0, 0, 77, 597 75, 75, 76, 76, 76, 76, 76, 76, 76, 76,
601 77, 77, 78, 78, 78, 78, 78, 78, 78, 78, 598 77, 0, 77, 77, 77, 77, 77, 77, 78, 0,
602 79, 79, 79, 79, 79, 79, 79, 79, 80, 0, 599 78, 78, 78, 78, 78, 78, 79, 79, 0, 79,
603 80, 80, 80, 80, 80, 80, 81, 0, 81, 81, 600 80, 0, 80, 81, 81, 81, 82, 0, 82, 83,
604 81, 81, 81, 81, 82, 82, 0, 82, 83, 0, 601 83, 83, 83, 83, 83, 83, 83, 84, 84, 84,
605 83, 84, 84, 84, 85, 0, 85, 86, 86, 86, 602 84, 84, 84, 84, 84, 72, 72, 72, 72, 72,
606 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 603 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
607 87, 87, 87, 75, 75, 75, 75, 75, 75, 75, 604 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
608 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 605 72, 72, 72, 72
609 606
610 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
611 75, 75
612 } ; 607 } ;
613 608
614static yy_state_type yy_last_accepting_state; 609static yy_state_type yy_last_accepting_state;
@@ -619,8 +614,8 @@ int yy_flex_debug = 1;
619 614
620static yyconst flex_int16_t yy_rule_linenum[13] = 615static yyconst flex_int16_t yy_rule_linenum[13] =
621 { 0, 616 { 0,
622 71, 72, 73, 76, 79, 80, 81, 87, 88, 89, 617 67, 68, 69, 72, 75, 76, 77, 83, 84, 85,
623 91, 94 618 87, 90
624 } ; 619 } ;
625 620
626/* The intent behind this definition is that it'll catch 621/* The intent behind this definition is that it'll catch
@@ -667,15 +662,11 @@ char *yytext;
667 and then we categorize those basic tokens in the second stage. */ 662 and then we categorize those basic tokens in the second stage. */
668#define YY_DECL static int yylex1(void) 663#define YY_DECL static int yylex1(void)
669 664
670/* Version 2 checksumming does proper tokenization; version 1 wasn't
671 quite so pedantic. */
672
673/* We don't do multiple input files. */ 665/* We don't do multiple input files. */
674#define YY_NO_INPUT 1 666#define YY_NO_INPUT 1
675#line 676 "scripts/genksyms/lex.c" 667#line 668 "scripts/genksyms/lex.c"
676 668
677#define INITIAL 0 669#define INITIAL 0
678#define V2_TOKENS 1
679 670
680#ifndef YY_NO_UNISTD_H 671#ifndef YY_NO_UNISTD_H
681/* Special case for "unistd.h", since it is non-ANSI. We include it way 672/* Special case for "unistd.h", since it is non-ANSI. We include it way
@@ -808,7 +799,7 @@ static int input (void );
808 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 799 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
809 { \ 800 { \
810 int c = '*'; \ 801 int c = '*'; \
811 size_t n; \ 802 int n; \
812 for ( n = 0; n < max_size && \ 803 for ( n = 0; n < max_size && \
813 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 804 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
814 buf[n] = (char) c; \ 805 buf[n] = (char) c; \
@@ -918,12 +909,12 @@ YY_DECL
918 register int yy_act; 909 register int yy_act;
919 910
920/* %% [7.0] user's declarations go here */ 911/* %% [7.0] user's declarations go here */
921#line 67 "scripts/genksyms/lex.l" 912#line 63 "scripts/genksyms/lex.l"
922 913
923 914
924 915
925 /* Keep track of our location in the original source files. */ 916 /* Keep track of our location in the original source files. */
926#line 927 "scripts/genksyms/lex.c" 917#line 918 "scripts/genksyms/lex.c"
927 918
928 if ( !(yy_init) ) 919 if ( !(yy_init) )
929 { 920 {
@@ -987,13 +978,13 @@ yy_match:
987 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 978 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
988 { 979 {
989 yy_current_state = (int) yy_def[yy_current_state]; 980 yy_current_state = (int) yy_def[yy_current_state];
990 if ( yy_current_state >= 76 ) 981 if ( yy_current_state >= 73 )
991 yy_c = yy_meta[(unsigned int) yy_c]; 982 yy_c = yy_meta[(unsigned int) yy_c];
992 } 983 }
993 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 984 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
994 ++yy_cp; 985 ++yy_cp;
995 } 986 }
996 while ( yy_base[yy_current_state] != 284 ); 987 while ( yy_base[yy_current_state] != 266 );
997 988
998yy_find_action: 989yy_find_action:
999/* %% [10.0] code to find the action number goes here */ 990/* %% [10.0] code to find the action number goes here */
@@ -1041,42 +1032,42 @@ do_action: /* This label is used only to access EOF actions. */
1041case 1: 1032case 1:
1042/* rule 1 can match eol */ 1033/* rule 1 can match eol */
1043YY_RULE_SETUP 1034YY_RULE_SETUP
1044#line 71 "scripts/genksyms/lex.l" 1035#line 67 "scripts/genksyms/lex.l"
1045return FILENAME; 1036return FILENAME;
1046 YY_BREAK 1037 YY_BREAK
1047case 2: 1038case 2:
1048/* rule 2 can match eol */ 1039/* rule 2 can match eol */
1049YY_RULE_SETUP 1040YY_RULE_SETUP
1050#line 72 "scripts/genksyms/lex.l" 1041#line 68 "scripts/genksyms/lex.l"
1051cur_line++; 1042cur_line++;
1052 YY_BREAK 1043 YY_BREAK
1053case 3: 1044case 3:
1054/* rule 3 can match eol */ 1045/* rule 3 can match eol */
1055YY_RULE_SETUP 1046YY_RULE_SETUP
1056#line 73 "scripts/genksyms/lex.l" 1047#line 69 "scripts/genksyms/lex.l"
1057cur_line++; 1048cur_line++;
1058 YY_BREAK 1049 YY_BREAK
1059/* Ignore all other whitespace. */ 1050/* Ignore all other whitespace. */
1060case 4: 1051case 4:
1061YY_RULE_SETUP 1052YY_RULE_SETUP
1062#line 76 "scripts/genksyms/lex.l" 1053#line 72 "scripts/genksyms/lex.l"
1063; 1054;
1064 YY_BREAK 1055 YY_BREAK
1065case 5: 1056case 5:
1066/* rule 5 can match eol */ 1057/* rule 5 can match eol */
1067YY_RULE_SETUP 1058YY_RULE_SETUP
1068#line 79 "scripts/genksyms/lex.l" 1059#line 75 "scripts/genksyms/lex.l"
1069return STRING; 1060return STRING;
1070 YY_BREAK 1061 YY_BREAK
1071case 6: 1062case 6:
1072/* rule 6 can match eol */ 1063/* rule 6 can match eol */
1073YY_RULE_SETUP 1064YY_RULE_SETUP
1074#line 80 "scripts/genksyms/lex.l" 1065#line 76 "scripts/genksyms/lex.l"
1075return CHAR; 1066return CHAR;
1076 YY_BREAK 1067 YY_BREAK
1077case 7: 1068case 7:
1078YY_RULE_SETUP 1069YY_RULE_SETUP
1079#line 81 "scripts/genksyms/lex.l" 1070#line 77 "scripts/genksyms/lex.l"
1080return IDENT; 1071return IDENT;
1081 YY_BREAK 1072 YY_BREAK
1082/* The Pedant requires that the other C multi-character tokens be 1073/* The Pedant requires that the other C multi-character tokens be
@@ -1085,38 +1076,37 @@ return IDENT;
1085 around them properly. */ 1076 around them properly. */
1086case 8: 1077case 8:
1087YY_RULE_SETUP 1078YY_RULE_SETUP
1088#line 87 "scripts/genksyms/lex.l" 1079#line 83 "scripts/genksyms/lex.l"
1089return OTHER; 1080return OTHER;
1090 YY_BREAK 1081 YY_BREAK
1091case 9: 1082case 9:
1092YY_RULE_SETUP 1083YY_RULE_SETUP
1093#line 88 "scripts/genksyms/lex.l" 1084#line 84 "scripts/genksyms/lex.l"
1094return INT; 1085return INT;
1095 YY_BREAK 1086 YY_BREAK
1096case 10: 1087case 10:
1097YY_RULE_SETUP 1088YY_RULE_SETUP
1098#line 89 "scripts/genksyms/lex.l" 1089#line 85 "scripts/genksyms/lex.l"
1099return REAL; 1090return REAL;
1100 YY_BREAK 1091 YY_BREAK
1101case 11: 1092case 11:
1102YY_RULE_SETUP 1093YY_RULE_SETUP
1103#line 91 "scripts/genksyms/lex.l" 1094#line 87 "scripts/genksyms/lex.l"
1104return DOTS; 1095return DOTS;
1105 YY_BREAK 1096 YY_BREAK
1106/* All other tokens are single characters. */ 1097/* All other tokens are single characters. */
1107case 12: 1098case 12:
1108YY_RULE_SETUP 1099YY_RULE_SETUP
1109#line 94 "scripts/genksyms/lex.l" 1100#line 90 "scripts/genksyms/lex.l"
1110return yytext[0]; 1101return yytext[0];
1111 YY_BREAK 1102 YY_BREAK
1112case 13: 1103case 13:
1113YY_RULE_SETUP 1104YY_RULE_SETUP
1114#line 97 "scripts/genksyms/lex.l" 1105#line 93 "scripts/genksyms/lex.l"
1115ECHO; 1106ECHO;
1116 YY_BREAK 1107 YY_BREAK
1117#line 1118 "scripts/genksyms/lex.c" 1108#line 1109 "scripts/genksyms/lex.c"
1118case YY_STATE_EOF(INITIAL): 1109case YY_STATE_EOF(INITIAL):
1119case YY_STATE_EOF(V2_TOKENS):
1120 yyterminate(); 1110 yyterminate();
1121 1111
1122 case YY_END_OF_BUFFER: 1112 case YY_END_OF_BUFFER:
@@ -1429,7 +1419,7 @@ static int yy_get_next_buffer (void)
1429 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1419 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1430 { 1420 {
1431 yy_current_state = (int) yy_def[yy_current_state]; 1421 yy_current_state = (int) yy_def[yy_current_state];
1432 if ( yy_current_state >= 76 ) 1422 if ( yy_current_state >= 73 )
1433 yy_c = yy_meta[(unsigned int) yy_c]; 1423 yy_c = yy_meta[(unsigned int) yy_c];
1434 } 1424 }
1435 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1425 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1462,11 +1452,11 @@ static int yy_get_next_buffer (void)
1462 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1452 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1463 { 1453 {
1464 yy_current_state = (int) yy_def[yy_current_state]; 1454 yy_current_state = (int) yy_def[yy_current_state];
1465 if ( yy_current_state >= 76 ) 1455 if ( yy_current_state >= 73 )
1466 yy_c = yy_meta[(unsigned int) yy_c]; 1456 yy_c = yy_meta[(unsigned int) yy_c];
1467 } 1457 }
1468 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1458 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1469 yy_is_jam = (yy_current_state == 75); 1459 yy_is_jam = (yy_current_state == 72);
1470 1460
1471 return yy_is_jam ? 0 : yy_current_state; 1461 return yy_is_jam ? 0 : yy_current_state;
1472} 1462}
@@ -2252,7 +2242,7 @@ void yyfree (void * ptr )
2252 2242
2253/* %ok-for-header */ 2243/* %ok-for-header */
2254 2244
2255#line 97 "scripts/genksyms/lex.l" 2245#line 93 "scripts/genksyms/lex.l"
2256 2246
2257 2247
2258 2248
@@ -2263,12 +2253,23 @@ void yyfree (void * ptr )
2263 2253
2264/* Macros to append to our phrase collection list. */ 2254/* Macros to append to our phrase collection list. */
2265 2255
2256/*
2257 * We mark any token, that that equals to a known enumerator, as
2258 * SYM_ENUM_CONST. The parser will change this for struct and union tags later,
2259 * the only problem is struct and union members:
2260 * enum e { a, b }; struct s { int a, b; }
2261 * but in this case, the only effect will be, that the ABI checksums become
2262 * more volatile, which is acceptable. Also, such collisions are quite rare,
2263 * so far it was only observed in include/linux/telephony.h.
2264 */
2266#define _APP(T,L) do { \ 2265#define _APP(T,L) do { \
2267 cur_node = next_node; \ 2266 cur_node = next_node; \
2268 next_node = xmalloc(sizeof(*next_node)); \ 2267 next_node = xmalloc(sizeof(*next_node)); \
2269 next_node->next = cur_node; \ 2268 next_node->next = cur_node; \
2270 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \ 2269 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
2271 cur_node->tag = SYM_NORMAL; \ 2270 cur_node->tag = \
2271 find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\
2272 SYM_ENUM_CONST : SYM_NORMAL ; \
2272 } while (0) 2273 } while (0)
2273 2274
2274#define APP _APP(yytext, yyleng) 2275#define APP _APP(yytext, yyleng)
@@ -2294,7 +2295,6 @@ yylex(void)
2294 2295
2295 if (lexstate == ST_NOTSTARTED) 2296 if (lexstate == ST_NOTSTARTED)
2296 { 2297 {
2297 BEGIN(V2_TOKENS);
2298 next_node = xmalloc(sizeof(*next_node)); 2298 next_node = xmalloc(sizeof(*next_node));
2299 next_node->next = NULL; 2299 next_node->next = NULL;
2300 lexstate = ST_NORMAL; 2300 lexstate = ST_NORMAL;
@@ -2347,8 +2347,8 @@ repeat:
2347 2347
2348 case STRUCT_KEYW: 2348 case STRUCT_KEYW:
2349 case UNION_KEYW: 2349 case UNION_KEYW:
2350 dont_want_brace_phrase = 3;
2351 case ENUM_KEYW: 2350 case ENUM_KEYW:
2351 dont_want_brace_phrase = 3;
2352 suppress_type_lookup = 2; 2352 suppress_type_lookup = 2;
2353 goto fini; 2353 goto fini;
2354 2354
@@ -2358,8 +2358,7 @@ repeat:
2358 } 2358 }
2359 if (!suppress_type_lookup) 2359 if (!suppress_type_lookup)
2360 { 2360 {
2361 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); 2361 if (find_symbol(yytext, SYM_TYPEDEF, 1))
2362 if (sym && sym->type == SYM_TYPEDEF)
2363 token = TYPE; 2362 token = TYPE;
2364 } 2363 }
2365 } 2364 }
@@ -2478,7 +2477,20 @@ repeat:
2478 ++count; 2477 ++count;
2479 APP; 2478 APP;
2480 goto repeat; 2479 goto repeat;
2481 case ')': case ']': case '}': 2480 case '}':
2481 /* is this the last line of an enum declaration? */
2482 if (count == 0)
2483 {
2484 /* Put back the token we just read so's we can find it again
2485 after registering the expression. */
2486 unput(token);
2487
2488 lexstate = ST_NORMAL;
2489 token = EXPRESSION_PHRASE;
2490 break;
2491 }
2492 /* FALLTHRU */
2493 case ')': case ']':
2482 --count; 2494 --count;
2483 APP; 2495 APP;
2484 goto repeat; 2496 goto repeat;
@@ -2567,143 +2579,4 @@ fini:
2567 2579
2568 return token; 2580 return token;
2569} 2581}
2570/* A Bison parser, made by GNU Bison 2.3. */
2571
2572/* Skeleton interface for Bison's Yacc-like parsers in C
2573
2574 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
2575 Free Software Foundation, Inc.
2576
2577 This program is free software; you can redistribute it and/or modify
2578 it under the terms of the GNU General Public License as published by
2579 the Free Software Foundation; either version 2, or (at your option)
2580 any later version.
2581
2582 This program is distributed in the hope that it will be useful,
2583 but WITHOUT ANY WARRANTY; without even the implied warranty of
2584 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2585 GNU General Public License for more details.
2586
2587 You should have received a copy of the GNU General Public License
2588 along with this program; if not, write to the Free Software
2589 Foundation, Inc., 51 Franklin Street, Fifth Floor,
2590 Boston, MA 02110-1301, USA. */
2591
2592/* As a special exception, you may create a larger work that contains
2593 part or all of the Bison parser skeleton and distribute that work
2594 under terms of your choice, so long as that work isn't itself a
2595 parser generator using the skeleton or a modified version thereof
2596 as a parser skeleton. Alternatively, if you modify or redistribute
2597 the parser skeleton itself, you may (at your option) remove this
2598 special exception, which will cause the skeleton and the resulting
2599 Bison output files to be licensed under the GNU General Public
2600 License without this special exception.
2601
2602 This special exception was added by the Free Software Foundation in
2603 version 2.2 of Bison. */
2604
2605/* Tokens. */
2606#ifndef YYTOKENTYPE
2607# define YYTOKENTYPE
2608 /* Put the tokens into the symbol table, so that GDB and other debuggers
2609 know about them. */
2610 enum yytokentype {
2611 ASM_KEYW = 258,
2612 ATTRIBUTE_KEYW = 259,
2613 AUTO_KEYW = 260,
2614 BOOL_KEYW = 261,
2615 CHAR_KEYW = 262,
2616 CONST_KEYW = 263,
2617 DOUBLE_KEYW = 264,
2618 ENUM_KEYW = 265,
2619 EXTERN_KEYW = 266,
2620 EXTENSION_KEYW = 267,
2621 FLOAT_KEYW = 268,
2622 INLINE_KEYW = 269,
2623 INT_KEYW = 270,
2624 LONG_KEYW = 271,
2625 REGISTER_KEYW = 272,
2626 RESTRICT_KEYW = 273,
2627 SHORT_KEYW = 274,
2628 SIGNED_KEYW = 275,
2629 STATIC_KEYW = 276,
2630 STRUCT_KEYW = 277,
2631 TYPEDEF_KEYW = 278,
2632 UNION_KEYW = 279,
2633 UNSIGNED_KEYW = 280,
2634 VOID_KEYW = 281,
2635 VOLATILE_KEYW = 282,
2636 TYPEOF_KEYW = 283,
2637 EXPORT_SYMBOL_KEYW = 284,
2638 ASM_PHRASE = 285,
2639 ATTRIBUTE_PHRASE = 286,
2640 BRACE_PHRASE = 287,
2641 BRACKET_PHRASE = 288,
2642 EXPRESSION_PHRASE = 289,
2643 CHAR = 290,
2644 DOTS = 291,
2645 IDENT = 292,
2646 INT = 293,
2647 REAL = 294,
2648 STRING = 295,
2649 TYPE = 296,
2650 OTHER = 297,
2651 FILENAME = 298
2652 };
2653#endif
2654/* Tokens. */
2655#define ASM_KEYW 258
2656#define ATTRIBUTE_KEYW 259
2657#define AUTO_KEYW 260
2658#define BOOL_KEYW 261
2659#define CHAR_KEYW 262
2660#define CONST_KEYW 263
2661#define DOUBLE_KEYW 264
2662#define ENUM_KEYW 265
2663#define EXTERN_KEYW 266
2664#define EXTENSION_KEYW 267
2665#define FLOAT_KEYW 268
2666#define INLINE_KEYW 269
2667#define INT_KEYW 270
2668#define LONG_KEYW 271
2669#define REGISTER_KEYW 272
2670#define RESTRICT_KEYW 273
2671#define SHORT_KEYW 274
2672#define SIGNED_KEYW 275
2673#define STATIC_KEYW 276
2674#define STRUCT_KEYW 277
2675#define TYPEDEF_KEYW 278
2676#define UNION_KEYW 279
2677#define UNSIGNED_KEYW 280
2678#define VOID_KEYW 281
2679#define VOLATILE_KEYW 282
2680#define TYPEOF_KEYW 283
2681#define EXPORT_SYMBOL_KEYW 284
2682#define ASM_PHRASE 285
2683#define ATTRIBUTE_PHRASE 286
2684#define BRACE_PHRASE 287
2685#define BRACKET_PHRASE 288
2686#define EXPRESSION_PHRASE 289
2687#define CHAR 290
2688#define DOTS 291
2689#define IDENT 292
2690#define INT 293
2691#define REAL 294
2692#define STRING 295
2693#define TYPE 296
2694#define OTHER 297
2695#define FILENAME 298
2696
2697
2698
2699
2700#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
2701typedef int YYSTYPE;
2702# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2703# define YYSTYPE_IS_DECLARED 1
2704# define YYSTYPE_IS_TRIVIAL 1
2705#endif
2706
2707extern YYSTYPE yylval;
2708
2709 2582
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index fe50ff9dacd0..e4ddd493fec3 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -55,10 +55,6 @@ CHAR L?\'([^\\\']*\\.)*[^\\\']*\'
55 55
56MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>) 56MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
57 57
58/* Version 2 checksumming does proper tokenization; version 1 wasn't
59 quite so pedantic. */
60%s V2_TOKENS
61
62/* We don't do multiple input files. */ 58/* We don't do multiple input files. */
63%option noyywrap 59%option noyywrap
64 60
@@ -84,9 +80,9 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
84 recognized as tokens. We don't actually use them since we don't 80 recognized as tokens. We don't actually use them since we don't
85 parse expressions, but we do want whitespace to be arranged 81 parse expressions, but we do want whitespace to be arranged
86 around them properly. */ 82 around them properly. */
87<V2_TOKENS>{MC_TOKEN} return OTHER; 83{MC_TOKEN} return OTHER;
88<V2_TOKENS>{INT} return INT; 84{INT} return INT;
89<V2_TOKENS>{REAL} return REAL; 85{REAL} return REAL;
90 86
91"..." return DOTS; 87"..." return DOTS;
92 88
@@ -103,12 +99,23 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>)
103 99
104/* Macros to append to our phrase collection list. */ 100/* Macros to append to our phrase collection list. */
105 101
102/*
103 * We mark any token, that that equals to a known enumerator, as
104 * SYM_ENUM_CONST. The parser will change this for struct and union tags later,
105 * the only problem is struct and union members:
106 * enum e { a, b }; struct s { int a, b; }
107 * but in this case, the only effect will be, that the ABI checksums become
108 * more volatile, which is acceptable. Also, such collisions are quite rare,
109 * so far it was only observed in include/linux/telephony.h.
110 */
106#define _APP(T,L) do { \ 111#define _APP(T,L) do { \
107 cur_node = next_node; \ 112 cur_node = next_node; \
108 next_node = xmalloc(sizeof(*next_node)); \ 113 next_node = xmalloc(sizeof(*next_node)); \
109 next_node->next = cur_node; \ 114 next_node->next = cur_node; \
110 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \ 115 cur_node->string = memcpy(xmalloc(L+1), T, L+1); \
111 cur_node->tag = SYM_NORMAL; \ 116 cur_node->tag = \
117 find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\
118 SYM_ENUM_CONST : SYM_NORMAL ; \
112 } while (0) 119 } while (0)
113 120
114#define APP _APP(yytext, yyleng) 121#define APP _APP(yytext, yyleng)
@@ -134,7 +141,6 @@ yylex(void)
134 141
135 if (lexstate == ST_NOTSTARTED) 142 if (lexstate == ST_NOTSTARTED)
136 { 143 {
137 BEGIN(V2_TOKENS);
138 next_node = xmalloc(sizeof(*next_node)); 144 next_node = xmalloc(sizeof(*next_node));
139 next_node->next = NULL; 145 next_node->next = NULL;
140 lexstate = ST_NORMAL; 146 lexstate = ST_NORMAL;
@@ -187,8 +193,8 @@ repeat:
187 193
188 case STRUCT_KEYW: 194 case STRUCT_KEYW:
189 case UNION_KEYW: 195 case UNION_KEYW:
190 dont_want_brace_phrase = 3;
191 case ENUM_KEYW: 196 case ENUM_KEYW:
197 dont_want_brace_phrase = 3;
192 suppress_type_lookup = 2; 198 suppress_type_lookup = 2;
193 goto fini; 199 goto fini;
194 200
@@ -198,8 +204,7 @@ repeat:
198 } 204 }
199 if (!suppress_type_lookup) 205 if (!suppress_type_lookup)
200 { 206 {
201 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); 207 if (find_symbol(yytext, SYM_TYPEDEF, 1))
202 if (sym && sym->type == SYM_TYPEDEF)
203 token = TYPE; 208 token = TYPE;
204 } 209 }
205 } 210 }
@@ -318,7 +323,20 @@ repeat:
318 ++count; 323 ++count;
319 APP; 324 APP;
320 goto repeat; 325 goto repeat;
321 case ')': case ']': case '}': 326 case '}':
327 /* is this the last line of an enum declaration? */
328 if (count == 0)
329 {
330 /* Put back the token we just read so's we can find it again
331 after registering the expression. */
332 unput(token);
333
334 lexstate = ST_NORMAL;
335 token = EXPRESSION_PHRASE;
336 break;
337 }
338 /* FALLTHRU */
339 case ')': case ']':
322 --count; 340 --count;
323 APP; 341 APP;
324 goto repeat; 342 goto repeat;
diff --git a/scripts/genksyms/parse.c_shipped b/scripts/genksyms/parse.c_shipped
index eaee44e66a43..1a0b8607fb0e 100644
--- a/scripts/genksyms/parse.c_shipped
+++ b/scripts/genksyms/parse.c_shipped
@@ -1,24 +1,23 @@
1/* A Bison parser, made by GNU Bison 2.3. */
2 1
3/* Skeleton implementation for Bison's Yacc-like parsers in C 2/* A Bison parser, made by GNU Bison 2.4.1. */
4 3
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc. 7 Free Software Foundation, Inc.
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation, either version 3 of the License, or
11 any later version. 12 (at your option) any later version.
12 13
13 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 17 GNU General Public License for more details.
17 18
18 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22 21
23/* As a special exception, you may create a larger work that contains 22/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work 23 part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
29 special exception, which will cause the skeleton and the resulting 28 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public 29 Bison output files to be licensed under the GNU General Public
31 License without this special exception. 30 License without this special exception.
32 31
33 This special exception was added by the Free Software Foundation in 32 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */ 33 version 2.2 of Bison. */
35 34
@@ -47,7 +46,7 @@
47#define YYBISON 1 46#define YYBISON 1
48 47
49/* Bison version. */ 48/* Bison version. */
50#define YYBISON_VERSION "2.3" 49#define YYBISON_VERSION "2.4.1"
51 50
52/* Skeleton name. */ 51/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c" 52#define YYSKELETON_NAME "yacc.c"
@@ -55,11 +54,75 @@
55/* Pure parsers. */ 54/* Pure parsers. */
56#define YYPURE 0 55#define YYPURE 0
57 56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
58/* Using locations. */ 63/* Using locations. */
59#define YYLSP_NEEDED 0 64#define YYLSP_NEEDED 0
60 65
61 66
62 67
68/* Copy the first part of user declarations. */
69
70/* Line 189 of yacc.c */
71#line 24 "scripts/genksyms/parse.y"
72
73
74#include <assert.h>
75#include <stdlib.h>
76#include <string.h>
77#include "genksyms.h"
78
79static int is_typedef;
80static int is_extern;
81static char *current_name;
82static struct string_list *decl_spec;
83
84static void yyerror(const char *);
85
86static inline void
87remove_node(struct string_list **p)
88{
89 struct string_list *node = *p;
90 *p = node->next;
91 free_node(node);
92}
93
94static inline void
95remove_list(struct string_list **pb, struct string_list **pe)
96{
97 struct string_list *b = *pb, *e = *pe;
98 *pb = e;
99 free_list(b, e);
100}
101
102
103
104/* Line 189 of yacc.c */
105#line 106 "scripts/genksyms/parse.c"
106
107/* Enabling traces. */
108#ifndef YYDEBUG
109# define YYDEBUG 1
110#endif
111
112/* Enabling verbose error messages. */
113#ifdef YYERROR_VERBOSE
114# undef YYERROR_VERBOSE
115# define YYERROR_VERBOSE 1
116#else
117# define YYERROR_VERBOSE 0
118#endif
119
120/* Enabling the token table. */
121#ifndef YYTOKEN_TABLE
122# define YYTOKEN_TABLE 0
123#endif
124
125
63/* Tokens. */ 126/* Tokens. */
64#ifndef YYTOKENTYPE 127#ifndef YYTOKENTYPE
65# define YYTOKENTYPE 128# define YYTOKENTYPE
@@ -109,117 +172,22 @@
109 FILENAME = 298 172 FILENAME = 298
110 }; 173 };
111#endif 174#endif
112/* Tokens. */
113#define ASM_KEYW 258
114#define ATTRIBUTE_KEYW 259
115#define AUTO_KEYW 260
116#define BOOL_KEYW 261
117#define CHAR_KEYW 262
118#define CONST_KEYW 263
119#define DOUBLE_KEYW 264
120#define ENUM_KEYW 265
121#define EXTERN_KEYW 266
122#define EXTENSION_KEYW 267
123#define FLOAT_KEYW 268
124#define INLINE_KEYW 269
125#define INT_KEYW 270
126#define LONG_KEYW 271
127#define REGISTER_KEYW 272
128#define RESTRICT_KEYW 273
129#define SHORT_KEYW 274
130#define SIGNED_KEYW 275
131#define STATIC_KEYW 276
132#define STRUCT_KEYW 277
133#define TYPEDEF_KEYW 278
134#define UNION_KEYW 279
135#define UNSIGNED_KEYW 280
136#define VOID_KEYW 281
137#define VOLATILE_KEYW 282
138#define TYPEOF_KEYW 283
139#define EXPORT_SYMBOL_KEYW 284
140#define ASM_PHRASE 285
141#define ATTRIBUTE_PHRASE 286
142#define BRACE_PHRASE 287
143#define BRACKET_PHRASE 288
144#define EXPRESSION_PHRASE 289
145#define CHAR 290
146#define DOTS 291
147#define IDENT 292
148#define INT 293
149#define REAL 294
150#define STRING 295
151#define TYPE 296
152#define OTHER 297
153#define FILENAME 298
154
155 175
156 176
157 177
158/* Copy the first part of user declarations. */
159#line 24 "scripts/genksyms/parse.y"
160
161
162#include <assert.h>
163#include <malloc.h>
164#include "genksyms.h"
165
166static int is_typedef;
167static int is_extern;
168static char *current_name;
169static struct string_list *decl_spec;
170
171static void yyerror(const char *);
172
173static inline void
174remove_node(struct string_list **p)
175{
176 struct string_list *node = *p;
177 *p = node->next;
178 free_node(node);
179}
180
181static inline void
182remove_list(struct string_list **pb, struct string_list **pe)
183{
184 struct string_list *b = *pb, *e = *pe;
185 *pb = e;
186 free_list(b, e);
187}
188
189
190
191/* Enabling traces. */
192#ifndef YYDEBUG
193# define YYDEBUG 1
194#endif
195
196/* Enabling verbose error messages. */
197#ifdef YYERROR_VERBOSE
198# undef YYERROR_VERBOSE
199# define YYERROR_VERBOSE 1
200#else
201# define YYERROR_VERBOSE 0
202#endif
203
204/* Enabling the token table. */
205#ifndef YYTOKEN_TABLE
206# define YYTOKEN_TABLE 0
207#endif
208
209#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 178#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
210typedef int YYSTYPE; 179typedef int YYSTYPE;
180# define YYSTYPE_IS_TRIVIAL 1
211# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 181# define yystype YYSTYPE /* obsolescent; will be withdrawn */
212# define YYSTYPE_IS_DECLARED 1 182# define YYSTYPE_IS_DECLARED 1
213# define YYSTYPE_IS_TRIVIAL 1
214#endif 183#endif
215 184
216 185
217
218/* Copy the second part of user declarations. */ 186/* Copy the second part of user declarations. */
219 187
220 188
221/* Line 216 of yacc.c. */ 189/* Line 264 of yacc.c */
222#line 223 "scripts/genksyms/parse.c" 190#line 191 "scripts/genksyms/parse.c"
223 191
224#ifdef short 192#ifdef short
225# undef short 193# undef short
@@ -294,14 +262,14 @@ typedef short int yytype_int16;
294#if (defined __STDC__ || defined __C99__FUNC__ \ 262#if (defined __STDC__ || defined __C99__FUNC__ \
295 || defined __cplusplus || defined _MSC_VER) 263 || defined __cplusplus || defined _MSC_VER)
296static int 264static int
297YYID (int i) 265YYID (int yyi)
298#else 266#else
299static int 267static int
300YYID (i) 268YYID (yyi)
301 int i; 269 int yyi;
302#endif 270#endif
303{ 271{
304 return i; 272 return yyi;
305} 273}
306#endif 274#endif
307 275
@@ -382,9 +350,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
382/* A type that is properly aligned for any stack member. */ 350/* A type that is properly aligned for any stack member. */
383union yyalloc 351union yyalloc
384{ 352{
385 yytype_int16 yyss; 353 yytype_int16 yyss_alloc;
386 YYSTYPE yyvs; 354 YYSTYPE yyvs_alloc;
387 }; 355};
388 356
389/* The size of the maximum gap between one aligned stack and the next. */ 357/* The size of the maximum gap between one aligned stack and the next. */
390# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 358# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -418,12 +386,12 @@ union yyalloc
418 elements in the stack, and YYPTR gives the new location of the 386 elements in the stack, and YYPTR gives the new location of the
419 stack. Advance YYPTR to a properly aligned location for the next 387 stack. Advance YYPTR to a properly aligned location for the next
420 stack. */ 388 stack. */
421# define YYSTACK_RELOCATE(Stack) \ 389# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
422 do \ 390 do \
423 { \ 391 { \
424 YYSIZE_T yynewbytes; \ 392 YYSIZE_T yynewbytes; \
425 YYCOPY (&yyptr->Stack, Stack, yysize); \ 393 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
426 Stack = &yyptr->Stack; \ 394 Stack = &yyptr->Stack_alloc; \
427 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 395 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
428 yyptr += yynewbytes / sizeof (*yyptr); \ 396 yyptr += yynewbytes / sizeof (*yyptr); \
429 } \ 397 } \
@@ -434,16 +402,16 @@ union yyalloc
434/* YYFINAL -- State number of the termination state. */ 402/* YYFINAL -- State number of the termination state. */
435#define YYFINAL 4 403#define YYFINAL 4
436/* YYLAST -- Last index in YYTABLE. */ 404/* YYLAST -- Last index in YYTABLE. */
437#define YYLAST 523 405#define YYLAST 532
438 406
439/* YYNTOKENS -- Number of terminals. */ 407/* YYNTOKENS -- Number of terminals. */
440#define YYNTOKENS 53 408#define YYNTOKENS 53
441/* YYNNTS -- Number of nonterminals. */ 409/* YYNNTS -- Number of nonterminals. */
442#define YYNNTS 46 410#define YYNNTS 49
443/* YYNRULES -- Number of rules. */ 411/* YYNRULES -- Number of rules. */
444#define YYNRULES 126 412#define YYNRULES 132
445/* YYNRULES -- Number of states. */ 413/* YYNRULES -- Number of states. */
446#define YYNSTATES 178 414#define YYNSTATES 188
447 415
448/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 416/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
449#define YYUNDEFTOK 2 417#define YYUNDEFTOK 2
@@ -504,7 +472,8 @@ static const yytype_uint16 yyprhs[] =
504 239, 242, 245, 247, 248, 250, 252, 257, 262, 265, 472 239, 242, 245, 247, 248, 250, 252, 257, 262, 265,
505 269, 273, 277, 278, 280, 283, 287, 291, 292, 294, 473 269, 273, 277, 278, 280, 283, 287, 291, 292, 294,
506 296, 299, 303, 306, 307, 309, 311, 315, 318, 321, 474 296, 299, 303, 306, 307, 309, 311, 315, 318, 321,
507 323, 326, 327, 330, 333, 334, 336 475 323, 326, 327, 330, 334, 339, 341, 345, 347, 351,
476 354, 355, 357
508}; 477};
509 478
510/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 479/* YYRHS -- A `-1'-separated list of the rules' RHS. */
@@ -512,16 +481,16 @@ static const yytype_int8 yyrhs[] =
512{ 481{
513 54, 0, -1, 55, -1, 54, 55, -1, -1, 56, 482 54, 0, -1, 55, -1, 54, 55, -1, -1, 56,
514 57, -1, -1, 12, 23, 58, 60, -1, -1, 23, 483 57, -1, -1, 12, 23, 58, 60, -1, -1, 23,
515 59, 60, -1, 60, -1, 84, -1, 96, -1, 98, 484 59, 60, -1, 60, -1, 84, -1, 99, -1, 101,
516 -1, 1, 44, -1, 1, 45, -1, 64, 61, 44, 485 -1, 1, 44, -1, 1, 45, -1, 64, 61, 44,
517 -1, -1, 62, -1, 63, -1, 62, 46, 63, -1, 486 -1, -1, 62, -1, 63, -1, 62, 46, 63, -1,
518 74, 97, 95, 85, -1, -1, 65, -1, 66, -1, 487 74, 100, 95, 85, -1, -1, 65, -1, 66, -1,
519 65, 66, -1, 67, -1, 68, -1, 5, -1, 17, 488 65, 66, -1, 67, -1, 68, -1, 5, -1, 17,
520 -1, 21, -1, 11, -1, 14, -1, 69, -1, 73, 489 -1, 21, -1, 11, -1, 14, -1, 69, -1, 73,
521 -1, 28, 47, 65, 48, 49, -1, 28, 47, 65, 490 -1, 28, 47, 65, 48, 49, -1, 28, 47, 65,
522 49, -1, 22, 37, -1, 24, 37, -1, 10, 37, 491 49, -1, 22, 37, -1, 24, 37, -1, 10, 37,
523 -1, 22, 37, 87, -1, 24, 37, 87, -1, 10, 492 -1, 22, 37, 87, -1, 24, 37, 87, -1, 10,
524 37, 32, -1, 10, 32, -1, 22, 87, -1, 24, 493 37, 96, -1, 10, 96, -1, 22, 87, -1, 24,
525 87, -1, 7, -1, 19, -1, 15, -1, 16, -1, 494 87, -1, 7, -1, 19, -1, 15, -1, 16, -1,
526 20, -1, 25, -1, 13, -1, 9, -1, 26, -1, 495 20, -1, 25, -1, 13, -1, 9, -1, 26, -1,
527 6, -1, 41, -1, 48, 71, -1, -1, 72, -1, 496 6, -1, 41, -1, 48, 71, -1, -1, 72, -1,
@@ -543,26 +512,29 @@ static const yytype_int8 yyrhs[] =
543 91, 44, -1, 1, 44, -1, -1, 92, -1, 93, 512 91, 44, -1, 1, 44, -1, -1, 92, -1, 93,
544 -1, 92, 46, 93, -1, 76, 95, -1, 37, 94, 513 -1, 92, 46, 93, -1, 76, 95, -1, 37, 94,
545 -1, 94, -1, 52, 34, -1, -1, 95, 31, -1, 514 -1, 94, -1, 52, 34, -1, -1, 95, 31, -1,
546 30, 44, -1, -1, 30, -1, 29, 47, 37, 49, 515 51, 97, 45, -1, 51, 97, 46, 45, -1, 98,
547 44, -1 516 -1, 97, 46, 98, -1, 37, -1, 37, 50, 34,
517 -1, 30, 44, -1, -1, 30, -1, 29, 47, 37,
518 49, 44, -1
548}; 519};
549 520
550/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 521/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
551static const yytype_uint16 yyrline[] = 522static const yytype_uint16 yyrline[] =
552{ 523{
553 0, 103, 103, 104, 108, 108, 114, 114, 116, 116, 524 0, 104, 104, 105, 109, 109, 115, 115, 117, 117,
554 118, 119, 120, 121, 122, 123, 127, 141, 142, 146, 525 119, 120, 121, 122, 123, 124, 128, 142, 143, 147,
555 154, 167, 173, 174, 178, 179, 183, 189, 193, 194, 526 155, 168, 174, 175, 179, 180, 184, 190, 194, 195,
556 195, 196, 197, 201, 202, 203, 204, 208, 210, 212, 527 196, 197, 198, 202, 203, 204, 205, 209, 211, 213,
557 216, 223, 230, 239, 240, 241, 245, 246, 247, 248, 528 217, 224, 231, 241, 244, 245, 249, 250, 251, 252,
558 249, 250, 251, 252, 253, 254, 255, 259, 264, 265, 529 253, 254, 255, 256, 257, 258, 259, 263, 268, 269,
559 269, 270, 274, 274, 274, 275, 283, 284, 288, 297, 530 273, 274, 278, 278, 278, 279, 287, 288, 292, 301,
560 299, 301, 303, 305, 312, 313, 317, 318, 319, 321, 531 303, 305, 307, 309, 316, 317, 321, 322, 323, 325,
561 323, 325, 327, 332, 333, 334, 338, 339, 343, 344, 532 327, 329, 331, 336, 337, 338, 342, 343, 347, 348,
562 349, 354, 356, 360, 361, 369, 373, 375, 377, 379, 533 353, 358, 360, 364, 365, 373, 377, 379, 381, 383,
563 381, 386, 395, 396, 401, 406, 407, 411, 412, 416, 534 385, 390, 399, 400, 405, 410, 411, 415, 416, 420,
564 417, 421, 423, 428, 429, 433, 434, 438, 439, 440, 535 421, 425, 427, 432, 433, 437, 438, 442, 443, 444,
565 444, 448, 449, 453, 457, 458, 462 536 448, 452, 453, 457, 458, 462, 463, 466, 471, 479,
537 483, 484, 488
566}; 538};
567#endif 539#endif
568 540
@@ -581,8 +553,8 @@ static const char *const yytname[] =
581 "ATTRIBUTE_PHRASE", "BRACE_PHRASE", "BRACKET_PHRASE", 553 "ATTRIBUTE_PHRASE", "BRACE_PHRASE", "BRACKET_PHRASE",
582 "EXPRESSION_PHRASE", "CHAR", "DOTS", "IDENT", "INT", "REAL", "STRING", 554 "EXPRESSION_PHRASE", "CHAR", "DOTS", "IDENT", "INT", "REAL", "STRING",
583 "TYPE", "OTHER", "FILENAME", "';'", "'}'", "','", "'('", "'*'", "')'", 555 "TYPE", "OTHER", "FILENAME", "';'", "'}'", "','", "'('", "'*'", "')'",
584 "'='", "'{'", "':'", "$accept", "declaration_seq", "declaration", "@1", 556 "'='", "'{'", "':'", "$accept", "declaration_seq", "declaration", "$@1",
585 "declaration1", "@2", "@3", "simple_declaration", 557 "declaration1", "$@2", "$@3", "simple_declaration",
586 "init_declarator_list_opt", "init_declarator_list", "init_declarator", 558 "init_declarator_list_opt", "init_declarator_list", "init_declarator",
587 "decl_specifier_seq_opt", "decl_specifier_seq", "decl_specifier", 559 "decl_specifier_seq_opt", "decl_specifier_seq", "decl_specifier",
588 "storage_class_specifier", "type_specifier", "simple_type_specifier", 560 "storage_class_specifier", "type_specifier", "simple_type_specifier",
@@ -596,7 +568,8 @@ static const char *const yytname[] =
596 "member_specification", "member_declaration", 568 "member_specification", "member_declaration",
597 "member_declarator_list_opt", "member_declarator_list", 569 "member_declarator_list_opt", "member_declarator_list",
598 "member_declarator", "member_bitfield_declarator", "attribute_opt", 570 "member_declarator", "member_bitfield_declarator", "attribute_opt",
599 "asm_definition", "asm_phrase_opt", "export_definition", 0 571 "enum_body", "enumerator_list", "enumerator", "asm_definition",
572 "asm_phrase_opt", "export_definition", 0
600}; 573};
601#endif 574#endif
602 575
@@ -629,7 +602,8 @@ static const yytype_uint8 yyr1[] =
629 81, 82, 82, 83, 83, 83, 83, 83, 83, 83, 602 81, 82, 82, 83, 83, 83, 83, 83, 83, 83,
630 83, 84, 85, 85, 86, 87, 87, 88, 88, 89, 603 83, 84, 85, 85, 86, 87, 87, 88, 88, 89,
631 89, 90, 90, 91, 91, 92, 92, 93, 93, 93, 604 89, 90, 90, 91, 91, 92, 92, 93, 93, 93,
632 94, 95, 95, 96, 97, 97, 98 605 94, 95, 95, 96, 96, 97, 97, 98, 98, 99,
606 100, 100, 101
633}; 607};
634 608
635/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 609/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@@ -647,7 +621,8 @@ static const yytype_uint8 yyr2[] =
647 2, 2, 1, 0, 1, 1, 4, 4, 2, 3, 621 2, 2, 1, 0, 1, 1, 4, 4, 2, 3,
648 3, 3, 0, 1, 2, 3, 3, 0, 1, 1, 622 3, 3, 0, 1, 2, 3, 3, 0, 1, 1,
649 2, 3, 2, 0, 1, 1, 3, 2, 2, 1, 623 2, 3, 2, 0, 1, 1, 3, 2, 2, 1,
650 2, 0, 2, 2, 0, 1, 5 624 2, 0, 2, 3, 4, 1, 3, 1, 3, 2,
625 0, 1, 5
651}; 626};
652 627
653/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 628/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -659,17 +634,18 @@ static const yytype_uint8 yydefact[] =
659 62, 53, 0, 31, 0, 52, 32, 48, 49, 29, 634 62, 53, 0, 31, 0, 52, 32, 48, 49, 29,
660 65, 47, 50, 30, 0, 8, 0, 51, 54, 63, 635 65, 47, 50, 30, 0, 8, 0, 51, 54, 63,
661 0, 0, 0, 64, 56, 5, 10, 17, 23, 24, 636 0, 0, 0, 64, 56, 5, 10, 17, 23, 24,
662 26, 27, 33, 34, 11, 12, 13, 14, 15, 43, 637 26, 27, 33, 34, 11, 12, 13, 14, 15, 39,
663 39, 6, 37, 0, 44, 22, 38, 45, 0, 0, 638 0, 43, 6, 37, 0, 44, 22, 38, 45, 0,
664 123, 68, 0, 58, 0, 18, 19, 0, 124, 67, 639 0, 129, 68, 0, 58, 0, 18, 19, 0, 130,
665 25, 42, 22, 40, 0, 113, 0, 0, 109, 9, 640 67, 25, 42, 127, 0, 125, 22, 40, 0, 113,
666 17, 41, 0, 0, 0, 0, 57, 59, 60, 16, 641 0, 0, 109, 9, 17, 41, 0, 0, 0, 0,
667 0, 66, 125, 101, 121, 71, 0, 7, 112, 106, 642 57, 59, 60, 16, 0, 66, 131, 101, 121, 71,
668 76, 77, 0, 0, 0, 121, 75, 0, 114, 115, 643 0, 0, 123, 0, 7, 112, 106, 76, 77, 0,
669 119, 105, 0, 110, 124, 0, 36, 0, 73, 72, 644 0, 0, 121, 75, 0, 114, 115, 119, 105, 0,
670 61, 20, 102, 0, 93, 0, 84, 87, 88, 118, 645 110, 130, 0, 36, 0, 73, 72, 61, 20, 102,
646 0, 93, 0, 84, 87, 88, 128, 124, 126, 118,
671 0, 76, 0, 120, 74, 117, 80, 0, 111, 0, 647 0, 76, 0, 120, 74, 117, 80, 0, 111, 0,
672 35, 126, 122, 0, 21, 103, 70, 94, 56, 0, 648 35, 132, 122, 0, 21, 103, 70, 94, 56, 0,
673 93, 90, 92, 69, 83, 0, 82, 81, 0, 0, 649 93, 90, 92, 69, 83, 0, 82, 81, 0, 0,
674 116, 104, 0, 95, 0, 91, 98, 0, 85, 89, 650 116, 104, 0, 95, 0, 91, 98, 0, 85, 89,
675 79, 78, 100, 99, 0, 0, 97, 96 651 79, 78, 100, 99, 0, 0, 97, 96
@@ -678,46 +654,47 @@ static const yytype_uint8 yydefact[] =
678/* YYDEFGOTO[NTERM-NUM]. */ 654/* YYDEFGOTO[NTERM-NUM]. */
679static const yytype_int16 yydefgoto[] = 655static const yytype_int16 yydefgoto[] =
680{ 656{
681 -1, 1, 2, 3, 35, 72, 55, 36, 64, 65, 657 -1, 1, 2, 3, 35, 76, 56, 36, 65, 66,
682 66, 75, 38, 39, 40, 41, 42, 67, 86, 87, 658 67, 79, 38, 39, 40, 41, 42, 68, 90, 91,
683 43, 114, 69, 105, 106, 125, 126, 127, 128, 151, 659 43, 121, 70, 112, 113, 132, 133, 134, 135, 161,
684 152, 44, 144, 145, 54, 76, 77, 78, 107, 108, 660 162, 44, 154, 155, 55, 80, 81, 82, 114, 115,
685 109, 110, 122, 45, 94, 46 661 116, 117, 129, 51, 74, 75, 45, 98, 46
686}; 662};
687 663
688/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 664/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
689 STATE-NUM. */ 665 STATE-NUM. */
690#define YYPACT_NINF -134 666#define YYPACT_NINF -135
691static const yytype_int16 yypact[] = 667static const yytype_int16 yypact[] =
692{ 668{
693 -134, 16, -134, 312, -134, -134, 20, -134, -134, -134, 669 -135, 20, -135, 321, -135, -135, 30, -135, -135, -135,
694 -134, -134, -18, -134, -3, -134, -134, -134, -134, -134, 670 -135, -135, -28, -135, 2, -135, -135, -135, -135, -135,
695 -134, -134, -134, -134, -26, -134, -25, -134, -134, -134, 671 -135, -135, -135, -135, -6, -135, 9, -135, -135, -135,
696 -7, 5, 27, -134, -134, -134, -134, 46, 482, -134, 672 -5, 15, -17, -135, -135, -135, -135, 18, 491, -135,
697 -134, -134, -134, -134, -134, -134, -134, -134, -134, -134, 673 -135, -135, -135, -135, -135, -135, -135, -135, -135, -22,
698 -8, -134, 30, 97, -134, 482, 30, -134, 482, 7, 674 31, -135, -135, 19, 106, -135, 491, 19, -135, 491,
699 -134, -134, 12, 10, 42, 55, -134, 46, -15, 15, 675 50, -135, -135, 11, -3, 51, 57, -135, 18, -14,
700 -134, -134, 482, -134, 25, 26, 47, 145, -134, -134, 676 14, -135, -135, 48, 46, -135, 491, -135, 33, 32,
701 46, -134, 356, 39, 71, 77, -134, 10, -134, -134, 677 59, 154, -135, -135, 18, -135, 365, 56, 60, 61,
702 46, -134, -134, -134, -134, -134, 193, -134, -134, -134, 678 -135, -3, -135, -135, 18, -135, -135, -135, -135, -135,
703 75, -134, 6, 95, 43, -134, 28, 86, 85, -134, 679 202, 74, -135, -23, -135, -135, -135, 77, -135, 16,
704 -134, -134, 88, -134, 103, 87, -134, 91, -134, -134, 680 101, 49, -135, 34, 92, 93, -135, -135, -135, 94,
705 -134, -134, -23, 90, 401, 94, 101, 102, -134, -134, 681 -135, 110, 95, -135, 97, -135, -135, -135, -135, -20,
706 98, -134, 108, -134, -134, 109, -134, 230, -134, 26, 682 96, 410, 99, 113, 100, -135, -135, -135, -135, -135,
707 -134, -134, -134, 134, -134, -134, -134, -134, -134, 9, 683 103, -135, 107, -135, -135, 111, -135, 239, -135, 32,
708 48, -134, 35, -134, -134, 445, -134, -134, 125, 126, 684 -135, -135, -135, 123, -135, -135, -135, -135, -135, 3,
709 -134, -134, 128, -134, 129, -134, -134, 267, -134, -134, 685 52, -135, 38, -135, -135, 454, -135, -135, 117, 128,
710 -134, -134, -134, -134, 130, 131, -134, -134 686 -135, -135, 134, -135, 135, -135, -135, 276, -135, -135,
687 -135, -135, -135, -135, 137, 138, -135, -135
711}; 688};
712 689
713/* YYPGOTO[NTERM-NUM]. */ 690/* YYPGOTO[NTERM-NUM]. */
714static const yytype_int16 yypgoto[] = 691static const yytype_int16 yypgoto[] =
715{ 692{
716 -134, -134, 180, -134, -134, -134, -134, -33, -134, -134, 693 -135, -135, 187, -135, -135, -135, -135, -50, -135, -135,
717 93, 0, -58, -37, -134, -134, -134, -73, -134, -134, 694 98, 0, -59, -37, -135, -135, -135, -77, -135, -135,
718 -54, -32, -134, -81, -134, -133, -134, -134, 29, -50, 695 -54, -30, -135, -90, -135, -134, -135, -135, 24, -58,
719 -134, -134, -134, -134, -20, -134, -134, 110, -134, -134, 696 -135, -135, -135, -135, -18, -135, -135, 109, -135, -135,
720 49, 96, 80, -134, -134, -134 697 44, 87, 84, 148, -135, 102, -135, -135, -135
721}; 698};
722 699
723/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 700/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -727,116 +704,118 @@ static const yytype_int16 yypgoto[] =
727#define YYTABLE_NINF -109 704#define YYTABLE_NINF -109
728static const yytype_int16 yytable[] = 705static const yytype_int16 yytable[] =
729{ 706{
730 82, 70, 104, 37, 159, 68, 57, 130, 142, 88, 707 86, 71, 111, 37, 172, 10, 83, 69, 58, 49,
731 162, 52, 56, 84, 49, 92, 4, 93, 10, 50, 708 92, 152, 88, 169, 73, 20, 96, 140, 97, 142,
732 51, 132, 79, 134, 71, 53, 53, 143, 20, 104, 709 4, 144, 137, 50, 29, 52, 104, 61, 33, 50,
733 85, 104, 73, 120, 175, 91, 81, 29, 124, 97, 710 153, 53, 111, 89, 111, 77, -93, 127, 95, 85,
734 58, 33, -93, 131, 83, 70, 147, 101, 95, 61, 711 157, 131, 59, 185, 173, 54, 57, 99, 62, 71,
735 163, 150, 59, 102, 63, 80, 149, 63, -93, 62, 712 159, 64, -93, 141, 160, 62, 84, 108, 63, 64,
736 63, 136, 96, 100, 47, 48, 104, 101, 166, 98, 713 54, 100, 60, 109, 64, 63, 64, 146, 73, 107,
737 99, 60, 80, 102, 63, 137, 150, 150, 103, 124, 714 54, 176, 111, 108, 47, 48, 84, 105, 106, 109,
738 131, 53, 167, 61, 101, 147, 89, 70, 117, 163, 715 64, 147, 160, 160, 110, 177, 141, 87, 131, 157,
739 102, 63, 111, 62, 63, 149, 63, 124, 74, 164, 716 108, 102, 103, 173, 71, 93, 109, 64, 101, 159,
740 165, 90, 7, 8, 9, 10, 11, 12, 13, 124, 717 64, 174, 175, 94, 118, 124, 131, 78, 136, 125,
741 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 718 126, 7, 8, 9, 10, 11, 12, 13, 131, 15,
742 118, 26, 27, 28, 29, 30, 119, 103, 33, 133, 719 16, 17, 18, 19, 20, 21, 22, 23, 24, 110,
743 138, 139, 98, 92, -22, 141, 140, 154, 34, 146, 720 26, 27, 28, 29, 30, 143, 148, 33, 105, 149,
744 142, -22, -107, 153, -22, -22, 112, 156, 155, -22, 721 96, 151, 152, -22, 150, 156, 165, 34, 163, 164,
745 7, 8, 9, 10, 11, 12, 13, 157, 15, 16, 722 -22, -107, 166, -22, -22, 119, 167, 171, -22, 7,
746 17, 18, 19, 20, 21, 22, 23, 24, 161, 26, 723 8, 9, 10, 11, 12, 13, 180, 15, 16, 17,
747 27, 28, 29, 30, 170, 171, 33, 172, 173, 176, 724 18, 19, 20, 21, 22, 23, 24, 181, 26, 27,
748 177, 5, -22, 121, 169, 135, 34, 113, 160, -22, 725 28, 29, 30, 182, 183, 33, 186, 187, 5, 179,
749 -108, 0, -22, -22, 123, 0, 129, -22, 7, 8, 726 120, -22, 128, 170, 139, 34, 145, 72, -22, -108,
750 9, 10, 11, 12, 13, 0, 15, 16, 17, 18, 727 0, -22, -22, 130, 0, 138, -22, 7, 8, 9,
751 19, 20, 21, 22, 23, 24, 0, 26, 27, 28, 728 10, 11, 12, 13, 0, 15, 16, 17, 18, 19,
752 29, 30, 0, 0, 33, 0, 0, 0, 0, -86, 729 20, 21, 22, 23, 24, 0, 26, 27, 28, 29,
753 0, 158, 0, 0, 34, 7, 8, 9, 10, 11, 730 30, 0, 0, 33, 0, 0, 0, 0, -86, 0,
754 12, 13, -86, 15, 16, 17, 18, 19, 20, 21, 731 168, 0, 0, 34, 7, 8, 9, 10, 11, 12,
755 22, 23, 24, 0, 26, 27, 28, 29, 30, 0, 732 13, -86, 15, 16, 17, 18, 19, 20, 21, 22,
756 0, 33, 0, 0, 0, 0, -86, 0, 174, 0, 733 23, 24, 0, 26, 27, 28, 29, 30, 0, 0,
757 0, 34, 7, 8, 9, 10, 11, 12, 13, -86, 734 33, 0, 0, 0, 0, -86, 0, 184, 0, 0,
758 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 735 34, 7, 8, 9, 10, 11, 12, 13, -86, 15,
759 0, 26, 27, 28, 29, 30, 0, 0, 33, 0,
760 0, 0, 0, -86, 0, 0, 0, 0, 34, 0,
761 0, 0, 0, 6, 0, 0, -86, 7, 8, 9,
762 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
763 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
764 30, 31, 32, 33, 0, 0, 0, 0, 0, -22,
765 0, 0, 0, 34, 0, 0, -22, 0, 0, -22,
766 -22, 7, 8, 9, 10, 11, 12, 13, 0, 15,
767 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 736 16, 17, 18, 19, 20, 21, 22, 23, 24, 0,
768 26, 27, 28, 29, 30, 0, 0, 33, 0, 0, 737 26, 27, 28, 29, 30, 0, 0, 33, 0, 0,
769 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 738 0, 0, -86, 0, 0, 0, 0, 34, 0, 0,
770 0, 0, 0, 0, 115, 116, 7, 8, 9, 10, 739 0, 0, 6, 0, 0, -86, 7, 8, 9, 10,
771 11, 12, 13, 0, 15, 16, 17, 18, 19, 20, 740 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
772 21, 22, 23, 24, 0, 26, 27, 28, 29, 30, 741 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
773 0, 0, 33, 0, 0, 0, 0, 0, 147, 0, 742 31, 32, 33, 0, 0, 0, 0, 0, -22, 0,
774 0, 0, 148, 0, 0, 0, 0, 0, 149, 63, 743 0, 0, 34, 0, 0, -22, 0, 0, -22, -22,
775 7, 8, 9, 10, 11, 12, 13, 0, 15, 16, 744 7, 8, 9, 10, 11, 12, 13, 0, 15, 16,
776 17, 18, 19, 20, 21, 22, 23, 24, 0, 26, 745 17, 18, 19, 20, 21, 22, 23, 24, 0, 26,
777 27, 28, 29, 30, 0, 0, 33, 0, 0, 0, 746 27, 28, 29, 30, 0, 0, 33, 0, 0, 0,
778 0, 168, 0, 0, 0, 0, 34, 7, 8, 9, 747 0, 0, 0, 0, 0, 0, 34, 0, 0, 0,
779 10, 11, 12, 13, 0, 15, 16, 17, 18, 19, 748 0, 0, 0, 122, 123, 7, 8, 9, 10, 11,
780 20, 21, 22, 23, 24, 0, 26, 27, 28, 29, 749 12, 13, 0, 15, 16, 17, 18, 19, 20, 21,
781 30, 0, 0, 33, 0, 0, 0, 0, 0, 0, 750 22, 23, 24, 0, 26, 27, 28, 29, 30, 0,
782 0, 0, 0, 34 751 0, 33, 0, 0, 0, 0, 0, 157, 0, 0,
752 0, 158, 0, 0, 0, 0, 0, 159, 64, 7,
753 8, 9, 10, 11, 12, 13, 0, 15, 16, 17,
754 18, 19, 20, 21, 22, 23, 24, 0, 26, 27,
755 28, 29, 30, 0, 0, 33, 0, 0, 0, 0,
756 178, 0, 0, 0, 0, 34, 7, 8, 9, 10,
757 11, 12, 13, 0, 15, 16, 17, 18, 19, 20,
758 21, 22, 23, 24, 0, 26, 27, 28, 29, 30,
759 0, 0, 33, 0, 0, 0, 0, 0, 0, 0,
760 0, 0, 34
783}; 761};
784 762
785static const yytype_int16 yycheck[] = 763static const yytype_int16 yycheck[] =
786{ 764{
787 58, 38, 75, 3, 137, 37, 26, 1, 31, 63, 765 59, 38, 79, 3, 1, 8, 56, 37, 26, 37,
788 1, 37, 37, 1, 32, 30, 0, 32, 8, 37, 766 64, 31, 1, 147, 37, 18, 30, 1, 32, 109,
789 23, 102, 55, 104, 32, 51, 51, 50, 18, 102, 767 0, 111, 45, 51, 27, 23, 76, 44, 31, 51,
790 62, 104, 52, 87, 167, 67, 56, 27, 96, 72, 768 50, 37, 109, 63, 111, 53, 33, 91, 68, 57,
791 47, 31, 33, 37, 37, 82, 37, 41, 33, 37, 769 37, 100, 47, 177, 41, 51, 37, 33, 37, 86,
792 41, 124, 47, 47, 48, 55, 47, 48, 49, 47, 770 47, 48, 49, 37, 131, 37, 56, 41, 47, 48,
793 48, 33, 47, 37, 44, 45, 139, 41, 33, 44, 771 51, 47, 47, 47, 48, 47, 48, 33, 37, 37,
794 45, 44, 72, 47, 48, 47, 149, 150, 52, 137, 772 51, 33, 149, 41, 44, 45, 76, 44, 45, 47,
795 37, 51, 47, 37, 41, 37, 44, 124, 49, 41, 773 48, 47, 159, 160, 52, 47, 37, 37, 147, 37,
796 47, 48, 45, 47, 48, 47, 48, 155, 1, 149, 774 41, 45, 46, 41, 131, 44, 47, 48, 50, 47,
797 150, 46, 5, 6, 7, 8, 9, 10, 11, 167, 775 48, 159, 160, 46, 45, 49, 165, 1, 34, 49,
798 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 776 49, 5, 6, 7, 8, 9, 10, 11, 177, 13,
799 49, 24, 25, 26, 27, 28, 49, 52, 31, 34, 777 14, 15, 16, 17, 18, 19, 20, 21, 22, 52,
800 44, 46, 44, 30, 37, 44, 49, 36, 41, 49, 778 24, 25, 26, 27, 28, 34, 44, 31, 44, 46,
801 31, 44, 45, 49, 47, 48, 1, 49, 46, 52, 779 30, 44, 31, 37, 49, 49, 46, 41, 49, 36,
802 5, 6, 7, 8, 9, 10, 11, 49, 13, 14, 780 44, 45, 49, 47, 48, 1, 49, 34, 52, 5,
803 15, 16, 17, 18, 19, 20, 21, 22, 34, 24, 781 6, 7, 8, 9, 10, 11, 49, 13, 14, 15,
804 25, 26, 27, 28, 49, 49, 31, 49, 49, 49, 782 16, 17, 18, 19, 20, 21, 22, 49, 24, 25,
805 49, 1, 37, 90, 155, 105, 41, 77, 139, 44, 783 26, 27, 28, 49, 49, 31, 49, 49, 1, 165,
806 45, -1, 47, 48, 1, -1, 100, 52, 5, 6, 784 81, 37, 94, 149, 107, 41, 112, 49, 44, 45,
807 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 785 -1, 47, 48, 1, -1, 103, 52, 5, 6, 7,
808 17, 18, 19, 20, 21, 22, -1, 24, 25, 26, 786 8, 9, 10, 11, -1, 13, 14, 15, 16, 17,
809 27, 28, -1, -1, 31, -1, -1, -1, -1, 36, 787 18, 19, 20, 21, 22, -1, 24, 25, 26, 27,
810 -1, 1, -1, -1, 41, 5, 6, 7, 8, 9, 788 28, -1, -1, 31, -1, -1, -1, -1, 36, -1,
811 10, 11, 49, 13, 14, 15, 16, 17, 18, 19, 789 1, -1, -1, 41, 5, 6, 7, 8, 9, 10,
812 20, 21, 22, -1, 24, 25, 26, 27, 28, -1, 790 11, 49, 13, 14, 15, 16, 17, 18, 19, 20,
813 -1, 31, -1, -1, -1, -1, 36, -1, 1, -1, 791 21, 22, -1, 24, 25, 26, 27, 28, -1, -1,
814 -1, 41, 5, 6, 7, 8, 9, 10, 11, 49, 792 31, -1, -1, -1, -1, 36, -1, 1, -1, -1,
815 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 793 41, 5, 6, 7, 8, 9, 10, 11, 49, 13,
816 -1, 24, 25, 26, 27, 28, -1, -1, 31, -1,
817 -1, -1, -1, 36, -1, -1, -1, -1, 41, -1,
818 -1, -1, -1, 1, -1, -1, 49, 5, 6, 7,
819 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
820 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
821 28, 29, 30, 31, -1, -1, -1, -1, -1, 37,
822 -1, -1, -1, 41, -1, -1, 44, -1, -1, 47,
823 48, 5, 6, 7, 8, 9, 10, 11, -1, 13,
824 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, 794 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
825 24, 25, 26, 27, 28, -1, -1, 31, -1, -1, 795 24, 25, 26, 27, 28, -1, -1, 31, -1, -1,
826 -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, 796 -1, -1, 36, -1, -1, -1, -1, 41, -1, -1,
827 -1, -1, -1, -1, 48, 49, 5, 6, 7, 8, 797 -1, -1, 1, -1, -1, 49, 5, 6, 7, 8,
828 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 798 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
829 19, 20, 21, 22, -1, 24, 25, 26, 27, 28, 799 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
830 -1, -1, 31, -1, -1, -1, -1, -1, 37, -1, 800 29, 30, 31, -1, -1, -1, -1, -1, 37, -1,
831 -1, -1, 41, -1, -1, -1, -1, -1, 47, 48, 801 -1, -1, 41, -1, -1, 44, -1, -1, 47, 48,
832 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 802 5, 6, 7, 8, 9, 10, 11, -1, 13, 14,
833 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, 803 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
834 25, 26, 27, 28, -1, -1, 31, -1, -1, -1, 804 25, 26, 27, 28, -1, -1, 31, -1, -1, -1,
835 -1, 36, -1, -1, -1, -1, 41, 5, 6, 7, 805 -1, -1, -1, -1, -1, -1, 41, -1, -1, -1,
836 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 806 -1, -1, -1, 48, 49, 5, 6, 7, 8, 9,
837 18, 19, 20, 21, 22, -1, 24, 25, 26, 27, 807 10, 11, -1, 13, 14, 15, 16, 17, 18, 19,
838 28, -1, -1, 31, -1, -1, -1, -1, -1, -1, 808 20, 21, 22, -1, 24, 25, 26, 27, 28, -1,
839 -1, -1, -1, 41 809 -1, 31, -1, -1, -1, -1, -1, 37, -1, -1,
810 -1, 41, -1, -1, -1, -1, -1, 47, 48, 5,
811 6, 7, 8, 9, 10, 11, -1, 13, 14, 15,
812 16, 17, 18, 19, 20, 21, 22, -1, 24, 25,
813 26, 27, 28, -1, -1, 31, -1, -1, -1, -1,
814 36, -1, -1, -1, -1, 41, 5, 6, 7, 8,
815 9, 10, 11, -1, 13, 14, 15, 16, 17, 18,
816 19, 20, 21, 22, -1, 24, 25, 26, 27, 28,
817 -1, -1, 31, -1, -1, -1, -1, -1, -1, -1,
818 -1, -1, 41
840}; 819};
841 820
842/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 821/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -847,15 +826,16 @@ static const yytype_uint8 yystos[] =
847 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 826 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
848 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 827 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
849 28, 29, 30, 31, 41, 57, 60, 64, 65, 66, 828 28, 29, 30, 31, 41, 57, 60, 64, 65, 66,
850 67, 68, 69, 73, 84, 96, 98, 44, 45, 32, 829 67, 68, 69, 73, 84, 99, 101, 44, 45, 37,
851 37, 23, 37, 51, 87, 59, 37, 87, 47, 47, 830 51, 96, 23, 37, 51, 87, 59, 37, 87, 47,
852 44, 37, 47, 48, 61, 62, 63, 70, 74, 75, 831 47, 44, 37, 47, 48, 61, 62, 63, 70, 74,
853 66, 32, 58, 87, 1, 64, 88, 89, 90, 60, 832 75, 66, 96, 37, 97, 98, 58, 87, 1, 64,
854 64, 87, 65, 37, 1, 74, 71, 72, 73, 44, 833 88, 89, 90, 60, 64, 87, 65, 37, 1, 74,
855 46, 74, 30, 32, 97, 33, 47, 60, 44, 45, 834 71, 72, 73, 44, 46, 74, 30, 32, 100, 33,
856 37, 41, 47, 52, 70, 76, 77, 91, 92, 93, 835 47, 50, 45, 46, 60, 44, 45, 37, 41, 47,
857 94, 45, 1, 90, 74, 48, 49, 49, 49, 49, 836 52, 70, 76, 77, 91, 92, 93, 94, 45, 1,
858 73, 63, 95, 1, 65, 78, 79, 80, 81, 94, 837 90, 74, 48, 49, 49, 49, 49, 73, 63, 95,
838 1, 65, 78, 79, 80, 81, 34, 45, 98, 94,
859 1, 37, 76, 34, 76, 95, 33, 47, 44, 46, 839 1, 37, 76, 34, 76, 95, 33, 47, 44, 46,
860 49, 44, 31, 50, 85, 86, 49, 37, 41, 47, 840 49, 44, 31, 50, 85, 86, 49, 37, 41, 47,
861 70, 82, 83, 49, 36, 46, 49, 49, 1, 78, 841 70, 82, 83, 49, 36, 46, 49, 49, 1, 78,
@@ -1045,17 +1025,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
1045#if (defined __STDC__ || defined __C99__FUNC__ \ 1025#if (defined __STDC__ || defined __C99__FUNC__ \
1046 || defined __cplusplus || defined _MSC_VER) 1026 || defined __cplusplus || defined _MSC_VER)
1047static void 1027static void
1048yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) 1028yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1049#else 1029#else
1050static void 1030static void
1051yy_stack_print (bottom, top) 1031yy_stack_print (yybottom, yytop)
1052 yytype_int16 *bottom; 1032 yytype_int16 *yybottom;
1053 yytype_int16 *top; 1033 yytype_int16 *yytop;
1054#endif 1034#endif
1055{ 1035{
1056 YYFPRINTF (stderr, "Stack now"); 1036 YYFPRINTF (stderr, "Stack now");
1057 for (; bottom <= top; ++bottom) 1037 for (; yybottom <= yytop; yybottom++)
1058 YYFPRINTF (stderr, " %d", *bottom); 1038 {
1039 int yybot = *yybottom;
1040 YYFPRINTF (stderr, " %d", yybot);
1041 }
1059 YYFPRINTF (stderr, "\n"); 1042 YYFPRINTF (stderr, "\n");
1060} 1043}
1061 1044
@@ -1089,11 +1072,11 @@ yy_reduce_print (yyvsp, yyrule)
1089 /* The symbols being reduced. */ 1072 /* The symbols being reduced. */
1090 for (yyi = 0; yyi < yynrhs; yyi++) 1073 for (yyi = 0; yyi < yynrhs; yyi++)
1091 { 1074 {
1092 fprintf (stderr, " $%d = ", yyi + 1); 1075 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1093 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 1076 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1094 &(yyvsp[(yyi + 1) - (yynrhs)]) 1077 &(yyvsp[(yyi + 1) - (yynrhs)])
1095 ); 1078 );
1096 fprintf (stderr, "\n"); 1079 YYFPRINTF (stderr, "\n");
1097 } 1080 }
1098} 1081}
1099 1082
@@ -1373,10 +1356,8 @@ yydestruct (yymsg, yytype, yyvaluep)
1373 break; 1356 break;
1374 } 1357 }
1375} 1358}
1376
1377 1359
1378/* Prevent warnings from -Wmissing-prototypes. */ 1360/* Prevent warnings from -Wmissing-prototypes. */
1379
1380#ifdef YYPARSE_PARAM 1361#ifdef YYPARSE_PARAM
1381#if defined __STDC__ || defined __cplusplus 1362#if defined __STDC__ || defined __cplusplus
1382int yyparse (void *YYPARSE_PARAM); 1363int yyparse (void *YYPARSE_PARAM);
@@ -1392,11 +1373,10 @@ int yyparse ();
1392#endif /* ! YYPARSE_PARAM */ 1373#endif /* ! YYPARSE_PARAM */
1393 1374
1394 1375
1395 1376/* The lookahead symbol. */
1396/* The look-ahead symbol. */
1397int yychar; 1377int yychar;
1398 1378
1399/* The semantic value of the look-ahead symbol. */ 1379/* The semantic value of the lookahead symbol. */
1400YYSTYPE yylval; 1380YYSTYPE yylval;
1401 1381
1402/* Number of syntax errors so far. */ 1382/* Number of syntax errors so far. */
@@ -1404,9 +1384,9 @@ int yynerrs;
1404 1384
1405 1385
1406 1386
1407/*----------. 1387/*-------------------------.
1408| yyparse. | 1388| yyparse or yypush_parse. |
1409`----------*/ 1389`-------------------------*/
1410 1390
1411#ifdef YYPARSE_PARAM 1391#ifdef YYPARSE_PARAM
1412#if (defined __STDC__ || defined __C99__FUNC__ \ 1392#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1430,66 +1410,68 @@ yyparse ()
1430#endif 1410#endif
1431#endif 1411#endif
1432{ 1412{
1433
1434 int yystate;
1435 int yyn;
1436 int yyresult;
1437 /* Number of tokens to shift before error messages enabled. */
1438 int yyerrstatus;
1439 /* Look-ahead token as an internal (translated) token number. */
1440 int yytoken = 0;
1441#if YYERROR_VERBOSE
1442 /* Buffer for error messages, and its allocated size. */
1443 char yymsgbuf[128];
1444 char *yymsg = yymsgbuf;
1445 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1446#endif
1447
1448 /* Three stacks and their tools:
1449 `yyss': related to states,
1450 `yyvs': related to semantic values,
1451 `yyls': related to locations.
1452 1413
1453 Refer to the stacks thru separate pointers, to allow yyoverflow
1454 to reallocate them elsewhere. */
1455 1414
1456 /* The state stack. */ 1415 int yystate;
1457 yytype_int16 yyssa[YYINITDEPTH]; 1416 /* Number of tokens to shift before error messages enabled. */
1458 yytype_int16 *yyss = yyssa; 1417 int yyerrstatus;
1459 yytype_int16 *yyssp;
1460 1418
1461 /* The semantic value stack. */ 1419 /* The stacks and their tools:
1462 YYSTYPE yyvsa[YYINITDEPTH]; 1420 `yyss': related to states.
1463 YYSTYPE *yyvs = yyvsa; 1421 `yyvs': related to semantic values.
1464 YYSTYPE *yyvsp;
1465 1422
1423 Refer to the stacks thru separate pointers, to allow yyoverflow
1424 to reallocate them elsewhere. */
1466 1425
1426 /* The state stack. */
1427 yytype_int16 yyssa[YYINITDEPTH];
1428 yytype_int16 *yyss;
1429 yytype_int16 *yyssp;
1467 1430
1468#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1431 /* The semantic value stack. */
1432 YYSTYPE yyvsa[YYINITDEPTH];
1433 YYSTYPE *yyvs;
1434 YYSTYPE *yyvsp;
1469 1435
1470 YYSIZE_T yystacksize = YYINITDEPTH; 1436 YYSIZE_T yystacksize;
1471 1437
1438 int yyn;
1439 int yyresult;
1440 /* Lookahead token as an internal (translated) token number. */
1441 int yytoken;
1472 /* The variables used to return semantic value and location from the 1442 /* The variables used to return semantic value and location from the
1473 action routines. */ 1443 action routines. */
1474 YYSTYPE yyval; 1444 YYSTYPE yyval;
1475 1445
1446#if YYERROR_VERBOSE
1447 /* Buffer for error messages, and its allocated size. */
1448 char yymsgbuf[128];
1449 char *yymsg = yymsgbuf;
1450 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1451#endif
1452
1453#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1476 1454
1477 /* The number of symbols on the RHS of the reduced rule. 1455 /* The number of symbols on the RHS of the reduced rule.
1478 Keep to zero when no symbol should be popped. */ 1456 Keep to zero when no symbol should be popped. */
1479 int yylen = 0; 1457 int yylen = 0;
1480 1458
1459 yytoken = 0;
1460 yyss = yyssa;
1461 yyvs = yyvsa;
1462 yystacksize = YYINITDEPTH;
1463
1481 YYDPRINTF ((stderr, "Starting parse\n")); 1464 YYDPRINTF ((stderr, "Starting parse\n"));
1482 1465
1483 yystate = 0; 1466 yystate = 0;
1484 yyerrstatus = 0; 1467 yyerrstatus = 0;
1485 yynerrs = 0; 1468 yynerrs = 0;
1486 yychar = YYEMPTY; /* Cause a token to be read. */ 1469 yychar = YYEMPTY; /* Cause a token to be read. */
1487 1470
1488 /* Initialize stack pointers. 1471 /* Initialize stack pointers.
1489 Waste one element of value and location stack 1472 Waste one element of value and location stack
1490 so that they stay on the same level as the state stack. 1473 so that they stay on the same level as the state stack.
1491 The wasted elements are never initialized. */ 1474 The wasted elements are never initialized. */
1492
1493 yyssp = yyss; 1475 yyssp = yyss;
1494 yyvsp = yyvs; 1476 yyvsp = yyvs;
1495 1477
@@ -1519,7 +1501,6 @@ yyparse ()
1519 YYSTYPE *yyvs1 = yyvs; 1501 YYSTYPE *yyvs1 = yyvs;
1520 yytype_int16 *yyss1 = yyss; 1502 yytype_int16 *yyss1 = yyss;
1521 1503
1522
1523 /* Each stack pointer address is followed by the size of the 1504 /* Each stack pointer address is followed by the size of the
1524 data in use in that stack, in bytes. This used to be a 1505 data in use in that stack, in bytes. This used to be a
1525 conditional around just the two extra args, but that might 1506 conditional around just the two extra args, but that might
@@ -1527,7 +1508,6 @@ yyparse ()
1527 yyoverflow (YY_("memory exhausted"), 1508 yyoverflow (YY_("memory exhausted"),
1528 &yyss1, yysize * sizeof (*yyssp), 1509 &yyss1, yysize * sizeof (*yyssp),
1529 &yyvs1, yysize * sizeof (*yyvsp), 1510 &yyvs1, yysize * sizeof (*yyvsp),
1530
1531 &yystacksize); 1511 &yystacksize);
1532 1512
1533 yyss = yyss1; 1513 yyss = yyss1;
@@ -1550,9 +1530,8 @@ yyparse ()
1550 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1530 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1551 if (! yyptr) 1531 if (! yyptr)
1552 goto yyexhaustedlab; 1532 goto yyexhaustedlab;
1553 YYSTACK_RELOCATE (yyss); 1533 YYSTACK_RELOCATE (yyss_alloc, yyss);
1554 YYSTACK_RELOCATE (yyvs); 1534 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1555
1556# undef YYSTACK_RELOCATE 1535# undef YYSTACK_RELOCATE
1557 if (yyss1 != yyssa) 1536 if (yyss1 != yyssa)
1558 YYSTACK_FREE (yyss1); 1537 YYSTACK_FREE (yyss1);
@@ -1563,7 +1542,6 @@ yyparse ()
1563 yyssp = yyss + yysize - 1; 1542 yyssp = yyss + yysize - 1;
1564 yyvsp = yyvs + yysize - 1; 1543 yyvsp = yyvs + yysize - 1;
1565 1544
1566
1567 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1545 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1568 (unsigned long int) yystacksize)); 1546 (unsigned long int) yystacksize));
1569 1547
@@ -1573,6 +1551,9 @@ yyparse ()
1573 1551
1574 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1552 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1575 1553
1554 if (yystate == YYFINAL)
1555 YYACCEPT;
1556
1576 goto yybackup; 1557 goto yybackup;
1577 1558
1578/*-----------. 1559/*-----------.
@@ -1581,16 +1562,16 @@ yyparse ()
1581yybackup: 1562yybackup:
1582 1563
1583 /* Do appropriate processing given the current state. Read a 1564 /* Do appropriate processing given the current state. Read a
1584 look-ahead token if we need one and don't already have one. */ 1565 lookahead token if we need one and don't already have one. */
1585 1566
1586 /* First try to decide what to do without reference to look-ahead token. */ 1567 /* First try to decide what to do without reference to lookahead token. */
1587 yyn = yypact[yystate]; 1568 yyn = yypact[yystate];
1588 if (yyn == YYPACT_NINF) 1569 if (yyn == YYPACT_NINF)
1589 goto yydefault; 1570 goto yydefault;
1590 1571
1591 /* Not known => get a look-ahead token if don't already have one. */ 1572 /* Not known => get a lookahead token if don't already have one. */
1592 1573
1593 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ 1574 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1594 if (yychar == YYEMPTY) 1575 if (yychar == YYEMPTY)
1595 { 1576 {
1596 YYDPRINTF ((stderr, "Reading a token: ")); 1577 YYDPRINTF ((stderr, "Reading a token: "));
@@ -1622,20 +1603,16 @@ yybackup:
1622 goto yyreduce; 1603 goto yyreduce;
1623 } 1604 }
1624 1605
1625 if (yyn == YYFINAL)
1626 YYACCEPT;
1627
1628 /* Count tokens shifted since error; after three, turn off error 1606 /* Count tokens shifted since error; after three, turn off error
1629 status. */ 1607 status. */
1630 if (yyerrstatus) 1608 if (yyerrstatus)
1631 yyerrstatus--; 1609 yyerrstatus--;
1632 1610
1633 /* Shift the look-ahead token. */ 1611 /* Shift the lookahead token. */
1634 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1612 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1635 1613
1636 /* Discard the shifted token unless it is eof. */ 1614 /* Discard the shifted token. */
1637 if (yychar != YYEOF) 1615 yychar = YYEMPTY;
1638 yychar = YYEMPTY;
1639 1616
1640 yystate = yyn; 1617 yystate = yyn;
1641 *++yyvsp = yylval; 1618 *++yyvsp = yylval;
@@ -1675,47 +1652,65 @@ yyreduce:
1675 switch (yyn) 1652 switch (yyn)
1676 { 1653 {
1677 case 4: 1654 case 4:
1678#line 108 "scripts/genksyms/parse.y" 1655
1656/* Line 1455 of yacc.c */
1657#line 109 "scripts/genksyms/parse.y"
1679 { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;} 1658 { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;}
1680 break; 1659 break;
1681 1660
1682 case 5: 1661 case 5:
1683#line 110 "scripts/genksyms/parse.y" 1662
1663/* Line 1455 of yacc.c */
1664#line 111 "scripts/genksyms/parse.y"
1684 { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; ;} 1665 { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; ;}
1685 break; 1666 break;
1686 1667
1687 case 6: 1668 case 6:
1688#line 114 "scripts/genksyms/parse.y" 1669
1670/* Line 1455 of yacc.c */
1671#line 115 "scripts/genksyms/parse.y"
1689 { is_typedef = 1; ;} 1672 { is_typedef = 1; ;}
1690 break; 1673 break;
1691 1674
1692 case 7: 1675 case 7:
1693#line 115 "scripts/genksyms/parse.y" 1676
1677/* Line 1455 of yacc.c */
1678#line 116 "scripts/genksyms/parse.y"
1694 { (yyval) = (yyvsp[(4) - (4)]); ;} 1679 { (yyval) = (yyvsp[(4) - (4)]); ;}
1695 break; 1680 break;
1696 1681
1697 case 8: 1682 case 8:
1698#line 116 "scripts/genksyms/parse.y" 1683
1684/* Line 1455 of yacc.c */
1685#line 117 "scripts/genksyms/parse.y"
1699 { is_typedef = 1; ;} 1686 { is_typedef = 1; ;}
1700 break; 1687 break;
1701 1688
1702 case 9: 1689 case 9:
1703#line 117 "scripts/genksyms/parse.y" 1690
1691/* Line 1455 of yacc.c */
1692#line 118 "scripts/genksyms/parse.y"
1704 { (yyval) = (yyvsp[(3) - (3)]); ;} 1693 { (yyval) = (yyvsp[(3) - (3)]); ;}
1705 break; 1694 break;
1706 1695
1707 case 14: 1696 case 14:
1708#line 122 "scripts/genksyms/parse.y" 1697
1698/* Line 1455 of yacc.c */
1699#line 123 "scripts/genksyms/parse.y"
1709 { (yyval) = (yyvsp[(2) - (2)]); ;} 1700 { (yyval) = (yyvsp[(2) - (2)]); ;}
1710 break; 1701 break;
1711 1702
1712 case 15: 1703 case 15:
1713#line 123 "scripts/genksyms/parse.y" 1704
1705/* Line 1455 of yacc.c */
1706#line 124 "scripts/genksyms/parse.y"
1714 { (yyval) = (yyvsp[(2) - (2)]); ;} 1707 { (yyval) = (yyvsp[(2) - (2)]); ;}
1715 break; 1708 break;
1716 1709
1717 case 16: 1710 case 16:
1718#line 128 "scripts/genksyms/parse.y" 1711
1712/* Line 1455 of yacc.c */
1713#line 129 "scripts/genksyms/parse.y"
1719 { if (current_name) { 1714 { if (current_name) {
1720 struct string_list *decl = (*(yyvsp[(3) - (3)]))->next; 1715 struct string_list *decl = (*(yyvsp[(3) - (3)]))->next;
1721 (*(yyvsp[(3) - (3)]))->next = NULL; 1716 (*(yyvsp[(3) - (3)]))->next = NULL;
@@ -1729,12 +1724,16 @@ yyreduce:
1729 break; 1724 break;
1730 1725
1731 case 17: 1726 case 17:
1732#line 141 "scripts/genksyms/parse.y" 1727
1728/* Line 1455 of yacc.c */
1729#line 142 "scripts/genksyms/parse.y"
1733 { (yyval) = NULL; ;} 1730 { (yyval) = NULL; ;}
1734 break; 1731 break;
1735 1732
1736 case 19: 1733 case 19:
1737#line 147 "scripts/genksyms/parse.y" 1734
1735/* Line 1455 of yacc.c */
1736#line 148 "scripts/genksyms/parse.y"
1738 { struct string_list *decl = *(yyvsp[(1) - (1)]); 1737 { struct string_list *decl = *(yyvsp[(1) - (1)]);
1739 *(yyvsp[(1) - (1)]) = NULL; 1738 *(yyvsp[(1) - (1)]) = NULL;
1740 add_symbol(current_name, 1739 add_symbol(current_name,
@@ -1745,7 +1744,9 @@ yyreduce:
1745 break; 1744 break;
1746 1745
1747 case 20: 1746 case 20:
1748#line 155 "scripts/genksyms/parse.y" 1747
1748/* Line 1455 of yacc.c */
1749#line 156 "scripts/genksyms/parse.y"
1749 { struct string_list *decl = *(yyvsp[(3) - (3)]); 1750 { struct string_list *decl = *(yyvsp[(3) - (3)]);
1750 *(yyvsp[(3) - (3)]) = NULL; 1751 *(yyvsp[(3) - (3)]) = NULL;
1751 free_list(*(yyvsp[(2) - (3)]), NULL); 1752 free_list(*(yyvsp[(2) - (3)]), NULL);
@@ -1758,27 +1759,37 @@ yyreduce:
1758 break; 1759 break;
1759 1760
1760 case 21: 1761 case 21:
1761#line 168 "scripts/genksyms/parse.y" 1762
1763/* Line 1455 of yacc.c */
1764#line 169 "scripts/genksyms/parse.y"
1762 { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); ;} 1765 { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); ;}
1763 break; 1766 break;
1764 1767
1765 case 22: 1768 case 22:
1766#line 173 "scripts/genksyms/parse.y" 1769
1770/* Line 1455 of yacc.c */
1771#line 174 "scripts/genksyms/parse.y"
1767 { decl_spec = NULL; ;} 1772 { decl_spec = NULL; ;}
1768 break; 1773 break;
1769 1774
1770 case 24: 1775 case 24:
1771#line 178 "scripts/genksyms/parse.y" 1776
1777/* Line 1455 of yacc.c */
1778#line 179 "scripts/genksyms/parse.y"
1772 { decl_spec = *(yyvsp[(1) - (1)]); ;} 1779 { decl_spec = *(yyvsp[(1) - (1)]); ;}
1773 break; 1780 break;
1774 1781
1775 case 25: 1782 case 25:
1776#line 179 "scripts/genksyms/parse.y" 1783
1784/* Line 1455 of yacc.c */
1785#line 180 "scripts/genksyms/parse.y"
1777 { decl_spec = *(yyvsp[(2) - (2)]); ;} 1786 { decl_spec = *(yyvsp[(2) - (2)]); ;}
1778 break; 1787 break;
1779 1788
1780 case 26: 1789 case 26:
1781#line 184 "scripts/genksyms/parse.y" 1790
1791/* Line 1455 of yacc.c */
1792#line 185 "scripts/genksyms/parse.y"
1782 { /* Version 2 checksumming ignores storage class, as that 1793 { /* Version 2 checksumming ignores storage class, as that
1783 is really irrelevant to the linkage. */ 1794 is really irrelevant to the linkage. */
1784 remove_node((yyvsp[(1) - (1)])); 1795 remove_node((yyvsp[(1) - (1)]));
@@ -1787,32 +1798,44 @@ yyreduce:
1787 break; 1798 break;
1788 1799
1789 case 31: 1800 case 31:
1790#line 196 "scripts/genksyms/parse.y" 1801
1802/* Line 1455 of yacc.c */
1803#line 197 "scripts/genksyms/parse.y"
1791 { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); ;} 1804 { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); ;}
1792 break; 1805 break;
1793 1806
1794 case 32: 1807 case 32:
1795#line 197 "scripts/genksyms/parse.y" 1808
1809/* Line 1455 of yacc.c */
1810#line 198 "scripts/genksyms/parse.y"
1796 { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); ;} 1811 { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); ;}
1797 break; 1812 break;
1798 1813
1799 case 37: 1814 case 37:
1800#line 209 "scripts/genksyms/parse.y" 1815
1816/* Line 1455 of yacc.c */
1817#line 210 "scripts/genksyms/parse.y"
1801 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); ;} 1818 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); ;}
1802 break; 1819 break;
1803 1820
1804 case 38: 1821 case 38:
1805#line 211 "scripts/genksyms/parse.y" 1822
1823/* Line 1455 of yacc.c */
1824#line 212 "scripts/genksyms/parse.y"
1806 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); ;} 1825 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); ;}
1807 break; 1826 break;
1808 1827
1809 case 39: 1828 case 39:
1810#line 213 "scripts/genksyms/parse.y" 1829
1830/* Line 1455 of yacc.c */
1831#line 214 "scripts/genksyms/parse.y"
1811 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); ;} 1832 { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); ;}
1812 break; 1833 break;
1813 1834
1814 case 40: 1835 case 40:
1815#line 217 "scripts/genksyms/parse.y" 1836
1837/* Line 1455 of yacc.c */
1838#line 218 "scripts/genksyms/parse.y"
1816 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; 1839 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
1817 r = copy_node(i); r->tag = SYM_STRUCT; 1840 r = copy_node(i); r->tag = SYM_STRUCT;
1818 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; 1841 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
@@ -1822,7 +1845,9 @@ yyreduce:
1822 break; 1845 break;
1823 1846
1824 case 41: 1847 case 41:
1825#line 224 "scripts/genksyms/parse.y" 1848
1849/* Line 1455 of yacc.c */
1850#line 225 "scripts/genksyms/parse.y"
1826 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; 1851 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
1827 r = copy_node(i); r->tag = SYM_UNION; 1852 r = copy_node(i); r->tag = SYM_UNION;
1828 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; 1853 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
@@ -1832,7 +1857,9 @@ yyreduce:
1832 break; 1857 break;
1833 1858
1834 case 42: 1859 case 42:
1835#line 231 "scripts/genksyms/parse.y" 1860
1861/* Line 1455 of yacc.c */
1862#line 232 "scripts/genksyms/parse.y"
1836 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; 1863 { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
1837 r = copy_node(i); r->tag = SYM_ENUM; 1864 r = copy_node(i); r->tag = SYM_ENUM;
1838 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; 1865 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
@@ -1842,42 +1869,58 @@ yyreduce:
1842 break; 1869 break;
1843 1870
1844 case 43: 1871 case 43:
1845#line 239 "scripts/genksyms/parse.y" 1872
1846 { (yyval) = (yyvsp[(2) - (2)]); ;} 1873/* Line 1455 of yacc.c */
1874#line 242 "scripts/genksyms/parse.y"
1875 { add_symbol(NULL, SYM_ENUM, NULL, 0); (yyval) = (yyvsp[(2) - (2)]); ;}
1847 break; 1876 break;
1848 1877
1849 case 44: 1878 case 44:
1850#line 240 "scripts/genksyms/parse.y" 1879
1880/* Line 1455 of yacc.c */
1881#line 244 "scripts/genksyms/parse.y"
1851 { (yyval) = (yyvsp[(2) - (2)]); ;} 1882 { (yyval) = (yyvsp[(2) - (2)]); ;}
1852 break; 1883 break;
1853 1884
1854 case 45: 1885 case 45:
1855#line 241 "scripts/genksyms/parse.y" 1886
1887/* Line 1455 of yacc.c */
1888#line 245 "scripts/genksyms/parse.y"
1856 { (yyval) = (yyvsp[(2) - (2)]); ;} 1889 { (yyval) = (yyvsp[(2) - (2)]); ;}
1857 break; 1890 break;
1858 1891
1859 case 56: 1892 case 56:
1860#line 255 "scripts/genksyms/parse.y" 1893
1894/* Line 1455 of yacc.c */
1895#line 259 "scripts/genksyms/parse.y"
1861 { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); ;} 1896 { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); ;}
1862 break; 1897 break;
1863 1898
1864 case 57: 1899 case 57:
1865#line 260 "scripts/genksyms/parse.y" 1900
1901/* Line 1455 of yacc.c */
1902#line 264 "scripts/genksyms/parse.y"
1866 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} 1903 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
1867 break; 1904 break;
1868 1905
1869 case 58: 1906 case 58:
1870#line 264 "scripts/genksyms/parse.y" 1907
1908/* Line 1455 of yacc.c */
1909#line 268 "scripts/genksyms/parse.y"
1871 { (yyval) = NULL; ;} 1910 { (yyval) = NULL; ;}
1872 break; 1911 break;
1873 1912
1874 case 61: 1913 case 61:
1875#line 270 "scripts/genksyms/parse.y" 1914
1915/* Line 1455 of yacc.c */
1916#line 274 "scripts/genksyms/parse.y"
1876 { (yyval) = (yyvsp[(2) - (2)]); ;} 1917 { (yyval) = (yyvsp[(2) - (2)]); ;}
1877 break; 1918 break;
1878 1919
1879 case 65: 1920 case 65:
1880#line 276 "scripts/genksyms/parse.y" 1921
1922/* Line 1455 of yacc.c */
1923#line 280 "scripts/genksyms/parse.y"
1881 { /* restrict has no effect in prototypes so ignore it */ 1924 { /* restrict has no effect in prototypes so ignore it */
1882 remove_node((yyvsp[(1) - (1)])); 1925 remove_node((yyvsp[(1) - (1)]));
1883 (yyval) = (yyvsp[(1) - (1)]); 1926 (yyval) = (yyvsp[(1) - (1)]);
@@ -1885,12 +1928,16 @@ yyreduce:
1885 break; 1928 break;
1886 1929
1887 case 66: 1930 case 66:
1888#line 283 "scripts/genksyms/parse.y" 1931
1932/* Line 1455 of yacc.c */
1933#line 287 "scripts/genksyms/parse.y"
1889 { (yyval) = (yyvsp[(2) - (2)]); ;} 1934 { (yyval) = (yyvsp[(2) - (2)]); ;}
1890 break; 1935 break;
1891 1936
1892 case 68: 1937 case 68:
1893#line 289 "scripts/genksyms/parse.y" 1938
1939/* Line 1455 of yacc.c */
1940#line 293 "scripts/genksyms/parse.y"
1894 { if (current_name != NULL) { 1941 { if (current_name != NULL) {
1895 error_with_pos("unexpected second declaration name"); 1942 error_with_pos("unexpected second declaration name");
1896 YYERROR; 1943 YYERROR;
@@ -1902,97 +1949,135 @@ yyreduce:
1902 break; 1949 break;
1903 1950
1904 case 69: 1951 case 69:
1905#line 298 "scripts/genksyms/parse.y" 1952
1953/* Line 1455 of yacc.c */
1954#line 302 "scripts/genksyms/parse.y"
1906 { (yyval) = (yyvsp[(4) - (4)]); ;} 1955 { (yyval) = (yyvsp[(4) - (4)]); ;}
1907 break; 1956 break;
1908 1957
1909 case 70: 1958 case 70:
1910#line 300 "scripts/genksyms/parse.y" 1959
1960/* Line 1455 of yacc.c */
1961#line 304 "scripts/genksyms/parse.y"
1911 { (yyval) = (yyvsp[(4) - (4)]); ;} 1962 { (yyval) = (yyvsp[(4) - (4)]); ;}
1912 break; 1963 break;
1913 1964
1914 case 71: 1965 case 71:
1915#line 302 "scripts/genksyms/parse.y" 1966
1967/* Line 1455 of yacc.c */
1968#line 306 "scripts/genksyms/parse.y"
1916 { (yyval) = (yyvsp[(2) - (2)]); ;} 1969 { (yyval) = (yyvsp[(2) - (2)]); ;}
1917 break; 1970 break;
1918 1971
1919 case 72: 1972 case 72:
1920#line 304 "scripts/genksyms/parse.y" 1973
1974/* Line 1455 of yacc.c */
1975#line 308 "scripts/genksyms/parse.y"
1921 { (yyval) = (yyvsp[(3) - (3)]); ;} 1976 { (yyval) = (yyvsp[(3) - (3)]); ;}
1922 break; 1977 break;
1923 1978
1924 case 73: 1979 case 73:
1925#line 306 "scripts/genksyms/parse.y" 1980
1981/* Line 1455 of yacc.c */
1982#line 310 "scripts/genksyms/parse.y"
1926 { (yyval) = (yyvsp[(3) - (3)]); ;} 1983 { (yyval) = (yyvsp[(3) - (3)]); ;}
1927 break; 1984 break;
1928 1985
1929 case 74: 1986 case 74:
1930#line 312 "scripts/genksyms/parse.y" 1987
1988/* Line 1455 of yacc.c */
1989#line 316 "scripts/genksyms/parse.y"
1931 { (yyval) = (yyvsp[(2) - (2)]); ;} 1990 { (yyval) = (yyvsp[(2) - (2)]); ;}
1932 break; 1991 break;
1933 1992
1934 case 78: 1993 case 78:
1935#line 320 "scripts/genksyms/parse.y" 1994
1995/* Line 1455 of yacc.c */
1996#line 324 "scripts/genksyms/parse.y"
1936 { (yyval) = (yyvsp[(4) - (4)]); ;} 1997 { (yyval) = (yyvsp[(4) - (4)]); ;}
1937 break; 1998 break;
1938 1999
1939 case 79: 2000 case 79:
1940#line 322 "scripts/genksyms/parse.y" 2001
2002/* Line 1455 of yacc.c */
2003#line 326 "scripts/genksyms/parse.y"
1941 { (yyval) = (yyvsp[(4) - (4)]); ;} 2004 { (yyval) = (yyvsp[(4) - (4)]); ;}
1942 break; 2005 break;
1943 2006
1944 case 80: 2007 case 80:
1945#line 324 "scripts/genksyms/parse.y" 2008
2009/* Line 1455 of yacc.c */
2010#line 328 "scripts/genksyms/parse.y"
1946 { (yyval) = (yyvsp[(2) - (2)]); ;} 2011 { (yyval) = (yyvsp[(2) - (2)]); ;}
1947 break; 2012 break;
1948 2013
1949 case 81: 2014 case 81:
1950#line 326 "scripts/genksyms/parse.y" 2015
2016/* Line 1455 of yacc.c */
2017#line 330 "scripts/genksyms/parse.y"
1951 { (yyval) = (yyvsp[(3) - (3)]); ;} 2018 { (yyval) = (yyvsp[(3) - (3)]); ;}
1952 break; 2019 break;
1953 2020
1954 case 82: 2021 case 82:
1955#line 328 "scripts/genksyms/parse.y" 2022
2023/* Line 1455 of yacc.c */
2024#line 332 "scripts/genksyms/parse.y"
1956 { (yyval) = (yyvsp[(3) - (3)]); ;} 2025 { (yyval) = (yyvsp[(3) - (3)]); ;}
1957 break; 2026 break;
1958 2027
1959 case 83: 2028 case 83:
1960#line 332 "scripts/genksyms/parse.y" 2029
2030/* Line 1455 of yacc.c */
2031#line 336 "scripts/genksyms/parse.y"
1961 { (yyval) = (yyvsp[(2) - (2)]); ;} 2032 { (yyval) = (yyvsp[(2) - (2)]); ;}
1962 break; 2033 break;
1963 2034
1964 case 85: 2035 case 85:
1965#line 334 "scripts/genksyms/parse.y" 2036
2037/* Line 1455 of yacc.c */
2038#line 338 "scripts/genksyms/parse.y"
1966 { (yyval) = (yyvsp[(3) - (3)]); ;} 2039 { (yyval) = (yyvsp[(3) - (3)]); ;}
1967 break; 2040 break;
1968 2041
1969 case 86: 2042 case 86:
1970#line 338 "scripts/genksyms/parse.y" 2043
2044/* Line 1455 of yacc.c */
2045#line 342 "scripts/genksyms/parse.y"
1971 { (yyval) = NULL; ;} 2046 { (yyval) = NULL; ;}
1972 break; 2047 break;
1973 2048
1974 case 89: 2049 case 89:
1975#line 345 "scripts/genksyms/parse.y" 2050
2051/* Line 1455 of yacc.c */
2052#line 349 "scripts/genksyms/parse.y"
1976 { (yyval) = (yyvsp[(3) - (3)]); ;} 2053 { (yyval) = (yyvsp[(3) - (3)]); ;}
1977 break; 2054 break;
1978 2055
1979 case 90: 2056 case 90:
1980#line 350 "scripts/genksyms/parse.y" 2057
2058/* Line 1455 of yacc.c */
2059#line 354 "scripts/genksyms/parse.y"
1981 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} 2060 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
1982 break; 2061 break;
1983 2062
1984 case 91: 2063 case 91:
1985#line 355 "scripts/genksyms/parse.y" 2064
2065/* Line 1455 of yacc.c */
2066#line 359 "scripts/genksyms/parse.y"
1986 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} 2067 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
1987 break; 2068 break;
1988 2069
1989 case 93: 2070 case 93:
1990#line 360 "scripts/genksyms/parse.y" 2071
2072/* Line 1455 of yacc.c */
2073#line 364 "scripts/genksyms/parse.y"
1991 { (yyval) = NULL; ;} 2074 { (yyval) = NULL; ;}
1992 break; 2075 break;
1993 2076
1994 case 94: 2077 case 94:
1995#line 362 "scripts/genksyms/parse.y" 2078
2079/* Line 1455 of yacc.c */
2080#line 366 "scripts/genksyms/parse.y"
1996 { /* For version 2 checksums, we don't want to remember 2081 { /* For version 2 checksums, we don't want to remember
1997 private parameter names. */ 2082 private parameter names. */
1998 remove_node((yyvsp[(1) - (1)])); 2083 remove_node((yyvsp[(1) - (1)]));
@@ -2001,39 +2086,53 @@ yyreduce:
2001 break; 2086 break;
2002 2087
2003 case 95: 2088 case 95:
2004#line 370 "scripts/genksyms/parse.y" 2089
2090/* Line 1455 of yacc.c */
2091#line 374 "scripts/genksyms/parse.y"
2005 { remove_node((yyvsp[(1) - (1)])); 2092 { remove_node((yyvsp[(1) - (1)]));
2006 (yyval) = (yyvsp[(1) - (1)]); 2093 (yyval) = (yyvsp[(1) - (1)]);
2007 ;} 2094 ;}
2008 break; 2095 break;
2009 2096
2010 case 96: 2097 case 96:
2011#line 374 "scripts/genksyms/parse.y" 2098
2099/* Line 1455 of yacc.c */
2100#line 378 "scripts/genksyms/parse.y"
2012 { (yyval) = (yyvsp[(4) - (4)]); ;} 2101 { (yyval) = (yyvsp[(4) - (4)]); ;}
2013 break; 2102 break;
2014 2103
2015 case 97: 2104 case 97:
2016#line 376 "scripts/genksyms/parse.y" 2105
2106/* Line 1455 of yacc.c */
2107#line 380 "scripts/genksyms/parse.y"
2017 { (yyval) = (yyvsp[(4) - (4)]); ;} 2108 { (yyval) = (yyvsp[(4) - (4)]); ;}
2018 break; 2109 break;
2019 2110
2020 case 98: 2111 case 98:
2021#line 378 "scripts/genksyms/parse.y" 2112
2113/* Line 1455 of yacc.c */
2114#line 382 "scripts/genksyms/parse.y"
2022 { (yyval) = (yyvsp[(2) - (2)]); ;} 2115 { (yyval) = (yyvsp[(2) - (2)]); ;}
2023 break; 2116 break;
2024 2117
2025 case 99: 2118 case 99:
2026#line 380 "scripts/genksyms/parse.y" 2119
2120/* Line 1455 of yacc.c */
2121#line 384 "scripts/genksyms/parse.y"
2027 { (yyval) = (yyvsp[(3) - (3)]); ;} 2122 { (yyval) = (yyvsp[(3) - (3)]); ;}
2028 break; 2123 break;
2029 2124
2030 case 100: 2125 case 100:
2031#line 382 "scripts/genksyms/parse.y" 2126
2127/* Line 1455 of yacc.c */
2128#line 386 "scripts/genksyms/parse.y"
2032 { (yyval) = (yyvsp[(3) - (3)]); ;} 2129 { (yyval) = (yyvsp[(3) - (3)]); ;}
2033 break; 2130 break;
2034 2131
2035 case 101: 2132 case 101:
2036#line 387 "scripts/genksyms/parse.y" 2133
2134/* Line 1455 of yacc.c */
2135#line 391 "scripts/genksyms/parse.y"
2037 { struct string_list *decl = *(yyvsp[(2) - (3)]); 2136 { struct string_list *decl = *(yyvsp[(2) - (3)]);
2038 *(yyvsp[(2) - (3)]) = NULL; 2137 *(yyvsp[(2) - (3)]) = NULL;
2039 add_symbol(current_name, SYM_NORMAL, decl, is_extern); 2138 add_symbol(current_name, SYM_NORMAL, decl, is_extern);
@@ -2042,93 +2141,163 @@ yyreduce:
2042 break; 2141 break;
2043 2142
2044 case 102: 2143 case 102:
2045#line 395 "scripts/genksyms/parse.y" 2144
2145/* Line 1455 of yacc.c */
2146#line 399 "scripts/genksyms/parse.y"
2046 { (yyval) = NULL; ;} 2147 { (yyval) = NULL; ;}
2047 break; 2148 break;
2048 2149
2049 case 104: 2150 case 104:
2050#line 402 "scripts/genksyms/parse.y" 2151
2152/* Line 1455 of yacc.c */
2153#line 406 "scripts/genksyms/parse.y"
2051 { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); ;} 2154 { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); ;}
2052 break; 2155 break;
2053 2156
2054 case 105: 2157 case 105:
2055#line 406 "scripts/genksyms/parse.y" 2158
2159/* Line 1455 of yacc.c */
2160#line 410 "scripts/genksyms/parse.y"
2056 { (yyval) = (yyvsp[(3) - (3)]); ;} 2161 { (yyval) = (yyvsp[(3) - (3)]); ;}
2057 break; 2162 break;
2058 2163
2059 case 106: 2164 case 106:
2060#line 407 "scripts/genksyms/parse.y" 2165
2166/* Line 1455 of yacc.c */
2167#line 411 "scripts/genksyms/parse.y"
2061 { (yyval) = (yyvsp[(3) - (3)]); ;} 2168 { (yyval) = (yyvsp[(3) - (3)]); ;}
2062 break; 2169 break;
2063 2170
2064 case 107: 2171 case 107:
2065#line 411 "scripts/genksyms/parse.y" 2172
2173/* Line 1455 of yacc.c */
2174#line 415 "scripts/genksyms/parse.y"
2066 { (yyval) = NULL; ;} 2175 { (yyval) = NULL; ;}
2067 break; 2176 break;
2068 2177
2069 case 110: 2178 case 110:
2070#line 417 "scripts/genksyms/parse.y" 2179
2180/* Line 1455 of yacc.c */
2181#line 421 "scripts/genksyms/parse.y"
2071 { (yyval) = (yyvsp[(2) - (2)]); ;} 2182 { (yyval) = (yyvsp[(2) - (2)]); ;}
2072 break; 2183 break;
2073 2184
2074 case 111: 2185 case 111:
2075#line 422 "scripts/genksyms/parse.y" 2186
2187/* Line 1455 of yacc.c */
2188#line 426 "scripts/genksyms/parse.y"
2076 { (yyval) = (yyvsp[(3) - (3)]); ;} 2189 { (yyval) = (yyvsp[(3) - (3)]); ;}
2077 break; 2190 break;
2078 2191
2079 case 112: 2192 case 112:
2080#line 424 "scripts/genksyms/parse.y" 2193
2194/* Line 1455 of yacc.c */
2195#line 428 "scripts/genksyms/parse.y"
2081 { (yyval) = (yyvsp[(2) - (2)]); ;} 2196 { (yyval) = (yyvsp[(2) - (2)]); ;}
2082 break; 2197 break;
2083 2198
2084 case 113: 2199 case 113:
2085#line 428 "scripts/genksyms/parse.y" 2200
2201/* Line 1455 of yacc.c */
2202#line 432 "scripts/genksyms/parse.y"
2086 { (yyval) = NULL; ;} 2203 { (yyval) = NULL; ;}
2087 break; 2204 break;
2088 2205
2089 case 116: 2206 case 116:
2090#line 434 "scripts/genksyms/parse.y" 2207
2208/* Line 1455 of yacc.c */
2209#line 438 "scripts/genksyms/parse.y"
2091 { (yyval) = (yyvsp[(3) - (3)]); ;} 2210 { (yyval) = (yyvsp[(3) - (3)]); ;}
2092 break; 2211 break;
2093 2212
2094 case 117: 2213 case 117:
2095#line 438 "scripts/genksyms/parse.y" 2214
2215/* Line 1455 of yacc.c */
2216#line 442 "scripts/genksyms/parse.y"
2096 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} 2217 { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
2097 break; 2218 break;
2098 2219
2099 case 118: 2220 case 118:
2100#line 439 "scripts/genksyms/parse.y" 2221
2222/* Line 1455 of yacc.c */
2223#line 443 "scripts/genksyms/parse.y"
2101 { (yyval) = (yyvsp[(2) - (2)]); ;} 2224 { (yyval) = (yyvsp[(2) - (2)]); ;}
2102 break; 2225 break;
2103 2226
2104 case 120: 2227 case 120:
2105#line 444 "scripts/genksyms/parse.y" 2228
2229/* Line 1455 of yacc.c */
2230#line 448 "scripts/genksyms/parse.y"
2106 { (yyval) = (yyvsp[(2) - (2)]); ;} 2231 { (yyval) = (yyvsp[(2) - (2)]); ;}
2107 break; 2232 break;
2108 2233
2109 case 121: 2234 case 121:
2110#line 448 "scripts/genksyms/parse.y" 2235
2236/* Line 1455 of yacc.c */
2237#line 452 "scripts/genksyms/parse.y"
2111 { (yyval) = NULL; ;} 2238 { (yyval) = NULL; ;}
2112 break; 2239 break;
2113 2240
2114 case 123: 2241 case 123:
2115#line 453 "scripts/genksyms/parse.y" 2242
2116 { (yyval) = (yyvsp[(2) - (2)]); ;} 2243/* Line 1455 of yacc.c */
2244#line 457 "scripts/genksyms/parse.y"
2245 { (yyval) = (yyvsp[(3) - (3)]); ;}
2117 break; 2246 break;
2118 2247
2119 case 124: 2248 case 124:
2120#line 457 "scripts/genksyms/parse.y" 2249
2250/* Line 1455 of yacc.c */
2251#line 458 "scripts/genksyms/parse.y"
2252 { (yyval) = (yyvsp[(4) - (4)]); ;}
2253 break;
2254
2255 case 127:
2256
2257/* Line 1455 of yacc.c */
2258#line 467 "scripts/genksyms/parse.y"
2259 {
2260 const char *name = strdup((*(yyvsp[(1) - (1)]))->string);
2261 add_symbol(name, SYM_ENUM_CONST, NULL, 0);
2262 ;}
2263 break;
2264
2265 case 128:
2266
2267/* Line 1455 of yacc.c */
2268#line 472 "scripts/genksyms/parse.y"
2269 {
2270 const char *name = strdup((*(yyvsp[(1) - (3)]))->string);
2271 struct string_list *expr = copy_list_range(*(yyvsp[(3) - (3)]), *(yyvsp[(2) - (3)]));
2272 add_symbol(name, SYM_ENUM_CONST, expr, 0);
2273 ;}
2274 break;
2275
2276 case 129:
2277
2278/* Line 1455 of yacc.c */
2279#line 479 "scripts/genksyms/parse.y"
2280 { (yyval) = (yyvsp[(2) - (2)]); ;}
2281 break;
2282
2283 case 130:
2284
2285/* Line 1455 of yacc.c */
2286#line 483 "scripts/genksyms/parse.y"
2121 { (yyval) = NULL; ;} 2287 { (yyval) = NULL; ;}
2122 break; 2288 break;
2123 2289
2124 case 126: 2290 case 132:
2125#line 463 "scripts/genksyms/parse.y" 2291
2292/* Line 1455 of yacc.c */
2293#line 489 "scripts/genksyms/parse.y"
2126 { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); ;} 2294 { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); ;}
2127 break; 2295 break;
2128 2296
2129 2297
2130/* Line 1267 of yacc.c. */ 2298
2131#line 2132 "scripts/genksyms/parse.c" 2299/* Line 1455 of yacc.c */
2300#line 2301 "scripts/genksyms/parse.c"
2132 default: break; 2301 default: break;
2133 } 2302 }
2134 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2303 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2139,7 +2308,6 @@ yyreduce:
2139 2308
2140 *++yyvsp = yyval; 2309 *++yyvsp = yyval;
2141 2310
2142
2143 /* Now `shift' the result of the reduction. Determine what state 2311 /* Now `shift' the result of the reduction. Determine what state
2144 that goes to, based on the state we popped back to and the rule 2312 that goes to, based on the state we popped back to and the rule
2145 number reduced by. */ 2313 number reduced by. */
@@ -2204,7 +2372,7 @@ yyerrlab:
2204 2372
2205 if (yyerrstatus == 3) 2373 if (yyerrstatus == 3)
2206 { 2374 {
2207 /* If just tried and failed to reuse look-ahead token after an 2375 /* If just tried and failed to reuse lookahead token after an
2208 error, discard it. */ 2376 error, discard it. */
2209 2377
2210 if (yychar <= YYEOF) 2378 if (yychar <= YYEOF)
@@ -2221,7 +2389,7 @@ yyerrlab:
2221 } 2389 }
2222 } 2390 }
2223 2391
2224 /* Else will try to reuse look-ahead token after shifting the error 2392 /* Else will try to reuse lookahead token after shifting the error
2225 token. */ 2393 token. */
2226 goto yyerrlab1; 2394 goto yyerrlab1;
2227 2395
@@ -2278,9 +2446,6 @@ yyerrlab1:
2278 YY_STACK_PRINT (yyss, yyssp); 2446 YY_STACK_PRINT (yyss, yyssp);
2279 } 2447 }
2280 2448
2281 if (yyn == YYFINAL)
2282 YYACCEPT;
2283
2284 *++yyvsp = yylval; 2449 *++yyvsp = yylval;
2285 2450
2286 2451
@@ -2305,7 +2470,7 @@ yyabortlab:
2305 yyresult = 1; 2470 yyresult = 1;
2306 goto yyreturn; 2471 goto yyreturn;
2307 2472
2308#ifndef yyoverflow 2473#if !defined(yyoverflow) || YYERROR_VERBOSE
2309/*-------------------------------------------------. 2474/*-------------------------------------------------.
2310| yyexhaustedlab -- memory exhaustion comes here. | 2475| yyexhaustedlab -- memory exhaustion comes here. |
2311`-------------------------------------------------*/ 2476`-------------------------------------------------*/
@@ -2316,7 +2481,7 @@ yyexhaustedlab:
2316#endif 2481#endif
2317 2482
2318yyreturn: 2483yyreturn:
2319 if (yychar != YYEOF && yychar != YYEMPTY) 2484 if (yychar != YYEMPTY)
2320 yydestruct ("Cleanup: discarding lookahead", 2485 yydestruct ("Cleanup: discarding lookahead",
2321 yytoken, &yylval); 2486 yytoken, &yylval);
2322 /* Do not reclaim the symbols of the rule which action triggered 2487 /* Do not reclaim the symbols of the rule which action triggered
@@ -2342,7 +2507,9 @@ yyreturn:
2342} 2507}
2343 2508
2344 2509
2345#line 467 "scripts/genksyms/parse.y" 2510
2511/* Line 1675 of yacc.c */
2512#line 493 "scripts/genksyms/parse.y"
2346 2513
2347 2514
2348static void 2515static void
diff --git a/scripts/genksyms/parse.h_shipped b/scripts/genksyms/parse.h_shipped
index c4eeec652b79..517523669251 100644
--- a/scripts/genksyms/parse.h_shipped
+++ b/scripts/genksyms/parse.h_shipped
@@ -1,24 +1,23 @@
1/* A Bison parser, made by GNU Bison 2.3. */
2 1
3/* Skeleton interface for Bison's Yacc-like parsers in C 2/* A Bison parser, made by GNU Bison 2.4.1. */
4 3
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 4/* Skeleton interface for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc. 7 Free Software Foundation, Inc.
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option) 11 the Free Software Foundation, either version 3 of the License, or
11 any later version. 12 (at your option) any later version.
12 13
13 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 17 GNU General Public License for more details.
17 18
18 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22 21
23/* As a special exception, you may create a larger work that contains 22/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work 23 part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
29 special exception, which will cause the skeleton and the resulting 28 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public 29 Bison output files to be licensed under the GNU General Public
31 License without this special exception. 30 License without this special exception.
32 31
33 This special exception was added by the Free Software Foundation in 32 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */ 33 version 2.2 of Bison. */
35 34
35
36/* Tokens. */ 36/* Tokens. */
37#ifndef YYTOKENTYPE 37#ifndef YYTOKENTYPE
38# define YYTOKENTYPE 38# define YYTOKENTYPE
@@ -82,58 +82,16 @@
82 FILENAME = 298 82 FILENAME = 298
83 }; 83 };
84#endif 84#endif
85/* Tokens. */
86#define ASM_KEYW 258
87#define ATTRIBUTE_KEYW 259
88#define AUTO_KEYW 260
89#define BOOL_KEYW 261
90#define CHAR_KEYW 262
91#define CONST_KEYW 263
92#define DOUBLE_KEYW 264
93#define ENUM_KEYW 265
94#define EXTERN_KEYW 266
95#define EXTENSION_KEYW 267
96#define FLOAT_KEYW 268
97#define INLINE_KEYW 269
98#define INT_KEYW 270
99#define LONG_KEYW 271
100#define REGISTER_KEYW 272
101#define RESTRICT_KEYW 273
102#define SHORT_KEYW 274
103#define SIGNED_KEYW 275
104#define STATIC_KEYW 276
105#define STRUCT_KEYW 277
106#define TYPEDEF_KEYW 278
107#define UNION_KEYW 279
108#define UNSIGNED_KEYW 280
109#define VOID_KEYW 281
110#define VOLATILE_KEYW 282
111#define TYPEOF_KEYW 283
112#define EXPORT_SYMBOL_KEYW 284
113#define ASM_PHRASE 285
114#define ATTRIBUTE_PHRASE 286
115#define BRACE_PHRASE 287
116#define BRACKET_PHRASE 288
117#define EXPRESSION_PHRASE 289
118#define CHAR 290
119#define DOTS 291
120#define IDENT 292
121#define INT 293
122#define REAL 294
123#define STRING 295
124#define TYPE 296
125#define OTHER 297
126#define FILENAME 298
127
128 85
129 86
130 87
131#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 88#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
132typedef int YYSTYPE; 89typedef int YYSTYPE;
90# define YYSTYPE_IS_TRIVIAL 1
133# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 91# define yystype YYSTYPE /* obsolescent; will be withdrawn */
134# define YYSTYPE_IS_DECLARED 1 92# define YYSTYPE_IS_DECLARED 1
135# define YYSTYPE_IS_TRIVIAL 1
136#endif 93#endif
137 94
138extern YYSTYPE yylval; 95extern YYSTYPE yylval;
139 96
97
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y
index 10d7dc724b6d..ba5c242866c1 100644
--- a/scripts/genksyms/parse.y
+++ b/scripts/genksyms/parse.y
@@ -24,7 +24,8 @@
24%{ 24%{
25 25
26#include <assert.h> 26#include <assert.h>
27#include <malloc.h> 27#include <stdlib.h>
28#include <string.h>
28#include "genksyms.h" 29#include "genksyms.h"
29 30
30static int is_typedef; 31static int is_typedef;
@@ -227,16 +228,19 @@ type_specifier:
227 add_symbol(i->string, SYM_UNION, s, is_extern); 228 add_symbol(i->string, SYM_UNION, s, is_extern);
228 $$ = $3; 229 $$ = $3;
229 } 230 }
230 | ENUM_KEYW IDENT BRACE_PHRASE 231 | ENUM_KEYW IDENT enum_body
231 { struct string_list *s = *$3, *i = *$2, *r; 232 { struct string_list *s = *$3, *i = *$2, *r;
232 r = copy_node(i); r->tag = SYM_ENUM; 233 r = copy_node(i); r->tag = SYM_ENUM;
233 r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; 234 r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL;
234 add_symbol(i->string, SYM_ENUM, s, is_extern); 235 add_symbol(i->string, SYM_ENUM, s, is_extern);
235 $$ = $3; 236 $$ = $3;
236 } 237 }
237 238 /*
238 /* Anonymous s/u/e definitions. Nothing needs doing. */ 239 * Anonymous enum definition. Tell add_symbol() to restart its counter.
239 | ENUM_KEYW BRACE_PHRASE { $$ = $2; } 240 */
241 | ENUM_KEYW enum_body
242 { add_symbol(NULL, SYM_ENUM, NULL, 0); $$ = $2; }
243 /* Anonymous s/u definitions. Nothing needs doing. */
240 | STRUCT_KEYW class_body { $$ = $2; } 244 | STRUCT_KEYW class_body { $$ = $2; }
241 | UNION_KEYW class_body { $$ = $2; } 245 | UNION_KEYW class_body { $$ = $2; }
242 ; 246 ;
@@ -449,6 +453,28 @@ attribute_opt:
449 | attribute_opt ATTRIBUTE_PHRASE 453 | attribute_opt ATTRIBUTE_PHRASE
450 ; 454 ;
451 455
456enum_body:
457 '{' enumerator_list '}' { $$ = $3; }
458 | '{' enumerator_list ',' '}' { $$ = $4; }
459 ;
460
461enumerator_list:
462 enumerator
463 | enumerator_list ',' enumerator
464
465enumerator:
466 IDENT
467 {
468 const char *name = strdup((*$1)->string);
469 add_symbol(name, SYM_ENUM_CONST, NULL, 0);
470 }
471 | IDENT '=' EXPRESSION_PHRASE
472 {
473 const char *name = strdup((*$1)->string);
474 struct string_list *expr = copy_list_range(*$3, *$2);
475 add_symbol(name, SYM_ENUM_CONST, expr, 0);
476 }
477
452asm_definition: 478asm_definition:
453 ASM_PHRASE ';' { $$ = $2; } 479 ASM_PHRASE ';' { $$ = $2; }
454 ; 480 ;
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index b2281982f52f..d29a8d75cb22 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -13,7 +13,7 @@
13use strict; 13use strict;
14 14
15my $P = $0; 15my $P = $0;
16my $V = '0.24'; 16my $V = '0.26';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19 19
@@ -24,19 +24,23 @@ my $email_maintainer = 1;
24my $email_list = 1; 24my $email_list = 1;
25my $email_subscriber_list = 0; 25my $email_subscriber_list = 0;
26my $email_git_penguin_chiefs = 0; 26my $email_git_penguin_chiefs = 0;
27my $email_git = 1; 27my $email_git = 0;
28my $email_git_all_signature_types = 0; 28my $email_git_all_signature_types = 0;
29my $email_git_blame = 0; 29my $email_git_blame = 0;
30my $email_git_blame_signatures = 1;
31my $email_git_fallback = 1;
30my $email_git_min_signatures = 1; 32my $email_git_min_signatures = 1;
31my $email_git_max_maintainers = 5; 33my $email_git_max_maintainers = 5;
32my $email_git_min_percent = 5; 34my $email_git_min_percent = 5;
33my $email_git_since = "1-year-ago"; 35my $email_git_since = "1-year-ago";
34my $email_hg_since = "-365"; 36my $email_hg_since = "-365";
37my $interactive = 0;
35my $email_remove_duplicates = 1; 38my $email_remove_duplicates = 1;
39my $email_use_mailmap = 1;
36my $output_multiline = 1; 40my $output_multiline = 1;
37my $output_separator = ", "; 41my $output_separator = ", ";
38my $output_roles = 0; 42my $output_roles = 0;
39my $output_rolestats = 0; 43my $output_rolestats = 1;
40my $scm = 0; 44my $scm = 0;
41my $web = 0; 45my $web = 0;
42my $subsystem = 0; 46my $subsystem = 0;
@@ -49,8 +53,13 @@ my $pattern_depth = 0;
49my $version = 0; 53my $version = 0;
50my $help = 0; 54my $help = 0;
51 55
56my $vcs_used = 0;
57
52my $exit = 0; 58my $exit = 0;
53 59
60my %commit_author_hash;
61my %commit_signer_hash;
62
54my @penguin_chief = (); 63my @penguin_chief = ();
55push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org"); 64push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org");
56#Andrew wants in on most everything - 2009/01/14 65#Andrew wants in on most everything - 2009/01/14
@@ -73,7 +82,6 @@ my @signature_tags = ();
73push(@signature_tags, "Signed-off-by:"); 82push(@signature_tags, "Signed-off-by:");
74push(@signature_tags, "Reviewed-by:"); 83push(@signature_tags, "Reviewed-by:");
75push(@signature_tags, "Acked-by:"); 84push(@signature_tags, "Acked-by:");
76my $signaturePattern = "\(" . join("|", @signature_tags) . "\)";
77 85
78# rfc822 email address - preloaded methods go here. 86# rfc822 email address - preloaded methods go here.
79my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; 87my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
@@ -86,31 +94,70 @@ my %VCS_cmds;
86my %VCS_cmds_git = ( 94my %VCS_cmds_git = (
87 "execute_cmd" => \&git_execute_cmd, 95 "execute_cmd" => \&git_execute_cmd,
88 "available" => '(which("git") ne "") && (-d ".git")', 96 "available" => '(which("git") ne "") && (-d ".git")',
89 "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file", 97 "find_signers_cmd" =>
90 "find_commit_signers_cmd" => "git log --no-color -1 \$commit", 98 "git log --no-color --since=\$email_git_since " .
99 '--format="GitCommit: %H%n' .
100 'GitAuthor: %an <%ae>%n' .
101 'GitDate: %aD%n' .
102 'GitSubject: %s%n' .
103 '%b%n"' .
104 " -- \$file",
105 "find_commit_signers_cmd" =>
106 "git log --no-color " .
107 '--format="GitCommit: %H%n' .
108 'GitAuthor: %an <%ae>%n' .
109 'GitDate: %aD%n' .
110 'GitSubject: %s%n' .
111 '%b%n"' .
112 " -1 \$commit",
113 "find_commit_author_cmd" =>
114 "git log --no-color " .
115 '--format="GitCommit: %H%n' .
116 'GitAuthor: %an <%ae>%n' .
117 'GitDate: %aD%n' .
118 'GitSubject: %s%n"' .
119 " -1 \$commit",
91 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", 120 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
92 "blame_file_cmd" => "git blame -l \$file", 121 "blame_file_cmd" => "git blame -l \$file",
93 "commit_pattern" => "^commit [0-9a-f]{40,40}", 122 "commit_pattern" => "^GitCommit: ([0-9a-f]{40,40})",
94 "blame_commit_pattern" => "^([0-9a-f]+) " 123 "blame_commit_pattern" => "^([0-9a-f]+) ",
124 "author_pattern" => "^GitAuthor: (.*)",
125 "subject_pattern" => "^GitSubject: (.*)",
95); 126);
96 127
97my %VCS_cmds_hg = ( 128my %VCS_cmds_hg = (
98 "execute_cmd" => \&hg_execute_cmd, 129 "execute_cmd" => \&hg_execute_cmd,
99 "available" => '(which("hg") ne "") && (-d ".hg")', 130 "available" => '(which("hg") ne "") && (-d ".hg")',
100 "find_signers_cmd" => 131 "find_signers_cmd" =>
101 "hg log --date=\$email_hg_since" . 132 "hg log --date=\$email_hg_since " .
102 " --template='commit {node}\\n{desc}\\n' -- \$file", 133 "--template='HgCommit: {node}\\n" .
103 "find_commit_signers_cmd" => "hg log --template='{desc}\\n' -r \$commit", 134 "HgAuthor: {author}\\n" .
135 "HgSubject: {desc}\\n'" .
136 " -- \$file",
137 "find_commit_signers_cmd" =>
138 "hg log " .
139 "--template='HgSubject: {desc}\\n'" .
140 " -r \$commit",
141 "find_commit_author_cmd" =>
142 "hg log " .
143 "--template='HgCommit: {node}\\n" .
144 "HgAuthor: {author}\\n" .
145 "HgSubject: {desc|firstline}\\n'" .
146 " -r \$commit",
104 "blame_range_cmd" => "", # not supported 147 "blame_range_cmd" => "", # not supported
105 "blame_file_cmd" => "hg blame -c \$file", 148 "blame_file_cmd" => "hg blame -n \$file",
106 "commit_pattern" => "^commit [0-9a-f]{40,40}", 149 "commit_pattern" => "^HgCommit: ([0-9a-f]{40,40})",
107 "blame_commit_pattern" => "^([0-9a-f]+):" 150 "blame_commit_pattern" => "^([ 0-9a-f]+):",
151 "author_pattern" => "^HgAuthor: (.*)",
152 "subject_pattern" => "^HgSubject: (.*)",
108); 153);
109 154
110if (-f "${lk_path}.get_maintainer.conf") { 155my $conf = which_conf(".get_maintainer.conf");
156if (-f $conf) {
111 my @conf_args; 157 my @conf_args;
112 open(my $conffile, '<', "${lk_path}.get_maintainer.conf") 158 open(my $conffile, '<', "$conf")
113 or warn "$P: Can't open .get_maintainer.conf: $!\n"; 159 or warn "$P: Can't find a readable .get_maintainer.conf file $!\n";
160
114 while (<$conffile>) { 161 while (<$conffile>) {
115 my $line = $_; 162 my $line = $_;
116 163
@@ -136,13 +183,17 @@ if (!GetOptions(
136 'git!' => \$email_git, 183 'git!' => \$email_git,
137 'git-all-signature-types!' => \$email_git_all_signature_types, 184 'git-all-signature-types!' => \$email_git_all_signature_types,
138 'git-blame!' => \$email_git_blame, 185 'git-blame!' => \$email_git_blame,
186 'git-blame-signatures!' => \$email_git_blame_signatures,
187 'git-fallback!' => \$email_git_fallback,
139 'git-chief-penguins!' => \$email_git_penguin_chiefs, 188 'git-chief-penguins!' => \$email_git_penguin_chiefs,
140 'git-min-signatures=i' => \$email_git_min_signatures, 189 'git-min-signatures=i' => \$email_git_min_signatures,
141 'git-max-maintainers=i' => \$email_git_max_maintainers, 190 'git-max-maintainers=i' => \$email_git_max_maintainers,
142 'git-min-percent=i' => \$email_git_min_percent, 191 'git-min-percent=i' => \$email_git_min_percent,
143 'git-since=s' => \$email_git_since, 192 'git-since=s' => \$email_git_since,
144 'hg-since=s' => \$email_hg_since, 193 'hg-since=s' => \$email_hg_since,
194 'i|interactive!' => \$interactive,
145 'remove-duplicates!' => \$email_remove_duplicates, 195 'remove-duplicates!' => \$email_remove_duplicates,
196 'mailmap!' => \$email_use_mailmap,
146 'm!' => \$email_maintainer, 197 'm!' => \$email_maintainer,
147 'n!' => \$email_usename, 198 'n!' => \$email_usename,
148 'l!' => \$email_list, 199 'l!' => \$email_list,
@@ -181,13 +232,9 @@ if (-t STDIN && !@ARGV) {
181 die "$P: missing patchfile or -f file - use --help if necessary\n"; 232 die "$P: missing patchfile or -f file - use --help if necessary\n";
182} 233}
183 234
184if ($output_separator ne ", ") { 235$output_multiline = 0 if ($output_separator ne ", ");
185 $output_multiline = 0; 236$output_rolestats = 1 if ($interactive);
186} 237$output_roles = 1 if ($output_rolestats);
187
188if ($output_rolestats) {
189 $output_roles = 1;
190}
191 238
192if ($sections) { 239if ($sections) {
193 $email = 0; 240 $email = 0;
@@ -197,6 +244,7 @@ if ($sections) {
197 $subsystem = 0; 244 $subsystem = 0;
198 $web = 0; 245 $web = 0;
199 $keywords = 0; 246 $keywords = 0;
247 $interactive = 0;
200} else { 248} else {
201 my $selections = $email + $scm + $status + $subsystem + $web; 249 my $selections = $email + $scm + $status + $subsystem + $web;
202 if ($selections == 0) { 250 if ($selections == 0) {
@@ -215,10 +263,6 @@ if (!top_of_kernel_tree($lk_path)) {
215 . "a linux kernel source tree.\n"; 263 . "a linux kernel source tree.\n";
216} 264}
217 265
218if ($email_git_all_signature_types) {
219 $signaturePattern = "(.+?)[Bb][Yy]:";
220}
221
222## Read MAINTAINERS for type/value pairs 266## Read MAINTAINERS for type/value pairs
223 267
224my @typevalue = (); 268my @typevalue = ();
@@ -253,31 +297,82 @@ while (<$maint>) {
253} 297}
254close($maint); 298close($maint);
255 299
256my %mailmap;
257 300
258if ($email_remove_duplicates) { 301#
259 open(my $mailmap, '<', "${lk_path}.mailmap") 302# Read mail address map
260 or warn "$P: Can't open .mailmap: $!\n"; 303#
261 while (<$mailmap>) {
262 my $line = $_;
263 304
264 next if ($line =~ m/^\s*#/); 305my $mailmap;
265 next if ($line =~ m/^\s*$/);
266 306
267 my ($name, $address) = parse_email($line); 307read_mailmap();
268 $line = format_email($name, $address, $email_usename);
269 308
270 next if ($line =~ m/^\s*$/); 309sub read_mailmap {
310 $mailmap = {
311 names => {},
312 addresses => {}
313 };
271 314
272 if (exists($mailmap{$name})) { 315 return if (!$email_use_mailmap || !(-f "${lk_path}.mailmap"));
273 my $obj = $mailmap{$name}; 316
274 push(@$obj, $address); 317 open(my $mailmap_file, '<', "${lk_path}.mailmap")
275 } else { 318 or warn "$P: Can't open .mailmap: $!\n";
276 my @arr = ($address); 319
277 $mailmap{$name} = \@arr; 320 while (<$mailmap_file>) {
321 s/#.*$//; #strip comments
322 s/^\s+|\s+$//g; #trim
323
324 next if (/^\s*$/); #skip empty lines
325 #entries have one of the following formats:
326 # name1 <mail1>
327 # <mail1> <mail2>
328 # name1 <mail1> <mail2>
329 # name1 <mail1> name2 <mail2>
330 # (see man git-shortlog)
331 if (/^(.+)<(.+)>$/) {
332 my $real_name = $1;
333 my $address = $2;
334
335 $real_name =~ s/\s+$//;
336 ($real_name, $address) = parse_email("$real_name <$address>");
337 $mailmap->{names}->{$address} = $real_name;
338
339 } elsif (/^<([^\s]+)>\s*<([^\s]+)>$/) {
340 my $real_address = $1;
341 my $wrong_address = $2;
342
343 $mailmap->{addresses}->{$wrong_address} = $real_address;
344
345 } elsif (/^(.+)<([^\s]+)>\s*<([^\s]+)>$/) {
346 my $real_name = $1;
347 my $real_address = $2;
348 my $wrong_address = $3;
349
350 $real_name =~ s/\s+$//;
351 ($real_name, $real_address) =
352 parse_email("$real_name <$real_address>");
353 $mailmap->{names}->{$wrong_address} = $real_name;
354 $mailmap->{addresses}->{$wrong_address} = $real_address;
355
356 } elsif (/^(.+)<([^\s]+)>\s*([^\s].*)<([^\s]+)>$/) {
357 my $real_name = $1;
358 my $real_address = $2;
359 my $wrong_name = $3;
360 my $wrong_address = $4;
361
362 $real_name =~ s/\s+$//;
363 ($real_name, $real_address) =
364 parse_email("$real_name <$real_address>");
365
366 $wrong_name =~ s/\s+$//;
367 ($wrong_name, $wrong_address) =
368 parse_email("$wrong_name <$wrong_address>");
369
370 my $wrong_email = format_email($wrong_name, $wrong_address, 1);
371 $mailmap->{names}->{$wrong_email} = $real_name;
372 $mailmap->{addresses}->{$wrong_email} = $real_address;
278 } 373 }
279 } 374 }
280 close($mailmap); 375 close($mailmap_file);
281} 376}
282 377
283## use the filenames on the command line or find the filenames in the patchfiles 378## use the filenames on the command line or find the filenames in the patchfiles
@@ -302,7 +397,7 @@ foreach my $file (@ARGV) {
302 } 397 }
303 if ($from_filename) { 398 if ($from_filename) {
304 push(@files, $file); 399 push(@files, $file);
305 if (-f $file && ($keywords || $file_emails)) { 400 if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) {
306 open(my $f, '<', $file) 401 open(my $f, '<', $file)
307 or die "$P: Can't open $file: $!\n"; 402 or die "$P: Can't open $file: $!\n";
308 my $text = do { local($/) ; <$f> }; 403 my $text = do { local($/) ; <$f> };
@@ -325,6 +420,14 @@ foreach my $file (@ARGV) {
325 420
326 open(my $patch, "< $file") 421 open(my $patch, "< $file")
327 or die "$P: Can't open $file: $!\n"; 422 or die "$P: Can't open $file: $!\n";
423
424 # We can check arbitrary information before the patch
425 # like the commit message, mail headers, etc...
426 # This allows us to match arbitrary keywords against any part
427 # of a git format-patch generated file (subject tags, etc...)
428
429 my $patch_prefix = ""; #Parsing the intro
430
328 while (<$patch>) { 431 while (<$patch>) {
329 my $patch_line = $_; 432 my $patch_line = $_;
330 if (m/^\+\+\+\s+(\S+)/) { 433 if (m/^\+\+\+\s+(\S+)/) {
@@ -333,13 +436,14 @@ foreach my $file (@ARGV) {
333 $filename =~ s@\n@@; 436 $filename =~ s@\n@@;
334 $lastfile = $filename; 437 $lastfile = $filename;
335 push(@files, $filename); 438 push(@files, $filename);
439 $patch_prefix = "^[+-].*"; #Now parsing the actual patch
336 } elsif (m/^\@\@ -(\d+),(\d+)/) { 440 } elsif (m/^\@\@ -(\d+),(\d+)/) {
337 if ($email_git_blame) { 441 if ($email_git_blame) {
338 push(@range, "$lastfile:$1:$2"); 442 push(@range, "$lastfile:$1:$2");
339 } 443 }
340 } elsif ($keywords) { 444 } elsif ($keywords) {
341 foreach my $line (keys %keyword_hash) { 445 foreach my $line (keys %keyword_hash) {
342 if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) { 446 if ($patch_line =~ m/${patch_prefix}$keyword_hash{$line}/x) {
343 push(@keyword_tvi, $line); 447 push(@keyword_tvi, $line);
344 } 448 }
345 } 449 }
@@ -357,67 +461,163 @@ foreach my $file (@ARGV) {
357 461
358@file_emails = uniq(@file_emails); 462@file_emails = uniq(@file_emails);
359 463
464my %email_hash_name;
465my %email_hash_address;
360my @email_to = (); 466my @email_to = ();
467my %hash_list_to;
361my @list_to = (); 468my @list_to = ();
362my @scm = (); 469my @scm = ();
363my @web = (); 470my @web = ();
364my @subsystem = (); 471my @subsystem = ();
365my @status = (); 472my @status = ();
473my %deduplicate_name_hash = ();
474my %deduplicate_address_hash = ();
475my $signature_pattern;
366 476
367# Find responsible parties 477my @maintainers = get_maintainers();
368 478
369foreach my $file (@files) { 479if (@maintainers) {
480 @maintainers = merge_email(@maintainers);
481 output(@maintainers);
482}
370 483
371 my %hash; 484if ($scm) {
372 my $tvi = find_first_section(); 485 @scm = uniq(@scm);
373 while ($tvi < @typevalue) { 486 output(@scm);
374 my $start = find_starting_index($tvi); 487}
375 my $end = find_ending_index($tvi); 488
376 my $exclude = 0; 489if ($status) {
377 my $i; 490 @status = uniq(@status);
378 491 output(@status);
379 #Do not match excluded file patterns 492}
380 493
381 for ($i = $start; $i < $end; $i++) { 494if ($subsystem) {
382 my $line = $typevalue[$i]; 495 @subsystem = uniq(@subsystem);
383 if ($line =~ m/^(\C):\s*(.*)/) { 496 output(@subsystem);
384 my $type = $1; 497}
385 my $value = $2; 498
386 if ($type eq 'X') { 499if ($web) {
387 if (file_match_pattern($file, $value)) { 500 @web = uniq(@web);
388 $exclude = 1; 501 output(@web);
389 last; 502}
390 } 503
504exit($exit);
505
506sub range_is_maintained {
507 my ($start, $end) = @_;
508
509 for (my $i = $start; $i < $end; $i++) {
510 my $line = $typevalue[$i];
511 if ($line =~ m/^(\C):\s*(.*)/) {
512 my $type = $1;
513 my $value = $2;
514 if ($type eq 'S') {
515 if ($value =~ /(maintain|support)/i) {
516 return 1;
391 } 517 }
392 } 518 }
393 } 519 }
520 }
521 return 0;
522}
523
524sub range_has_maintainer {
525 my ($start, $end) = @_;
526
527 for (my $i = $start; $i < $end; $i++) {
528 my $line = $typevalue[$i];
529 if ($line =~ m/^(\C):\s*(.*)/) {
530 my $type = $1;
531 my $value = $2;
532 if ($type eq 'M') {
533 return 1;
534 }
535 }
536 }
537 return 0;
538}
539
540sub get_maintainers {
541 %email_hash_name = ();
542 %email_hash_address = ();
543 %commit_author_hash = ();
544 %commit_signer_hash = ();
545 @email_to = ();
546 %hash_list_to = ();
547 @list_to = ();
548 @scm = ();
549 @web = ();
550 @subsystem = ();
551 @status = ();
552 %deduplicate_name_hash = ();
553 %deduplicate_address_hash = ();
554 if ($email_git_all_signature_types) {
555 $signature_pattern = "(.+?)[Bb][Yy]:";
556 } else {
557 $signature_pattern = "\(" . join("|", @signature_tags) . "\)";
558 }
559
560 # Find responsible parties
561
562 my %exact_pattern_match_hash = ();
563
564 foreach my $file (@files) {
565
566 my %hash;
567 my $tvi = find_first_section();
568 while ($tvi < @typevalue) {
569 my $start = find_starting_index($tvi);
570 my $end = find_ending_index($tvi);
571 my $exclude = 0;
572 my $i;
573
574 #Do not match excluded file patterns
394 575
395 if (!$exclude) {
396 for ($i = $start; $i < $end; $i++) { 576 for ($i = $start; $i < $end; $i++) {
397 my $line = $typevalue[$i]; 577 my $line = $typevalue[$i];
398 if ($line =~ m/^(\C):\s*(.*)/) { 578 if ($line =~ m/^(\C):\s*(.*)/) {
399 my $type = $1; 579 my $type = $1;
400 my $value = $2; 580 my $value = $2;
401 if ($type eq 'F') { 581 if ($type eq 'X') {
402 if (file_match_pattern($file, $value)) { 582 if (file_match_pattern($file, $value)) {
403 my $value_pd = ($value =~ tr@/@@); 583 $exclude = 1;
404 my $file_pd = ($file =~ tr@/@@); 584 last;
405 $value_pd++ if (substr($value,-1,1) ne "/"); 585 }
406 if ($pattern_depth == 0 || 586 }
407 (($file_pd - $value_pd) < $pattern_depth)) { 587 }
408 $hash{$tvi} = $value_pd; 588 }
589
590 if (!$exclude) {
591 for ($i = $start; $i < $end; $i++) {
592 my $line = $typevalue[$i];
593 if ($line =~ m/^(\C):\s*(.*)/) {
594 my $type = $1;
595 my $value = $2;
596 if ($type eq 'F') {
597 if (file_match_pattern($file, $value)) {
598 my $value_pd = ($value =~ tr@/@@);
599 my $file_pd = ($file =~ tr@/@@);
600 $value_pd++ if (substr($value,-1,1) ne "/");
601 $value_pd = -1 if ($value =~ /^\.\*/);
602 if ($value_pd >= $file_pd &&
603 range_is_maintained($start, $end) &&
604 range_has_maintainer($start, $end)) {
605 $exact_pattern_match_hash{$file} = 1;
606 }
607 if ($pattern_depth == 0 ||
608 (($file_pd - $value_pd) < $pattern_depth)) {
609 $hash{$tvi} = $value_pd;
610 }
409 } 611 }
410 } 612 }
411 } 613 }
412 } 614 }
413 } 615 }
616 $tvi = $end + 1;
414 } 617 }
415 618
416 $tvi = $end + 1; 619 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
417 } 620 add_categories($line);
418
419 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
420 add_categories($line);
421 if ($sections) { 621 if ($sections) {
422 my $i; 622 my $i;
423 my $start = find_starting_index($line); 623 my $start = find_starting_index($line);
@@ -435,80 +635,71 @@ foreach my $file (@files) {
435 } 635 }
436 print("\n"); 636 print("\n");
437 } 637 }
638 }
438 } 639 }
439 640
440 if ($email && $email_git) { 641 if ($keywords) {
441 vcs_file_signoffs($file); 642 @keyword_tvi = sort_and_uniq(@keyword_tvi);
643 foreach my $line (@keyword_tvi) {
644 add_categories($line);
645 }
442 } 646 }
443 647
444 if ($email && $email_git_blame) { 648 foreach my $email (@email_to, @list_to) {
445 vcs_file_blame($file); 649 $email->[0] = deduplicate_email($email->[0]);
446 } 650 }
447}
448 651
449if ($keywords) { 652 foreach my $file (@files) {
450 @keyword_tvi = sort_and_uniq(@keyword_tvi); 653 if ($email &&
451 foreach my $line (@keyword_tvi) { 654 ($email_git || ($email_git_fallback &&
452 add_categories($line); 655 !$exact_pattern_match_hash{$file}))) {
656 vcs_file_signoffs($file);
657 }
658 if ($email && $email_git_blame) {
659 vcs_file_blame($file);
660 }
453 } 661 }
454}
455 662
456if ($email) { 663 if ($email) {
457 foreach my $chief (@penguin_chief) { 664 foreach my $chief (@penguin_chief) {
458 if ($chief =~ m/^(.*):(.*)/) { 665 if ($chief =~ m/^(.*):(.*)/) {
459 my $email_address; 666 my $email_address;
460 667
461 $email_address = format_email($1, $2, $email_usename); 668 $email_address = format_email($1, $2, $email_usename);
462 if ($email_git_penguin_chiefs) { 669 if ($email_git_penguin_chiefs) {
463 push(@email_to, [$email_address, 'chief penguin']); 670 push(@email_to, [$email_address, 'chief penguin']);
464 } else { 671 } else {
465 @email_to = grep($_->[0] !~ /${email_address}/, @email_to); 672 @email_to = grep($_->[0] !~ /${email_address}/, @email_to);
673 }
466 } 674 }
467 } 675 }
468 }
469 676
470 foreach my $email (@file_emails) { 677 foreach my $email (@file_emails) {
471 my ($name, $address) = parse_email($email); 678 my ($name, $address) = parse_email($email);
472 679
473 my $tmp_email = format_email($name, $address, $email_usename); 680 my $tmp_email = format_email($name, $address, $email_usename);
474 push_email_address($tmp_email, ''); 681 push_email_address($tmp_email, '');
475 add_role($tmp_email, 'in file'); 682 add_role($tmp_email, 'in file');
683 }
476 } 684 }
477}
478 685
479if ($email || $email_list) {
480 my @to = (); 686 my @to = ();
481 if ($email) { 687 if ($email || $email_list) {
482 @to = (@to, @email_to); 688 if ($email) {
483 } 689 @to = (@to, @email_to);
484 if ($email_list) { 690 }
485 @to = (@to, @list_to); 691 if ($email_list) {
692 @to = (@to, @list_to);
693 }
486 } 694 }
487 output(merge_email(@to));
488}
489 695
490if ($scm) { 696 if ($interactive) {
491 @scm = uniq(@scm); 697 @to = interactive_get_maintainers(\@to);
492 output(@scm); 698 }
493}
494
495if ($status) {
496 @status = uniq(@status);
497 output(@status);
498}
499
500if ($subsystem) {
501 @subsystem = uniq(@subsystem);
502 output(@subsystem);
503}
504 699
505if ($web) { 700 return @to;
506 @web = uniq(@web);
507 output(@web);
508} 701}
509 702
510exit($exit);
511
512sub file_match_pattern { 703sub file_match_pattern {
513 my ($file, $pattern) = @_; 704 my ($file, $pattern) = @_;
514 if (substr($pattern, -1) eq "/") { 705 if (substr($pattern, -1) eq "/") {
@@ -537,7 +728,8 @@ MAINTAINER field selection options:
537 --email => print email address(es) if any 728 --email => print email address(es) if any
538 --git => include recent git \*-by: signers 729 --git => include recent git \*-by: signers
539 --git-all-signature-types => include signers regardless of signature type 730 --git-all-signature-types => include signers regardless of signature type
540 or use only ${signaturePattern} signers (default: $email_git_all_signature_types) 731 or use only ${signature_pattern} signers (default: $email_git_all_signature_types)
732 --git-fallback => use git when no exact MAINTAINERS pattern (default: $email_git_fallback)
541 --git-chief-penguins => include ${penguin_chiefs} 733 --git-chief-penguins => include ${penguin_chiefs}
542 --git-min-signatures => number of signatures required (default: $email_git_min_signatures) 734 --git-min-signatures => number of signatures required (default: $email_git_min_signatures)
543 --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers) 735 --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers)
@@ -545,6 +737,7 @@ MAINTAINER field selection options:
545 --git-blame => use git blame to find modified commits for patch or file 737 --git-blame => use git blame to find modified commits for patch or file
546 --git-since => git history to use (default: $email_git_since) 738 --git-since => git history to use (default: $email_git_since)
547 --hg-since => hg history to use (default: $email_hg_since) 739 --hg-since => hg history to use (default: $email_hg_since)
740 --interactive => display a menu (mostly useful if used with the --git option)
548 --m => include maintainer(s) if any 741 --m => include maintainer(s) if any
549 --n => include name 'Full Name <addr\@domain.tld>' 742 --n => include name 'Full Name <addr\@domain.tld>'
550 --l => include list(s) if any 743 --l => include list(s) if any
@@ -565,13 +758,15 @@ Output type options:
565 758
566Other options: 759Other options:
567 --pattern-depth => Number of pattern directory traversals (default: 0 (all)) 760 --pattern-depth => Number of pattern directory traversals (default: 0 (all))
568 --keywords => scan patch for keywords (default: 1 (on)) 761 --keywords => scan patch for keywords (default: $keywords)
569 --sections => print the entire subsystem sections with pattern matches 762 --sections => print all of the subsystem sections with pattern matches
763 --mailmap => use .mailmap file (default: $email_use_mailmap)
570 --version => show version 764 --version => show version
571 --help => show this help information 765 --help => show this help information
572 766
573Default options: 767Default options:
574 [--email --git --m --n --l --multiline --pattern-depth=0 --remove-duplicates] 768 [--email --nogit --git-fallback --m --n --l --multiline -pattern-depth=0
769 --remove-duplicates --rolestats]
575 770
576Notes: 771Notes:
577 Using "-f directory" may give unexpected results: 772 Using "-f directory" may give unexpected results:
@@ -606,30 +801,30 @@ EOT
606} 801}
607 802
608sub top_of_kernel_tree { 803sub top_of_kernel_tree {
609 my ($lk_path) = @_; 804 my ($lk_path) = @_;
610 805
611 if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") { 806 if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") {
612 $lk_path .= "/"; 807 $lk_path .= "/";
613 } 808 }
614 if ( (-f "${lk_path}COPYING") 809 if ( (-f "${lk_path}COPYING")
615 && (-f "${lk_path}CREDITS") 810 && (-f "${lk_path}CREDITS")
616 && (-f "${lk_path}Kbuild") 811 && (-f "${lk_path}Kbuild")
617 && (-f "${lk_path}MAINTAINERS") 812 && (-f "${lk_path}MAINTAINERS")
618 && (-f "${lk_path}Makefile") 813 && (-f "${lk_path}Makefile")
619 && (-f "${lk_path}README") 814 && (-f "${lk_path}README")
620 && (-d "${lk_path}Documentation") 815 && (-d "${lk_path}Documentation")
621 && (-d "${lk_path}arch") 816 && (-d "${lk_path}arch")
622 && (-d "${lk_path}include") 817 && (-d "${lk_path}include")
623 && (-d "${lk_path}drivers") 818 && (-d "${lk_path}drivers")
624 && (-d "${lk_path}fs") 819 && (-d "${lk_path}fs")
625 && (-d "${lk_path}init") 820 && (-d "${lk_path}init")
626 && (-d "${lk_path}ipc") 821 && (-d "${lk_path}ipc")
627 && (-d "${lk_path}kernel") 822 && (-d "${lk_path}kernel")
628 && (-d "${lk_path}lib") 823 && (-d "${lk_path}lib")
629 && (-d "${lk_path}scripts")) { 824 && (-d "${lk_path}scripts")) {
630 return 1; 825 return 1;
631 } 826 }
632 return 0; 827 return 0;
633} 828}
634 829
635sub parse_email { 830sub parse_email {
@@ -821,11 +1016,19 @@ sub add_categories {
821 } 1016 }
822 if ($list_additional =~ m/subscribers-only/) { 1017 if ($list_additional =~ m/subscribers-only/) {
823 if ($email_subscriber_list) { 1018 if ($email_subscriber_list) {
824 push(@list_to, [$list_address, "subscriber list${list_role}"]); 1019 if (!$hash_list_to{lc($list_address)}) {
1020 $hash_list_to{lc($list_address)} = 1;
1021 push(@list_to, [$list_address,
1022 "subscriber list${list_role}"]);
1023 }
825 } 1024 }
826 } else { 1025 } else {
827 if ($email_list) { 1026 if ($email_list) {
828 push(@list_to, [$list_address, "open list${list_role}"]); 1027 if (!$hash_list_to{lc($list_address)}) {
1028 $hash_list_to{lc($list_address)} = 1;
1029 push(@list_to, [$list_address,
1030 "open list${list_role}"]);
1031 }
829 } 1032 }
830 } 1033 }
831 } elsif ($ptype eq "M") { 1034 } elsif ($ptype eq "M") {
@@ -856,15 +1059,12 @@ sub add_categories {
856 } 1059 }
857} 1060}
858 1061
859my %email_hash_name;
860my %email_hash_address;
861
862sub email_inuse { 1062sub email_inuse {
863 my ($name, $address) = @_; 1063 my ($name, $address) = @_;
864 1064
865 return 1 if (($name eq "") && ($address eq "")); 1065 return 1 if (($name eq "") && ($address eq ""));
866 return 1 if (($name ne "") && exists($email_hash_name{$name})); 1066 return 1 if (($name ne "") && exists($email_hash_name{lc($name)}));
867 return 1 if (($address ne "") && exists($email_hash_address{$address})); 1067 return 1 if (($address ne "") && exists($email_hash_address{lc($address)}));
868 1068
869 return 0; 1069 return 0;
870} 1070}
@@ -882,8 +1082,8 @@ sub push_email_address {
882 push(@email_to, [format_email($name, $address, $email_usename), $role]); 1082 push(@email_to, [format_email($name, $address, $email_usename), $role]);
883 } elsif (!email_inuse($name, $address)) { 1083 } elsif (!email_inuse($name, $address)) {
884 push(@email_to, [format_email($name, $address, $email_usename), $role]); 1084 push(@email_to, [format_email($name, $address, $email_usename), $role]);
885 $email_hash_name{$name}++; 1085 $email_hash_name{lc($name)}++ if ($name ne "");
886 $email_hash_address{$address}++; 1086 $email_hash_address{lc($address)}++;
887 } 1087 }
888 1088
889 return 1; 1089 return 1;
@@ -952,30 +1152,69 @@ sub which {
952 return ""; 1152 return "";
953} 1153}
954 1154
955sub mailmap { 1155sub which_conf {
956 my (@lines) = @_; 1156 my ($conf) = @_;
957 my %hash;
958 1157
959 foreach my $line (@lines) { 1158 foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
960 my ($name, $address) = parse_email($line); 1159 if (-e "$path/$conf") {
961 if (!exists($hash{$name})) { 1160 return "$path/$conf";
962 $hash{$name} = $address;
963 } elsif ($address ne $hash{$name}) {
964 $address = $hash{$name};
965 $line = format_email($name, $address, $email_usename);
966 } 1161 }
967 if (exists($mailmap{$name})) { 1162 }
968 my $obj = $mailmap{$name}; 1163
969 foreach my $map_address (@$obj) { 1164 return "";
970 if (($map_address eq $address) && 1165}
971 ($map_address ne $hash{$name})) { 1166
972 $line = format_email($name, $hash{$name}, $email_usename); 1167sub mailmap_email {
973 } 1168 my ($line) = @_;
974 } 1169
1170 my ($name, $address) = parse_email($line);
1171 my $email = format_email($name, $address, 1);
1172 my $real_name = $name;
1173 my $real_address = $address;
1174
1175 if (exists $mailmap->{names}->{$email} ||
1176 exists $mailmap->{addresses}->{$email}) {
1177 if (exists $mailmap->{names}->{$email}) {
1178 $real_name = $mailmap->{names}->{$email};
1179 }
1180 if (exists $mailmap->{addresses}->{$email}) {
1181 $real_address = $mailmap->{addresses}->{$email};
1182 }
1183 } else {
1184 if (exists $mailmap->{names}->{$address}) {
1185 $real_name = $mailmap->{names}->{$address};
1186 }
1187 if (exists $mailmap->{addresses}->{$address}) {
1188 $real_address = $mailmap->{addresses}->{$address};
975 } 1189 }
976 } 1190 }
1191 return format_email($real_name, $real_address, 1);
1192}
977 1193
978 return @lines; 1194sub mailmap {
1195 my (@addresses) = @_;
1196
1197 my @mapped_emails = ();
1198 foreach my $line (@addresses) {
1199 push(@mapped_emails, mailmap_email($line));
1200 }
1201 merge_by_realname(@mapped_emails) if ($email_use_mailmap);
1202 return @mapped_emails;
1203}
1204
1205sub merge_by_realname {
1206 my %address_map;
1207 my (@emails) = @_;
1208
1209 foreach my $email (@emails) {
1210 my ($name, $address) = parse_email($email);
1211 if (exists $address_map{$name}) {
1212 $address = $address_map{$name};
1213 $email = format_email($name, $address, 1);
1214 } else {
1215 $address_map{$name} = $address;
1216 }
1217 }
979} 1218}
980 1219
981sub git_execute_cmd { 1220sub git_execute_cmd {
@@ -999,10 +1238,30 @@ sub hg_execute_cmd {
999 return @lines; 1238 return @lines;
1000} 1239}
1001 1240
1241sub extract_formatted_signatures {
1242 my (@signature_lines) = @_;
1243
1244 my @type = @signature_lines;
1245
1246 s/\s*(.*):.*/$1/ for (@type);
1247
1248 # cut -f2- -d":"
1249 s/\s*.*:\s*(.+)\s*/$1/ for (@signature_lines);
1250
1251## Reformat email addresses (with names) to avoid badly written signatures
1252
1253 foreach my $signer (@signature_lines) {
1254 $signer = deduplicate_email($signer);
1255 }
1256
1257 return (\@type, \@signature_lines);
1258}
1259
1002sub vcs_find_signers { 1260sub vcs_find_signers {
1003 my ($cmd) = @_; 1261 my ($cmd) = @_;
1004 my @lines = ();
1005 my $commits; 1262 my $commits;
1263 my @lines = ();
1264 my @signatures = ();
1006 1265
1007 @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); 1266 @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
1008 1267
@@ -1010,21 +1269,48 @@ sub vcs_find_signers {
1010 1269
1011 $commits = grep(/$pattern/, @lines); # of commits 1270 $commits = grep(/$pattern/, @lines); # of commits
1012 1271
1013 @lines = grep(/^[ \t]*${signaturePattern}.*\@.*$/, @lines); 1272 @signatures = grep(/^[ \t]*${signature_pattern}.*\@.*$/, @lines);
1273
1274 return (0, @signatures) if !@signatures;
1275
1276 save_commits_by_author(@lines) if ($interactive);
1277 save_commits_by_signer(@lines) if ($interactive);
1278
1279 if (!$email_git_penguin_chiefs) {
1280 @signatures = grep(!/${penguin_chiefs}/i, @signatures);
1281 }
1282
1283 my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
1284
1285 return ($commits, @$signers_ref);
1286}
1287
1288sub vcs_find_author {
1289 my ($cmd) = @_;
1290 my @lines = ();
1291
1292 @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
1293
1014 if (!$email_git_penguin_chiefs) { 1294 if (!$email_git_penguin_chiefs) {
1015 @lines = grep(!/${penguin_chiefs}/i, @lines); 1295 @lines = grep(!/${penguin_chiefs}/i, @lines);
1016 } 1296 }
1017 # cut -f2- -d":"
1018 s/.*:\s*(.+)\s*/$1/ for (@lines);
1019 1297
1020## Reformat email addresses (with names) to avoid badly written signatures 1298 return @lines if !@lines;
1021 1299
1300 my @authors = ();
1022 foreach my $line (@lines) { 1301 foreach my $line (@lines) {
1023 my ($name, $address) = parse_email($line); 1302 if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
1024 $line = format_email($name, $address, 1); 1303 my $author = $1;
1304 my ($name, $address) = parse_email($author);
1305 $author = format_email($name, $address, 1);
1306 push(@authors, $author);
1307 }
1025 } 1308 }
1026 1309
1027 return ($commits, @lines); 1310 save_commits_by_author(@lines) if ($interactive);
1311 save_commits_by_signer(@lines) if ($interactive);
1312
1313 return @authors;
1028} 1314}
1029 1315
1030sub vcs_save_commits { 1316sub vcs_save_commits {
@@ -1084,6 +1370,10 @@ sub vcs_blame {
1084 @commits = vcs_save_commits($cmd); 1370 @commits = vcs_save_commits($cmd);
1085 } 1371 }
1086 1372
1373 foreach my $commit (@commits) {
1374 $commit =~ s/^\^//g;
1375 }
1376
1087 return @commits; 1377 return @commits;
1088} 1378}
1089 1379
@@ -1092,7 +1382,7 @@ sub vcs_exists {
1092 %VCS_cmds = %VCS_cmds_git; 1382 %VCS_cmds = %VCS_cmds_git;
1093 return 1 if eval $VCS_cmds{"available"}; 1383 return 1 if eval $VCS_cmds{"available"};
1094 %VCS_cmds = %VCS_cmds_hg; 1384 %VCS_cmds = %VCS_cmds_hg;
1095 return 1 if eval $VCS_cmds{"available"}; 1385 return 2 if eval $VCS_cmds{"available"};
1096 %VCS_cmds = (); 1386 %VCS_cmds = ();
1097 if (!$printed_novcs) { 1387 if (!$printed_novcs) {
1098 warn("$P: No supported VCS found. Add --nogit to options?\n"); 1388 warn("$P: No supported VCS found. Add --nogit to options?\n");
@@ -1104,6 +1394,405 @@ sub vcs_exists {
1104 return 0; 1394 return 0;
1105} 1395}
1106 1396
1397sub vcs_is_git {
1398 vcs_exists();
1399 return $vcs_used == 1;
1400}
1401
1402sub vcs_is_hg {
1403 return $vcs_used == 2;
1404}
1405
1406sub interactive_get_maintainers {
1407 my ($list_ref) = @_;
1408 my @list = @$list_ref;
1409
1410 vcs_exists();
1411
1412 my %selected;
1413 my %authored;
1414 my %signed;
1415 my $count = 0;
1416 my $maintained = 0;
1417 foreach my $entry (@list) {
1418 $maintained = 1 if ($entry->[1] =~ /^(maintainer|supporter)/i);
1419 $selected{$count} = 1;
1420 $authored{$count} = 0;
1421 $signed{$count} = 0;
1422 $count++;
1423 }
1424
1425 #menu loop
1426 my $done = 0;
1427 my $print_options = 0;
1428 my $redraw = 1;
1429 while (!$done) {
1430 $count = 0;
1431 if ($redraw) {
1432 printf STDERR "\n%1s %2s %-65s",
1433 "*", "#", "email/list and role:stats";
1434 if ($email_git ||
1435 ($email_git_fallback && !$maintained) ||
1436 $email_git_blame) {
1437 print STDERR "auth sign";
1438 }
1439 print STDERR "\n";
1440 foreach my $entry (@list) {
1441 my $email = $entry->[0];
1442 my $role = $entry->[1];
1443 my $sel = "";
1444 $sel = "*" if ($selected{$count});
1445 my $commit_author = $commit_author_hash{$email};
1446 my $commit_signer = $commit_signer_hash{$email};
1447 my $authored = 0;
1448 my $signed = 0;
1449 $authored++ for (@{$commit_author});
1450 $signed++ for (@{$commit_signer});
1451 printf STDERR "%1s %2d %-65s", $sel, $count + 1, $email;
1452 printf STDERR "%4d %4d", $authored, $signed
1453 if ($authored > 0 || $signed > 0);
1454 printf STDERR "\n %s\n", $role;
1455 if ($authored{$count}) {
1456 my $commit_author = $commit_author_hash{$email};
1457 foreach my $ref (@{$commit_author}) {
1458 print STDERR " Author: @{$ref}[1]\n";
1459 }
1460 }
1461 if ($signed{$count}) {
1462 my $commit_signer = $commit_signer_hash{$email};
1463 foreach my $ref (@{$commit_signer}) {
1464 print STDERR " @{$ref}[2]: @{$ref}[1]\n";
1465 }
1466 }
1467
1468 $count++;
1469 }
1470 }
1471 my $date_ref = \$email_git_since;
1472 $date_ref = \$email_hg_since if (vcs_is_hg());
1473 if ($print_options) {
1474 $print_options = 0;
1475 if (vcs_exists()) {
1476 print STDERR <<EOT
1477
1478Version Control options:
1479g use git history [$email_git]
1480gf use git-fallback [$email_git_fallback]
1481b use git blame [$email_git_blame]
1482bs use blame signatures [$email_git_blame_signatures]
1483c# minimum commits [$email_git_min_signatures]
1484%# min percent [$email_git_min_percent]
1485d# history to use [$$date_ref]
1486x# max maintainers [$email_git_max_maintainers]
1487t all signature types [$email_git_all_signature_types]
1488m use .mailmap [$email_use_mailmap]
1489EOT
1490 }
1491 print STDERR <<EOT
1492
1493Additional options:
14940 toggle all
1495tm toggle maintainers
1496tg toggle git entries
1497tl toggle open list entries
1498ts toggle subscriber list entries
1499f emails in file [$file_emails]
1500k keywords in file [$keywords]
1501r remove duplicates [$email_remove_duplicates]
1502p# pattern match depth [$pattern_depth]
1503EOT
1504 }
1505 print STDERR
1506"\n#(toggle), A#(author), S#(signed) *(all), ^(none), O(options), Y(approve): ";
1507
1508 my $input = <STDIN>;
1509 chomp($input);
1510
1511 $redraw = 1;
1512 my $rerun = 0;
1513 my @wish = split(/[, ]+/, $input);
1514 foreach my $nr (@wish) {
1515 $nr = lc($nr);
1516 my $sel = substr($nr, 0, 1);
1517 my $str = substr($nr, 1);
1518 my $val = 0;
1519 $val = $1 if $str =~ /^(\d+)$/;
1520
1521 if ($sel eq "y") {
1522 $interactive = 0;
1523 $done = 1;
1524 $output_rolestats = 0;
1525 $output_roles = 0;
1526 last;
1527 } elsif ($nr =~ /^\d+$/ && $nr > 0 && $nr <= $count) {
1528 $selected{$nr - 1} = !$selected{$nr - 1};
1529 } elsif ($sel eq "*" || $sel eq '^') {
1530 my $toggle = 0;
1531 $toggle = 1 if ($sel eq '*');
1532 for (my $i = 0; $i < $count; $i++) {
1533 $selected{$i} = $toggle;
1534 }
1535 } elsif ($sel eq "0") {
1536 for (my $i = 0; $i < $count; $i++) {
1537 $selected{$i} = !$selected{$i};
1538 }
1539 } elsif ($sel eq "t") {
1540 if (lc($str) eq "m") {
1541 for (my $i = 0; $i < $count; $i++) {
1542 $selected{$i} = !$selected{$i}
1543 if ($list[$i]->[1] =~ /^(maintainer|supporter)/i);
1544 }
1545 } elsif (lc($str) eq "g") {
1546 for (my $i = 0; $i < $count; $i++) {
1547 $selected{$i} = !$selected{$i}
1548 if ($list[$i]->[1] =~ /^(author|commit|signer)/i);
1549 }
1550 } elsif (lc($str) eq "l") {
1551 for (my $i = 0; $i < $count; $i++) {
1552 $selected{$i} = !$selected{$i}
1553 if ($list[$i]->[1] =~ /^(open list)/i);
1554 }
1555 } elsif (lc($str) eq "s") {
1556 for (my $i = 0; $i < $count; $i++) {
1557 $selected{$i} = !$selected{$i}
1558 if ($list[$i]->[1] =~ /^(subscriber list)/i);
1559 }
1560 }
1561 } elsif ($sel eq "a") {
1562 if ($val > 0 && $val <= $count) {
1563 $authored{$val - 1} = !$authored{$val - 1};
1564 } elsif ($str eq '*' || $str eq '^') {
1565 my $toggle = 0;
1566 $toggle = 1 if ($str eq '*');
1567 for (my $i = 0; $i < $count; $i++) {
1568 $authored{$i} = $toggle;
1569 }
1570 }
1571 } elsif ($sel eq "s") {
1572 if ($val > 0 && $val <= $count) {
1573 $signed{$val - 1} = !$signed{$val - 1};
1574 } elsif ($str eq '*' || $str eq '^') {
1575 my $toggle = 0;
1576 $toggle = 1 if ($str eq '*');
1577 for (my $i = 0; $i < $count; $i++) {
1578 $signed{$i} = $toggle;
1579 }
1580 }
1581 } elsif ($sel eq "o") {
1582 $print_options = 1;
1583 $redraw = 1;
1584 } elsif ($sel eq "g") {
1585 if ($str eq "f") {
1586 bool_invert(\$email_git_fallback);
1587 } else {
1588 bool_invert(\$email_git);
1589 }
1590 $rerun = 1;
1591 } elsif ($sel eq "b") {
1592 if ($str eq "s") {
1593 bool_invert(\$email_git_blame_signatures);
1594 } else {
1595 bool_invert(\$email_git_blame);
1596 }
1597 $rerun = 1;
1598 } elsif ($sel eq "c") {
1599 if ($val > 0) {
1600 $email_git_min_signatures = $val;
1601 $rerun = 1;
1602 }
1603 } elsif ($sel eq "x") {
1604 if ($val > 0) {
1605 $email_git_max_maintainers = $val;
1606 $rerun = 1;
1607 }
1608 } elsif ($sel eq "%") {
1609 if ($str ne "" && $val >= 0) {
1610 $email_git_min_percent = $val;
1611 $rerun = 1;
1612 }
1613 } elsif ($sel eq "d") {
1614 if (vcs_is_git()) {
1615 $email_git_since = $str;
1616 } elsif (vcs_is_hg()) {
1617 $email_hg_since = $str;
1618 }
1619 $rerun = 1;
1620 } elsif ($sel eq "t") {
1621 bool_invert(\$email_git_all_signature_types);
1622 $rerun = 1;
1623 } elsif ($sel eq "f") {
1624 bool_invert(\$file_emails);
1625 $rerun = 1;
1626 } elsif ($sel eq "r") {
1627 bool_invert(\$email_remove_duplicates);
1628 $rerun = 1;
1629 } elsif ($sel eq "m") {
1630 bool_invert(\$email_use_mailmap);
1631 read_mailmap();
1632 $rerun = 1;
1633 } elsif ($sel eq "k") {
1634 bool_invert(\$keywords);
1635 $rerun = 1;
1636 } elsif ($sel eq "p") {
1637 if ($str ne "" && $val >= 0) {
1638 $pattern_depth = $val;
1639 $rerun = 1;
1640 }
1641 } elsif ($sel eq "h" || $sel eq "?") {
1642 print STDERR <<EOT
1643
1644Interactive mode allows you to select the various maintainers, submitters,
1645commit signers and mailing lists that could be CC'd on a patch.
1646
1647Any *'d entry is selected.
1648
1649If you have git or hg installed, you can choose to summarize the commit
1650history of files in the patch. Also, each line of the current file can
1651be matched to its commit author and that commits signers with blame.
1652
1653Various knobs exist to control the length of time for active commit
1654tracking, the maximum number of commit authors and signers to add,
1655and such.
1656
1657Enter selections at the prompt until you are satisfied that the selected
1658maintainers are appropriate. You may enter multiple selections separated
1659by either commas or spaces.
1660
1661EOT
1662 } else {
1663 print STDERR "invalid option: '$nr'\n";
1664 $redraw = 0;
1665 }
1666 }
1667 if ($rerun) {
1668 print STDERR "git-blame can be very slow, please have patience..."
1669 if ($email_git_blame);
1670 goto &get_maintainers;
1671 }
1672 }
1673
1674 #drop not selected entries
1675 $count = 0;
1676 my @new_emailto = ();
1677 foreach my $entry (@list) {
1678 if ($selected{$count}) {
1679 push(@new_emailto, $list[$count]);
1680 }
1681 $count++;
1682 }
1683 return @new_emailto;
1684}
1685
1686sub bool_invert {
1687 my ($bool_ref) = @_;
1688
1689 if ($$bool_ref) {
1690 $$bool_ref = 0;
1691 } else {
1692 $$bool_ref = 1;
1693 }
1694}
1695
1696sub deduplicate_email {
1697 my ($email) = @_;
1698
1699 my $matched = 0;
1700 my ($name, $address) = parse_email($email);
1701 $email = format_email($name, $address, 1);
1702 $email = mailmap_email($email);
1703
1704 return $email if (!$email_remove_duplicates);
1705
1706 ($name, $address) = parse_email($email);
1707
1708 if ($name ne "" && $deduplicate_name_hash{lc($name)}) {
1709 $name = $deduplicate_name_hash{lc($name)}->[0];
1710 $address = $deduplicate_name_hash{lc($name)}->[1];
1711 $matched = 1;
1712 } elsif ($deduplicate_address_hash{lc($address)}) {
1713 $name = $deduplicate_address_hash{lc($address)}->[0];
1714 $address = $deduplicate_address_hash{lc($address)}->[1];
1715 $matched = 1;
1716 }
1717 if (!$matched) {
1718 $deduplicate_name_hash{lc($name)} = [ $name, $address ];
1719 $deduplicate_address_hash{lc($address)} = [ $name, $address ];
1720 }
1721 $email = format_email($name, $address, 1);
1722 $email = mailmap_email($email);
1723 return $email;
1724}
1725
1726sub save_commits_by_author {
1727 my (@lines) = @_;
1728
1729 my @authors = ();
1730 my @commits = ();
1731 my @subjects = ();
1732
1733 foreach my $line (@lines) {
1734 if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
1735 my $author = $1;
1736 $author = deduplicate_email($author);
1737 push(@authors, $author);
1738 }
1739 push(@commits, $1) if ($line =~ m/$VCS_cmds{"commit_pattern"}/);
1740 push(@subjects, $1) if ($line =~ m/$VCS_cmds{"subject_pattern"}/);
1741 }
1742
1743 for (my $i = 0; $i < @authors; $i++) {
1744 my $exists = 0;
1745 foreach my $ref(@{$commit_author_hash{$authors[$i]}}) {
1746 if (@{$ref}[0] eq $commits[$i] &&
1747 @{$ref}[1] eq $subjects[$i]) {
1748 $exists = 1;
1749 last;
1750 }
1751 }
1752 if (!$exists) {
1753 push(@{$commit_author_hash{$authors[$i]}},
1754 [ ($commits[$i], $subjects[$i]) ]);
1755 }
1756 }
1757}
1758
1759sub save_commits_by_signer {
1760 my (@lines) = @_;
1761
1762 my $commit = "";
1763 my $subject = "";
1764
1765 foreach my $line (@lines) {
1766 $commit = $1 if ($line =~ m/$VCS_cmds{"commit_pattern"}/);
1767 $subject = $1 if ($line =~ m/$VCS_cmds{"subject_pattern"}/);
1768 if ($line =~ /^[ \t]*${signature_pattern}.*\@.*$/) {
1769 my @signatures = ($line);
1770 my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures);
1771 my @types = @$types_ref;
1772 my @signers = @$signers_ref;
1773
1774 my $type = $types[0];
1775 my $signer = $signers[0];
1776
1777 $signer = deduplicate_email($signer);
1778
1779 my $exists = 0;
1780 foreach my $ref(@{$commit_signer_hash{$signer}}) {
1781 if (@{$ref}[0] eq $commit &&
1782 @{$ref}[1] eq $subject &&
1783 @{$ref}[2] eq $type) {
1784 $exists = 1;
1785 last;
1786 }
1787 }
1788 if (!$exists) {
1789 push(@{$commit_signer_hash{$signer}},
1790 [ ($commit, $subject, $type) ]);
1791 }
1792 }
1793 }
1794}
1795
1107sub vcs_assign { 1796sub vcs_assign {
1108 my ($role, $divisor, @lines) = @_; 1797 my ($role, $divisor, @lines) = @_;
1109 1798
@@ -1117,9 +1806,9 @@ sub vcs_assign {
1117 $divisor = 1; 1806 $divisor = 1;
1118 } 1807 }
1119 1808
1120 if ($email_remove_duplicates) { 1809 @lines = mailmap(@lines);
1121 @lines = mailmap(@lines); 1810
1122 } 1811 return if (@lines <= 0);
1123 1812
1124 @lines = sort(@lines); 1813 @lines = sort(@lines);
1125 1814
@@ -1152,12 +1841,18 @@ sub vcs_file_signoffs {
1152 my @signers = (); 1841 my @signers = ();
1153 my $commits; 1842 my $commits;
1154 1843
1155 return if (!vcs_exists()); 1844 $vcs_used = vcs_exists();
1845 return if (!$vcs_used);
1156 1846
1157 my $cmd = $VCS_cmds{"find_signers_cmd"}; 1847 my $cmd = $VCS_cmds{"find_signers_cmd"};
1158 $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd 1848 $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
1159 1849
1160 ($commits, @signers) = vcs_find_signers($cmd); 1850 ($commits, @signers) = vcs_find_signers($cmd);
1851
1852 foreach my $signer (@signers) {
1853 $signer = deduplicate_email($signer);
1854 }
1855
1161 vcs_assign("commit_signer", $commits, @signers); 1856 vcs_assign("commit_signer", $commits, @signers);
1162} 1857}
1163 1858
@@ -1165,29 +1860,114 @@ sub vcs_file_blame {
1165 my ($file) = @_; 1860 my ($file) = @_;
1166 1861
1167 my @signers = (); 1862 my @signers = ();
1863 my @all_commits = ();
1168 my @commits = (); 1864 my @commits = ();
1169 my $total_commits; 1865 my $total_commits;
1866 my $total_lines;
1170 1867
1171 return if (!vcs_exists()); 1868 $vcs_used = vcs_exists();
1869 return if (!$vcs_used);
1172 1870
1173 @commits = vcs_blame($file); 1871 @all_commits = vcs_blame($file);
1174 @commits = uniq(@commits); 1872 @commits = uniq(@all_commits);
1175 $total_commits = @commits; 1873 $total_commits = @commits;
1874 $total_lines = @all_commits;
1176 1875
1177 foreach my $commit (@commits) { 1876 if ($email_git_blame_signatures) {
1178 my $commit_count; 1877 if (vcs_is_hg()) {
1179 my @commit_signers = (); 1878 my $commit_count;
1879 my @commit_signers = ();
1880 my $commit = join(" -r ", @commits);
1881 my $cmd;
1882
1883 $cmd = $VCS_cmds{"find_commit_signers_cmd"};
1884 $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
1885
1886 ($commit_count, @commit_signers) = vcs_find_signers($cmd);
1887
1888 push(@signers, @commit_signers);
1889 } else {
1890 foreach my $commit (@commits) {
1891 my $commit_count;
1892 my @commit_signers = ();
1893 my $cmd;
1894
1895 $cmd = $VCS_cmds{"find_commit_signers_cmd"};
1896 $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
1180 1897
1181 my $cmd = $VCS_cmds{"find_commit_signers_cmd"}; 1898 ($commit_count, @commit_signers) = vcs_find_signers($cmd);
1182 $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
1183 1899
1184 ($commit_count, @commit_signers) = vcs_find_signers($cmd); 1900 push(@signers, @commit_signers);
1185 push(@signers, @commit_signers); 1901 }
1902 }
1186 } 1903 }
1187 1904
1188 if ($from_filename) { 1905 if ($from_filename) {
1906 if ($output_rolestats) {
1907 my @blame_signers;
1908 if (vcs_is_hg()) {{ # Double brace for last exit
1909 my $commit_count;
1910 my @commit_signers = ();
1911 @commits = uniq(@commits);
1912 @commits = sort(@commits);
1913 my $commit = join(" -r ", @commits);
1914 my $cmd;
1915
1916 $cmd = $VCS_cmds{"find_commit_author_cmd"};
1917 $cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
1918
1919 my @lines = ();
1920
1921 @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
1922
1923 if (!$email_git_penguin_chiefs) {
1924 @lines = grep(!/${penguin_chiefs}/i, @lines);
1925 }
1926
1927 last if !@lines;
1928
1929 my @authors = ();
1930 foreach my $line (@lines) {
1931 if ($line =~ m/$VCS_cmds{"author_pattern"}/) {
1932 my $author = $1;
1933 $author = deduplicate_email($author);
1934 push(@authors, $author);
1935 }
1936 }
1937
1938 save_commits_by_author(@lines) if ($interactive);
1939 save_commits_by_signer(@lines) if ($interactive);
1940
1941 push(@signers, @authors);
1942 }}
1943 else {
1944 foreach my $commit (@commits) {
1945 my $i;
1946 my $cmd = $VCS_cmds{"find_commit_author_cmd"};
1947 $cmd =~ s/(\$\w+)/$1/eeg; #interpolate $cmd
1948 my @author = vcs_find_author($cmd);
1949 next if !@author;
1950
1951 my $formatted_author = deduplicate_email($author[0]);
1952
1953 my $count = grep(/$commit/, @all_commits);
1954 for ($i = 0; $i < $count ; $i++) {
1955 push(@blame_signers, $formatted_author);
1956 }
1957 }
1958 }
1959 if (@blame_signers) {
1960 vcs_assign("authored lines", $total_lines, @blame_signers);
1961 }
1962 }
1963 foreach my $signer (@signers) {
1964 $signer = deduplicate_email($signer);
1965 }
1189 vcs_assign("commits", $total_commits, @signers); 1966 vcs_assign("commits", $total_commits, @signers);
1190 } else { 1967 } else {
1968 foreach my $signer (@signers) {
1969 $signer = deduplicate_email($signer);
1970 }
1191 vcs_assign("modified commits", $total_commits, @signers); 1971 vcs_assign("modified commits", $total_commits, @signers);
1192 } 1972 }
1193} 1973}
diff --git a/scripts/gfp-translate b/scripts/gfp-translate
index d81b968d864e..c9230e158a8f 100644
--- a/scripts/gfp-translate
+++ b/scripts/gfp-translate
@@ -63,7 +63,12 @@ fi
63 63
64# Extract GFP flags from the kernel source 64# Extract GFP flags from the kernel source
65TMPFILE=`mktemp -t gfptranslate-XXXXXX` || exit 1 65TMPFILE=`mktemp -t gfptranslate-XXXXXX` || exit 1
66grep "^#define __GFP" $SOURCE/include/linux/gfp.h | sed -e 's/(__force gfp_t)//' | sed -e 's/u)/)/' | grep -v GFP_BITS | sed -e 's/)\//) \//' > $TMPFILE 66grep -q ___GFP $SOURCE/include/linux/gfp.h
67if [ $? -eq 0 ]; then
68 grep "^#define ___GFP" $SOURCE/include/linux/gfp.h | sed -e 's/u$//' | grep -v GFP_BITS > $TMPFILE
69else
70 grep "^#define __GFP" $SOURCE/include/linux/gfp.h | sed -e 's/(__force gfp_t)//' | sed -e 's/u)/)/' | grep -v GFP_BITS | sed -e 's/)\//) \//' > $TMPFILE
71fi
67 72
68# Parse the flags 73# Parse the flags
69IFS=" 74IFS="
diff --git a/scripts/headers.sh b/scripts/headers.sh
index 1ddcdd38d97f..978b42b3acd7 100755
--- a/scripts/headers.sh
+++ b/scripts/headers.sh
@@ -13,7 +13,7 @@ do_command()
13 fi 13 fi
14} 14}
15 15
16archs=$(ls ${srctree}/arch) 16archs=${HDR_ARCH_LIST:-$(ls ${srctree}/arch)}
17 17
18for arch in ${archs}; do 18for arch in ${archs}; do
19 case ${arch} in 19 case ${arch} in
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 50d6cfd1fa77..7957e7a5166a 100644
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -64,10 +64,10 @@ sub check_include
64 64
65sub check_declarations 65sub check_declarations
66{ 66{
67 if ($line =~m/^\s*extern\b/) { 67 if ($line =~m/^(\s*extern|unsigned|char|short|int|long|void)\b/) {
68 printf STDERR "$filename:$lineno: " . 68 printf STDERR "$filename:$lineno: " .
69 "userspace cannot call function or variable " . 69 "userspace cannot reference function or " .
70 "defined in the kernel\n"; 70 "variable defined in the kernel\n";
71 } 71 }
72} 72}
73 73
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index 4ca3be3b2e50..efb3be10d428 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -45,6 +45,13 @@ foreach my $file (@files) {
45 close $in; 45 close $in;
46 46
47 system $unifdef . " $tmpfile > $installdir/$file"; 47 system $unifdef . " $tmpfile > $installdir/$file";
48 # unifdef will exit 0 on success, and will exit 1 when the
49 # file was processed successfully but no changes were made,
50 # so abort only when it's higher than that.
51 my $e = $? >> 8;
52 if ($e > 1) {
53 die "$tmpfile: $!\n";
54 }
48 unlink $tmpfile; 55 unlink $tmpfile;
49} 56}
50exit 0; 57exit 0;
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index e3902fb39afd..487ac6f37ca2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -107,12 +107,8 @@ static int read_symbol(FILE *in, struct sym_entry *s)
107 107
108 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); 108 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
109 if (rc != 3) { 109 if (rc != 3) {
110 if (rc != EOF) { 110 if (rc != EOF && fgets(str, 500, in) == NULL)
111 /* skip line. sym is used as dummy to 111 fprintf(stderr, "Read error or end of file.\n");
112 * shut of "warn_unused_result" warning.
113 */
114 sym = fgets(str, 500, in);
115 }
116 return -1; 112 return -1;
117 } 113 }
118 114
@@ -504,6 +500,8 @@ static void optimize_result(void)
504 500
505 /* find the token with the breates profit value */ 501 /* find the token with the breates profit value */
506 best = find_best_token(); 502 best = find_best_token();
503 if (token_profit[best] == 0)
504 break;
507 505
508 /* place it in the "best" table */ 506 /* place it in the "best" table */
509 best_table_len[i] = 2; 507 best_table_len[i] = 2;
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index de934def410f..faa9a4701b6f 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -8,7 +8,7 @@ PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-c
8ifdef KBUILD_KCONFIG 8ifdef KBUILD_KCONFIG
9Kconfig := $(KBUILD_KCONFIG) 9Kconfig := $(KBUILD_KCONFIG)
10else 10else
11Kconfig := arch/$(SRCARCH)/Kconfig 11Kconfig := Kconfig
12endif 12endif
13 13
14xconfig: $(obj)/qconf 14xconfig: $(obj)/qconf
@@ -77,14 +77,15 @@ localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
77# The symlink is used to repair a deficiency in arch/um 77# The symlink is used to repair a deficiency in arch/um
78update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h 78update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
79 $(Q)echo " GEN config" 79 $(Q)echo " GEN config"
80 $(Q)xgettext --default-domain=linux \ 80 $(Q)xgettext --default-domain=linux \
81 --add-comments --keyword=_ --keyword=N_ \ 81 --add-comments --keyword=_ --keyword=N_ \
82 --from-code=UTF-8 \ 82 --from-code=UTF-8 \
83 --files-from=scripts/kconfig/POTFILES.in \ 83 --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
84 --directory=$(srctree) --directory=$(objtree) \
84 --output $(obj)/config.pot 85 --output $(obj)/config.pot
85 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 86 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
86 $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch 87 $(Q)ln -fs Kconfig.x86 arch/um/Kconfig
87 $(Q)(for i in `ls arch/*/Kconfig`; \ 88 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \
88 do \ 89 do \
89 echo " GEN $$i"; \ 90 echo " GEN $$i"; \
90 $(obj)/kxgettext $$i \ 91 $(obj)/kxgettext $$i \
@@ -92,7 +93,7 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
92 done ) 93 done )
93 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 94 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
94 --output $(obj)/linux.pot 95 --output $(obj)/linux.pot
95 $(Q)rm -f arch/um/Kconfig.arch 96 $(Q)rm -f $(srctree)/arch/um/Kconfig
96 $(Q)rm -f $(obj)/config.pot 97 $(Q)rm -f $(obj)/config.pot
97 98
98PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 99PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
@@ -145,11 +146,8 @@ check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
145 146
146# Use recursively expanded variables so we do not call gcc unless 147# Use recursively expanded variables so we do not call gcc unless
147# we really need to do so. (Do not call gcc as part of make mrproper) 148# we really need to do so. (Do not call gcc as part of make mrproper)
148HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) 149HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
149HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 150 -DLOCALE
150
151HOST_EXTRACFLAGS += -DLOCALE
152
153 151
154# =========================================================================== 152# ===========================================================================
155# Shared Makefile for the various kconfig executables: 153# Shared Makefile for the various kconfig executables:
@@ -171,8 +169,11 @@ conf-objs := conf.o zconf.tab.o
171mconf-objs := mconf.o zconf.tab.o $(lxdialog) 169mconf-objs := mconf.o zconf.tab.o $(lxdialog)
172nconf-objs := nconf.o zconf.tab.o nconf.gui.o 170nconf-objs := nconf.o zconf.tab.o nconf.gui.o
173kxgettext-objs := kxgettext.o zconf.tab.o 171kxgettext-objs := kxgettext.o zconf.tab.o
172qconf-cxxobjs := qconf.o
173qconf-objs := kconfig_load.o zconf.tab.o
174gconf-objs := gconf.o kconfig_load.o zconf.tab.o
174 175
175hostprogs-y := conf qconf gconf kxgettext 176hostprogs-y := conf
176 177
177ifeq ($(MAKECMDGOALS),nconfig) 178ifeq ($(MAKECMDGOALS),nconfig)
178 hostprogs-y += nconf 179 hostprogs-y += nconf
@@ -182,6 +183,10 @@ ifeq ($(MAKECMDGOALS),menuconfig)
182 hostprogs-y += mconf 183 hostprogs-y += mconf
183endif 184endif
184 185
186ifeq ($(MAKECMDGOALS),update-po-config)
187 hostprogs-y += kxgettext
188endif
189
185ifeq ($(MAKECMDGOALS),xconfig) 190ifeq ($(MAKECMDGOALS),xconfig)
186 qconf-target := 1 191 qconf-target := 1
187endif 192endif
@@ -191,16 +196,15 @@ endif
191 196
192 197
193ifeq ($(qconf-target),1) 198ifeq ($(qconf-target),1)
194qconf-cxxobjs := qconf.o 199 hostprogs-y += qconf
195qconf-objs := kconfig_load.o zconf.tab.o
196endif 200endif
197 201
198ifeq ($(gconf-target),1) 202ifeq ($(gconf-target),1)
199gconf-objs := gconf.o kconfig_load.o zconf.tab.o 203 hostprogs-y += gconf
200endif 204endif
201 205
202clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ 206clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck
203 .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h 207clean-files += zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
204clean-files += mconf qconf gconf nconf 208clean-files += mconf qconf gconf nconf
205clean-files += config.pot linux.pot 209clean-files += config.pot linux.pot
206 210
@@ -208,7 +212,7 @@ clean-files += config.pot linux.pot
208PHONY += $(obj)/dochecklxdialog 212PHONY += $(obj)/dochecklxdialog
209$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog 213$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
210$(obj)/dochecklxdialog: 214$(obj)/dochecklxdialog:
211 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES) 215 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
212 216
213always := dochecklxdialog 217always := dochecklxdialog
214 218
@@ -226,6 +230,8 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl
226HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 230HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
227 -D LKC_DIRECT_LINK 231 -D LKC_DIRECT_LINK
228 232
233HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
234
229HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses 235HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
230$(obj)/qconf.o: $(obj)/.tmp_qtcheck 236$(obj)/qconf.o: $(obj)/.tmp_qtcheck
231 237
@@ -236,40 +242,48 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile
236# QT needs some extra effort... 242# QT needs some extra effort...
237$(obj)/.tmp_qtcheck: 243$(obj)/.tmp_qtcheck:
238 @set -e; echo " CHECK qt"; dir=""; pkg=""; \ 244 @set -e; echo " CHECK qt"; dir=""; pkg=""; \
239 pkg-config --exists qt 2> /dev/null && pkg=qt; \ 245 if ! pkg-config --exists QtCore 2> /dev/null; then \
240 pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ 246 echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
241 if [ -n "$$pkg" ]; then \ 247 pkg-config --exists qt 2> /dev/null && pkg=qt; \
242 cflags="\$$(shell pkg-config $$pkg --cflags)"; \ 248 pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
243 libs="\$$(shell pkg-config $$pkg --libs)"; \ 249 if [ -n "$$pkg" ]; then \
244 moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ 250 cflags="\$$(shell pkg-config $$pkg --cflags)"; \
245 dir="$$(pkg-config $$pkg --variable=prefix)"; \ 251 libs="\$$(shell pkg-config $$pkg --libs)"; \
252 moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
253 dir="$$(pkg-config $$pkg --variable=prefix)"; \
254 else \
255 for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
256 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
257 done; \
258 if [ -z "$$dir" ]; then \
259 echo "*"; \
260 echo "* Unable to find any QT installation. Please make sure that"; \
261 echo "* the QT4 or QT3 development package is correctly installed and"; \
262 echo "* either qmake can be found or install pkg-config or set"; \
263 echo "* the QTDIR environment variable to the correct location."; \
264 echo "*"; \
265 false; \
266 fi; \
267 libpath=$$dir/lib; lib=qt; osdir=""; \
268 $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
269 osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
270 test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
271 test -f $$libpath/libqt-mt.so && lib=qt-mt; \
272 cflags="-I$$dir/include"; \
273 libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
274 moc="$$dir/bin/moc"; \
275 fi; \
276 if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
277 echo "*"; \
278 echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
279 echo "*"; \
280 moc="/usr/bin/moc"; \
281 fi; \
246 else \ 282 else \
247 for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ 283 cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
248 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 284 libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
249 done; \ 285 binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \
250 if [ -z "$$dir" ]; then \ 286 moc="$$binpath/bin/moc"; \
251 echo "*"; \
252 echo "* Unable to find the QT3 installation. Please make sure that"; \
253 echo "* the QT3 development package is correctly installed and"; \
254 echo "* either install pkg-config or set the QTDIR environment"; \
255 echo "* variable to the correct location."; \
256 echo "*"; \
257 false; \
258 fi; \
259 libpath=$$dir/lib; lib=qt; osdir=""; \
260 $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
261 osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
262 test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
263 test -f $$libpath/libqt-mt.so && lib=qt-mt; \
264 cflags="-I$$dir/include"; \
265 libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
266 moc="$$dir/bin/moc"; \
267 fi; \
268 if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
269 echo "*"; \
270 echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
271 echo "*"; \
272 moc="/usr/bin/moc"; \
273 fi; \ 287 fi; \
274 echo "KC_QT_CFLAGS=$$cflags" > $@; \ 288 echo "KC_QT_CFLAGS=$$cflags" > $@; \
275 echo "KC_QT_LIBS=$$libs" >> $@; \ 289 echo "KC_QT_LIBS=$$libs" >> $@; \
@@ -314,11 +328,12 @@ $(obj)/%.moc: $(src)/%.h
314 $(KC_QT_MOC) -i $< -o $@ 328 $(KC_QT_MOC) -i $< -o $@
315 329
316$(obj)/lkc_defs.h: $(src)/lkc_proto.h 330$(obj)/lkc_defs.h: $(src)/lkc_proto.h
317 sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' 331 $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
318 332
319# Extract gconf menu items for I18N support 333# Extract gconf menu items for I18N support
320$(obj)/gconf.glade.h: $(obj)/gconf.glade 334$(obj)/gconf.glade.h: $(obj)/gconf.glade
321 intltool-extract --type=gettext/glade $(obj)/gconf.glade 335 $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
336 $(obj)/gconf.glade
322 337
323### 338###
324# The following requires flex/bison/gperf 339# The following requires flex/bison/gperf
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 7ef429cd5cb3..006ad817cd5f 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -332,7 +332,7 @@ static int conf_choice(struct menu *menu)
332 } 332 }
333 if (!child) 333 if (!child)
334 continue; 334 continue;
335 if (line[strlen(line) - 1] == '?') { 335 if (line[0] && line[strlen(line) - 1] == '?') {
336 print_help(child); 336 print_help(child);
337 continue; 337 continue;
338 } 338 }
@@ -425,7 +425,7 @@ static void check_conf(struct menu *menu)
425 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { 425 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
426 if (input_mode == listnewconfig) { 426 if (input_mode == listnewconfig) {
427 if (sym->name && !sym_is_choice_value(sym)) { 427 if (sym->name && !sym_is_choice_value(sym)) {
428 printf("CONFIG_%s\n", sym->name); 428 printf("%s%s\n", CONFIG_, sym->name);
429 } 429 }
430 } else if (input_mode != oldnoconfig) { 430 } else if (input_mode != oldnoconfig) {
431 if (!conf_cnt++) 431 if (!conf_cnt++)
@@ -466,7 +466,7 @@ int main(int ac, char **av)
466 bindtextdomain(PACKAGE, LOCALEDIR); 466 bindtextdomain(PACKAGE, LOCALEDIR);
467 textdomain(PACKAGE); 467 textdomain(PACKAGE);
468 468
469 while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) { 469 while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
470 input_mode = (enum input_mode)opt; 470 input_mode = (enum input_mode)opt;
471 switch (opt) { 471 switch (opt) {
472 case silentoldconfig: 472 case silentoldconfig:
@@ -508,8 +508,7 @@ int main(int ac, char **av)
508 name = conf_get_configname(); 508 name = conf_get_configname();
509 if (stat(name, &tmpstat)) { 509 if (stat(name, &tmpstat)) {
510 fprintf(stderr, _("***\n" 510 fprintf(stderr, _("***\n"
511 "*** You have not yet configured your kernel!\n" 511 "*** Configuration file \"%s\" not found!\n"
512 "*** (missing kernel config file \"%s\")\n"
513 "***\n" 512 "***\n"
514 "*** Please run some configurator (e.g. \"make oldconfig\" or\n" 513 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
515 "*** \"make menuconfig\" or \"make xconfig\").\n" 514 "*** \"make menuconfig\" or \"make xconfig\").\n"
@@ -530,8 +529,6 @@ int main(int ac, char **av)
530 } 529 }
531 break; 530 break;
532 case savedefconfig: 531 case savedefconfig:
533 conf_read(NULL);
534 break;
535 case silentoldconfig: 532 case silentoldconfig:
536 case oldaskconfig: 533 case oldaskconfig:
537 case oldconfig: 534 case oldconfig:
@@ -571,7 +568,7 @@ int main(int ac, char **av)
571 name = getenv("KCONFIG_NOSILENTUPDATE"); 568 name = getenv("KCONFIG_NOSILENTUPDATE");
572 if (name && *name) { 569 if (name && *name) {
573 fprintf(stderr, 570 fprintf(stderr,
574 _("\n*** Kernel configuration requires explicit update.\n\n")); 571 _("\n*** The configuration requires explicit update.\n\n"));
575 return 1; 572 return 1;
576 } 573 }
577 } 574 }
@@ -623,11 +620,11 @@ int main(int ac, char **av)
623 * All other commands are only used to generate a config. 620 * All other commands are only used to generate a config.
624 */ 621 */
625 if (conf_get_changed() && conf_write(NULL)) { 622 if (conf_get_changed() && conf_write(NULL)) {
626 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 623 fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
627 exit(1); 624 exit(1);
628 } 625 }
629 if (conf_write_autoconf()) { 626 if (conf_write_autoconf()) {
630 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); 627 fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
631 return 1; 628 return 1;
632 } 629 }
633 } else if (input_mode == savedefconfig) { 630 } else if (input_mode == savedefconfig) {
@@ -638,7 +635,7 @@ int main(int ac, char **av)
638 } 635 }
639 } else if (input_mode != listnewconfig) { 636 } else if (input_mode != listnewconfig) {
640 if (conf_write(NULL)) { 637 if (conf_write(NULL)) {
641 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 638 fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
642 exit(1); 639 exit(1);
643 } 640 }
644 } 641 }
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 515253fe46cf..2bafd9a7c8da 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -5,6 +5,7 @@
5 5
6#include <sys/stat.h> 6#include <sys/stat.h>
7#include <ctype.h> 7#include <ctype.h>
8#include <errno.h>
8#include <fcntl.h> 9#include <fcntl.h>
9#include <stdio.h> 10#include <stdio.h>
10#include <stdlib.h> 11#include <stdlib.h>
@@ -18,6 +19,9 @@
18static void conf_warning(const char *fmt, ...) 19static void conf_warning(const char *fmt, ...)
19 __attribute__ ((format (printf, 1, 2))); 20 __attribute__ ((format (printf, 1, 2)));
20 21
22static void conf_message(const char *fmt, ...)
23 __attribute__ ((format (printf, 1, 2)));
24
21static const char *conf_filename; 25static const char *conf_filename;
22static int conf_lineno, conf_warnings, conf_unsaved; 26static int conf_lineno, conf_warnings, conf_unsaved;
23 27
@@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
34 conf_warnings++; 38 conf_warnings++;
35} 39}
36 40
41static void conf_default_message_callback(const char *fmt, va_list ap)
42{
43 printf("#\n# ");
44 vprintf(fmt, ap);
45 printf("\n#\n");
46}
47
48static void (*conf_message_callback) (const char *fmt, va_list ap) =
49 conf_default_message_callback;
50void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
51{
52 conf_message_callback = fn;
53}
54
55static void conf_message(const char *fmt, ...)
56{
57 va_list ap;
58
59 va_start(ap, fmt);
60 if (conf_message_callback)
61 conf_message_callback(fmt, ap);
62}
63
37const char *conf_get_configname(void) 64const char *conf_get_configname(void)
38{ 65{
39 char *name = getenv("KCONFIG_CONFIG"); 66 char *name = getenv("KCONFIG_CONFIG");
@@ -183,9 +210,8 @@ int conf_read_simple(const char *name, int def)
183 name = conf_expand_value(prop->expr->left.sym->name); 210 name = conf_expand_value(prop->expr->left.sym->name);
184 in = zconf_fopen(name); 211 in = zconf_fopen(name);
185 if (in) { 212 if (in) {
186 printf(_("#\n" 213 conf_message(_("using defaults found in %s"),
187 "# using defaults found in %s\n" 214 name);
188 "#\n"), name);
189 goto load; 215 goto load;
190 } 216 }
191 } 217 }
@@ -220,24 +246,23 @@ load:
220 while (fgets(line, sizeof(line), in)) { 246 while (fgets(line, sizeof(line), in)) {
221 conf_lineno++; 247 conf_lineno++;
222 sym = NULL; 248 sym = NULL;
223 switch (line[0]) { 249 if (line[0] == '#') {
224 case '#': 250 if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
225 if (memcmp(line + 2, "CONFIG_", 7))
226 continue; 251 continue;
227 p = strchr(line + 9, ' '); 252 p = strchr(line + 2 + strlen(CONFIG_), ' ');
228 if (!p) 253 if (!p)
229 continue; 254 continue;
230 *p++ = 0; 255 *p++ = 0;
231 if (strncmp(p, "is not set", 10)) 256 if (strncmp(p, "is not set", 10))
232 continue; 257 continue;
233 if (def == S_DEF_USER) { 258 if (def == S_DEF_USER) {
234 sym = sym_find(line + 9); 259 sym = sym_find(line + 2 + strlen(CONFIG_));
235 if (!sym) { 260 if (!sym) {
236 sym_add_change_count(1); 261 sym_add_change_count(1);
237 break; 262 goto setsym;
238 } 263 }
239 } else { 264 } else {
240 sym = sym_lookup(line + 9, 0); 265 sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
241 if (sym->type == S_UNKNOWN) 266 if (sym->type == S_UNKNOWN)
242 sym->type = S_BOOLEAN; 267 sym->type = S_BOOLEAN;
243 } 268 }
@@ -253,13 +278,8 @@ load:
253 default: 278 default:
254 ; 279 ;
255 } 280 }
256 break; 281 } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
257 case 'C': 282 p = strchr(line + strlen(CONFIG_), '=');
258 if (memcmp(line, "CONFIG_", 7)) {
259 conf_warning("unexpected data");
260 continue;
261 }
262 p = strchr(line + 7, '=');
263 if (!p) 283 if (!p)
264 continue; 284 continue;
265 *p++ = 0; 285 *p++ = 0;
@@ -270,13 +290,13 @@ load:
270 *p2 = 0; 290 *p2 = 0;
271 } 291 }
272 if (def == S_DEF_USER) { 292 if (def == S_DEF_USER) {
273 sym = sym_find(line + 7); 293 sym = sym_find(line + strlen(CONFIG_));
274 if (!sym) { 294 if (!sym) {
275 sym_add_change_count(1); 295 sym_add_change_count(1);
276 break; 296 goto setsym;
277 } 297 }
278 } else { 298 } else {
279 sym = sym_lookup(line + 7, 0); 299 sym = sym_lookup(line + strlen(CONFIG_), 0);
280 if (sym->type == S_UNKNOWN) 300 if (sym->type == S_UNKNOWN)
281 sym->type = S_OTHER; 301 sym->type = S_OTHER;
282 } 302 }
@@ -285,14 +305,12 @@ load:
285 } 305 }
286 if (conf_set_sym_val(sym, def, def_flags, p)) 306 if (conf_set_sym_val(sym, def, def_flags, p))
287 continue; 307 continue;
288 break; 308 } else {
289 case '\r': 309 if (line[0] != '\r' && line[0] != '\n')
290 case '\n': 310 conf_warning("unexpected data");
291 break;
292 default:
293 conf_warning("unexpected data");
294 continue; 311 continue;
295 } 312 }
313setsym:
296 if (sym && sym_is_choice_value(sym)) { 314 if (sym && sym_is_choice_value(sym)) {
297 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); 315 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
298 switch (sym->def[def].tri) { 316 switch (sym->def[def].tri) {
@@ -405,9 +423,9 @@ static void conf_write_string(bool headerfile, const char *name,
405{ 423{
406 int l; 424 int l;
407 if (headerfile) 425 if (headerfile)
408 fprintf(out, "#define CONFIG_%s \"", name); 426 fprintf(out, "#define %s%s \"", CONFIG_, name);
409 else 427 else
410 fprintf(out, "CONFIG_%s=\"", name); 428 fprintf(out, "%s%s=\"", CONFIG_, name);
411 429
412 while (1) { 430 while (1) {
413 l = strcspn(str, "\"\\"); 431 l = strcspn(str, "\"\\");
@@ -422,24 +440,24 @@ static void conf_write_string(bool headerfile, const char *name,
422 fputs("\"\n", out); 440 fputs("\"\n", out);
423} 441}
424 442
425static void conf_write_symbol(struct symbol *sym, enum symbol_type type, 443static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
426 FILE *out, bool write_no)
427{ 444{
428 const char *str; 445 const char *str;
429 446
430 switch (type) { 447 switch (sym->type) {
431 case S_BOOLEAN: 448 case S_BOOLEAN:
432 case S_TRISTATE: 449 case S_TRISTATE:
433 switch (sym_get_tristate_value(sym)) { 450 switch (sym_get_tristate_value(sym)) {
434 case no: 451 case no:
435 if (write_no) 452 if (write_no)
436 fprintf(out, "# CONFIG_%s is not set\n", sym->name); 453 fprintf(out, "# %s%s is not set\n",
454 CONFIG_, sym->name);
437 break; 455 break;
438 case mod: 456 case mod:
439 fprintf(out, "CONFIG_%s=m\n", sym->name); 457 fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
440 break; 458 break;
441 case yes: 459 case yes:
442 fprintf(out, "CONFIG_%s=y\n", sym->name); 460 fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
443 break; 461 break;
444 } 462 }
445 break; 463 break;
@@ -449,7 +467,7 @@ static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
449 case S_HEX: 467 case S_HEX:
450 case S_INT: 468 case S_INT:
451 str = sym_get_string_value(sym); 469 str = sym_get_string_value(sym);
452 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 470 fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
453 break; 471 break;
454 case S_OTHER: 472 case S_OTHER:
455 case S_UNKNOWN: 473 case S_UNKNOWN:
@@ -513,7 +531,7 @@ int conf_write_defconfig(const char *filename)
513 goto next_menu; 531 goto next_menu;
514 } 532 }
515 } 533 }
516 conf_write_symbol(sym, sym->type, out, true); 534 conf_write_symbol(sym, out, true);
517 } 535 }
518next_menu: 536next_menu:
519 if (menu->list != NULL) { 537 if (menu->list != NULL) {
@@ -541,10 +559,7 @@ int conf_write(const char *name)
541 struct menu *menu; 559 struct menu *menu;
542 const char *basename; 560 const char *basename;
543 const char *str; 561 const char *str;
544 char dirname[128], tmpname[128], newname[128]; 562 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
545 enum symbol_type type;
546 time_t now;
547 int use_timestamp = 1;
548 char *env; 563 char *env;
549 564
550 dirname[0] = 0; 565 dirname[0] = 0;
@@ -581,21 +596,11 @@ int conf_write(const char *name)
581 if (!out) 596 if (!out)
582 return 1; 597 return 1;
583 598
584 sym = sym_lookup("KERNELVERSION", 0);
585 sym_calc_value(sym);
586 time(&now);
587 env = getenv("KCONFIG_NOTIMESTAMP");
588 if (env && *env)
589 use_timestamp = 0;
590
591 fprintf(out, _("#\n" 599 fprintf(out, _("#\n"
592 "# Automatically generated make config: don't edit\n" 600 "# Automatically generated make config: don't edit\n"
593 "# Linux kernel version: %s\n" 601 "# %s\n"
594 "%s%s"
595 "#\n"), 602 "#\n"),
596 sym_get_string_value(sym), 603 rootmenu.prompt->text);
597 use_timestamp ? "# " : "",
598 use_timestamp ? ctime(&now) : "");
599 604
600 if (!conf_get_changed()) 605 if (!conf_get_changed())
601 sym_clear_all_valid(); 606 sym_clear_all_valid();
@@ -616,14 +621,8 @@ int conf_write(const char *name)
616 if (!(sym->flags & SYMBOL_WRITE)) 621 if (!(sym->flags & SYMBOL_WRITE))
617 goto next; 622 goto next;
618 sym->flags &= ~SYMBOL_WRITE; 623 sym->flags &= ~SYMBOL_WRITE;
619 type = sym->type;
620 if (type == S_TRISTATE) {
621 sym_calc_value(modules_sym);
622 if (modules_sym->curr.tri == no)
623 type = S_BOOLEAN;
624 }
625 /* Write config symbol to file */ 624 /* Write config symbol to file */
626 conf_write_symbol(sym, type, out, true); 625 conf_write_symbol(sym, out, true);
627 } 626 }
628 627
629next: 628next:
@@ -650,9 +649,7 @@ next:
650 return 1; 649 return 1;
651 } 650 }
652 651
653 printf(_("#\n" 652 conf_message(_("configuration written to %s"), newname);
654 "# configuration written to %s\n"
655 "#\n"), newname);
656 653
657 sym_set_change_count(0); 654 sym_set_change_count(0);
658 655
@@ -662,7 +659,7 @@ next:
662static int conf_split_config(void) 659static int conf_split_config(void)
663{ 660{
664 const char *name; 661 const char *name;
665 char path[128]; 662 char path[PATH_MAX+1];
666 char *s, *d, c; 663 char *s, *d, c;
667 struct symbol *sym; 664 struct symbol *sym;
668 struct stat sb; 665 struct stat sb;
@@ -777,7 +774,6 @@ int conf_write_autoconf(void)
777 const char *str; 774 const char *str;
778 const char *name; 775 const char *name;
779 FILE *out, *tristate, *out_h; 776 FILE *out, *tristate, *out_h;
780 time_t now;
781 int i; 777 int i;
782 778
783 sym_clear_all_valid(); 779 sym_clear_all_valid();
@@ -804,25 +800,19 @@ int conf_write_autoconf(void)
804 return 1; 800 return 1;
805 } 801 }
806 802
807 sym = sym_lookup("KERNELVERSION", 0);
808 sym_calc_value(sym);
809 time(&now);
810 fprintf(out, "#\n" 803 fprintf(out, "#\n"
811 "# Automatically generated make config: don't edit\n" 804 "# Automatically generated make config: don't edit\n"
812 "# Linux kernel version: %s\n" 805 "# %s\n"
813 "# %s"
814 "#\n", 806 "#\n",
815 sym_get_string_value(sym), ctime(&now)); 807 rootmenu.prompt->text);
816 fprintf(tristate, "#\n" 808 fprintf(tristate, "#\n"
817 "# Automatically generated - do not edit\n" 809 "# Automatically generated - do not edit\n"
818 "\n"); 810 "\n");
819 fprintf(out_h, "/*\n" 811 fprintf(out_h, "/*\n"
820 " * Automatically generated C config: don't edit\n" 812 " * Automatically generated C config: don't edit\n"
821 " * Linux kernel version: %s\n" 813 " * %s\n"
822 " * %s" 814 " */\n",
823 " */\n" 815 rootmenu.prompt->text);
824 "#define AUTOCONF_INCLUDED\n",
825 sym_get_string_value(sym), ctime(&now));
826 816
827 for_all_symbols(i, sym) { 817 for_all_symbols(i, sym) {
828 sym_calc_value(sym); 818 sym_calc_value(sym);
@@ -830,7 +820,7 @@ int conf_write_autoconf(void)
830 continue; 820 continue;
831 821
832 /* write symbol to config file */ 822 /* write symbol to config file */
833 conf_write_symbol(sym, sym->type, out, false); 823 conf_write_symbol(sym, out, false);
834 824
835 /* update autoconf and tristate files */ 825 /* update autoconf and tristate files */
836 switch (sym->type) { 826 switch (sym->type) {
@@ -840,14 +830,17 @@ int conf_write_autoconf(void)
840 case no: 830 case no:
841 break; 831 break;
842 case mod: 832 case mod:
843 fprintf(tristate, "CONFIG_%s=M\n", sym->name); 833 fprintf(tristate, "%s%s=M\n",
844 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 834 CONFIG_, sym->name);
835 fprintf(out_h, "#define %s%s_MODULE 1\n",
836 CONFIG_, sym->name);
845 break; 837 break;
846 case yes: 838 case yes:
847 if (sym->type == S_TRISTATE) 839 if (sym->type == S_TRISTATE)
848 fprintf(tristate, "CONFIG_%s=Y\n", 840 fprintf(tristate,"%s%s=Y\n",
849 sym->name); 841 CONFIG_, sym->name);
850 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); 842 fprintf(out_h, "#define %s%s 1\n",
843 CONFIG_, sym->name);
851 break; 844 break;
852 } 845 }
853 break; 846 break;
@@ -857,12 +850,14 @@ int conf_write_autoconf(void)
857 case S_HEX: 850 case S_HEX:
858 str = sym_get_string_value(sym); 851 str = sym_get_string_value(sym);
859 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 852 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
860 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); 853 fprintf(out_h, "#define %s%s 0x%s\n",
854 CONFIG_, sym->name, str);
861 break; 855 break;
862 } 856 }
863 case S_INT: 857 case S_INT:
864 str = sym_get_string_value(sym); 858 str = sym_get_string_value(sym);
865 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); 859 fprintf(out_h, "#define %s%s %s\n",
860 CONFIG_, sym->name, str);
866 break; 861 break;
867 default: 862 default:
868 break; 863 break;
@@ -928,7 +923,7 @@ static void randomize_choice_values(struct symbol *csym)
928 int cnt, def; 923 int cnt, def;
929 924
930 /* 925 /*
931 * If choice is mod then we may have more items slected 926 * If choice is mod then we may have more items selected
932 * and if no then no-one. 927 * and if no then no-one.
933 * In both cases stop. 928 * In both cases stop.
934 */ 929 */
@@ -1024,10 +1019,10 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1024 1019
1025 /* 1020 /*
1026 * We have different type of choice blocks. 1021 * We have different type of choice blocks.
1027 * If curr.tri equal to mod then we can select several 1022 * If curr.tri equals to mod then we can select several
1028 * choice symbols in one block. 1023 * choice symbols in one block.
1029 * In this case we do nothing. 1024 * In this case we do nothing.
1030 * If curr.tri equal yes then only one symbol can be 1025 * If curr.tri equals yes then only one symbol can be
1031 * selected in a choice block and we set it to yes, 1026 * selected in a choice block and we set it to yes,
1032 * and the rest to no. 1027 * and the rest to no.
1033 */ 1028 */
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 330e7c0048a8..001003452f68 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
64 return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; 64 return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
65} 65}
66 66
67struct expr *expr_copy(struct expr *org) 67struct expr *expr_copy(const struct expr *org)
68{ 68{
69 struct expr *e; 69 struct expr *e;
70 70
@@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
1013#endif 1013#endif
1014} 1014}
1015 1015
1016static inline struct expr *
1017expr_get_leftmost_symbol(const struct expr *e)
1018{
1019
1020 if (e == NULL)
1021 return NULL;
1022
1023 while (e->type != E_SYMBOL)
1024 e = e->left.expr;
1025
1026 return expr_copy(e);
1027}
1028
1029/*
1030 * Given expression `e1' and `e2', returns the leaf of the longest
1031 * sub-expression of `e1' not containing 'e2.
1032 */
1033struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
1034{
1035 struct expr *ret;
1036
1037 switch (e1->type) {
1038 case E_OR:
1039 return expr_alloc_and(
1040 expr_simplify_unmet_dep(e1->left.expr, e2),
1041 expr_simplify_unmet_dep(e1->right.expr, e2));
1042 case E_AND: {
1043 struct expr *e;
1044 e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
1045 e = expr_eliminate_dups(e);
1046 ret = (!expr_eq(e, e1)) ? e1 : NULL;
1047 expr_free(e);
1048 break;
1049 }
1050 default:
1051 ret = e1;
1052 break;
1053 }
1054
1055 return expr_get_leftmost_symbol(ret);
1056}
1057
1016void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) 1058void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
1017{ 1059{
1018 if (!e) { 1060 if (!e) {
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 170459c224a1..16bfae2d3217 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -18,14 +18,10 @@ extern "C" {
18struct file { 18struct file {
19 struct file *next; 19 struct file *next;
20 struct file *parent; 20 struct file *parent;
21 char *name; 21 const char *name;
22 int lineno; 22 int lineno;
23 int flags;
24}; 23};
25 24
26#define FILE_BUSY 0x0001
27#define FILE_SCANNED 0x0002
28
29typedef enum tristate { 25typedef enum tristate {
30 no, mod, yes 26 no, mod, yes
31} tristate; 27} tristate;
@@ -164,6 +160,7 @@ struct menu {
164 struct menu *list; 160 struct menu *list;
165 struct symbol *sym; 161 struct symbol *sym;
166 struct property *prompt; 162 struct property *prompt;
163 struct expr *visibility;
167 struct expr *dep; 164 struct expr *dep;
168 unsigned int flags; 165 unsigned int flags;
169 char *help; 166 char *help;
@@ -191,7 +188,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
191struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); 188struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
192struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); 189struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
193struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); 190struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
194struct expr *expr_copy(struct expr *org); 191struct expr *expr_copy(const struct expr *org);
195void expr_free(struct expr *e); 192void expr_free(struct expr *e);
196int expr_eq(struct expr *e1, struct expr *e2); 193int expr_eq(struct expr *e1, struct expr *e2);
197void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); 194void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
@@ -206,6 +203,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
206struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); 203struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
207void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); 204void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
208struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); 205struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
206struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
209 207
210void expr_fprint(struct expr *e, FILE *out); 208void expr_fprint(struct expr *e, FILE *out);
211struct gstr; /* forward */ 209struct gstr; /* forward */
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index d66988265f89..a11d5f7b9eeb 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -133,7 +133,6 @@ void init_main_window(const gchar * glade_file)
133 GladeXML *xml; 133 GladeXML *xml;
134 GtkWidget *widget; 134 GtkWidget *widget;
135 GtkTextBuffer *txtbuf; 135 GtkTextBuffer *txtbuf;
136 char title[256];
137 GtkStyle *style; 136 GtkStyle *style;
138 137
139 xml = glade_xml_new(glade_file, "window1", NULL); 138 xml = glade_xml_new(glade_file, "window1", NULL);
@@ -210,9 +209,7 @@ void init_main_window(const gchar * glade_file)
210 /*"style", PANGO_STYLE_OBLIQUE, */ 209 /*"style", PANGO_STYLE_OBLIQUE, */
211 NULL); 210 NULL);
212 211
213 sprintf(title, _("Linux Kernel v%s Configuration"), 212 gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
214 getenv("KERNELVERSION"));
215 gtk_window_set_title(GTK_WINDOW(main_wnd), title);
216 213
217 gtk_widget_show(main_wnd); 214 gtk_widget_show(main_wnd);
218} 215}
@@ -256,7 +253,7 @@ void init_left_tree(void)
256 253
257 gtk_tree_view_set_model(view, model1); 254 gtk_tree_view_set_model(view, model1);
258 gtk_tree_view_set_headers_visible(view, TRUE); 255 gtk_tree_view_set_headers_visible(view, TRUE);
259 gtk_tree_view_set_rules_hint(view, FALSE); 256 gtk_tree_view_set_rules_hint(view, TRUE);
260 257
261 column = gtk_tree_view_column_new(); 258 column = gtk_tree_view_column_new();
262 gtk_tree_view_append_column(view, column); 259 gtk_tree_view_append_column(view, column);
@@ -301,7 +298,7 @@ void init_right_tree(void)
301 298
302 gtk_tree_view_set_model(view, model2); 299 gtk_tree_view_set_model(view, model2);
303 gtk_tree_view_set_headers_visible(view, TRUE); 300 gtk_tree_view_set_headers_visible(view, TRUE);
304 gtk_tree_view_set_rules_hint(view, FALSE); 301 gtk_tree_view_set_rules_hint(view, TRUE);
305 302
306 column = gtk_tree_view_column_new(); 303 column = gtk_tree_view_column_new();
307 gtk_tree_view_append_column(view, column); 304 gtk_tree_view_append_column(view, column);
@@ -671,8 +668,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
671{ 668{
672 GtkWidget *dialog; 669 GtkWidget *dialog;
673 const gchar *intro_text = _( 670 const gchar *intro_text = _(
674 "Welcome to gkc, the GTK+ graphical kernel configuration tool\n" 671 "Welcome to gkc, the GTK+ graphical configuration tool\n"
675 "for Linux.\n"
676 "For each option, a blank box indicates the feature is disabled, a\n" 672 "For each option, a blank box indicates the feature is disabled, a\n"
677 "check indicates it is enabled, and a dot indicates that it is to\n" 673 "check indicates it is enabled, and a dot indicates that it is to\n"
678 "be compiled as a module. Clicking on the box will cycle through the three states.\n" 674 "be compiled as a module. Clicking on the box will cycle through the three states.\n"
@@ -760,7 +756,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
760void on_single_clicked(GtkButton * button, gpointer user_data) 756void on_single_clicked(GtkButton * button, gpointer user_data)
761{ 757{
762 view_mode = SINGLE_VIEW; 758 view_mode = SINGLE_VIEW;
763 gtk_paned_set_position(GTK_PANED(hpaned), 0);
764 gtk_widget_hide(tree1_w); 759 gtk_widget_hide(tree1_w);
765 current = &rootmenu; 760 current = &rootmenu;
766 display_tree_part(); 761 display_tree_part();
@@ -786,7 +781,6 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
786void on_full_clicked(GtkButton * button, gpointer user_data) 781void on_full_clicked(GtkButton * button, gpointer user_data)
787{ 782{
788 view_mode = FULL_VIEW; 783 view_mode = FULL_VIEW;
789 gtk_paned_set_position(GTK_PANED(hpaned), 0);
790 gtk_widget_hide(tree1_w); 784 gtk_widget_hide(tree1_w);
791 if (tree2) 785 if (tree2)
792 gtk_tree_store_clear(tree2); 786 gtk_tree_store_clear(tree2);
@@ -1448,6 +1442,12 @@ static void display_tree(struct menu *menu)
1448 if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) 1442 if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
1449 || (view_mode == FULL_VIEW) 1443 || (view_mode == FULL_VIEW)
1450 || (view_mode == SPLIT_VIEW))*/ 1444 || (view_mode == SPLIT_VIEW))*/
1445
1446 /* Change paned position if the view is not in 'split mode' */
1447 if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
1448 gtk_paned_set_position(GTK_PANED(hpaned), 0);
1449 }
1450
1451 if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) 1451 if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
1452 || (view_mode == FULL_VIEW) 1452 || (view_mode == FULL_VIEW)
1453 || (view_mode == SPLIT_VIEW)) { 1453 || (view_mode == SPLIT_VIEW)) {
@@ -1531,12 +1531,6 @@ int main(int ac, char *av[])
1531 else 1531 else
1532 glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL); 1532 glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
1533 1533
1534 /* Load the interface and connect signals */
1535 init_main_window(glade_file);
1536 init_tree_model();
1537 init_left_tree();
1538 init_right_tree();
1539
1540 /* Conf stuffs */ 1534 /* Conf stuffs */
1541 if (ac > 1 && av[1][0] == '-') { 1535 if (ac > 1 && av[1][0] == '-') {
1542 switch (av[1][1]) { 1536 switch (av[1][1]) {
@@ -1556,6 +1550,12 @@ int main(int ac, char *av[])
1556 fixup_rootmenu(&rootmenu); 1550 fixup_rootmenu(&rootmenu);
1557 conf_read(NULL); 1551 conf_read(NULL);
1558 1552
1553 /* Load the interface and connect signals */
1554 init_main_window(glade_file);
1555 init_tree_model();
1556 init_left_tree();
1557 init_right_tree();
1558
1559 switch (view_mode) { 1559 switch (view_mode) {
1560 case SINGLE_VIEW: 1560 case SINGLE_VIEW:
1561 display_tree_part(); 1561 display_tree_part();
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index d52b0a75d824..aa483cb32755 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -1,5 +1,4 @@
1<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> 1<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
2<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
3 2
4<glade-interface> 3<glade-interface>
5 4
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index dcc3fcc0cc9a..e9d8e791bf0d 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -63,11 +63,11 @@ next:
63 63
64struct file_line { 64struct file_line {
65 struct file_line *next; 65 struct file_line *next;
66 char* file; 66 const char *file;
67 int lineno; 67 int lineno;
68}; 68};
69 69
70static struct file_line *file_line__new(char *file, int lineno) 70static struct file_line *file_line__new(const char *file, int lineno)
71{ 71{
72 struct file_line *self = malloc(sizeof(*self)); 72 struct file_line *self = malloc(sizeof(*self));
73 73
@@ -90,7 +90,8 @@ struct message {
90 90
91static struct message *message__list; 91static struct message *message__list;
92 92
93static struct message *message__new(const char *msg, char *option, char *file, int lineno) 93static struct message *message__new(const char *msg, char *option,
94 const char *file, int lineno)
94{ 95{
95 struct message *self = malloc(sizeof(*self)); 96 struct message *self = malloc(sizeof(*self));
96 97
@@ -130,7 +131,8 @@ static struct message *mesage__find(const char *msg)
130 return m; 131 return m;
131} 132}
132 133
133static int message__add_file_line(struct message *self, char *file, int lineno) 134static int message__add_file_line(struct message *self, const char *file,
135 int lineno)
134{ 136{
135 int rc = -1; 137 int rc = -1;
136 struct file_line *fl = file_line__new(file, lineno); 138 struct file_line *fl = file_line__new(file, lineno);
@@ -145,7 +147,8 @@ out:
145 return rc; 147 return rc;
146} 148}
147 149
148static int message__add(const char *msg, char *option, char *file, int lineno) 150static int message__add(const char *msg, char *option, const char *file,
151 int lineno)
149{ 152{
150 int rc = 0; 153 int rc = 0;
151 char bf[16384]; 154 char bf[16384];
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index fdc7113b08d1..d9182916f724 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -2363,37 +2363,45 @@ void zconf_initscan(const char *name)
2363 2363
2364 current_file = file_lookup(name); 2364 current_file = file_lookup(name);
2365 current_file->lineno = 1; 2365 current_file->lineno = 1;
2366 current_file->flags = FILE_BUSY;
2367} 2366}
2368 2367
2369void zconf_nextfile(const char *name) 2368void zconf_nextfile(const char *name)
2370{ 2369{
2370 struct file *iter;
2371 struct file *file = file_lookup(name); 2371 struct file *file = file_lookup(name);
2372 struct buffer *buf = malloc(sizeof(*buf)); 2372 struct buffer *buf = malloc(sizeof(*buf));
2373 memset(buf, 0, sizeof(*buf)); 2373 memset(buf, 0, sizeof(*buf));
2374 2374
2375 current_buf->state = YY_CURRENT_BUFFER; 2375 current_buf->state = YY_CURRENT_BUFFER;
2376 zconfin = zconf_fopen(name); 2376 zconfin = zconf_fopen(file->name);
2377 if (!zconfin) { 2377 if (!zconfin) {
2378 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); 2378 printf("%s:%d: can't open file \"%s\"\n",
2379 zconf_curname(), zconf_lineno(), file->name);
2379 exit(1); 2380 exit(1);
2380 } 2381 }
2381 zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); 2382 zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
2382 buf->parent = current_buf; 2383 buf->parent = current_buf;
2383 current_buf = buf; 2384 current_buf = buf;
2384 2385
2385 if (file->flags & FILE_BUSY) { 2386 for (iter = current_file->parent; iter; iter = iter->parent ) {
2386 printf("%s:%d: do not source '%s' from itself\n", 2387 if (!strcmp(current_file->name,iter->name) ) {
2387 zconf_curname(), zconf_lineno(), name); 2388 printf("%s:%d: recursive inclusion detected. "
2388 exit(1); 2389 "Inclusion path:\n current file : '%s'\n",
2389 } 2390 zconf_curname(), zconf_lineno(),
2390 if (file->flags & FILE_SCANNED) { 2391 zconf_curname());
2391 printf("%s:%d: file '%s' is already sourced from '%s'\n", 2392 iter = current_file->parent;
2392 zconf_curname(), zconf_lineno(), name, 2393 while (iter && \
2393 file->parent->name); 2394 strcmp(iter->name,current_file->name)) {
2394 exit(1); 2395 printf(" included from: '%s:%d'\n",
2396 iter->name, iter->lineno-1);
2397 iter = iter->parent;
2398 }
2399 if (iter)
2400 printf(" included from: '%s:%d'\n",
2401 iter->name, iter->lineno+1);
2402 exit(1);
2403 }
2395 } 2404 }
2396 file->flags |= FILE_BUSY;
2397 file->lineno = 1; 2405 file->lineno = 1;
2398 file->parent = current_file; 2406 file->parent = current_file;
2399 current_file = file; 2407 current_file = file;
@@ -2403,8 +2411,6 @@ static void zconf_endfile(void)
2403{ 2411{
2404 struct buffer *parent; 2412 struct buffer *parent;
2405 2413
2406 current_file->flags |= FILE_SCANNED;
2407 current_file->flags &= ~FILE_BUSY;
2408 current_file = current_file->parent; 2414 current_file = current_file->parent;
2409 2415
2410 parent = current_buf->parent; 2416 parent = current_buf->parent;
@@ -2422,7 +2428,7 @@ int zconf_lineno(void)
2422 return current_pos.lineno; 2428 return current_pos.lineno;
2423} 2429}
2424 2430
2425char *zconf_curname(void) 2431const char *zconf_curname(void)
2426{ 2432{
2427 return current_pos.file ? current_pos.file->name : "<none>"; 2433 return current_pos.file ? current_pos.file->name : "<none>";
2428} 2434}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index bdf71bd31412..febf0c94d558 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -14,6 +14,7 @@
14static inline const char *gettext(const char *txt) { return txt; } 14static inline const char *gettext(const char *txt) { return txt; }
15static inline void textdomain(const char *domainname) {} 15static inline void textdomain(const char *domainname) {}
16static inline void bindtextdomain(const char *name, const char *dir) {} 16static inline void bindtextdomain(const char *name, const char *dir) {}
17static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
17#endif 18#endif
18 19
19#ifdef __cplusplus 20#ifdef __cplusplus
@@ -31,12 +32,18 @@ extern "C" {
31 32
32#define SRCTREE "srctree" 33#define SRCTREE "srctree"
33 34
35#ifndef PACKAGE
34#define PACKAGE "linux" 36#define PACKAGE "linux"
37#endif
38
35#define LOCALEDIR "/usr/share/locale" 39#define LOCALEDIR "/usr/share/locale"
36 40
37#define _(text) gettext(text) 41#define _(text) gettext(text)
38#define N_(text) (text) 42#define N_(text) (text)
39 43
44#ifndef CONFIG_
45#define CONFIG_ "CONFIG_"
46#endif
40 47
41#define TF_COMMAND 0x0001 48#define TF_COMMAND 0x0001
42#define TF_PARAM 0x0002 49#define TF_PARAM 0x0002
@@ -61,16 +68,18 @@ struct kconf_id {
61 enum symbol_type stype; 68 enum symbol_type stype;
62}; 69};
63 70
71#ifdef YYDEBUG
72extern int zconfdebug;
73#endif
74
64int zconfparse(void); 75int zconfparse(void);
65void zconfdump(FILE *out); 76void zconfdump(FILE *out);
66
67extern int zconfdebug;
68void zconf_starthelp(void); 77void zconf_starthelp(void);
69FILE *zconf_fopen(const char *name); 78FILE *zconf_fopen(const char *name);
70void zconf_initscan(const char *name); 79void zconf_initscan(const char *name);
71void zconf_nextfile(const char *name); 80void zconf_nextfile(const char *name);
72int zconf_lineno(void); 81int zconf_lineno(void);
73char *zconf_curname(void); 82const char *zconf_curname(void);
74 83
75/* conf.c */ 84/* conf.c */
76void xfgets(char *str, int size, FILE *in); 85void xfgets(char *str, int size, FILE *in);
@@ -101,6 +110,7 @@ void menu_end_menu(void);
101void menu_add_entry(struct symbol *sym); 110void menu_add_entry(struct symbol *sym);
102void menu_end_entry(void); 111void menu_end_entry(void);
103void menu_add_dep(struct expr *dep); 112void menu_add_dep(struct expr *dep);
113void menu_add_visibility(struct expr *dep);
104struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 114struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
105struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 115struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
106void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 116void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 9a948c9ce44e..17342fef38b9 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -1,3 +1,4 @@
1#include <stdarg.h>
1 2
2/* confdata.c */ 3/* confdata.c */
3P(conf_parse,void,(const char *name)); 4P(conf_parse,void,(const char *name));
@@ -8,6 +9,7 @@ P(conf_write,int,(const char *name));
8P(conf_write_autoconf,int,(void)); 9P(conf_write_autoconf,int,(void));
9P(conf_get_changed,bool,(void)); 10P(conf_get_changed,bool,(void));
10P(conf_set_changed_callback, void,(void (*fn)(void))); 11P(conf_set_changed_callback, void,(void (*fn)(void)));
12P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
11 13
12/* menu.c */ 14/* menu.c */
13P(rootmenu,struct menu,); 15P(rootmenu,struct menu,);
@@ -28,6 +30,7 @@ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
28 30
29P(sym_lookup,struct symbol *,(const char *name, int flags)); 31P(sym_lookup,struct symbol *,(const char *name, int flags));
30P(sym_find,struct symbol *,(const char *name)); 32P(sym_find,struct symbol *,(const char *name));
33P(sym_expand_string_value,const char *,(const char *in));
31P(sym_re_search,struct symbol **,(const char *pattern)); 34P(sym_re_search,struct symbol **,(const char *pattern));
32P(sym_type_name,const char *,(enum symbol_type type)); 35P(sym_type_name,const char *,(enum symbol_type type));
33P(sym_calc_value,void,(struct symbol *sym)); 36P(sym_calc_value,void,(struct symbol *sym));
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index fcef0f59d553..82cc3a85e7f8 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -23,6 +23,8 @@ ccflags()
23 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' 23 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
24 elif [ -f /usr/include/ncurses/curses.h ]; then 24 elif [ -f /usr/include/ncurses/curses.h ]; then
25 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"' 25 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
26 elif [ -f /usr/include/ncursesw/curses.h ]; then
27 echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
26 elif [ -f /usr/include/ncurses.h ]; then 28 elif [ -f /usr/include/ncurses.h ]; then
27 echo '-DCURSES_LOC="<ncurses.h>"' 29 echo '-DCURSES_LOC="<ncurses.h>"'
28 else 30 else
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d2f6e056c058..d433c7a24745 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -25,11 +25,9 @@
25static const char mconf_readme[] = N_( 25static const char mconf_readme[] = N_(
26"Overview\n" 26"Overview\n"
27"--------\n" 27"--------\n"
28"Some kernel features may be built directly into the kernel.\n" 28"This interface let you select features and parameters for the build.\n"
29"Some may be made into loadable runtime modules. Some features\n" 29"Features can either be built-in, modularized, or ignored. Parameters\n"
30"may be completely removed altogether. There are also certain\n" 30"must be entered in as decimal or hexadecimal numbers or text.\n"
31"kernel parameters which are not really features, but must be\n"
32"entered in as decimal or hexadecimal numbers or possibly text.\n"
33"\n" 31"\n"
34"Menu items beginning with following braces represent features that\n" 32"Menu items beginning with following braces represent features that\n"
35" [ ] can be built in or removed\n" 33" [ ] can be built in or removed\n"
@@ -117,7 +115,7 @@ static const char mconf_readme[] = N_(
117"-----------------------------\n" 115"-----------------------------\n"
118"Menuconfig supports the use of alternate configuration files for\n" 116"Menuconfig supports the use of alternate configuration files for\n"
119"those who, for various reasons, find it necessary to switch\n" 117"those who, for various reasons, find it necessary to switch\n"
120"between different kernel configurations.\n" 118"between different configurations.\n"
121"\n" 119"\n"
122"At the end of the main menu you will find two options. One is\n" 120"At the end of the main menu you will find two options. One is\n"
123"for saving the current configuration to a file of your choosing.\n" 121"for saving the current configuration to a file of your choosing.\n"
@@ -150,9 +148,9 @@ static const char mconf_readme[] = N_(
150"\n" 148"\n"
151"Optional personality available\n" 149"Optional personality available\n"
152"------------------------------\n" 150"------------------------------\n"
153"If you prefer to have all of the kernel options listed in a single\n" 151"If you prefer to have all of the options listed in a single menu, rather\n"
154"menu, rather than the default multimenu hierarchy, run the menuconfig\n" 152"than the default multimenu hierarchy, run the menuconfig with\n"
155"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" 153"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
156"\n" 154"\n"
157"make MENUCONFIG_MODE=single_menu menuconfig\n" 155"make MENUCONFIG_MODE=single_menu menuconfig\n"
158"\n" 156"\n"
@@ -207,12 +205,12 @@ load_config_text[] = N_(
207 "last retrieved. Leave blank to abort."), 205 "last retrieved. Leave blank to abort."),
208load_config_help[] = N_( 206load_config_help[] = N_(
209 "\n" 207 "\n"
210 "For various reasons, one may wish to keep several different kernel\n" 208 "For various reasons, one may wish to keep several different\n"
211 "configurations available on a single machine.\n" 209 "configurations available on a single machine.\n"
212 "\n" 210 "\n"
213 "If you have saved a previous configuration in a file other than the\n" 211 "If you have saved a previous configuration in a file other than the\n"
214 "kernel's default, entering the name of the file here will allow you\n" 212 "default one, entering its name here will allow you to modify that\n"
215 "to modify that configuration.\n" 213 "configuration.\n"
216 "\n" 214 "\n"
217 "If you are uncertain, then you have probably never used alternate\n" 215 "If you are uncertain, then you have probably never used alternate\n"
218 "configuration files. You should therefore leave this blank to abort.\n"), 216 "configuration files. You should therefore leave this blank to abort.\n"),
@@ -221,8 +219,8 @@ save_config_text[] = N_(
221 "as an alternate. Leave blank to abort."), 219 "as an alternate. Leave blank to abort."),
222save_config_help[] = N_( 220save_config_help[] = N_(
223 "\n" 221 "\n"
224 "For various reasons, one may wish to keep different kernel\n" 222 "For various reasons, one may wish to keep different configurations\n"
225 "configurations available on a single machine.\n" 223 "available on a single machine.\n"
226 "\n" 224 "\n"
227 "Entering a file name here will allow you to later retrieve, modify\n" 225 "Entering a file name here will allow you to later retrieve, modify\n"
228 "and use the current configuration as an alternate to whatever\n" 226 "and use the current configuration as an alternate to whatever\n"
@@ -232,7 +230,7 @@ save_config_help[] = N_(
232 "leave this blank.\n"), 230 "leave this blank.\n"),
233search_help[] = N_( 231search_help[] = N_(
234 "\n" 232 "\n"
235 "Search for CONFIG_ symbols and display their relations.\n" 233 "Search for symbols and display their relations.\n"
236 "Regular expressions are allowed.\n" 234 "Regular expressions are allowed.\n"
237 "Example: search for \"^FOO\"\n" 235 "Example: search for \"^FOO\"\n"
238 "Result:\n" 236 "Result:\n"
@@ -249,7 +247,7 @@ search_help[] = N_(
249 "Selected by: BAR\n" 247 "Selected by: BAR\n"
250 "-----------------------------------------------------------------\n" 248 "-----------------------------------------------------------------\n"
251 "o The line 'Prompt:' shows the text used in the menu structure for\n" 249 "o The line 'Prompt:' shows the text used in the menu structure for\n"
252 " this CONFIG_ symbol\n" 250 " this symbol\n"
253 "o The 'Defined at' line tell at what file / line number the symbol\n" 251 "o The 'Defined at' line tell at what file / line number the symbol\n"
254 " is defined\n" 252 " is defined\n"
255 "o The 'Depends on:' line tell what symbols needs to be defined for\n" 253 "o The 'Depends on:' line tell what symbols needs to be defined for\n"
@@ -265,9 +263,9 @@ search_help[] = N_(
265 "Only relevant lines are shown.\n" 263 "Only relevant lines are shown.\n"
266 "\n\n" 264 "\n\n"
267 "Search examples:\n" 265 "Search examples:\n"
268 "Examples: USB => find all CONFIG_ symbols containing USB\n" 266 "Examples: USB => find all symbols containing USB\n"
269 " ^USB => find all CONFIG_ symbols starting with USB\n" 267 " ^USB => find all symbols starting with USB\n"
270 " USB$ => find all CONFIG_ symbols ending with USB\n" 268 " USB$ => find all symbols ending with USB\n"
271 "\n"); 269 "\n");
272 270
273static int indent; 271static int indent;
@@ -290,13 +288,9 @@ static void set_config_filename(const char *config_filename)
290{ 288{
291 static char menu_backtitle[PATH_MAX+128]; 289 static char menu_backtitle[PATH_MAX+128];
292 int size; 290 int size;
293 struct symbol *sym;
294 291
295 sym = sym_lookup("KERNELVERSION", 0);
296 sym_calc_value(sym);
297 size = snprintf(menu_backtitle, sizeof(menu_backtitle), 292 size = snprintf(menu_backtitle, sizeof(menu_backtitle),
298 _("%s - Linux Kernel v%s Configuration"), 293 "%s - %s", config_filename, rootmenu.prompt->text);
299 config_filename, sym_get_string_value(sym));
300 if (size >= sizeof(menu_backtitle)) 294 if (size >= sizeof(menu_backtitle))
301 menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; 295 menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
302 set_dialog_backtitle(menu_backtitle); 296 set_dialog_backtitle(menu_backtitle);
@@ -316,8 +310,8 @@ static void search_conf(void)
316again: 310again:
317 dialog_clear(); 311 dialog_clear();
318 dres = dialog_inputbox(_("Search Configuration Parameter"), 312 dres = dialog_inputbox(_("Search Configuration Parameter"),
319 _("Enter CONFIG_ (sub)string to search for " 313 _("Enter " CONFIG_ " (sub)string to search for "
320 "(with or without \"CONFIG\")"), 314 "(with or without \"" CONFIG_ "\")"),
321 10, 75, ""); 315 10, 75, "");
322 switch (dres) { 316 switch (dres) {
323 case 0: 317 case 0:
@@ -329,10 +323,10 @@ again:
329 return; 323 return;
330 } 324 }
331 325
332 /* strip CONFIG_ if necessary */ 326 /* strip the prefix if necessary */
333 dialog_input = dialog_input_result; 327 dialog_input = dialog_input_result;
334 if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) 328 if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
335 dialog_input += 7; 329 dialog_input += strlen(CONFIG_);
336 330
337 sym_arr = sym_re_search(dialog_input); 331 sym_arr = sym_re_search(dialog_input);
338 res = get_relations_str(sym_arr); 332 res = get_relations_str(sym_arr);
@@ -834,7 +828,7 @@ int main(int ac, char **av)
834 if (conf_get_changed()) 828 if (conf_get_changed())
835 res = dialog_yesno(NULL, 829 res = dialog_yesno(NULL,
836 _("Do you wish to save your " 830 _("Do you wish to save your "
837 "new kernel configuration?\n" 831 "new configuration?\n"
838 "<ESC><ESC> to continue."), 832 "<ESC><ESC> to continue."),
839 6, 60); 833 6, 60);
840 else 834 else
@@ -846,20 +840,20 @@ int main(int ac, char **av)
846 case 0: 840 case 0:
847 if (conf_write(filename)) { 841 if (conf_write(filename)) {
848 fprintf(stderr, _("\n\n" 842 fprintf(stderr, _("\n\n"
849 "Error during writing of the kernel configuration.\n" 843 "Error while writing of the configuration.\n"
850 "Your kernel configuration changes were NOT saved." 844 "Your configuration changes were NOT saved."
851 "\n\n")); 845 "\n\n"));
852 return 1; 846 return 1;
853 } 847 }
854 case -1: 848 case -1:
855 printf(_("\n\n" 849 printf(_("\n\n"
856 "*** End of Linux kernel configuration.\n" 850 "*** End of the configuration.\n"
857 "*** Execute 'make' to build the kernel or try 'make help'." 851 "*** Execute 'make' to start the build or try 'make help'."
858 "\n\n")); 852 "\n\n"));
859 break; 853 break;
860 default: 854 default:
861 fprintf(stderr, _("\n\n" 855 fprintf(stderr, _("\n\n"
862 "Your kernel configuration changes were NOT saved." 856 "Your configuration changes were NOT saved."
863 "\n\n")); 857 "\n\n"));
864 } 858 }
865 859
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index edda8b49619d..5fdf10dc1d8a 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -10,7 +10,7 @@
10#include "lkc.h" 10#include "lkc.h"
11 11
12static const char nohelp_text[] = N_( 12static const char nohelp_text[] = N_(
13 "There is no help available for this kernel option.\n"); 13 "There is no help available for this option.\n");
14 14
15struct menu rootmenu; 15struct menu rootmenu;
16static struct menu **last_entry_ptr; 16static struct menu **last_entry_ptr;
@@ -138,8 +138,22 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
138 while (isspace(*prompt)) 138 while (isspace(*prompt))
139 prompt++; 139 prompt++;
140 } 140 }
141 if (current_entry->prompt) 141 if (current_entry->prompt && current_entry != &rootmenu)
142 prop_warn(prop, "prompt redefined"); 142 prop_warn(prop, "prompt redefined");
143
144 /* Apply all upper menus' visibilities to actual prompts. */
145 if(type == P_PROMPT) {
146 struct menu *menu = current_entry;
147
148 while ((menu = menu->parent) != NULL) {
149 if (!menu->visibility)
150 continue;
151 prop->visible.expr
152 = expr_alloc_and(prop->visible.expr,
153 menu->visibility);
154 }
155 }
156
143 current_entry->prompt = prop; 157 current_entry->prompt = prop;
144 } 158 }
145 prop->text = prompt; 159 prop->text = prompt;
@@ -152,6 +166,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
152 return menu_add_prop(type, prompt, NULL, dep); 166 return menu_add_prop(type, prompt, NULL, dep);
153} 167}
154 168
169void menu_add_visibility(struct expr *expr)
170{
171 current_entry->visibility = expr_alloc_and(current_entry->visibility,
172 expr);
173}
174
155void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) 175void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
156{ 176{
157 menu_add_prop(type, NULL, expr, dep); 177 menu_add_prop(type, NULL, expr, dep);
@@ -183,7 +203,7 @@ void menu_add_option(int token, char *arg)
183 } 203 }
184} 204}
185 205
186static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) 206static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
187{ 207{
188 return sym2->type == S_INT || sym2->type == S_HEX || 208 return sym2->type == S_INT || sym2->type == S_HEX ||
189 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); 209 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
@@ -201,6 +221,15 @@ static void sym_check_prop(struct symbol *sym)
201 prop_warn(prop, 221 prop_warn(prop,
202 "default for config symbol '%s'" 222 "default for config symbol '%s'"
203 " must be a single symbol", sym->name); 223 " must be a single symbol", sym->name);
224 if (prop->expr->type != E_SYMBOL)
225 break;
226 sym2 = prop_get_symbol(prop);
227 if (sym->type == S_HEX || sym->type == S_INT) {
228 if (!menu_validate_number(sym, sym2))
229 prop_warn(prop,
230 "'%s': number is invalid",
231 sym->name);
232 }
204 break; 233 break;
205 case P_SELECT: 234 case P_SELECT:
206 sym2 = prop_get_symbol(prop); 235 sym2 = prop_get_symbol(prop);
@@ -220,8 +249,8 @@ static void sym_check_prop(struct symbol *sym)
220 if (sym->type != S_INT && sym->type != S_HEX) 249 if (sym->type != S_INT && sym->type != S_HEX)
221 prop_warn(prop, "range is only allowed " 250 prop_warn(prop, "range is only allowed "
222 "for int or hex symbols"); 251 "for int or hex symbols");
223 if (!menu_range_valid_sym(sym, prop->expr->left.sym) || 252 if (!menu_validate_number(sym, prop->expr->left.sym) ||
224 !menu_range_valid_sym(sym, prop->expr->right.sym)) 253 !menu_validate_number(sym, prop->expr->right.sym))
225 prop_warn(prop, "range is invalid"); 254 prop_warn(prop, "range is invalid");
226 break; 255 break;
227 default: 256 default:
@@ -410,6 +439,11 @@ bool menu_is_visible(struct menu *menu)
410 if (!menu->prompt) 439 if (!menu->prompt)
411 return false; 440 return false;
412 441
442 if (menu->visibility) {
443 if (expr_calc_value(menu->visibility) == no)
444 return no;
445 }
446
413 sym = menu->sym; 447 sym = menu->sym;
414 if (sym) { 448 if (sym) {
415 sym_calc_value(sym); 449 sym_calc_value(sym);
@@ -563,7 +597,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help)
563 597
564 if (menu_has_help(menu)) { 598 if (menu_has_help(menu)) {
565 if (sym->name) { 599 if (sym->name) {
566 str_printf(help, "CONFIG_%s:\n\n", sym->name); 600 str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
567 str_append(help, _(menu_get_help(menu))); 601 str_append(help, _(menu_get_help(menu)));
568 str_append(help, "\n"); 602 str_append(help, "\n");
569 } 603 }
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 2ba71bcd38e6..488dd7410787 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -5,25 +5,26 @@
5 * Derived from menuconfig. 5 * Derived from menuconfig.
6 * 6 *
7 */ 7 */
8#define _GNU_SOURCE
9#include <string.h>
8#define LKC_DIRECT_LINK 10#define LKC_DIRECT_LINK
9#include "lkc.h" 11#include "lkc.h"
10#include "nconf.h" 12#include "nconf.h"
13#include <ctype.h>
11 14
12static const char nconf_readme[] = N_( 15static const char nconf_readme[] = N_(
13"Overview\n" 16"Overview\n"
14"--------\n" 17"--------\n"
15"Some kernel features may be built directly into the kernel.\n" 18"This interface let you select features and parameters for the build.\n"
16"Some may be made into loadable runtime modules. Some features\n" 19"Features can either be built-in, modularized, or ignored. Parameters\n"
17"may be completely removed altogether. There are also certain\n" 20"must be entered in as decimal or hexadecimal numbers or text.\n"
18"kernel parameters which are not really features, but must be\n"
19"entered in as decimal or hexadecimal numbers or possibly text.\n"
20"\n" 21"\n"
21"Menu items beginning with following braces represent features that\n" 22"Menu items beginning with following braces represent features that\n"
22" [ ] can be built in or removed\n" 23" [ ] can be built in or removed\n"
23" < > can be built in, modularized or removed\n" 24" < > can be built in, modularized or removed\n"
24" { } can be built in or modularized (selected by other feature)\n" 25" { } can be built in or modularized (selected by other feature)\n"
25" - - are selected by other feature,\n" 26" - - are selected by other feature,\n"
26" XXX cannot be selected. use Symbol Info to find out why,\n" 27" XXX cannot be selected. Use Symbol Info to find out why,\n"
27"while *, M or whitespace inside braces means to build in, build as\n" 28"while *, M or whitespace inside braces means to build in, build as\n"
28"a module or to exclude the feature respectively.\n" 29"a module or to exclude the feature respectively.\n"
29"\n" 30"\n"
@@ -41,9 +42,13 @@ static const char nconf_readme[] = N_(
41" pressing <Enter> of <right-arrow>. Use <Esc> or <left-arrow> to go back.\n" 42" pressing <Enter> of <right-arrow>. Use <Esc> or <left-arrow> to go back.\n"
42" Submenus are designated by \"--->\".\n" 43" Submenus are designated by \"--->\".\n"
43"\n" 44"\n"
44" Shortcut: Press the option's highlighted letter (hotkey).\n" 45" Searching: pressing '/' triggers interactive search mode.\n"
45" Pressing a hotkey more than once will sequence\n" 46" nconfig performs a case insensitive search for the string\n"
46" through all visible items which use that hotkey.\n" 47" in the menu prompts (no regex support).\n"
48" Pressing the up/down keys highlights the previous/next\n"
49" matching item. Backspace removes one character from the\n"
50" match string. Pressing either '/' again or ESC exits\n"
51" search mode. All other keys behave normally.\n"
47"\n" 52"\n"
48" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" 53" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
49" unseen options into view.\n" 54" unseen options into view.\n"
@@ -88,7 +93,7 @@ static const char nconf_readme[] = N_(
88"-----------------------------\n" 93"-----------------------------\n"
89"nconfig supports the use of alternate configuration files for\n" 94"nconfig supports the use of alternate configuration files for\n"
90"those who, for various reasons, find it necessary to switch\n" 95"those who, for various reasons, find it necessary to switch\n"
91"between different kernel configurations.\n" 96"between different configurations.\n"
92"\n" 97"\n"
93"At the end of the main menu you will find two options. One is\n" 98"At the end of the main menu you will find two options. One is\n"
94"for saving the current configuration to a file of your choosing.\n" 99"for saving the current configuration to a file of your choosing.\n"
@@ -121,9 +126,9 @@ static const char nconf_readme[] = N_(
121"\n" 126"\n"
122"Optional personality available\n" 127"Optional personality available\n"
123"------------------------------\n" 128"------------------------------\n"
124"If you prefer to have all of the kernel options listed in a single\n" 129"If you prefer to have all of the options listed in a single menu, rather\n"
125"menu, rather than the default multimenu hierarchy, run the nconfig\n" 130"than the default multimenu hierarchy, run the nconfig with NCONFIG_MODE\n"
126"with NCONFIG_MODE environment variable set to single_menu. Example:\n" 131"environment variable set to single_menu. Example:\n"
127"\n" 132"\n"
128"make NCONFIG_MODE=single_menu nconfig\n" 133"make NCONFIG_MODE=single_menu nconfig\n"
129"\n" 134"\n"
@@ -141,21 +146,21 @@ menu_no_f_instructions[] = N_(
141" <Enter> or <right-arrow> selects submenus --->.\n" 146" <Enter> or <right-arrow> selects submenus --->.\n"
142" Capital Letters are hotkeys.\n" 147" Capital Letters are hotkeys.\n"
143" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n" 148" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
144" Pressing SpaceBar toggles between the above options\n" 149" Pressing SpaceBar toggles between the above options.\n"
145" Press <Esc> or <left-arrow> to go back one menu, \n" 150" Press <Esc> or <left-arrow> to go back one menu,\n"
146" <?> or <h> for Help, </> for Search.\n" 151" <?> or <h> for Help, </> for Search.\n"
147" <1> is interchangable with <F1>, <2> with <F2>, etc.\n" 152" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
148" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 153" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
149" <Esc> always leaves the current window\n"), 154" <Esc> always leaves the current window.\n"),
150menu_instructions[] = N_( 155menu_instructions[] = N_(
151" Arrow keys navigate the menu.\n" 156" Arrow keys navigate the menu.\n"
152" <Enter> or <right-arrow> selects submenus --->.\n" 157" <Enter> or <right-arrow> selects submenus --->.\n"
153" Capital Letters are hotkeys.\n" 158" Capital Letters are hotkeys.\n"
154" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n" 159" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
155" Pressing SpaceBar toggles between the above options\n" 160" Pressing SpaceBar toggles between the above options\n"
156" Press <Esc>, <F3> or <left-arrow> to go back one menu, \n" 161" Press <Esc>, <F5> or <left-arrow> to go back one menu,\n"
157" <?>, <F1> or <h> for Help, </> for Search.\n" 162" <?>, <F1> or <h> for Help, </> for Search.\n"
158" <1> is interchangable with <F1>, <2> with <F2>, etc.\n" 163" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
159" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 164" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
160" <Esc> always leaves the current window\n"), 165" <Esc> always leaves the current window\n"),
161radiolist_instructions[] = N_( 166radiolist_instructions[] = N_(
@@ -178,19 +183,19 @@ setmod_text[] = N_(
178"has been configured as a module.\n" 183"has been configured as a module.\n"
179"As a result, this feature will be built as a module."), 184"As a result, this feature will be built as a module."),
180nohelp_text[] = N_( 185nohelp_text[] = N_(
181"There is no help available for this kernel option.\n"), 186"There is no help available for this option.\n"),
182load_config_text[] = N_( 187load_config_text[] = N_(
183"Enter the name of the configuration file you wish to load.\n" 188"Enter the name of the configuration file you wish to load.\n"
184"Accept the name shown to restore the configuration you\n" 189"Accept the name shown to restore the configuration you\n"
185"last retrieved. Leave blank to abort."), 190"last retrieved. Leave blank to abort."),
186load_config_help[] = N_( 191load_config_help[] = N_(
187"\n" 192"\n"
188"For various reasons, one may wish to keep several different kernel\n" 193"For various reasons, one may wish to keep several different\n"
189"configurations available on a single machine.\n" 194"configurations available on a single machine.\n"
190"\n" 195"\n"
191"If you have saved a previous configuration in a file other than the\n" 196"If you have saved a previous configuration in a file other than the\n"
192"kernel's default, entering the name of the file here will allow you\n" 197"default one, entering its name here will allow you to modify that\n"
193"to modify that configuration.\n" 198"configuration.\n"
194"\n" 199"\n"
195"If you are uncertain, then you have probably never used alternate\n" 200"If you are uncertain, then you have probably never used alternate\n"
196"configuration files. You should therefor leave this blank to abort.\n"), 201"configuration files. You should therefor leave this blank to abort.\n"),
@@ -199,8 +204,8 @@ save_config_text[] = N_(
199"as an alternate. Leave blank to abort."), 204"as an alternate. Leave blank to abort."),
200save_config_help[] = N_( 205save_config_help[] = N_(
201"\n" 206"\n"
202"For various reasons, one may wish to keep different kernel\n" 207"For various reasons, one may wish to keep different configurations\n"
203"configurations available on a single machine.\n" 208"available on a single machine.\n"
204"\n" 209"\n"
205"Entering a file name here will allow you to later retrieve, modify\n" 210"Entering a file name here will allow you to later retrieve, modify\n"
206"and use the current configuration as an alternate to whatever\n" 211"and use the current configuration as an alternate to whatever\n"
@@ -210,8 +215,8 @@ save_config_help[] = N_(
210"leave this blank.\n"), 215"leave this blank.\n"),
211search_help[] = N_( 216search_help[] = N_(
212"\n" 217"\n"
213"Search for CONFIG_ symbols and display their relations.\n" 218"Search for symbols and display their relations. Regular expressions\n"
214"Regular expressions are allowed.\n" 219"are allowed.\n"
215"Example: search for \"^FOO\"\n" 220"Example: search for \"^FOO\"\n"
216"Result:\n" 221"Result:\n"
217"-----------------------------------------------------------------\n" 222"-----------------------------------------------------------------\n"
@@ -227,7 +232,7 @@ search_help[] = N_(
227"Selected by: BAR\n" 232"Selected by: BAR\n"
228"-----------------------------------------------------------------\n" 233"-----------------------------------------------------------------\n"
229"o The line 'Prompt:' shows the text used in the menu structure for\n" 234"o The line 'Prompt:' shows the text used in the menu structure for\n"
230" this CONFIG_ symbol\n" 235" this symbol\n"
231"o The 'Defined at' line tell at what file / line number the symbol\n" 236"o The 'Defined at' line tell at what file / line number the symbol\n"
232" is defined\n" 237" is defined\n"
233"o The 'Depends on:' line tell what symbols needs to be defined for\n" 238"o The 'Depends on:' line tell what symbols needs to be defined for\n"
@@ -243,16 +248,15 @@ search_help[] = N_(
243"Only relevant lines are shown.\n" 248"Only relevant lines are shown.\n"
244"\n\n" 249"\n\n"
245"Search examples:\n" 250"Search examples:\n"
246"Examples: USB = > find all CONFIG_ symbols containing USB\n" 251"Examples: USB => find all symbols containing USB\n"
247" ^USB => find all CONFIG_ symbols starting with USB\n" 252" ^USB => find all symbols starting with USB\n"
248" USB$ => find all CONFIG_ symbols ending with USB\n" 253" USB$ => find all symbols ending with USB\n"
249"\n"); 254"\n");
250 255
251struct mitem { 256struct mitem {
252 char str[256]; 257 char str[256];
253 char tag; 258 char tag;
254 void *usrptr; 259 void *usrptr;
255 int is_hot;
256 int is_visible; 260 int is_visible;
257}; 261};
258 262
@@ -275,14 +279,6 @@ static int items_num;
275static int global_exit; 279static int global_exit;
276/* the currently selected button */ 280/* the currently selected button */
277const char *current_instructions = menu_instructions; 281const char *current_instructions = menu_instructions;
278/* this array is used to implement hot keys. it is updated in item_make and
279 * resetted in clean_items. It would be better to use a hash, but lets keep it
280 * simple... */
281#define MAX_SAME_KEY MAX_MENU_ITEMS
282struct {
283 int count;
284 int ptrs[MAX_MENU_ITEMS];
285} hotkeys[1<<(sizeof(char)*8)];
286 282
287static void conf(struct menu *menu); 283static void conf(struct menu *menu);
288static void conf_choice(struct menu *menu); 284static void conf_choice(struct menu *menu);
@@ -292,6 +288,7 @@ static void conf_save(void);
292static void show_help(struct menu *menu); 288static void show_help(struct menu *menu);
293static int do_exit(void); 289static int do_exit(void);
294static void setup_windows(void); 290static void setup_windows(void);
291static void search_conf(void);
295 292
296typedef void (*function_key_handler_t)(int *key, struct menu *menu); 293typedef void (*function_key_handler_t)(int *key, struct menu *menu);
297static void handle_f1(int *key, struct menu *current_item); 294static void handle_f1(int *key, struct menu *current_item);
@@ -302,6 +299,7 @@ static void handle_f5(int *key, struct menu *current_item);
302static void handle_f6(int *key, struct menu *current_item); 299static void handle_f6(int *key, struct menu *current_item);
303static void handle_f7(int *key, struct menu *current_item); 300static void handle_f7(int *key, struct menu *current_item);
304static void handle_f8(int *key, struct menu *current_item); 301static void handle_f8(int *key, struct menu *current_item);
302static void handle_f9(int *key, struct menu *current_item);
305 303
306struct function_keys { 304struct function_keys {
307 const char *key_str; 305 const char *key_str;
@@ -310,7 +308,7 @@ struct function_keys {
310 function_key_handler_t handler; 308 function_key_handler_t handler;
311}; 309};
312 310
313static const int function_keys_num = 8; 311static const int function_keys_num = 9;
314struct function_keys function_keys[] = { 312struct function_keys function_keys[] = {
315 { 313 {
316 .key_str = "F1", 314 .key_str = "F1",
@@ -320,13 +318,13 @@ struct function_keys function_keys[] = {
320 }, 318 },
321 { 319 {
322 .key_str = "F2", 320 .key_str = "F2",
323 .func = "Symbol Info", 321 .func = "Sym Info",
324 .key = F_SYMBOL, 322 .key = F_SYMBOL,
325 .handler = handle_f2, 323 .handler = handle_f2,
326 }, 324 },
327 { 325 {
328 .key_str = "F3", 326 .key_str = "F3",
329 .func = "Instructions", 327 .func = "Insts",
330 .key = F_INSTS, 328 .key = F_INSTS,
331 .handler = handle_f3, 329 .handler = handle_f3,
332 }, 330 },
@@ -356,9 +354,15 @@ struct function_keys function_keys[] = {
356 }, 354 },
357 { 355 {
358 .key_str = "F8", 356 .key_str = "F8",
357 .func = "Sym Search",
358 .key = F_SEARCH,
359 .handler = handle_f8,
360 },
361 {
362 .key_str = "F9",
359 .func = "Exit", 363 .func = "Exit",
360 .key = F_EXIT, 364 .key = F_EXIT,
361 .handler = handle_f8, 365 .handler = handle_f9,
362 }, 366 },
363}; 367};
364 368
@@ -369,18 +373,18 @@ static void print_function_line(void)
369 const int skip = 1; 373 const int skip = 1;
370 374
371 for (i = 0; i < function_keys_num; i++) { 375 for (i = 0; i < function_keys_num; i++) {
372 wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); 376 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
373 mvwprintw(main_window, LINES-3, offset, 377 mvwprintw(main_window, LINES-3, offset,
374 "%s", 378 "%s",
375 function_keys[i].key_str); 379 function_keys[i].key_str);
376 wattrset(main_window, attributes[FUNCTION_TEXT]); 380 (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
377 offset += strlen(function_keys[i].key_str); 381 offset += strlen(function_keys[i].key_str);
378 mvwprintw(main_window, LINES-3, 382 mvwprintw(main_window, LINES-3,
379 offset, "%s", 383 offset, "%s",
380 function_keys[i].func); 384 function_keys[i].func);
381 offset += strlen(function_keys[i].func) + skip; 385 offset += strlen(function_keys[i].func) + skip;
382 } 386 }
383 wattrset(main_window, attributes[NORMAL]); 387 (void) wattrset(main_window, attributes[NORMAL]);
384} 388}
385 389
386/* help */ 390/* help */
@@ -444,9 +448,16 @@ static void handle_f7(int *key, struct menu *current_item)
444 return; 448 return;
445} 449}
446 450
447/* exit */ 451/* search */
448static void handle_f8(int *key, struct menu *current_item) 452static void handle_f8(int *key, struct menu *current_item)
449{ 453{
454 search_conf();
455 return;
456}
457
458/* exit */
459static void handle_f9(int *key, struct menu *current_item)
460{
450 do_exit(); 461 do_exit();
451 return; 462 return;
452} 463}
@@ -479,110 +490,44 @@ static void clean_items(void)
479 free_item(curses_menu_items[i]); 490 free_item(curses_menu_items[i]);
480 bzero(curses_menu_items, sizeof(curses_menu_items)); 491 bzero(curses_menu_items, sizeof(curses_menu_items));
481 bzero(k_menu_items, sizeof(k_menu_items)); 492 bzero(k_menu_items, sizeof(k_menu_items));
482 bzero(hotkeys, sizeof(hotkeys));
483 items_num = 0; 493 items_num = 0;
484} 494}
485 495
486/* return the index of the next hot item, or -1 if no such item exists */ 496typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN,
487static int get_next_hot(int c) 497 FIND_NEXT_MATCH_DOWN, FIND_NEXT_MATCH_UP} match_f;
488{
489 static int hot_index;
490 static int hot_char;
491
492 if (c < 0 || c > 255 || hotkeys[c].count <= 0)
493 return -1;
494
495 if (hot_char == c) {
496 hot_index = (hot_index+1)%hotkeys[c].count;
497 return hotkeys[c].ptrs[hot_index];
498 } else {
499 hot_char = c;
500 hot_index = 0;
501 return hotkeys[c].ptrs[0];
502 }
503}
504
505/* can the char c be a hot key? no, if c is a common shortcut used elsewhere */
506static int canbhot(char c)
507{
508 c = tolower(c);
509 return isalnum(c) && c != 'y' && c != 'm' && c != 'h' &&
510 c != 'n' && c != '?';
511}
512
513/* check if str already contains a hot key. */
514static int is_hot(int index)
515{
516 return k_menu_items[index].is_hot;
517}
518 498
519/* find the first possible hot key, and mark it. 499/* return the index of the matched item, or -1 if no such item exists */
520 * index is the index of the item in the menu 500static int get_mext_match(const char *match_str, match_f flag)
521 * return 0 on success*/
522static int make_hot(char *dest, int len, const char *org, int index)
523{ 501{
524 int position = -1; 502 int match_start = item_index(current_item(curses_menu));
525 int i; 503 int index;
526 int tmp; 504
527 int c; 505 if (flag == FIND_NEXT_MATCH_DOWN)
528 int org_len = strlen(org); 506 ++match_start;
529 507 else if (flag == FIND_NEXT_MATCH_UP)
530 if (org == NULL || is_hot(index)) 508 --match_start;
531 return 1; 509
532 510 index = match_start;
533 /* make sure not to make hot keys out of markers. 511 index = (index + items_num) % items_num;
534 * find where to start looking for a hot key 512 while (true) {
535 */ 513 char *str = k_menu_items[index].str;
536 i = 0; 514 if (strcasestr(str, match_str) != 0)
537 /* skip white space */ 515 return index;
538 while (i < org_len && org[i] == ' ') 516 if (flag == FIND_NEXT_MATCH_UP ||
539 i++; 517 flag == MATCH_TINKER_PATTERN_UP)
540 if (i == org_len) 518 --index;
541 return -1; 519 else
542 /* if encountering '(' or '<' or '[', find the match and look from there 520 ++index;
543 **/ 521 index = (index + items_num) % items_num;
544 if (org[i] == '[' || org[i] == '<' || org[i] == '(') { 522 if (index == match_start)
545 i++; 523 return -1;
546 for (; i < org_len; i++)
547 if (org[i] == ']' || org[i] == '>' || org[i] == ')')
548 break;
549 }
550 if (i == org_len)
551 return -1;
552 for (; i < org_len; i++) {
553 if (canbhot(org[i]) && org[i-1] != '<' && org[i-1] != '(') {
554 position = i;
555 break;
556 }
557 } 524 }
558 if (position == -1)
559 return 1;
560
561 /* ok, char at org[position] should be a hot key to this item */
562 c = tolower(org[position]);
563 tmp = hotkeys[c].count;
564 hotkeys[c].ptrs[tmp] = index;
565 hotkeys[c].count++;
566 /*
567 snprintf(dest, len, "%.*s(%c)%s", position, org, org[position],
568 &org[position+1]);
569 */
570 /* make org[position] uppercase, and all leading letter small case */
571 strncpy(dest, org, len);
572 for (i = 0; i < position; i++)
573 dest[i] = tolower(dest[i]);
574 dest[position] = toupper(dest[position]);
575 k_menu_items[index].is_hot = 1;
576 return 0;
577} 525}
578 526
579/* Make a new item. Add a hotkey mark in the first possible letter. 527/* Make a new item. */
580 * As ncurses does not allow any attributes inside menue item, we mark the
581 * hot key as the first capitalized letter in the string */
582static void item_make(struct menu *menu, char tag, const char *fmt, ...) 528static void item_make(struct menu *menu, char tag, const char *fmt, ...)
583{ 529{
584 va_list ap; 530 va_list ap;
585 char tmp_str[256];
586 531
587 if (items_num > MAX_MENU_ITEMS-1) 532 if (items_num > MAX_MENU_ITEMS-1)
588 return; 533 return;
@@ -597,16 +542,13 @@ static void item_make(struct menu *menu, char tag, const char *fmt, ...)
597 k_menu_items[items_num].is_visible = 1; 542 k_menu_items[items_num].is_visible = 1;
598 543
599 va_start(ap, fmt); 544 va_start(ap, fmt);
600 vsnprintf(tmp_str, sizeof(tmp_str), fmt, ap); 545 vsnprintf(k_menu_items[items_num].str,
601 if (!k_menu_items[items_num].is_visible) 546 sizeof(k_menu_items[items_num].str),
602 memcpy(tmp_str, "XXX", 3); 547 fmt, ap);
603 va_end(ap); 548 va_end(ap);
604 if (make_hot( 549
605 k_menu_items[items_num].str, 550 if (!k_menu_items[items_num].is_visible)
606 sizeof(k_menu_items[items_num].str), tmp_str, items_num) != 0) 551 memcpy(k_menu_items[items_num].str, "XXX", 3);
607 strncpy(k_menu_items[items_num].str,
608 tmp_str,
609 sizeof(k_menu_items[items_num].str));
610 552
611 curses_menu_items[items_num] = new_item( 553 curses_menu_items[items_num] = new_item(
612 k_menu_items[items_num].str, 554 k_menu_items[items_num].str,
@@ -638,11 +580,9 @@ static void item_add_str(const char *fmt, ...)
638 va_end(ap); 580 va_end(ap);
639 snprintf(tmp_str, sizeof(tmp_str), "%s%s", 581 snprintf(tmp_str, sizeof(tmp_str), "%s%s",
640 k_menu_items[index].str, new_str); 582 k_menu_items[index].str, new_str);
641 if (make_hot(k_menu_items[index].str, 583 strncpy(k_menu_items[index].str,
642 sizeof(k_menu_items[index].str), tmp_str, index) != 0) 584 tmp_str,
643 strncpy(k_menu_items[index].str, 585 sizeof(k_menu_items[index].str));
644 tmp_str,
645 sizeof(k_menu_items[index].str));
646 586
647 free_item(curses_menu_items[index]); 587 free_item(curses_menu_items[index]);
648 curses_menu_items[index] = new_item( 588 curses_menu_items[index] = new_item(
@@ -693,13 +633,9 @@ static char menu_backtitle[PATH_MAX+128];
693static const char *set_config_filename(const char *config_filename) 633static const char *set_config_filename(const char *config_filename)
694{ 634{
695 int size; 635 int size;
696 struct symbol *sym;
697 636
698 sym = sym_lookup("KERNELVERSION", 0);
699 sym_calc_value(sym);
700 size = snprintf(menu_backtitle, sizeof(menu_backtitle), 637 size = snprintf(menu_backtitle, sizeof(menu_backtitle),
701 _("%s - Linux Kernel v%s Configuration"), 638 "%s - %s", config_filename, rootmenu.prompt->text);
702 config_filename, sym_get_string_value(sym));
703 if (size >= sizeof(menu_backtitle)) 639 if (size >= sizeof(menu_backtitle))
704 menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; 640 menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
705 641
@@ -709,25 +645,6 @@ static const char *set_config_filename(const char *config_filename)
709 return menu_backtitle; 645 return menu_backtitle;
710} 646}
711 647
712/* command = 0 is supress, 1 is restore */
713static void supress_stdout(int command)
714{
715 static FILE *org_stdout;
716 static FILE *org_stderr;
717
718 if (command == 0) {
719 org_stdout = stdout;
720 org_stderr = stderr;
721 stdout = fopen("/dev/null", "a");
722 stderr = fopen("/dev/null", "a");
723 } else {
724 fclose(stdout);
725 fclose(stderr);
726 stdout = org_stdout;
727 stderr = org_stderr;
728 }
729}
730
731/* return = 0 means we are successful. 648/* return = 0 means we are successful.
732 * -1 means go on doing what you were doing 649 * -1 means go on doing what you were doing
733 */ 650 */
@@ -739,8 +656,7 @@ static int do_exit(void)
739 return 0; 656 return 0;
740 } 657 }
741 res = btn_dialog(main_window, 658 res = btn_dialog(main_window,
742 _("Do you wish to save your " 659 _("Do you wish to save your new configuration?\n"
743 "new kernel configuration?\n"
744 "<ESC> to cancel and resume nconfig."), 660 "<ESC> to cancel and resume nconfig."),
745 2, 661 2,
746 " <save> ", 662 " <save> ",
@@ -753,36 +669,19 @@ static int do_exit(void)
753 /* if we got here, the user really wants to exit */ 669 /* if we got here, the user really wants to exit */
754 switch (res) { 670 switch (res) {
755 case 0: 671 case 0:
756 supress_stdout(0);
757 res = conf_write(filename); 672 res = conf_write(filename);
758 supress_stdout(1);
759 if (res) 673 if (res)
760 btn_dialog( 674 btn_dialog(
761 main_window, 675 main_window,
762 _("Error during writing of the kernel " 676 _("Error during writing of configuration.\n"
763 "configuration.\n" 677 "Your configuration changes were NOT saved."),
764 "Your kernel configuration "
765 "changes were NOT saved."),
766 1, 678 1,
767 "<OK>"); 679 "<OK>");
768 else {
769 char buf[1024];
770 snprintf(buf, 1024,
771 _("Configuration written to %s\n"
772 "End of Linux kernel configuration.\n"
773 "Execute 'make' to build the kernel or try"
774 " 'make help'."), filename);
775 btn_dialog(
776 main_window,
777 buf,
778 1,
779 "<OK>");
780 }
781 break; 680 break;
782 default: 681 default:
783 btn_dialog( 682 btn_dialog(
784 main_window, 683 main_window,
785 _("Your kernel configuration changes were NOT saved."), 684 _("Your configuration changes were NOT saved."),
786 1, 685 1,
787 "<OK>"); 686 "<OK>");
788 break; 687 break;
@@ -802,8 +701,8 @@ static void search_conf(void)
802again: 701again:
803 dres = dialog_inputbox(main_window, 702 dres = dialog_inputbox(main_window,
804 _("Search Configuration Parameter"), 703 _("Search Configuration Parameter"),
805 _("Enter CONFIG_ (sub)string to search for " 704 _("Enter " CONFIG_ " (sub)string to search for "
806 "(with or without \"CONFIG\")"), 705 "(with or without \"" CONFIG_ "\")"),
807 "", dialog_input_result, 99); 706 "", dialog_input_result, 99);
808 switch (dres) { 707 switch (dres) {
809 case 0: 708 case 0:
@@ -816,10 +715,10 @@ again:
816 return; 715 return;
817 } 716 }
818 717
819 /* strip CONFIG_ if necessary */ 718 /* strip the prefix if necessary */
820 dialog_input = dialog_input_result; 719 dialog_input = dialog_input_result;
821 if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) 720 if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
822 dialog_input += 7; 721 dialog_input += strlen(CONFIG_);
823 722
824 sym_arr = sym_re_search(dialog_input); 723 sym_arr = sym_re_search(dialog_input);
825 res = get_relations_str(sym_arr); 724 res = get_relations_str(sym_arr);
@@ -1027,23 +926,18 @@ static void reset_menu(void)
1027static void center_item(int selected_index, int *last_top_row) 926static void center_item(int selected_index, int *last_top_row)
1028{ 927{
1029 int toprow; 928 int toprow;
1030 int maxy, maxx;
1031 929
1032 scale_menu(curses_menu, &maxy, &maxx);
1033 set_top_row(curses_menu, *last_top_row); 930 set_top_row(curses_menu, *last_top_row);
1034 toprow = top_row(curses_menu); 931 toprow = top_row(curses_menu);
1035 if (selected_index >= toprow && selected_index < toprow+maxy) { 932 if (selected_index < toprow ||
1036 /* we can only move the selected item. no need to scroll */ 933 selected_index >= toprow+mwin_max_lines) {
1037 set_current_item(curses_menu, 934 toprow = max(selected_index-mwin_max_lines/2, 0);
1038 curses_menu_items[selected_index]); 935 if (toprow >= item_count(curses_menu)-mwin_max_lines)
1039 } else {
1040 toprow = max(selected_index-maxy/2, 0);
1041 if (toprow >= item_count(curses_menu)-maxy)
1042 toprow = item_count(curses_menu)-mwin_max_lines; 936 toprow = item_count(curses_menu)-mwin_max_lines;
1043 set_top_row(curses_menu, toprow); 937 set_top_row(curses_menu, toprow);
1044 set_current_item(curses_menu,
1045 curses_menu_items[selected_index]);
1046 } 938 }
939 set_current_item(curses_menu,
940 curses_menu_items[selected_index]);
1047 *last_top_row = toprow; 941 *last_top_row = toprow;
1048 post_menu(curses_menu); 942 post_menu(curses_menu);
1049 refresh_all_windows(main_window); 943 refresh_all_windows(main_window);
@@ -1059,23 +953,23 @@ static void show_menu(const char *prompt, const char *instructions,
1059 current_instructions = instructions; 953 current_instructions = instructions;
1060 954
1061 clear(); 955 clear();
1062 wattrset(main_window, attributes[NORMAL]); 956 (void) wattrset(main_window, attributes[NORMAL]);
1063 print_in_middle(stdscr, 1, 0, COLS, 957 print_in_middle(stdscr, 1, 0, COLS,
1064 menu_backtitle, 958 menu_backtitle,
1065 attributes[MAIN_HEADING]); 959 attributes[MAIN_HEADING]);
1066 960
1067 wattrset(main_window, attributes[MAIN_MENU_BOX]); 961 (void) wattrset(main_window, attributes[MAIN_MENU_BOX]);
1068 box(main_window, 0, 0); 962 box(main_window, 0, 0);
1069 wattrset(main_window, attributes[MAIN_MENU_HEADING]); 963 (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]);
1070 mvwprintw(main_window, 0, 3, " %s ", prompt); 964 mvwprintw(main_window, 0, 3, " %s ", prompt);
1071 wattrset(main_window, attributes[NORMAL]); 965 (void) wattrset(main_window, attributes[NORMAL]);
1072 966
1073 set_menu_items(curses_menu, curses_menu_items); 967 set_menu_items(curses_menu, curses_menu_items);
1074 968
1075 /* position the menu at the middle of the screen */ 969 /* position the menu at the middle of the screen */
1076 scale_menu(curses_menu, &maxy, &maxx); 970 scale_menu(curses_menu, &maxy, &maxx);
1077 maxx = min(maxx, mwin_max_cols-2); 971 maxx = min(maxx, mwin_max_cols-2);
1078 maxy = mwin_max_lines-2; 972 maxy = mwin_max_lines;
1079 menu_window = derwin(main_window, 973 menu_window = derwin(main_window,
1080 maxy, 974 maxy,
1081 maxx, 975 maxx,
@@ -1099,10 +993,77 @@ static void show_menu(const char *prompt, const char *instructions,
1099 refresh_all_windows(main_window); 993 refresh_all_windows(main_window);
1100} 994}
1101 995
996static void adj_match_dir(match_f *match_direction)
997{
998 if (*match_direction == FIND_NEXT_MATCH_DOWN)
999 *match_direction =
1000 MATCH_TINKER_PATTERN_DOWN;
1001 else if (*match_direction == FIND_NEXT_MATCH_UP)
1002 *match_direction =
1003 MATCH_TINKER_PATTERN_UP;
1004 /* else, do no change.. */
1005}
1102 1006
1103static void conf(struct menu *menu) 1007struct match_state
1104{ 1008{
1009 int in_search;
1010 match_f match_direction;
1105 char pattern[256]; 1011 char pattern[256];
1012};
1013
1014/* Return 0 means I have handled the key. In such a case, ans should hold the
1015 * item to center, or -1 otherwise.
1016 * Else return -1 .
1017 */
1018static int do_match(int key, struct match_state *state, int *ans)
1019{
1020 char c = (char) key;
1021 int terminate_search = 0;
1022 *ans = -1;
1023 if (key == '/' || (state->in_search && key == 27)) {
1024 move(0, 0);
1025 refresh();
1026 clrtoeol();
1027 state->in_search = 1-state->in_search;
1028 bzero(state->pattern, sizeof(state->pattern));
1029 state->match_direction = MATCH_TINKER_PATTERN_DOWN;
1030 return 0;
1031 } else if (!state->in_search)
1032 return 1;
1033
1034 if (isalnum(c) || isgraph(c) || c == ' ') {
1035 state->pattern[strlen(state->pattern)] = c;
1036 state->pattern[strlen(state->pattern)] = '\0';
1037 adj_match_dir(&state->match_direction);
1038 *ans = get_mext_match(state->pattern,
1039 state->match_direction);
1040 } else if (key == KEY_DOWN) {
1041 state->match_direction = FIND_NEXT_MATCH_DOWN;
1042 *ans = get_mext_match(state->pattern,
1043 state->match_direction);
1044 } else if (key == KEY_UP) {
1045 state->match_direction = FIND_NEXT_MATCH_UP;
1046 *ans = get_mext_match(state->pattern,
1047 state->match_direction);
1048 } else if (key == KEY_BACKSPACE || key == 127) {
1049 state->pattern[strlen(state->pattern)-1] = '\0';
1050 adj_match_dir(&state->match_direction);
1051 } else
1052 terminate_search = 1;
1053
1054 if (terminate_search) {
1055 state->in_search = 0;
1056 bzero(state->pattern, sizeof(state->pattern));
1057 move(0, 0);
1058 refresh();
1059 clrtoeol();
1060 return -1;
1061 }
1062 return 0;
1063}
1064
1065static void conf(struct menu *menu)
1066{
1106 struct menu *submenu = 0; 1067 struct menu *submenu = 0;
1107 const char *prompt = menu_get_prompt(menu); 1068 const char *prompt = menu_get_prompt(menu);
1108 struct symbol *sym; 1069 struct symbol *sym;
@@ -1110,8 +1071,11 @@ static void conf(struct menu *menu)
1110 int res; 1071 int res;
1111 int current_index = 0; 1072 int current_index = 0;
1112 int last_top_row = 0; 1073 int last_top_row = 0;
1113 1074 struct match_state match_state = {
1114 bzero(pattern, sizeof(pattern)); 1075 .in_search = 0,
1076 .match_direction = MATCH_TINKER_PATTERN_DOWN,
1077 .pattern = "",
1078 };
1115 1079
1116 while (!global_exit) { 1080 while (!global_exit) {
1117 reset_menu(); 1081 reset_menu();
@@ -1124,7 +1088,22 @@ static void conf(struct menu *menu)
1124 _(menu_instructions), 1088 _(menu_instructions),
1125 current_index, &last_top_row); 1089 current_index, &last_top_row);
1126 keypad((menu_win(curses_menu)), TRUE); 1090 keypad((menu_win(curses_menu)), TRUE);
1127 while (!global_exit && (res = wgetch(menu_win(curses_menu)))) { 1091 while (!global_exit) {
1092 if (match_state.in_search) {
1093 mvprintw(0, 0,
1094 "searching: %s", match_state.pattern);
1095 clrtoeol();
1096 }
1097 refresh_all_windows(main_window);
1098 res = wgetch(menu_win(curses_menu));
1099 if (!res)
1100 break;
1101 if (do_match(res, &match_state, &current_index) == 0) {
1102 if (current_index != -1)
1103 center_item(current_index,
1104 &last_top_row);
1105 continue;
1106 }
1128 if (process_special_keys(&res, 1107 if (process_special_keys(&res,
1129 (struct menu *) item_data())) 1108 (struct menu *) item_data()))
1130 break; 1109 break;
@@ -1155,19 +1134,13 @@ static void conf(struct menu *menu)
1155 if (res == 10 || res == 27 || 1134 if (res == 10 || res == 27 ||
1156 res == 32 || res == 'n' || res == 'y' || 1135 res == 32 || res == 'n' || res == 'y' ||
1157 res == KEY_LEFT || res == KEY_RIGHT || 1136 res == KEY_LEFT || res == KEY_RIGHT ||
1158 res == 'm' || res == '/') 1137 res == 'm')
1159 break; 1138 break;
1160 else if (canbhot(res)) {
1161 /* check for hot keys: */
1162 int tmp = get_next_hot(res);
1163 if (tmp != -1)
1164 center_item(tmp, &last_top_row);
1165 }
1166 refresh_all_windows(main_window); 1139 refresh_all_windows(main_window);
1167 } 1140 }
1168 1141
1169 refresh_all_windows(main_window); 1142 refresh_all_windows(main_window);
1170 /* if ESC or left*/ 1143 /* if ESC or left*/
1171 if (res == 27 || (menu != &rootmenu && res == KEY_LEFT)) 1144 if (res == 27 || (menu != &rootmenu && res == KEY_LEFT))
1172 break; 1145 break;
1173 1146
@@ -1235,23 +1208,30 @@ static void conf(struct menu *menu)
1235 if (item_is_tag('t')) 1208 if (item_is_tag('t'))
1236 sym_set_tristate_value(sym, mod); 1209 sym_set_tristate_value(sym, mod);
1237 break; 1210 break;
1238 case '/':
1239 search_conf();
1240 break;
1241 } 1211 }
1242 } 1212 }
1243} 1213}
1244 1214
1215static void conf_message_callback(const char *fmt, va_list ap)
1216{
1217 char buf[1024];
1218
1219 vsnprintf(buf, sizeof(buf), fmt, ap);
1220 btn_dialog(main_window, buf, 1, "<OK>");
1221}
1222
1245static void show_help(struct menu *menu) 1223static void show_help(struct menu *menu)
1246{ 1224{
1247 struct gstr help = str_new(); 1225 struct gstr help = str_new();
1248 1226
1249 if (menu && menu->sym && menu_has_help(menu)) { 1227 if (menu && menu->sym && menu_has_help(menu)) {
1250 if (menu->sym->name) { 1228 if (menu->sym->name) {
1251 str_printf(&help, "CONFIG_%s:\n\n", menu->sym->name); 1229 str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name);
1252 str_append(&help, _(menu_get_help(menu))); 1230 str_append(&help, _(menu_get_help(menu)));
1253 str_append(&help, "\n"); 1231 str_append(&help, "\n");
1254 get_symbol_str(&help, menu->sym); 1232 get_symbol_str(&help, menu->sym);
1233 } else {
1234 str_append(&help, _(menu_get_help(menu)));
1255 } 1235 }
1256 } else { 1236 } else {
1257 str_append(&help, nohelp_text); 1237 str_append(&help, nohelp_text);
@@ -1268,6 +1248,11 @@ static void conf_choice(struct menu *menu)
1268 int selected_index = 0; 1248 int selected_index = 0;
1269 int last_top_row = 0; 1249 int last_top_row = 0;
1270 int res, i = 0; 1250 int res, i = 0;
1251 struct match_state match_state = {
1252 .in_search = 0,
1253 .match_direction = MATCH_TINKER_PATTERN_DOWN,
1254 .pattern = "",
1255 };
1271 1256
1272 active = sym_get_choice_value(menu->sym); 1257 active = sym_get_choice_value(menu->sym);
1273 /* this is mostly duplicated from the conf() function. */ 1258 /* this is mostly duplicated from the conf() function. */
@@ -1281,9 +1266,13 @@ static void conf_choice(struct menu *menu)
1281 if (child->sym == sym_get_choice_value(menu->sym)) 1266 if (child->sym == sym_get_choice_value(menu->sym))
1282 item_make(child, ':', "<X> %s", 1267 item_make(child, ':', "<X> %s",
1283 _(menu_get_prompt(child))); 1268 _(menu_get_prompt(child)));
1284 else 1269 else if (child->sym)
1285 item_make(child, ':', " %s", 1270 item_make(child, ':', " %s",
1286 _(menu_get_prompt(child))); 1271 _(menu_get_prompt(child)));
1272 else
1273 item_make(child, ':', "*** %s ***",
1274 _(menu_get_prompt(child)));
1275
1287 if (child->sym == active){ 1276 if (child->sym == active){
1288 last_top_row = top_row(curses_menu); 1277 last_top_row = top_row(curses_menu);
1289 selected_index = i; 1278 selected_index = i;
@@ -1294,7 +1283,22 @@ static void conf_choice(struct menu *menu)
1294 _(radiolist_instructions), 1283 _(radiolist_instructions),
1295 selected_index, 1284 selected_index,
1296 &last_top_row); 1285 &last_top_row);
1297 while (!global_exit && (res = wgetch(menu_win(curses_menu)))) { 1286 while (!global_exit) {
1287 if (match_state.in_search) {
1288 mvprintw(0, 0, "searching: %s",
1289 match_state.pattern);
1290 clrtoeol();
1291 }
1292 refresh_all_windows(main_window);
1293 res = wgetch(menu_win(curses_menu));
1294 if (!res)
1295 break;
1296 if (do_match(res, &match_state, &selected_index) == 0) {
1297 if (selected_index != -1)
1298 center_item(selected_index,
1299 &last_top_row);
1300 continue;
1301 }
1298 if (process_special_keys( 1302 if (process_special_keys(
1299 &res, 1303 &res,
1300 (struct menu *) item_data())) 1304 (struct menu *) item_data()))
@@ -1324,13 +1328,8 @@ static void conf_choice(struct menu *menu)
1324 break; 1328 break;
1325 } 1329 }
1326 if (res == 10 || res == 27 || res == ' ' || 1330 if (res == 10 || res == 27 || res == ' ' ||
1327 res == KEY_LEFT) 1331 res == KEY_LEFT){
1328 break; 1332 break;
1329 else if (canbhot(res)) {
1330 /* check for hot keys: */
1331 int tmp = get_next_hot(res);
1332 if (tmp != -1)
1333 center_item(tmp, &last_top_row);
1334 } 1333 }
1335 refresh_all_windows(main_window); 1334 refresh_all_windows(main_window);
1336 } 1335 }
@@ -1339,7 +1338,7 @@ static void conf_choice(struct menu *menu)
1339 break; 1338 break;
1340 1339
1341 child = item_data(); 1340 child = item_data();
1342 if (!child || !menu_is_visible(child)) 1341 if (!child || !menu_is_visible(child) || !child->sym)
1343 continue; 1342 continue;
1344 switch (res) { 1343 switch (res) {
1345 case ' ': 1344 case ' ':
@@ -1449,16 +1448,8 @@ static void conf_save(void)
1449 case 0: 1448 case 0:
1450 if (!dialog_input_result[0]) 1449 if (!dialog_input_result[0])
1451 return; 1450 return;
1452 supress_stdout(0);
1453 res = conf_write(dialog_input_result); 1451 res = conf_write(dialog_input_result);
1454 supress_stdout(1);
1455 if (!res) { 1452 if (!res) {
1456 char buf[1024];
1457 sprintf(buf, "%s %s",
1458 _("configuration file saved to: "),
1459 dialog_input_result);
1460 btn_dialog(main_window,
1461 buf, 1, "<OK>");
1462 set_config_filename(dialog_input_result); 1453 set_config_filename(dialog_input_result);
1463 return; 1454 return;
1464 } 1455 }
@@ -1485,7 +1476,7 @@ void setup_windows(void)
1485 /* set up the menu and menu window */ 1476 /* set up the menu and menu window */
1486 main_window = newwin(LINES-2, COLS-2, 2, 1); 1477 main_window = newwin(LINES-2, COLS-2, 2, 1);
1487 keypad(main_window, TRUE); 1478 keypad(main_window, TRUE);
1488 mwin_max_lines = LINES-6; 1479 mwin_max_lines = LINES-7;
1489 mwin_max_cols = COLS-6; 1480 mwin_max_cols = COLS-6;
1490 1481
1491 /* panels order is from bottom to top */ 1482 /* panels order is from bottom to top */
@@ -1532,9 +1523,10 @@ int main(int ac, char **av)
1532 /* set btns menu */ 1523 /* set btns menu */
1533 curses_menu = new_menu(curses_menu_items); 1524 curses_menu = new_menu(curses_menu_items);
1534 menu_opts_off(curses_menu, O_SHOWDESC); 1525 menu_opts_off(curses_menu, O_SHOWDESC);
1535 menu_opts_off(curses_menu, O_SHOWMATCH); 1526 menu_opts_on(curses_menu, O_SHOWMATCH);
1536 menu_opts_on(curses_menu, O_ONEVALUE); 1527 menu_opts_on(curses_menu, O_ONEVALUE);
1537 menu_opts_on(curses_menu, O_NONCYCLIC); 1528 menu_opts_on(curses_menu, O_NONCYCLIC);
1529 menu_opts_on(curses_menu, O_IGNORECASE);
1538 set_menu_mark(curses_menu, " "); 1530 set_menu_mark(curses_menu, " ");
1539 set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]); 1531 set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]);
1540 set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]); 1532 set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]);
@@ -1550,8 +1542,7 @@ int main(int ac, char **av)
1550 _(menu_no_f_instructions)); 1542 _(menu_no_f_instructions));
1551 } 1543 }
1552 1544
1553 1545 conf_set_message_callback(conf_message_callback);
1554
1555 /* do the work */ 1546 /* do the work */
1556 while (!global_exit) { 1547 while (!global_exit) {
1557 conf(&rootmenu); 1548 conf(&rootmenu);
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index a9d9344e1365..f8137b3a5382 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -137,7 +137,7 @@ void set_colors()
137 if (has_colors()) { 137 if (has_colors()) {
138 normal_color_theme(); 138 normal_color_theme();
139 } else { 139 } else {
140 /* give deafults */ 140 /* give defaults */
141 no_colors_theme(); 141 no_colors_theme();
142 } 142 }
143} 143}
@@ -167,7 +167,7 @@ void print_in_middle(WINDOW *win,
167 length = strlen(string); 167 length = strlen(string);
168 temp = (width - length) / 2; 168 temp = (width - length) / 2;
169 x = startx + (int)temp; 169 x = startx + (int)temp;
170 wattrset(win, color); 170 (void) wattrset(win, color);
171 mvwprintw(win, y, x, "%s", string); 171 mvwprintw(win, y, x, "%s", string);
172 refresh(); 172 refresh();
173} 173}
@@ -297,11 +297,11 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
297 set_menu_fore(menu, attributes[DIALOG_MENU_FORE]); 297 set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
298 set_menu_back(menu, attributes[DIALOG_MENU_BACK]); 298 set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
299 299
300 wattrset(win, attributes[DIALOG_BOX]); 300 (void) wattrset(win, attributes[DIALOG_BOX]);
301 box(win, 0, 0); 301 box(win, 0, 0);
302 302
303 /* print message */ 303 /* print message */
304 wattrset(msg_win, attributes[DIALOG_TEXT]); 304 (void) wattrset(msg_win, attributes[DIALOG_TEXT]);
305 fill_window(msg_win, msg); 305 fill_window(msg_win, msg);
306 306
307 set_menu_win(menu, win); 307 set_menu_win(menu, win);
@@ -392,16 +392,16 @@ int dialog_inputbox(WINDOW *main_window,
392 form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); 392 form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
393 keypad(form_win, TRUE); 393 keypad(form_win, TRUE);
394 394
395 wattrset(form_win, attributes[INPUT_FIELD]); 395 (void) wattrset(form_win, attributes[INPUT_FIELD]);
396 396
397 wattrset(win, attributes[INPUT_BOX]); 397 (void) wattrset(win, attributes[INPUT_BOX]);
398 box(win, 0, 0); 398 box(win, 0, 0);
399 wattrset(win, attributes[INPUT_HEADING]); 399 (void) wattrset(win, attributes[INPUT_HEADING]);
400 if (title) 400 if (title)
401 mvwprintw(win, 0, 3, "%s", title); 401 mvwprintw(win, 0, 3, "%s", title);
402 402
403 /* print message */ 403 /* print message */
404 wattrset(prompt_win, attributes[INPUT_TEXT]); 404 (void) wattrset(prompt_win, attributes[INPUT_TEXT]);
405 fill_window(prompt_win, prompt); 405 fill_window(prompt_win, prompt);
406 406
407 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); 407 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
@@ -531,7 +531,7 @@ void show_scroll_win(WINDOW *main_window,
531 531
532 /* create the pad */ 532 /* create the pad */
533 pad = newpad(total_lines+10, total_cols+10); 533 pad = newpad(total_lines+10, total_cols+10);
534 wattrset(pad, attributes[SCROLLWIN_TEXT]); 534 (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
535 fill_window(pad, text); 535 fill_window(pad, text);
536 536
537 win_lines = min(total_lines+4, LINES-2); 537 win_lines = min(total_lines+4, LINES-2);
@@ -546,9 +546,9 @@ void show_scroll_win(WINDOW *main_window,
546 win = newwin(win_lines, win_cols, y, x); 546 win = newwin(win_lines, win_cols, y, x);
547 keypad(win, TRUE); 547 keypad(win, TRUE);
548 /* show the help in the help window, and show the help panel */ 548 /* show the help in the help window, and show the help panel */
549 wattrset(win, attributes[SCROLLWIN_BOX]); 549 (void) wattrset(win, attributes[SCROLLWIN_BOX]);
550 box(win, 0, 0); 550 box(win, 0, 0);
551 wattrset(win, attributes[SCROLLWIN_HEADING]); 551 (void) wattrset(win, attributes[SCROLLWIN_HEADING]);
552 mvwprintw(win, 0, 3, " %s ", title); 552 mvwprintw(win, 0, 3, " %s ", title);
553 panel = new_panel(win); 553 panel = new_panel(win);
554 554
diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h
index fb4296666004..58fbda8fc0dc 100644
--- a/scripts/kconfig/nconf.h
+++ b/scripts/kconfig/nconf.h
@@ -69,7 +69,8 @@ typedef enum {
69 F_BACK = 5, 69 F_BACK = 5,
70 F_SAVE = 6, 70 F_SAVE = 6,
71 F_LOAD = 7, 71 F_LOAD = 7,
72 F_EXIT = 8 72 F_SEARCH = 8,
73 F_EXIT = 9,
73} function_key; 74} function_key;
74 75
75void set_colors(void); 76void set_colors(void);
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 820df2d1217b..c2796b866f8f 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -3,25 +3,42 @@
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#include <qapplication.h> 6#include <qglobal.h>
7
8#if QT_VERSION < 0x040000
7#include <qmainwindow.h> 9#include <qmainwindow.h>
10#include <qvbox.h>
11#include <qvaluelist.h>
12#include <qtextbrowser.h>
13#include <qaction.h>
14#include <qheader.h>
15#include <qfiledialog.h>
16#include <qdragobject.h>
17#include <qpopupmenu.h>
18#else
19#include <q3mainwindow.h>
20#include <q3vbox.h>
21#include <q3valuelist.h>
22#include <q3textbrowser.h>
23#include <q3action.h>
24#include <q3header.h>
25#include <q3filedialog.h>
26#include <q3dragobject.h>
27#include <q3popupmenu.h>
28#endif
29
30#include <qapplication.h>
8#include <qdesktopwidget.h> 31#include <qdesktopwidget.h>
9#include <qtoolbar.h> 32#include <qtoolbar.h>
10#include <qlayout.h> 33#include <qlayout.h>
11#include <qvbox.h>
12#include <qsplitter.h> 34#include <qsplitter.h>
13#include <qlistview.h>
14#include <qtextbrowser.h>
15#include <qlineedit.h> 35#include <qlineedit.h>
16#include <qlabel.h> 36#include <qlabel.h>
17#include <qpushbutton.h> 37#include <qpushbutton.h>
18#include <qmenubar.h> 38#include <qmenubar.h>
19#include <qmessagebox.h> 39#include <qmessagebox.h>
20#include <qaction.h>
21#include <qheader.h>
22#include <qfiledialog.h>
23#include <qdragobject.h>
24#include <qregexp.h> 40#include <qregexp.h>
41#include <qevent.h>
25 42
26#include <stdlib.h> 43#include <stdlib.h>
27 44
@@ -39,7 +56,7 @@
39static QApplication *configApp; 56static QApplication *configApp;
40static ConfigSettings *configSettings; 57static ConfigSettings *configSettings;
41 58
42QAction *ConfigMainWindow::saveAction; 59Q3Action *ConfigMainWindow::saveAction;
43 60
44static inline QString qgettext(const char* str) 61static inline QString qgettext(const char* str)
45{ 62{
@@ -54,9 +71,9 @@ static inline QString qgettext(const QString& str)
54/** 71/**
55 * Reads a list of integer values from the application settings. 72 * Reads a list of integer values from the application settings.
56 */ 73 */
57QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok) 74Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
58{ 75{
59 QValueList<int> result; 76 Q3ValueList<int> result;
60 QStringList entryList = readListEntry(key, ok); 77 QStringList entryList = readListEntry(key, ok);
61 QStringList::Iterator it; 78 QStringList::Iterator it;
62 79
@@ -69,10 +86,10 @@ QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
69/** 86/**
70 * Writes a list of integer values to the application settings. 87 * Writes a list of integer values to the application settings.
71 */ 88 */
72bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value) 89bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value)
73{ 90{
74 QStringList stringList; 91 QStringList stringList;
75 QValueList<int>::ConstIterator it; 92 Q3ValueList<int>::ConstIterator it;
76 93
77 for (it = value.begin(); it != value.end(); ++it) 94 for (it = value.begin(); it != value.end(); ++it)
78 stringList.push_back(QString::number(*it)); 95 stringList.push_back(QString::number(*it));
@@ -80,7 +97,6 @@ bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value
80} 97}
81 98
82 99
83#if QT_VERSION >= 300
84/* 100/*
85 * set the new data 101 * set the new data
86 * TODO check the value 102 * TODO check the value
@@ -91,7 +107,6 @@ void ConfigItem::okRename(int col)
91 sym_set_string_value(menu->sym, text(dataColIdx).latin1()); 107 sym_set_string_value(menu->sym, text(dataColIdx).latin1());
92 listView()->updateList(this); 108 listView()->updateList(this);
93} 109}
94#endif
95 110
96/* 111/*
97 * update the displayed of a menu entry 112 * update the displayed of a menu entry
@@ -195,11 +210,9 @@ void ConfigItem::updateMenu(void)
195 210
196 data = sym_get_string_value(sym); 211 data = sym_get_string_value(sym);
197 212
198#if QT_VERSION >= 300
199 int i = list->mapIdx(dataColIdx); 213 int i = list->mapIdx(dataColIdx);
200 if (i >= 0) 214 if (i >= 0)
201 setRenameEnabled(i, TRUE); 215 setRenameEnabled(i, TRUE);
202#endif
203 setText(dataColIdx, data); 216 setText(dataColIdx, data);
204 if (type == S_STRING) 217 if (type == S_STRING)
205 prompt = QString("%1: %2").arg(prompt).arg(data); 218 prompt = QString("%1: %2").arg(prompt).arg(data);
@@ -432,7 +445,7 @@ void ConfigList::updateList(ConfigItem* item)
432 if (!rootEntry) { 445 if (!rootEntry) {
433 if (mode != listMode) 446 if (mode != listMode)
434 goto update; 447 goto update;
435 QListViewItemIterator it(this); 448 Q3ListViewItemIterator it(this);
436 ConfigItem* item; 449 ConfigItem* item;
437 450
438 for (; it.current(); ++it) { 451 for (; it.current(); ++it) {
@@ -527,11 +540,9 @@ void ConfigList::changeValue(ConfigItem* item)
527 case S_INT: 540 case S_INT:
528 case S_HEX: 541 case S_HEX:
529 case S_STRING: 542 case S_STRING:
530#if QT_VERSION >= 300
531 if (colMap[dataColIdx] >= 0) 543 if (colMap[dataColIdx] >= 0)
532 item->startRename(colMap[dataColIdx]); 544 item->startRename(colMap[dataColIdx]);
533 else 545 else
534#endif
535 parent()->lineEdit->show(item); 546 parent()->lineEdit->show(item);
536 break; 547 break;
537 } 548 }
@@ -563,7 +574,7 @@ void ConfigList::setParentMenu(void)
563 return; 574 return;
564 setRootMenu(menu_get_parent_menu(rootEntry->parent)); 575 setRootMenu(menu_get_parent_menu(rootEntry->parent));
565 576
566 QListViewItemIterator it(this); 577 Q3ListViewItemIterator it(this);
567 for (; (item = (ConfigItem*)it.current()); it++) { 578 for (; (item = (ConfigItem*)it.current()); it++) {
568 if (item->menu == oldroot) { 579 if (item->menu == oldroot) {
569 setCurrentItem(item); 580 setCurrentItem(item);
@@ -645,7 +656,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
645 656
646void ConfigList::keyPressEvent(QKeyEvent* ev) 657void ConfigList::keyPressEvent(QKeyEvent* ev)
647{ 658{
648 QListViewItem* i = currentItem(); 659 Q3ListViewItem* i = currentItem();
649 ConfigItem* item; 660 ConfigItem* item;
650 struct menu *menu; 661 struct menu *menu;
651 enum prop_type type; 662 enum prop_type type;
@@ -811,10 +822,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
811{ 822{
812 if (e->y() <= header()->geometry().bottom()) { 823 if (e->y() <= header()->geometry().bottom()) {
813 if (!headerPopup) { 824 if (!headerPopup) {
814 QAction *action; 825 Q3Action *action;
815 826
816 headerPopup = new QPopupMenu(this); 827 headerPopup = new Q3PopupMenu(this);
817 action = new QAction(NULL, _("Show Name"), 0, this); 828 action = new Q3Action(NULL, _("Show Name"), 0, this);
818 action->setToggleAction(TRUE); 829 action->setToggleAction(TRUE);
819 connect(action, SIGNAL(toggled(bool)), 830 connect(action, SIGNAL(toggled(bool)),
820 parent(), SLOT(setShowName(bool))); 831 parent(), SLOT(setShowName(bool)));
@@ -822,7 +833,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
822 action, SLOT(setOn(bool))); 833 action, SLOT(setOn(bool)));
823 action->setOn(showName); 834 action->setOn(showName);
824 action->addTo(headerPopup); 835 action->addTo(headerPopup);
825 action = new QAction(NULL, _("Show Range"), 0, this); 836 action = new Q3Action(NULL, _("Show Range"), 0, this);
826 action->setToggleAction(TRUE); 837 action->setToggleAction(TRUE);
827 connect(action, SIGNAL(toggled(bool)), 838 connect(action, SIGNAL(toggled(bool)),
828 parent(), SLOT(setShowRange(bool))); 839 parent(), SLOT(setShowRange(bool)));
@@ -830,7 +841,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
830 action, SLOT(setOn(bool))); 841 action, SLOT(setOn(bool)));
831 action->setOn(showRange); 842 action->setOn(showRange);
832 action->addTo(headerPopup); 843 action->addTo(headerPopup);
833 action = new QAction(NULL, _("Show Data"), 0, this); 844 action = new Q3Action(NULL, _("Show Data"), 0, this);
834 action->setToggleAction(TRUE); 845 action->setToggleAction(TRUE);
835 connect(action, SIGNAL(toggled(bool)), 846 connect(action, SIGNAL(toggled(bool)),
836 parent(), SLOT(setShowData(bool))); 847 parent(), SLOT(setShowData(bool)));
@@ -914,7 +925,7 @@ void ConfigView::setShowData(bool b)
914 925
915void ConfigList::setAllOpen(bool open) 926void ConfigList::setAllOpen(bool open)
916{ 927{
917 QListViewItemIterator it(this); 928 Q3ListViewItemIterator it(this);
918 929
919 for (; it.current(); it++) 930 for (; it.current(); it++)
920 it.current()->setOpen(open); 931 it.current()->setOpen(open);
@@ -937,7 +948,7 @@ void ConfigView::updateListAll(void)
937} 948}
938 949
939ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) 950ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
940 : Parent(parent, name), sym(0), menu(0) 951 : Parent(parent, name), sym(0), _menu(0)
941{ 952{
942 if (name) { 953 if (name) {
943 configSettings->beginGroup(name); 954 configSettings->beginGroup(name);
@@ -960,7 +971,7 @@ void ConfigInfoView::setShowDebug(bool b)
960{ 971{
961 if (_showDebug != b) { 972 if (_showDebug != b) {
962 _showDebug = b; 973 _showDebug = b;
963 if (menu) 974 if (_menu)
964 menuInfo(); 975 menuInfo();
965 else if (sym) 976 else if (sym)
966 symbolInfo(); 977 symbolInfo();
@@ -970,11 +981,11 @@ void ConfigInfoView::setShowDebug(bool b)
970 981
971void ConfigInfoView::setInfo(struct menu *m) 982void ConfigInfoView::setInfo(struct menu *m)
972{ 983{
973 if (menu == m) 984 if (_menu == m)
974 return; 985 return;
975 menu = m; 986 _menu = m;
976 sym = NULL; 987 sym = NULL;
977 if (!menu) 988 if (!_menu)
978 clear(); 989 clear();
979 else 990 else
980 menuInfo(); 991 menuInfo();
@@ -1001,11 +1012,11 @@ void ConfigInfoView::menuInfo(void)
1001 struct symbol* sym; 1012 struct symbol* sym;
1002 QString head, debug, help; 1013 QString head, debug, help;
1003 1014
1004 sym = menu->sym; 1015 sym = _menu->sym;
1005 if (sym) { 1016 if (sym) {
1006 if (menu->prompt) { 1017 if (_menu->prompt) {
1007 head += "<big><b>"; 1018 head += "<big><b>";
1008 head += print_filter(_(menu->prompt->text)); 1019 head += print_filter(_(_menu->prompt->text));
1009 head += "</b></big>"; 1020 head += "</b></big>";
1010 if (sym->name) { 1021 if (sym->name) {
1011 head += " ("; 1022 head += " (";
@@ -1031,23 +1042,23 @@ void ConfigInfoView::menuInfo(void)
1031 debug = debug_info(sym); 1042 debug = debug_info(sym);
1032 1043
1033 struct gstr help_gstr = str_new(); 1044 struct gstr help_gstr = str_new();
1034 menu_get_ext_help(menu, &help_gstr); 1045 menu_get_ext_help(_menu, &help_gstr);
1035 help = print_filter(str_get(&help_gstr)); 1046 help = print_filter(str_get(&help_gstr));
1036 str_free(&help_gstr); 1047 str_free(&help_gstr);
1037 } else if (menu->prompt) { 1048 } else if (_menu->prompt) {
1038 head += "<big><b>"; 1049 head += "<big><b>";
1039 head += print_filter(_(menu->prompt->text)); 1050 head += print_filter(_(_menu->prompt->text));
1040 head += "</b></big><br><br>"; 1051 head += "</b></big><br><br>";
1041 if (showDebug()) { 1052 if (showDebug()) {
1042 if (menu->prompt->visible.expr) { 1053 if (_menu->prompt->visible.expr) {
1043 debug += "&nbsp;&nbsp;dep: "; 1054 debug += "&nbsp;&nbsp;dep: ";
1044 expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); 1055 expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
1045 debug += "<br><br>"; 1056 debug += "<br><br>";
1046 } 1057 }
1047 } 1058 }
1048 } 1059 }
1049 if (showDebug()) 1060 if (showDebug())
1050 debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); 1061 debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
1051 1062
1052 setText(head + debug + help); 1063 setText(head + debug + help);
1053} 1064}
@@ -1150,10 +1161,10 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
1150 *text += str2; 1161 *text += str2;
1151} 1162}
1152 1163
1153QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) 1164Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
1154{ 1165{
1155 QPopupMenu* popup = Parent::createPopupMenu(pos); 1166 Q3PopupMenu* popup = Parent::createPopupMenu(pos);
1156 QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup); 1167 Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup);
1157 action->setToggleAction(TRUE); 1168 action->setToggleAction(TRUE);
1158 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 1169 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1159 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); 1170 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1210,7 +1221,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
1210 y = configSettings->readNumEntry("/window y", 0, &ok); 1221 y = configSettings->readNumEntry("/window y", 0, &ok);
1211 if (ok) 1222 if (ok)
1212 move(x, y); 1223 move(x, y);
1213 QValueList<int> sizes = configSettings->readSizes("/split", &ok); 1224 Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok);
1214 if (ok) 1225 if (ok)
1215 split->setSizes(sizes); 1226 split->setSizes(sizes);
1216 configSettings->endGroup(); 1227 configSettings->endGroup();
@@ -1263,8 +1274,14 @@ ConfigMainWindow::ConfigMainWindow(void)
1263 char title[256]; 1274 char title[256];
1264 1275
1265 QDesktopWidget *d = configApp->desktop(); 1276 QDesktopWidget *d = configApp->desktop();
1266 snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"), 1277 snprintf(title, sizeof(title), "%s%s",
1267 getenv("KERNELVERSION")); 1278 rootmenu.prompt->text,
1279#if QT_VERSION < 0x040000
1280 " (Qt3)"
1281#else
1282 ""
1283#endif
1284 );
1268 setCaption(title); 1285 setCaption(title);
1269 1286
1270 width = configSettings->readNumEntry("/window width", d->width() - 64); 1287 width = configSettings->readNumEntry("/window width", d->width() - 64);
@@ -1297,42 +1314,42 @@ ConfigMainWindow::ConfigMainWindow(void)
1297 configList->setFocus(); 1314 configList->setFocus();
1298 1315
1299 menu = menuBar(); 1316 menu = menuBar();
1300 toolBar = new QToolBar("Tools", this); 1317 toolBar = new Q3ToolBar("Tools", this);
1301 1318
1302 backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this); 1319 backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this);
1303 connect(backAction, SIGNAL(activated()), SLOT(goBack())); 1320 connect(backAction, SIGNAL(activated()), SLOT(goBack()));
1304 backAction->setEnabled(FALSE); 1321 backAction->setEnabled(FALSE);
1305 QAction *quitAction = new QAction("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this); 1322 Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
1306 connect(quitAction, SIGNAL(activated()), SLOT(close())); 1323 connect(quitAction, SIGNAL(activated()), SLOT(close()));
1307 QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this); 1324 Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
1308 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); 1325 connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
1309 saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this); 1326 saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
1310 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); 1327 connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
1311 conf_set_changed_callback(conf_changed); 1328 conf_set_changed_callback(conf_changed);
1312 // Set saveAction's initial state 1329 // Set saveAction's initial state
1313 conf_changed(); 1330 conf_changed();
1314 QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this); 1331 Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this);
1315 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); 1332 connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
1316 QAction *searchAction = new QAction("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this); 1333 Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
1317 connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); 1334 connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
1318 QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); 1335 Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
1319 connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); 1336 connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
1320 QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); 1337 Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
1321 connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); 1338 connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
1322 QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); 1339 Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
1323 connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); 1340 connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
1324 1341
1325 QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this); 1342 Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this);
1326 showNameAction->setToggleAction(TRUE); 1343 showNameAction->setToggleAction(TRUE);
1327 connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); 1344 connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
1328 connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); 1345 connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
1329 showNameAction->setOn(configView->showName()); 1346 showNameAction->setOn(configView->showName());
1330 QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this); 1347 Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this);
1331 showRangeAction->setToggleAction(TRUE); 1348 showRangeAction->setToggleAction(TRUE);
1332 connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); 1349 connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
1333 connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); 1350 connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
1334 showRangeAction->setOn(configList->showRange); 1351 showRangeAction->setOn(configList->showRange);
1335 QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this); 1352 Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this);
1336 showDataAction->setToggleAction(TRUE); 1353 showDataAction->setToggleAction(TRUE);
1337 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); 1354 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
1338 connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); 1355 connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
@@ -1345,9 +1362,15 @@ ConfigMainWindow::ConfigMainWindow(void)
1345 connect(optGroup, SIGNAL(selected(QAction *)), menuView, 1362 connect(optGroup, SIGNAL(selected(QAction *)), menuView,
1346 SLOT(setOptionMode(QAction *))); 1363 SLOT(setOptionMode(QAction *)));
1347 1364
1348 configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup); 1365#if QT_VERSION >= 0x040000
1349 configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup); 1366 configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
1350 configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup); 1367 configView->showAllAction = new QAction(_("Show All Options"), optGroup);
1368 configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
1369#else
1370 configView->showNormalAction = new QAction(_("Show Normal Options"), 0, optGroup);
1371 configView->showAllAction = new QAction(_("Show All Options"), 0, optGroup);
1372 configView->showPromptAction = new QAction(_("Show Prompt Options"), 0, optGroup);
1373#endif
1351 configView->showNormalAction->setToggleAction(TRUE); 1374 configView->showNormalAction->setToggleAction(TRUE);
1352 configView->showNormalAction->setOn(configList->optMode == normalOpt); 1375 configView->showNormalAction->setOn(configList->optMode == normalOpt);
1353 configView->showAllAction->setToggleAction(TRUE); 1376 configView->showAllAction->setToggleAction(TRUE);
@@ -1355,15 +1378,15 @@ ConfigMainWindow::ConfigMainWindow(void)
1355 configView->showPromptAction->setToggleAction(TRUE); 1378 configView->showPromptAction->setToggleAction(TRUE);
1356 configView->showPromptAction->setOn(configList->optMode == promptOpt); 1379 configView->showPromptAction->setOn(configList->optMode == promptOpt);
1357 1380
1358 QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); 1381 Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this);
1359 showDebugAction->setToggleAction(TRUE); 1382 showDebugAction->setToggleAction(TRUE);
1360 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); 1383 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
1361 connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); 1384 connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
1362 showDebugAction->setOn(helpText->showDebug()); 1385 showDebugAction->setOn(helpText->showDebug());
1363 1386
1364 QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this); 1387 Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this);
1365 connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); 1388 connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
1366 QAction *showAboutAction = new QAction(NULL, _("About"), 0, this); 1389 Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this);
1367 connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); 1390 connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
1368 1391
1369 // init tool bar 1392 // init tool bar
@@ -1377,7 +1400,7 @@ ConfigMainWindow::ConfigMainWindow(void)
1377 fullViewAction->addTo(toolBar); 1400 fullViewAction->addTo(toolBar);
1378 1401
1379 // create config menu 1402 // create config menu
1380 QPopupMenu* config = new QPopupMenu(this); 1403 Q3PopupMenu* config = new Q3PopupMenu(this);
1381 menu->insertItem(_("&File"), config); 1404 menu->insertItem(_("&File"), config);
1382 loadAction->addTo(config); 1405 loadAction->addTo(config);
1383 saveAction->addTo(config); 1406 saveAction->addTo(config);
@@ -1386,12 +1409,12 @@ ConfigMainWindow::ConfigMainWindow(void)
1386 quitAction->addTo(config); 1409 quitAction->addTo(config);
1387 1410
1388 // create edit menu 1411 // create edit menu
1389 QPopupMenu* editMenu = new QPopupMenu(this); 1412 Q3PopupMenu* editMenu = new Q3PopupMenu(this);
1390 menu->insertItem(_("&Edit"), editMenu); 1413 menu->insertItem(_("&Edit"), editMenu);
1391 searchAction->addTo(editMenu); 1414 searchAction->addTo(editMenu);
1392 1415
1393 // create options menu 1416 // create options menu
1394 QPopupMenu* optionMenu = new QPopupMenu(this); 1417 Q3PopupMenu* optionMenu = new Q3PopupMenu(this);
1395 menu->insertItem(_("&Option"), optionMenu); 1418 menu->insertItem(_("&Option"), optionMenu);
1396 showNameAction->addTo(optionMenu); 1419 showNameAction->addTo(optionMenu);
1397 showRangeAction->addTo(optionMenu); 1420 showRangeAction->addTo(optionMenu);
@@ -1399,10 +1422,9 @@ ConfigMainWindow::ConfigMainWindow(void)
1399 optionMenu->insertSeparator(); 1422 optionMenu->insertSeparator();
1400 optGroup->addTo(optionMenu); 1423 optGroup->addTo(optionMenu);
1401 optionMenu->insertSeparator(); 1424 optionMenu->insertSeparator();
1402 showDebugAction->addTo(optionMenu);
1403 1425
1404 // create help menu 1426 // create help menu
1405 QPopupMenu* helpMenu = new QPopupMenu(this); 1427 Q3PopupMenu* helpMenu = new Q3PopupMenu(this);
1406 menu->insertSeparator(); 1428 menu->insertSeparator();
1407 menu->insertItem(_("&Help"), helpMenu); 1429 menu->insertItem(_("&Help"), helpMenu);
1408 showIntroAction->addTo(helpMenu); 1430 showIntroAction->addTo(helpMenu);
@@ -1437,7 +1459,7 @@ ConfigMainWindow::ConfigMainWindow(void)
1437 showSplitView(); 1459 showSplitView();
1438 1460
1439 // UI setup done, restore splitter positions 1461 // UI setup done, restore splitter positions
1440 QValueList<int> sizes = configSettings->readSizes("/split1", &ok); 1462 Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok);
1441 if (ok) 1463 if (ok)
1442 split1->setSizes(sizes); 1464 split1->setSizes(sizes);
1443 1465
@@ -1448,7 +1470,7 @@ ConfigMainWindow::ConfigMainWindow(void)
1448 1470
1449void ConfigMainWindow::loadConfig(void) 1471void ConfigMainWindow::loadConfig(void)
1450{ 1472{
1451 QString s = QFileDialog::getOpenFileName(conf_get_configname(), NULL, this); 1473 QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this);
1452 if (s.isNull()) 1474 if (s.isNull())
1453 return; 1475 return;
1454 if (conf_read(QFile::encodeName(s))) 1476 if (conf_read(QFile::encodeName(s)))
@@ -1464,11 +1486,10 @@ void ConfigMainWindow::saveConfig(void)
1464 1486
1465void ConfigMainWindow::saveConfigAs(void) 1487void ConfigMainWindow::saveConfigAs(void)
1466{ 1488{
1467 QString s = QFileDialog::getSaveFileName(conf_get_configname(), NULL, this); 1489 QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this);
1468 if (s.isNull()) 1490 if (s.isNull())
1469 return; 1491 return;
1470 if (conf_write(QFile::encodeName(s))) 1492 saveConfig();
1471 QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
1472} 1493}
1473 1494
1474void ConfigMainWindow::searchConfig(void) 1495void ConfigMainWindow::searchConfig(void)
@@ -1621,7 +1642,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
1621 mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); 1642 mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
1622 switch (mb.exec()) { 1643 switch (mb.exec()) {
1623 case QMessageBox::Yes: 1644 case QMessageBox::Yes:
1624 conf_write(NULL); 1645 saveConfig();
1625 case QMessageBox::No: 1646 case QMessageBox::No:
1626 e->accept(); 1647 e->accept();
1627 break; 1648 break;
@@ -1633,7 +1654,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
1633 1654
1634void ConfigMainWindow::showIntro(void) 1655void ConfigMainWindow::showIntro(void)
1635{ 1656{
1636 static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" 1657 static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
1637 "For each option, a blank box indicates the feature is disabled, a check\n" 1658 "For each option, a blank box indicates the feature is disabled, a check\n"
1638 "indicates it is enabled, and a dot indicates that it is to be compiled\n" 1659 "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1639 "as a module. Clicking on the box will cycle through the three states.\n\n" 1660 "as a module. Clicking on the box will cycle through the three states.\n\n"
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index 636a74b23bf9..91677d900dbd 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -3,26 +3,25 @@
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#if QT_VERSION < 0x040000
6#include <qlistview.h> 7#include <qlistview.h>
7#if QT_VERSION >= 300
8#include <qsettings.h>
9#else 8#else
10class QSettings { 9#include <q3listview.h>
11public: 10#endif
12 void beginGroup(const QString& group) { } 11#include <qsettings.h>
13 void endGroup(void) { } 12
14 bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const 13#if QT_VERSION < 0x040000
15 { if (ok) *ok = FALSE; return def; } 14#define Q3ValueList QValueList
16 int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const 15#define Q3PopupMenu QPopupMenu
17 { if (ok) *ok = FALSE; return def; } 16#define Q3ListView QListView
18 QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const 17#define Q3ListViewItem QListViewItem
19 { if (ok) *ok = FALSE; return def; } 18#define Q3VBox QVBox
20 QStringList readListEntry(const QString& key, bool* ok = 0) const 19#define Q3TextBrowser QTextBrowser
21 { if (ok) *ok = FALSE; return QStringList(); } 20#define Q3MainWindow QMainWindow
22 template <class t> 21#define Q3Action QAction
23 bool writeEntry(const QString& key, t value) 22#define Q3ToolBar QToolBar
24 { return TRUE; } 23#define Q3ListViewItemIterator QListViewItemIterator
25}; 24#define Q3FileDialog QFileDialog
26#endif 25#endif
27 26
28class ConfigView; 27class ConfigView;
@@ -31,11 +30,10 @@ class ConfigItem;
31class ConfigLineEdit; 30class ConfigLineEdit;
32class ConfigMainWindow; 31class ConfigMainWindow;
33 32
34
35class ConfigSettings : public QSettings { 33class ConfigSettings : public QSettings {
36public: 34public:
37 QValueList<int> readSizes(const QString& key, bool *ok); 35 Q3ValueList<int> readSizes(const QString& key, bool *ok);
38 bool writeSizes(const QString& key, const QValueList<int>& value); 36 bool writeSizes(const QString& key, const Q3ValueList<int>& value);
39}; 37};
40 38
41enum colIdx { 39enum colIdx {
@@ -48,9 +46,9 @@ enum optionMode {
48 normalOpt = 0, allOpt, promptOpt 46 normalOpt = 0, allOpt, promptOpt
49}; 47};
50 48
51class ConfigList : public QListView { 49class ConfigList : public Q3ListView {
52 Q_OBJECT 50 Q_OBJECT
53 typedef class QListView Parent; 51 typedef class Q3ListView Parent;
54public: 52public:
55 ConfigList(ConfigView* p, const char *name = 0); 53 ConfigList(ConfigView* p, const char *name = 0);
56 void reinit(void); 54 void reinit(void);
@@ -135,17 +133,17 @@ public:
135 struct menu *rootEntry; 133 struct menu *rootEntry;
136 QColorGroup disabledColorGroup; 134 QColorGroup disabledColorGroup;
137 QColorGroup inactivedColorGroup; 135 QColorGroup inactivedColorGroup;
138 QPopupMenu* headerPopup; 136 Q3PopupMenu* headerPopup;
139 137
140private: 138private:
141 int colMap[colNr]; 139 int colMap[colNr];
142 int colRevMap[colNr]; 140 int colRevMap[colNr];
143}; 141};
144 142
145class ConfigItem : public QListViewItem { 143class ConfigItem : public Q3ListViewItem {
146 typedef class QListViewItem Parent; 144 typedef class Q3ListViewItem Parent;
147public: 145public:
148 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) 146 ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
149 : Parent(parent, after), menu(m), visible(v), goParent(false) 147 : Parent(parent, after), menu(m), visible(v), goParent(false)
150 { 148 {
151 init(); 149 init();
@@ -155,16 +153,14 @@ public:
155 { 153 {
156 init(); 154 init();
157 } 155 }
158 ConfigItem(QListView *parent, ConfigItem *after, bool v) 156 ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
159 : Parent(parent, after), menu(0), visible(v), goParent(true) 157 : Parent(parent, after), menu(0), visible(v), goParent(true)
160 { 158 {
161 init(); 159 init();
162 } 160 }
163 ~ConfigItem(void); 161 ~ConfigItem(void);
164 void init(void); 162 void init(void);
165#if QT_VERSION >= 300
166 void okRename(int col); 163 void okRename(int col);
167#endif
168 void updateMenu(void); 164 void updateMenu(void);
169 void testUpdateMenu(bool v); 165 void testUpdateMenu(bool v);
170 ConfigList* listView() const 166 ConfigList* listView() const
@@ -219,9 +215,9 @@ public:
219 ConfigItem *item; 215 ConfigItem *item;
220}; 216};
221 217
222class ConfigView : public QVBox { 218class ConfigView : public Q3VBox {
223 Q_OBJECT 219 Q_OBJECT
224 typedef class QVBox Parent; 220 typedef class Q3VBox Parent;
225public: 221public:
226 ConfigView(QWidget* parent, const char *name = 0); 222 ConfigView(QWidget* parent, const char *name = 0);
227 ~ConfigView(void); 223 ~ConfigView(void);
@@ -252,9 +248,9 @@ public:
252 static QAction *showPromptAction; 248 static QAction *showPromptAction;
253}; 249};
254 250
255class ConfigInfoView : public QTextBrowser { 251class ConfigInfoView : public Q3TextBrowser {
256 Q_OBJECT 252 Q_OBJECT
257 typedef class QTextBrowser Parent; 253 typedef class Q3TextBrowser Parent;
258public: 254public:
259 ConfigInfoView(QWidget* parent, const char *name = 0); 255 ConfigInfoView(QWidget* parent, const char *name = 0);
260 bool showDebug(void) const { return _showDebug; } 256 bool showDebug(void) const { return _showDebug; }
@@ -274,11 +270,11 @@ protected:
274 QString debug_info(struct symbol *sym); 270 QString debug_info(struct symbol *sym);
275 static QString print_filter(const QString &str); 271 static QString print_filter(const QString &str);
276 static void expr_print_help(void *data, struct symbol *sym, const char *str); 272 static void expr_print_help(void *data, struct symbol *sym, const char *str);
277 QPopupMenu* createPopupMenu(const QPoint& pos); 273 Q3PopupMenu* createPopupMenu(const QPoint& pos);
278 void contentsContextMenuEvent(QContextMenuEvent *e); 274 void contentsContextMenuEvent(QContextMenuEvent *e);
279 275
280 struct symbol *sym; 276 struct symbol *sym;
281 struct menu *menu; 277 struct menu *_menu;
282 bool _showDebug; 278 bool _showDebug;
283}; 279};
284 280
@@ -302,10 +298,10 @@ protected:
302 struct symbol **result; 298 struct symbol **result;
303}; 299};
304 300
305class ConfigMainWindow : public QMainWindow { 301class ConfigMainWindow : public Q3MainWindow {
306 Q_OBJECT 302 Q_OBJECT
307 303
308 static QAction *saveAction; 304 static Q3Action *saveAction;
309 static void conf_changed(void); 305 static void conf_changed(void);
310public: 306public:
311 ConfigMainWindow(void); 307 ConfigMainWindow(void);
@@ -334,8 +330,8 @@ protected:
334 ConfigView *configView; 330 ConfigView *configView;
335 ConfigList *configList; 331 ConfigList *configList;
336 ConfigInfoView *helpText; 332 ConfigInfoView *helpText;
337 QToolBar *toolBar; 333 Q3ToolBar *toolBar;
338 QAction *backAction; 334 Q3Action *backAction;
339 QSplitter* split1; 335 QSplitter* split1;
340 QSplitter* split2; 336 QSplitter* split2;
341}; 337};
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index c70a27d924f0..a4fe923c0131 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -1,6 +1,6 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2# 2#
3# Copywrite 2005-2009 - Steven Rostedt 3# Copyright 2005-2009 - Steven Rostedt
4# Licensed under the terms of the GNU GPL License version 2 4# Licensed under the terms of the GNU GPL License version 2
5# 5#
6# It's simple enough to figure out how this works. 6# It's simple enough to figure out how this works.
@@ -42,6 +42,8 @@
42# mv config_strip .config 42# mv config_strip .config
43# make oldconfig 43# make oldconfig
44# 44#
45use strict;
46
45my $config = ".config"; 47my $config = ".config";
46 48
47my $uname = `uname -r`; 49my $uname = `uname -r`;
@@ -123,7 +125,6 @@ my %selects;
123my %prompts; 125my %prompts;
124my %objects; 126my %objects;
125my $var; 127my $var;
126my $cont = 0;
127my $iflevel = 0; 128my $iflevel = 0;
128my @ifdeps; 129my @ifdeps;
129 130
@@ -137,19 +138,45 @@ sub read_kconfig {
137 my $config; 138 my $config;
138 my @kconfigs; 139 my @kconfigs;
139 140
140 open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig"; 141 my $cont = 0;
142 my $line;
143
144 my $source = "$ksource/$kconfig";
145 my $last_source = "";
146
147 # Check for any environment variables used
148 while ($source =~ /\$(\w+)/ && $last_source ne $source) {
149 my $env = $1;
150 $last_source = $source;
151 $source =~ s/\$$env/$ENV{$env}/;
152 }
153
154 open(KIN, "$source") || die "Can't open $kconfig";
141 while (<KIN>) { 155 while (<KIN>) {
142 chomp; 156 chomp;
143 157
158 # Make sure that lines ending with \ continue
159 if ($cont) {
160 $_ = $line . " " . $_;
161 }
162
163 if (s/\\$//) {
164 $cont = 1;
165 $line = $_;
166 next;
167 }
168
169 $cont = 0;
170
144 # collect any Kconfig sources 171 # collect any Kconfig sources
145 if (/^source\s*"(.*)"/) { 172 if (/^source\s*"(.*)"/) {
146 $kconfigs[$#kconfigs+1] = $1; 173 $kconfigs[$#kconfigs+1] = $1;
147 } 174 }
148 175
149 # configs found 176 # configs found
150 if (/^\s*config\s+(\S+)\s*$/) { 177 if (/^\s*(menu)?config\s+(\S+)\s*$/) {
151 $state = "NEW"; 178 $state = "NEW";
152 $config = $1; 179 $config = $2;
153 180
154 for (my $i = 0; $i < $iflevel; $i++) { 181 for (my $i = 0; $i < $iflevel; $i++) {
155 if ($i) { 182 if ($i) {
@@ -178,7 +205,7 @@ sub read_kconfig {
178 # configs without prompts must be selected 205 # configs without prompts must be selected
179 } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { 206 } elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
180 # note if the config has a prompt 207 # note if the config has a prompt
181 $prompt{$config} = 1; 208 $prompts{$config} = 1;
182 209
183 # Check for if statements 210 # Check for if statements
184 } elsif (/^if\s+(.*\S)\s*$/) { 211 } elsif (/^if\s+(.*\S)\s*$/) {
@@ -218,6 +245,8 @@ if ($kconfig) {
218# Read all Makefiles to map the configs to the objects 245# Read all Makefiles to map the configs to the objects
219foreach my $makefile (@makefiles) { 246foreach my $makefile (@makefiles) {
220 247
248 my $cont = 0;
249
221 open(MIN,$makefile) || die "Can't open $makefile"; 250 open(MIN,$makefile) || die "Can't open $makefile";
222 while (<MIN>) { 251 while (<MIN>) {
223 my $objs; 252 my $objs;
@@ -281,7 +310,7 @@ if (defined($lsmod_file)) {
281 # see what modules are loaded on this system 310 # see what modules are loaded on this system
282 my $lsmod; 311 my $lsmod;
283 312
284 foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) { 313 foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
285 if ( -x "$dir/lsmod" ) { 314 if ( -x "$dir/lsmod" ) {
286 $lsmod = "$dir/lsmod"; 315 $lsmod = "$dir/lsmod";
287 last; 316 last;
@@ -363,7 +392,7 @@ while ($repeat) {
363 parse_config_dep_select $depends{$config}; 392 parse_config_dep_select $depends{$config};
364 } 393 }
365 394
366 if (defined($prompt{$config}) || !defined($selects{$config})) { 395 if (defined($prompts{$config}) || !defined($selects{$config})) {
367 next; 396 next;
368 } 397 }
369 398
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 1f8b305449db..a796c95fe8a0 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -350,16 +350,18 @@ void sym_calc_value(struct symbol *sym)
350 } 350 }
351 } 351 }
352 calc_newval: 352 calc_newval:
353#if 0
354 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { 353 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
354 struct expr *e;
355 e = expr_simplify_unmet_dep(sym->rev_dep.expr,
356 sym->dir_dep.expr);
355 fprintf(stderr, "warning: ("); 357 fprintf(stderr, "warning: (");
356 expr_fprint(sym->rev_dep.expr, stderr); 358 expr_fprint(e, stderr);
357 fprintf(stderr, ") selects %s which has unmet direct dependencies (", 359 fprintf(stderr, ") selects %s which has unmet direct dependencies (",
358 sym->name); 360 sym->name);
359 expr_fprint(sym->dir_dep.expr, stderr); 361 expr_fprint(sym->dir_dep.expr, stderr);
360 fprintf(stderr, ")\n"); 362 fprintf(stderr, ")\n");
363 expr_free(e);
361 } 364 }
362#endif
363 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); 365 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
364 } 366 }
365 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) 367 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
@@ -688,7 +690,7 @@ const char *sym_get_string_default(struct symbol *sym)
688 switch (sym->type) { 690 switch (sym->type) {
689 case S_BOOLEAN: 691 case S_BOOLEAN:
690 case S_TRISTATE: 692 case S_TRISTATE:
691 /* The visibility imay limit the value from yes => mod */ 693 /* The visibility may limit the value from yes => mod */
692 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); 694 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
693 break; 695 break;
694 default: 696 default:
@@ -842,6 +844,55 @@ struct symbol *sym_find(const char *name)
842 return symbol; 844 return symbol;
843} 845}
844 846
847/*
848 * Expand symbol's names embedded in the string given in argument. Symbols'
849 * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
850 * the empty string.
851 */
852const char *sym_expand_string_value(const char *in)
853{
854 const char *src;
855 char *res;
856 size_t reslen;
857
858 reslen = strlen(in) + 1;
859 res = malloc(reslen);
860 res[0] = '\0';
861
862 while ((src = strchr(in, '$'))) {
863 char *p, name[SYMBOL_MAXLENGTH];
864 const char *symval = "";
865 struct symbol *sym;
866 size_t newlen;
867
868 strncat(res, in, src - in);
869 src++;
870
871 p = name;
872 while (isalnum(*src) || *src == '_')
873 *p++ = *src++;
874 *p = '\0';
875
876 sym = sym_find(name);
877 if (sym != NULL) {
878 sym_calc_value(sym);
879 symval = sym_get_string_value(sym);
880 }
881
882 newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
883 if (newlen > reslen) {
884 reslen = newlen;
885 res = realloc(res, reslen);
886 }
887
888 strcat(res, symval);
889 in = src;
890 }
891 strcat(res, in);
892
893 return res;
894}
895
845struct symbol **sym_re_search(const char *pattern) 896struct symbol **sym_re_search(const char *pattern)
846{ 897{
847 struct symbol *sym, **sym_arr = NULL; 898 struct symbol *sym, **sym_arr = NULL;
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 78b5c04e736b..6330cc871a47 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -12,15 +12,18 @@
12struct file *file_lookup(const char *name) 12struct file *file_lookup(const char *name)
13{ 13{
14 struct file *file; 14 struct file *file;
15 const char *file_name = sym_expand_string_value(name);
15 16
16 for (file = file_list; file; file = file->next) { 17 for (file = file_list; file; file = file->next) {
17 if (!strcmp(name, file->name)) 18 if (!strcmp(name, file->name)) {
19 free((void *)file_name);
18 return file; 20 return file;
21 }
19 } 22 }
20 23
21 file = malloc(sizeof(*file)); 24 file = malloc(sizeof(*file));
22 memset(file, 0, sizeof(*file)); 25 memset(file, 0, sizeof(*file));
23 file->name = strdup(name); 26 file->name = file_name;
24 file->next = file_list; 27 file->next = file_list;
25 file_list = file; 28 file_list = file;
26 return file; 29 return file;
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index d8bc74249622..c9e690eb7545 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -38,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX
38string, T_TYPE, TF_COMMAND, S_STRING 38string, T_TYPE, TF_COMMAND, S_STRING
39select, T_SELECT, TF_COMMAND 39select, T_SELECT, TF_COMMAND
40range, T_RANGE, TF_COMMAND 40range, T_RANGE, TF_COMMAND
41visible, T_VISIBLE, TF_COMMAND
41option, T_OPTION, TF_COMMAND 42option, T_OPTION, TF_COMMAND
42on, T_ON, TF_PARAM 43on, T_ON, TF_PARAM
43modules, T_OPT_MODULES, TF_OPTION 44modules, T_OPT_MODULES, TF_OPTION
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
index c1748faf4634..4055d5de1750 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -32,7 +32,7 @@
32struct kconf_id; 32struct kconf_id;
33 33
34static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); 34static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
35/* maximum key range = 47, duplicates = 0 */ 35/* maximum key range = 50, duplicates = 0 */
36 36
37#ifdef __GNUC__ 37#ifdef __GNUC__
38__inline 38__inline
@@ -46,32 +46,32 @@ kconf_id_hash (register const char *str, register unsigned int len)
46{ 46{
47 static unsigned char asso_values[] = 47 static unsigned char asso_values[] =
48 { 48 {
49 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
50 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
51 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 51 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 52 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
53 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
54 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 54 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
55 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 55 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
56 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 56 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
57 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 57 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
58 49, 49, 49, 49, 49, 49, 49, 49, 11, 5, 58 52, 52, 52, 52, 52, 52, 52, 52, 40, 5,
59 0, 0, 5, 49, 5, 20, 49, 49, 5, 20, 59 0, 0, 5, 52, 0, 20, 52, 52, 10, 20,
60 5, 0, 30, 49, 0, 15, 0, 10, 0, 49, 60 5, 0, 35, 52, 0, 30, 0, 15, 0, 52,
61 25, 49, 49, 49, 49, 49, 49, 49, 49, 49, 61 15, 52, 52, 52, 52, 52, 52, 52, 52, 52,
62 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 62 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
63 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 63 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
64 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 64 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
65 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 65 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
66 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 66 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
67 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 67 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
68 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 68 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
69 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 69 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
70 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 70 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
71 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 71 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
72 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 72 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
73 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 73 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
74 49, 49, 49, 49, 49, 49 74 52, 52, 52, 52, 52, 52
75 }; 75 };
76 register int hval = len; 76 register int hval = len;
77 77
@@ -102,25 +102,26 @@ struct kconf_id_strings_t
102 char kconf_id_strings_str12[sizeof("default")]; 102 char kconf_id_strings_str12[sizeof("default")];
103 char kconf_id_strings_str13[sizeof("def_bool")]; 103 char kconf_id_strings_str13[sizeof("def_bool")];
104 char kconf_id_strings_str14[sizeof("help")]; 104 char kconf_id_strings_str14[sizeof("help")];
105 char kconf_id_strings_str15[sizeof("bool")];
106 char kconf_id_strings_str16[sizeof("config")]; 105 char kconf_id_strings_str16[sizeof("config")];
107 char kconf_id_strings_str17[sizeof("def_tristate")]; 106 char kconf_id_strings_str17[sizeof("def_tristate")];
108 char kconf_id_strings_str18[sizeof("boolean")]; 107 char kconf_id_strings_str18[sizeof("hex")];
109 char kconf_id_strings_str19[sizeof("defconfig_list")]; 108 char kconf_id_strings_str19[sizeof("defconfig_list")];
110 char kconf_id_strings_str21[sizeof("string")];
111 char kconf_id_strings_str22[sizeof("if")]; 109 char kconf_id_strings_str22[sizeof("if")];
112 char kconf_id_strings_str23[sizeof("int")]; 110 char kconf_id_strings_str23[sizeof("int")];
113 char kconf_id_strings_str26[sizeof("select")];
114 char kconf_id_strings_str27[sizeof("modules")]; 111 char kconf_id_strings_str27[sizeof("modules")];
115 char kconf_id_strings_str28[sizeof("tristate")]; 112 char kconf_id_strings_str28[sizeof("tristate")];
116 char kconf_id_strings_str29[sizeof("menu")]; 113 char kconf_id_strings_str29[sizeof("menu")];
117 char kconf_id_strings_str31[sizeof("source")];
118 char kconf_id_strings_str32[sizeof("comment")]; 114 char kconf_id_strings_str32[sizeof("comment")];
119 char kconf_id_strings_str33[sizeof("hex")];
120 char kconf_id_strings_str35[sizeof("menuconfig")]; 115 char kconf_id_strings_str35[sizeof("menuconfig")];
121 char kconf_id_strings_str36[sizeof("prompt")]; 116 char kconf_id_strings_str36[sizeof("string")];
122 char kconf_id_strings_str37[sizeof("depends")]; 117 char kconf_id_strings_str37[sizeof("visible")];
118 char kconf_id_strings_str41[sizeof("prompt")];
119 char kconf_id_strings_str42[sizeof("depends")];
120 char kconf_id_strings_str44[sizeof("bool")];
121 char kconf_id_strings_str46[sizeof("select")];
122 char kconf_id_strings_str47[sizeof("boolean")];
123 char kconf_id_strings_str48[sizeof("mainmenu")]; 123 char kconf_id_strings_str48[sizeof("mainmenu")];
124 char kconf_id_strings_str51[sizeof("source")];
124 }; 125 };
125static struct kconf_id_strings_t kconf_id_strings_contents = 126static struct kconf_id_strings_t kconf_id_strings_contents =
126 { 127 {
@@ -136,25 +137,26 @@ static struct kconf_id_strings_t kconf_id_strings_contents =
136 "default", 137 "default",
137 "def_bool", 138 "def_bool",
138 "help", 139 "help",
139 "bool",
140 "config", 140 "config",
141 "def_tristate", 141 "def_tristate",
142 "boolean", 142 "hex",
143 "defconfig_list", 143 "defconfig_list",
144 "string",
145 "if", 144 "if",
146 "int", 145 "int",
147 "select",
148 "modules", 146 "modules",
149 "tristate", 147 "tristate",
150 "menu", 148 "menu",
151 "source",
152 "comment", 149 "comment",
153 "hex",
154 "menuconfig", 150 "menuconfig",
151 "string",
152 "visible",
155 "prompt", 153 "prompt",
156 "depends", 154 "depends",
157 "mainmenu" 155 "bool",
156 "select",
157 "boolean",
158 "mainmenu",
159 "source"
158 }; 160 };
159#define kconf_id_strings ((const char *) &kconf_id_strings_contents) 161#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
160#ifdef __GNUC__ 162#ifdef __GNUC__
@@ -168,11 +170,11 @@ kconf_id_lookup (register const char *str, register unsigned int len)
168{ 170{
169 enum 171 enum
170 { 172 {
171 TOTAL_KEYWORDS = 31, 173 TOTAL_KEYWORDS = 32,
172 MIN_WORD_LENGTH = 2, 174 MIN_WORD_LENGTH = 2,
173 MAX_WORD_LENGTH = 14, 175 MAX_WORD_LENGTH = 14,
174 MIN_HASH_VALUE = 2, 176 MIN_HASH_VALUE = 2,
175 MAX_HASH_VALUE = 48 177 MAX_HASH_VALUE = 51
176 }; 178 };
177 179
178 static struct kconf_id wordlist[] = 180 static struct kconf_id wordlist[] =
@@ -191,31 +193,35 @@ kconf_id_lookup (register const char *str, register unsigned int len)
191 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, 193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
192 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, 194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, 195 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND},
194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN}, 196 {-1},
195 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, 197 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND},
196 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, 198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
197 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN}, 199 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX},
198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, 200 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION},
199 {-1}, 201 {-1}, {-1},
200 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
201 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, 202 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
202 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, 203 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
203 {-1}, {-1}, 204 {-1}, {-1}, {-1},
204 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
205 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, 205 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
206 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, 206 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
207 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, 207 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
208 {-1}, 208 {-1}, {-1},
209 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND},
210 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, 209 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
211 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, 210 {-1}, {-1},
212 {-1},
213 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, 211 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND},
214 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND}, 212 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING},
215 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND}, 213 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND},
216 {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, 214 {-1}, {-1}, {-1},
215 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND},
216 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND},
217 {-1}, 217 {-1},
218 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} 218 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN},
219 {-1},
220 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND},
221 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
222 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND},
223 {-1}, {-1},
224 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND}
219 }; 225 };
220 226
221 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 227 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index d8f7236cb0a3..b22f884f9022 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -294,37 +294,45 @@ void zconf_initscan(const char *name)
294 294
295 current_file = file_lookup(name); 295 current_file = file_lookup(name);
296 current_file->lineno = 1; 296 current_file->lineno = 1;
297 current_file->flags = FILE_BUSY;
298} 297}
299 298
300void zconf_nextfile(const char *name) 299void zconf_nextfile(const char *name)
301{ 300{
301 struct file *iter;
302 struct file *file = file_lookup(name); 302 struct file *file = file_lookup(name);
303 struct buffer *buf = malloc(sizeof(*buf)); 303 struct buffer *buf = malloc(sizeof(*buf));
304 memset(buf, 0, sizeof(*buf)); 304 memset(buf, 0, sizeof(*buf));
305 305
306 current_buf->state = YY_CURRENT_BUFFER; 306 current_buf->state = YY_CURRENT_BUFFER;
307 yyin = zconf_fopen(name); 307 yyin = zconf_fopen(file->name);
308 if (!yyin) { 308 if (!yyin) {
309 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); 309 printf("%s:%d: can't open file \"%s\"\n",
310 zconf_curname(), zconf_lineno(), file->name);
310 exit(1); 311 exit(1);
311 } 312 }
312 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); 313 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
313 buf->parent = current_buf; 314 buf->parent = current_buf;
314 current_buf = buf; 315 current_buf = buf;
315 316
316 if (file->flags & FILE_BUSY) { 317 for (iter = current_file->parent; iter; iter = iter->parent ) {
317 printf("%s:%d: do not source '%s' from itself\n", 318 if (!strcmp(current_file->name,iter->name) ) {
318 zconf_curname(), zconf_lineno(), name); 319 printf("%s:%d: recursive inclusion detected. "
319 exit(1); 320 "Inclusion path:\n current file : '%s'\n",
320 } 321 zconf_curname(), zconf_lineno(),
321 if (file->flags & FILE_SCANNED) { 322 zconf_curname());
322 printf("%s:%d: file '%s' is already sourced from '%s'\n", 323 iter = current_file->parent;
323 zconf_curname(), zconf_lineno(), name, 324 while (iter && \
324 file->parent->name); 325 strcmp(iter->name,current_file->name)) {
325 exit(1); 326 printf(" included from: '%s:%d'\n",
327 iter->name, iter->lineno-1);
328 iter = iter->parent;
329 }
330 if (iter)
331 printf(" included from: '%s:%d'\n",
332 iter->name, iter->lineno+1);
333 exit(1);
334 }
326 } 335 }
327 file->flags |= FILE_BUSY;
328 file->lineno = 1; 336 file->lineno = 1;
329 file->parent = current_file; 337 file->parent = current_file;
330 current_file = file; 338 current_file = file;
@@ -334,8 +342,6 @@ static void zconf_endfile(void)
334{ 342{
335 struct buffer *parent; 343 struct buffer *parent;
336 344
337 current_file->flags |= FILE_SCANNED;
338 current_file->flags &= ~FILE_BUSY;
339 current_file = current_file->parent; 345 current_file = current_file->parent;
340 346
341 parent = current_buf->parent; 347 parent = current_buf->parent;
@@ -353,7 +359,7 @@ int zconf_lineno(void)
353 return current_pos.lineno; 359 return current_pos.lineno;
354} 360}
355 361
356char *zconf_curname(void) 362const char *zconf_curname(void)
357{ 363{
358 return current_pos.file ? current_pos.file->name : "<none>"; 364 return current_pos.file ? current_pos.file->name : "<none>";
359} 365}
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 32a9eefd842c..4c5495ea205e 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -160,18 +160,19 @@ static struct menu *current_menu, *current_entry;
160 T_DEFAULT = 275, 160 T_DEFAULT = 275,
161 T_SELECT = 276, 161 T_SELECT = 276,
162 T_RANGE = 277, 162 T_RANGE = 277,
163 T_OPTION = 278, 163 T_VISIBLE = 278,
164 T_ON = 279, 164 T_OPTION = 279,
165 T_WORD = 280, 165 T_ON = 280,
166 T_WORD_QUOTE = 281, 166 T_WORD = 281,
167 T_UNEQUAL = 282, 167 T_WORD_QUOTE = 282,
168 T_CLOSE_PAREN = 283, 168 T_UNEQUAL = 283,
169 T_OPEN_PAREN = 284, 169 T_CLOSE_PAREN = 284,
170 T_EOL = 285, 170 T_OPEN_PAREN = 285,
171 T_OR = 286, 171 T_EOL = 286,
172 T_AND = 287, 172 T_OR = 287,
173 T_EQUAL = 288, 173 T_AND = 288,
174 T_NOT = 289 174 T_EQUAL = 289,
175 T_NOT = 290
175 }; 176 };
176#endif 177#endif
177 178
@@ -417,22 +418,22 @@ union yyalloc
417#endif 418#endif
418 419
419/* YYFINAL -- State number of the termination state. */ 420/* YYFINAL -- State number of the termination state. */
420#define YYFINAL 3 421#define YYFINAL 11
421/* YYLAST -- Last index in YYTABLE. */ 422/* YYLAST -- Last index in YYTABLE. */
422#define YYLAST 259 423#define YYLAST 290
423 424
424/* YYNTOKENS -- Number of terminals. */ 425/* YYNTOKENS -- Number of terminals. */
425#define YYNTOKENS 35 426#define YYNTOKENS 36
426/* YYNNTS -- Number of nonterminals. */ 427/* YYNNTS -- Number of nonterminals. */
427#define YYNNTS 46 428#define YYNNTS 50
428/* YYNRULES -- Number of rules. */ 429/* YYNRULES -- Number of rules. */
429#define YYNRULES 110 430#define YYNRULES 118
430/* YYNRULES -- Number of states. */ 431/* YYNRULES -- Number of states. */
431#define YYNSTATES 180 432#define YYNSTATES 191
432 433
433/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 434/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
434#define YYUNDEFTOK 2 435#define YYUNDEFTOK 2
435#define YYMAXUTOK 289 436#define YYMAXUTOK 290
436 437
437#define YYTRANSLATE(YYX) \ 438#define YYTRANSLATE(YYX) \
438 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 439 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -468,7 +469,8 @@ static const yytype_uint8 yytranslate[] =
468 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 469 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
469 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 470 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
470 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 471 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
471 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 472 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
473 35
472}; 474};
473 475
474#if YYDEBUG 476#if YYDEBUG
@@ -476,73 +478,75 @@ static const yytype_uint8 yytranslate[] =
476 YYRHS. */ 478 YYRHS. */
477static const yytype_uint16 yyprhs[] = 479static const yytype_uint16 yyprhs[] =
478{ 480{
479 0, 0, 3, 5, 6, 9, 12, 15, 20, 23, 481 0, 0, 3, 6, 8, 11, 13, 14, 17, 20,
480 28, 33, 37, 39, 41, 43, 45, 47, 49, 51, 482 23, 26, 31, 36, 40, 42, 44, 46, 48, 50,
481 53, 55, 57, 59, 61, 63, 67, 70, 74, 77, 483 52, 54, 56, 58, 60, 62, 64, 66, 68, 72,
482 81, 84, 85, 88, 91, 94, 97, 100, 103, 107, 484 75, 79, 82, 86, 89, 90, 93, 96, 99, 102,
483 112, 117, 122, 128, 132, 133, 137, 138, 141, 145, 485 105, 108, 112, 117, 122, 127, 133, 137, 138, 142,
484 148, 150, 154, 155, 158, 161, 164, 167, 170, 175, 486 143, 146, 150, 153, 155, 159, 160, 163, 166, 169,
485 179, 182, 187, 188, 191, 195, 197, 201, 202, 205, 487 172, 175, 180, 184, 187, 192, 193, 196, 200, 202,
486 208, 211, 215, 218, 220, 224, 225, 228, 231, 234, 488 206, 207, 210, 213, 216, 220, 224, 228, 230, 234,
487 238, 242, 245, 248, 251, 252, 255, 258, 261, 266, 489 235, 238, 241, 244, 248, 252, 255, 258, 261, 262,
488 267, 270, 272, 274, 277, 280, 283, 285, 288, 289, 490 265, 268, 271, 276, 277, 280, 283, 286, 287, 290,
489 292, 294, 298, 302, 306, 309, 313, 317, 319, 321, 491 292, 294, 297, 300, 303, 305, 308, 309, 312, 314,
490 322 492 318, 322, 326, 329, 333, 337, 339, 341, 342
491}; 493};
492 494
493/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 495/* YYRHS -- A `-1'-separated list of the rules' RHS. */
494static const yytype_int8 yyrhs[] = 496static const yytype_int8 yyrhs[] =
495{ 497{
496 36, 0, -1, 37, -1, -1, 37, 39, -1, 37, 498 37, 0, -1, 81, 38, -1, 38, -1, 63, 39,
497 53, -1, 37, 64, -1, 37, 3, 74, 76, -1, 499 -1, 39, -1, -1, 39, 41, -1, 39, 55, -1,
498 37, 75, -1, 37, 25, 1, 30, -1, 37, 38, 500 39, 67, -1, 39, 80, -1, 39, 26, 1, 31,
499 1, 30, -1, 37, 1, 30, -1, 16, -1, 18, 501 -1, 39, 40, 1, 31, -1, 39, 1, 31, -1,
500 -1, 19, -1, 21, -1, 17, -1, 22, -1, 20, 502 16, -1, 18, -1, 19, -1, 21, -1, 17, -1,
501 -1, 30, -1, 59, -1, 68, -1, 42, -1, 44, 503 22, -1, 20, -1, 23, -1, 31, -1, 61, -1,
502 -1, 66, -1, 25, 1, 30, -1, 1, 30, -1, 504 71, -1, 44, -1, 46, -1, 69, -1, 26, 1,
503 10, 25, 30, -1, 41, 45, -1, 11, 25, 30, 505 31, -1, 1, 31, -1, 10, 26, 31, -1, 43,
504 -1, 43, 45, -1, -1, 45, 46, -1, 45, 47, 506 47, -1, 11, 26, 31, -1, 45, 47, -1, -1,
505 -1, 45, 72, -1, 45, 70, -1, 45, 40, -1, 507 47, 48, -1, 47, 49, -1, 47, 75, -1, 47,
506 45, 30, -1, 19, 73, 30, -1, 18, 74, 77, 508 73, -1, 47, 42, -1, 47, 31, -1, 19, 78,
507 30, -1, 20, 78, 77, 30, -1, 21, 25, 77, 509 31, -1, 18, 79, 82, 31, -1, 20, 83, 82,
508 30, -1, 22, 79, 79, 77, 30, -1, 23, 48, 510 31, -1, 21, 26, 82, 31, -1, 22, 84, 84,
509 30, -1, -1, 48, 25, 49, -1, -1, 33, 74, 511 82, 31, -1, 24, 50, 31, -1, -1, 50, 26,
510 -1, 7, 80, 30, -1, 50, 54, -1, 75, -1, 512 51, -1, -1, 34, 79, -1, 7, 85, 31, -1,
511 51, 56, 52, -1, -1, 54, 55, -1, 54, 72, 513 52, 56, -1, 80, -1, 53, 58, 54, -1, -1,
512 -1, 54, 70, -1, 54, 30, -1, 54, 40, -1, 514 56, 57, -1, 56, 75, -1, 56, 73, -1, 56,
513 18, 74, 77, 30, -1, 19, 73, 30, -1, 17, 515 31, -1, 56, 42, -1, 18, 79, 82, 31, -1,
514 30, -1, 20, 25, 77, 30, -1, -1, 56, 39, 516 19, 78, 31, -1, 17, 31, -1, 20, 26, 82,
515 -1, 14, 78, 76, -1, 75, -1, 57, 60, 58, 517 31, -1, -1, 58, 41, -1, 14, 83, 81, -1,
516 -1, -1, 60, 39, -1, 60, 64, -1, 60, 53, 518 80, -1, 59, 62, 60, -1, -1, 62, 41, -1,
517 -1, 4, 74, 30, -1, 61, 71, -1, 75, -1, 519 62, 67, -1, 62, 55, -1, 3, 79, 81, -1,
518 62, 65, 63, -1, -1, 65, 39, -1, 65, 64, 520 4, 79, 31, -1, 64, 76, 74, -1, 80, -1,
519 -1, 65, 53, -1, 6, 74, 30, -1, 9, 74, 521 65, 68, 66, -1, -1, 68, 41, -1, 68, 67,
520 30, -1, 67, 71, -1, 12, 30, -1, 69, 13, 522 -1, 68, 55, -1, 6, 79, 31, -1, 9, 79,
521 -1, -1, 71, 72, -1, 71, 30, -1, 71, 40, 523 31, -1, 70, 74, -1, 12, 31, -1, 72, 13,
522 -1, 16, 24, 78, 30, -1, -1, 74, 77, -1, 524 -1, -1, 74, 75, -1, 74, 31, -1, 74, 42,
523 25, -1, 26, -1, 5, 30, -1, 8, 30, -1, 525 -1, 16, 25, 83, 31, -1, -1, 76, 77, -1,
524 15, 30, -1, 30, -1, 76, 30, -1, -1, 14, 526 76, 31, -1, 23, 82, -1, -1, 79, 82, -1,
525 78, -1, 79, -1, 79, 33, 79, -1, 79, 27, 527 26, -1, 27, -1, 5, 31, -1, 8, 31, -1,
526 79, -1, 29, 78, 28, -1, 34, 78, -1, 78, 528 15, 31, -1, 31, -1, 81, 31, -1, -1, 14,
527 31, 78, -1, 78, 32, 78, -1, 25, -1, 26, 529 83, -1, 84, -1, 84, 34, 84, -1, 84, 28,
528 -1, -1, 25, -1 530 84, -1, 30, 83, 29, -1, 35, 83, -1, 83,
531 32, 83, -1, 83, 33, 83, -1, 26, -1, 27,
532 -1, -1, 26, -1
529}; 533};
530 534
531/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 535/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
532static const yytype_uint16 yyrline[] = 536static const yytype_uint16 yyrline[] =
533{ 537{
534 0, 107, 107, 109, 111, 112, 113, 114, 115, 116, 538 0, 108, 108, 108, 110, 110, 112, 114, 115, 116,
535 117, 121, 125, 125, 125, 125, 125, 125, 125, 129, 539 117, 118, 119, 123, 127, 127, 127, 127, 127, 127,
536 130, 131, 132, 133, 134, 138, 139, 145, 153, 159, 540 127, 127, 131, 132, 133, 134, 135, 136, 140, 141,
537 167, 177, 179, 180, 181, 182, 183, 184, 187, 195, 541 147, 155, 161, 169, 179, 181, 182, 183, 184, 185,
538 201, 211, 217, 223, 226, 228, 239, 240, 245, 254, 542 186, 189, 197, 203, 213, 219, 225, 228, 230, 241,
539 259, 267, 270, 272, 273, 274, 275, 276, 279, 285, 543 242, 247, 256, 261, 269, 272, 274, 275, 276, 277,
540 296, 302, 312, 314, 319, 327, 335, 338, 340, 341, 544 278, 281, 287, 298, 304, 314, 316, 321, 329, 337,
541 342, 347, 354, 359, 367, 370, 372, 373, 374, 377, 545 340, 342, 343, 344, 349, 356, 363, 368, 376, 379,
542 385, 392, 399, 405, 412, 414, 415, 416, 419, 427, 546 381, 382, 383, 386, 394, 401, 408, 414, 421, 423,
543 429, 434, 435, 438, 439, 440, 444, 445, 448, 449, 547 424, 425, 428, 436, 438, 439, 442, 449, 451, 456,
544 452, 453, 454, 455, 456, 457, 458, 461, 462, 465, 548 457, 460, 461, 462, 466, 467, 470, 471, 474, 475,
545 466 549 476, 477, 478, 479, 480, 483, 484, 487, 488
546}; 550};
547#endif 551#endif
548 552
@@ -555,19 +559,19 @@ static const char *const yytname[] =
555 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", 559 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
556 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", 560 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
557 "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", 561 "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE",
558 "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", 562 "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
559 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", 563 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
560 "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt", 564 "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
561 "option_error", "config_entry_start", "config_stmt", 565 "common_stmt", "option_error", "config_entry_start", "config_stmt",
562 "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", 566 "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
563 "config_option", "symbol_option", "symbol_option_list", 567 "config_option", "symbol_option", "symbol_option_list",
564 "symbol_option_arg", "choice", "choice_entry", "choice_end", 568 "symbol_option_arg", "choice", "choice_entry", "choice_end",
565 "choice_stmt", "choice_option_list", "choice_option", "choice_block", 569 "choice_stmt", "choice_option_list", "choice_option", "choice_block",
566 "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry", 570 "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
567 "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment", 571 "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
568 "comment_stmt", "help_start", "help", "depends_list", "depends", 572 "comment", "comment_stmt", "help_start", "help", "depends_list",
569 "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", 573 "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
570 "word_opt", 0 574 "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0
571}; 575};
572#endif 576#endif
573 577
@@ -579,42 +583,42 @@ static const yytype_uint16 yytoknum[] =
579 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 583 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
580 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 584 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
581 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 585 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
582 285, 286, 287, 288, 289 586 285, 286, 287, 288, 289, 290
583}; 587};
584# endif 588# endif
585 589
586/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 590/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
587static const yytype_uint8 yyr1[] = 591static const yytype_uint8 yyr1[] =
588{ 592{
589 0, 35, 36, 37, 37, 37, 37, 37, 37, 37, 593 0, 36, 37, 37, 38, 38, 39, 39, 39, 39,
590 37, 37, 38, 38, 38, 38, 38, 38, 38, 39, 594 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
591 39, 39, 39, 39, 39, 40, 40, 41, 42, 43, 595 40, 40, 41, 41, 41, 41, 41, 41, 42, 42,
592 44, 45, 45, 45, 45, 45, 45, 45, 46, 46, 596 43, 44, 45, 46, 47, 47, 47, 47, 47, 47,
593 46, 46, 46, 47, 48, 48, 49, 49, 50, 51, 597 47, 48, 48, 48, 48, 48, 49, 50, 50, 51,
594 52, 53, 54, 54, 54, 54, 54, 54, 55, 55, 598 51, 52, 53, 54, 55, 56, 56, 56, 56, 56,
595 55, 55, 56, 56, 57, 58, 59, 60, 60, 60, 599 56, 57, 57, 57, 57, 58, 58, 59, 60, 61,
596 60, 61, 62, 63, 64, 65, 65, 65, 65, 66, 600 62, 62, 62, 62, 63, 64, 65, 66, 67, 68,
597 67, 68, 69, 70, 71, 71, 71, 71, 72, 73, 601 68, 68, 68, 69, 70, 71, 72, 73, 74, 74,
598 73, 74, 74, 75, 75, 75, 76, 76, 77, 77, 602 74, 74, 75, 76, 76, 76, 77, 78, 78, 79,
599 78, 78, 78, 78, 78, 78, 78, 79, 79, 80, 603 79, 80, 80, 80, 81, 81, 82, 82, 83, 83,
600 80 604 83, 83, 83, 83, 83, 84, 84, 85, 85
601}; 605};
602 606
603/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 607/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
604static const yytype_uint8 yyr2[] = 608static const yytype_uint8 yyr2[] =
605{ 609{
606 0, 2, 1, 0, 2, 2, 2, 4, 2, 4, 610 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
607 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 611 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
608 1, 1, 1, 1, 1, 3, 2, 3, 2, 3, 612 1, 1, 1, 1, 1, 1, 1, 1, 3, 2,
609 2, 0, 2, 2, 2, 2, 2, 2, 3, 4, 613 3, 2, 3, 2, 0, 2, 2, 2, 2, 2,
610 4, 4, 5, 3, 0, 3, 0, 2, 3, 2, 614 2, 3, 4, 4, 4, 5, 3, 0, 3, 0,
611 1, 3, 0, 2, 2, 2, 2, 2, 4, 3, 615 2, 3, 2, 1, 3, 0, 2, 2, 2, 2,
612 2, 4, 0, 2, 3, 1, 3, 0, 2, 2, 616 2, 4, 3, 2, 4, 0, 2, 3, 1, 3,
613 2, 3, 2, 1, 3, 0, 2, 2, 2, 3, 617 0, 2, 2, 2, 3, 3, 3, 1, 3, 0,
614 3, 2, 2, 2, 0, 2, 2, 2, 4, 0, 618 2, 2, 2, 3, 3, 2, 2, 2, 0, 2,
615 2, 1, 1, 2, 2, 2, 1, 2, 0, 2, 619 2, 2, 4, 0, 2, 2, 2, 0, 2, 1,
616 1, 3, 3, 3, 2, 3, 3, 1, 1, 0, 620 1, 2, 2, 2, 1, 2, 0, 2, 1, 3,
617 1 621 3, 3, 2, 3, 3, 1, 1, 0, 1
618}; 622};
619 623
620/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 624/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -622,158 +626,172 @@ static const yytype_uint8 yyr2[] =
622 means the default is an error. */ 626 means the default is an error. */
623static const yytype_uint8 yydefact[] = 627static const yytype_uint8 yydefact[] =
624{ 628{
625 3, 0, 0, 1, 0, 0, 0, 0, 0, 109, 629 6, 0, 104, 0, 3, 0, 6, 6, 99, 100,
626 0, 0, 0, 0, 0, 0, 12, 16, 13, 14, 630 0, 1, 0, 0, 0, 0, 117, 0, 0, 0,
627 18, 15, 17, 0, 19, 0, 4, 31, 22, 31, 631 0, 0, 0, 14, 18, 15, 16, 20, 17, 19,
628 23, 52, 62, 5, 67, 20, 84, 75, 6, 24, 632 21, 0, 22, 0, 7, 34, 25, 34, 26, 55,
629 84, 21, 8, 11, 91, 92, 0, 0, 93, 0, 633 65, 8, 70, 23, 93, 79, 9, 27, 88, 24,
630 110, 0, 94, 0, 0, 0, 107, 108, 0, 0, 634 10, 0, 105, 2, 74, 13, 0, 101, 0, 118,
631 0, 100, 95, 0, 0, 0, 0, 0, 0, 0, 635 0, 102, 0, 0, 0, 115, 116, 0, 0, 0,
632 0, 0, 0, 96, 7, 71, 79, 48, 80, 27, 636 108, 103, 0, 0, 0, 0, 0, 0, 0, 88,
633 29, 0, 104, 0, 0, 64, 0, 0, 9, 10, 637 0, 0, 75, 83, 51, 84, 30, 32, 0, 112,
634 0, 0, 0, 0, 89, 0, 0, 0, 44, 0, 638 0, 0, 67, 0, 0, 11, 12, 0, 0, 0,
635 37, 36, 32, 33, 0, 35, 34, 0, 0, 89, 639 0, 97, 0, 0, 0, 47, 0, 40, 39, 35,
636 0, 56, 57, 53, 55, 54, 63, 51, 50, 68, 640 36, 0, 38, 37, 0, 0, 97, 0, 59, 60,
637 70, 66, 69, 65, 86, 87, 85, 76, 78, 74, 641 56, 58, 57, 66, 54, 53, 71, 73, 69, 72,
638 77, 73, 97, 103, 105, 106, 102, 101, 26, 82, 642 68, 106, 95, 0, 94, 80, 82, 78, 81, 77,
639 0, 98, 0, 98, 98, 98, 0, 0, 0, 83, 643 90, 91, 89, 111, 113, 114, 110, 109, 29, 86,
640 60, 98, 0, 98, 0, 0, 0, 38, 90, 0, 644 0, 106, 0, 106, 106, 106, 0, 0, 0, 87,
641 0, 98, 46, 43, 25, 0, 59, 0, 88, 99, 645 63, 106, 0, 106, 0, 96, 0, 0, 41, 98,
642 39, 40, 41, 0, 0, 45, 58, 61, 42, 47 646 0, 0, 106, 49, 46, 28, 0, 62, 0, 107,
647 92, 42, 43, 44, 0, 0, 48, 61, 64, 45,
648 50
643}; 649};
644 650
645/* YYDEFGOTO[NTERM-NUM]. */ 651/* YYDEFGOTO[NTERM-NUM]. */
646static const yytype_int16 yydefgoto[] = 652static const yytype_int16 yydefgoto[] =
647{ 653{
648 -1, 1, 2, 25, 26, 101, 27, 28, 29, 30, 654 -1, 3, 4, 5, 33, 34, 108, 35, 36, 37,
649 65, 102, 103, 147, 175, 31, 32, 117, 33, 67, 655 38, 74, 109, 110, 157, 186, 39, 40, 124, 41,
650 113, 68, 34, 121, 35, 69, 36, 37, 129, 38, 656 76, 120, 77, 42, 128, 43, 78, 6, 44, 45,
651 71, 39, 40, 41, 104, 105, 70, 106, 142, 143, 657 137, 46, 80, 47, 48, 49, 111, 112, 81, 113,
652 42, 74, 156, 60, 61, 51 658 79, 134, 152, 153, 50, 7, 165, 69, 70, 60
653}; 659};
654 660
655/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 661/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
656 STATE-NUM. */ 662 STATE-NUM. */
657#define YYPACT_NINF -80 663#define YYPACT_NINF -90
658static const yytype_int16 yypact[] = 664static const yytype_int16 yypact[] =
659{ 665{
660 -80, 2, 132, -80, -13, -1, -1, -2, -1, 9, 666 4, 42, -90, 96, -90, 111, -90, 15, -90, -90,
661 33, -1, 27, 40, -3, 38, -80, -80, -80, -80, 667 75, -90, 82, 42, 104, 42, 110, 107, 42, 115,
662 -80, -80, -80, 71, -80, 77, -80, -80, -80, -80, 668 125, -4, 121, -90, -90, -90, -90, -90, -90, -90,
663 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, 669 -90, 162, -90, 163, -90, -90, -90, -90, -90, -90,
664 -80, -80, -80, -80, -80, -80, 57, 61, -80, 63, 670 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
665 -80, 76, -80, 87, 101, 133, -80, -80, -3, -3, 671 -90, 139, -90, -90, 138, -90, 142, -90, 143, -90,
666 195, -6, -80, 136, 149, 39, 104, 65, 150, 5, 672 152, -90, 164, 167, 168, -90, -90, -4, -4, 77,
667 194, 5, 167, -80, 176, -80, -80, -80, -80, -80, 673 -18, -90, 177, 185, 33, 71, 195, 247, 236, -2,
668 -80, 68, -80, -3, -3, 176, 72, 72, -80, -80, 674 236, 171, -90, -90, -90, -90, -90, -90, 41, -90,
669 177, 187, 78, -1, -1, -3, 196, 72, -80, 222, 675 -4, -4, 138, 97, 97, -90, -90, 186, 187, 194,
670 -80, -80, -80, -80, 221, -80, -80, 205, -1, -1, 676 42, 42, -4, 196, 97, -90, 219, -90, -90, -90,
671 211, -80, -80, -80, -80, -80, -80, -80, -80, -80, 677 -90, 210, -90, -90, 204, 42, 42, 199, -90, -90,
672 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80, 678 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
673 -80, -80, -80, -80, 206, -80, -80, -80, -80, -80, 679 -90, 222, -90, 223, -90, -90, -90, -90, -90, -90,
674 -3, 223, 209, 223, 197, 223, 72, 7, 210, -80, 680 -90, -90, -90, -90, 215, -90, -90, -90, -90, -90,
675 -80, 223, 212, 223, 201, -3, 213, -80, -80, 214, 681 -4, 222, 228, 222, -5, 222, 97, 35, 229, -90,
676 215, 223, 208, -80, -80, 216, -80, 217, -80, 113, 682 -90, 222, 232, 222, -4, -90, 135, 233, -90, -90,
677 -80, -80, -80, 218, -1, -80, -80, -80, -80, -80 683 234, 235, 222, 240, -90, -90, 237, -90, 239, -13,
684 -90, -90, -90, -90, 244, 42, -90, -90, -90, -90,
685 -90
678}; 686};
679 687
680/* YYPGOTO[NTERM-NUM]. */ 688/* YYPGOTO[NTERM-NUM]. */
681static const yytype_int16 yypgoto[] = 689static const yytype_int16 yypgoto[] =
682{ 690{
683 -80, -80, -80, -80, 122, -34, -80, -80, -80, -80, 691 -90, -90, 269, 271, -90, 23, -70, -90, -90, -90,
684 220, -80, -80, -80, -80, -80, -80, -80, 59, -80, 692 -90, 243, -90, -90, -90, -90, -90, -90, -90, -48,
685 -80, -80, -80, -80, -80, -80, -80, -80, -80, 125, 693 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
686 -80, -80, -80, -80, -80, 183, 219, 22, 142, -5, 694 -90, -20, -90, -90, -90, -90, -90, 206, 205, -68,
687 147, 192, 69, -54, -79, -80 695 -90, -90, 169, -1, 27, -7, 118, -66, -89, -90
688}; 696};
689 697
690/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 698/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
691 positive, shift that token. If negative, reduce the rule which 699 positive, shift that token. If negative, reduce the rule which
692 number is the opposite. If zero, do what YYDEFACT says. 700 number is the opposite. If zero, do what YYDEFACT says.
693 If YYTABLE_NINF, syntax error. */ 701 If YYTABLE_NINF, syntax error. */
694#define YYTABLE_NINF -82 702#define YYTABLE_NINF -86
695static const yytype_int16 yytable[] = 703static const yytype_int16 yytable[] =
696{ 704{
697 46, 47, 3, 49, 81, 82, 53, 136, 137, 6, 705 10, 88, 89, 54, 146, 147, 119, 1, 122, 164,
698 7, 8, 9, 10, 11, 12, 13, 43, 146, 14, 706 93, 141, 56, 142, 58, 156, 94, 62, 1, 90,
699 15, 86, 56, 57, 44, 45, 58, 87, 48, 134, 707 91, 131, 65, 66, 144, 145, 67, 90, 91, 132,
700 135, 59, 162, 112, 50, 24, 125, 163, 125, -28, 708 127, 68, 136, -31, 97, 2, 154, -31, -31, -31,
701 90, 144, -28, -28, -28, -28, -28, -28, -28, -28, 709 -31, -31, -31, -31, -31, 98, 52, -31, -31, 99,
702 -28, 91, 54, -28, -28, 92, -28, 93, 94, 95, 710 -31, 100, 101, 102, 103, 104, -31, 105, 129, 106,
703 96, 97, 98, 52, 99, 55, 90, 161, 62, 100, 711 138, 173, 92, 141, 107, 142, 174, 172, 8, 9,
704 -49, -49, 63, -49, -49, -49, -49, 91, 64, -49, 712 143, -33, 97, 90, 91, -33, -33, -33, -33, -33,
705 -49, 92, 107, 108, 109, 110, 154, 73, 141, 115, 713 -33, -33, -33, 98, 166, -33, -33, 99, -33, 100,
706 99, 75, 126, 76, 126, 111, 133, 56, 57, 83, 714 101, 102, 103, 104, -33, 105, 11, 106, 179, 151,
707 84, 169, 140, 151, -30, 90, 77, -30, -30, -30, 715 123, 126, 107, 135, 125, 130, 2, 139, 2, 90,
708 -30, -30, -30, -30, -30, -30, 91, 78, -30, -30, 716 91, -5, 12, 55, 161, 13, 14, 15, 16, 17,
709 92, -30, 93, 94, 95, 96, 97, 98, 120, 99, 717 18, 19, 20, 65, 66, 21, 22, 23, 24, 25,
710 128, 79, -2, 4, 100, 5, 6, 7, 8, 9, 718 26, 27, 28, 29, 30, 57, 59, 31, 61, -4,
711 10, 11, 12, 13, 83, 84, 14, 15, 16, 17, 719 12, 63, 32, 13, 14, 15, 16, 17, 18, 19,
712 18, 19, 20, 21, 22, 7, 8, 23, 10, 11, 720 20, 64, 71, 21, 22, 23, 24, 25, 26, 27,
713 12, 13, 24, 80, 14, 15, 88, -81, 90, 179, 721 28, 29, 30, 72, 73, 31, 180, 90, 91, 52,
714 -81, -81, -81, -81, -81, -81, -81, -81, -81, 89, 722 32, -85, 97, 82, 83, -85, -85, -85, -85, -85,
715 24, -81, -81, 92, -81, -81, -81, -81, -81, -81, 723 -85, -85, -85, 84, 190, -85, -85, 99, -85, -85,
716 116, 119, 99, 127, 122, 90, 130, 124, -72, -72, 724 -85, -85, -85, -85, -85, 85, 97, 106, 86, 87,
717 -72, -72, -72, -72, -72, -72, 132, 138, -72, -72, 725 -52, -52, 140, -52, -52, -52, -52, 98, 95, -52,
718 92, 155, 158, 159, 160, 118, 123, 139, 131, 99, 726 -52, 99, 114, 115, 116, 117, 96, 148, 149, 150,
719 165, 145, 167, 148, 124, 73, 83, 84, 83, 84, 727 158, 106, 155, 159, 97, 163, 118, -76, -76, -76,
720 173, 168, 83, 84, 149, 150, 153, 155, 84, 157, 728 -76, -76, -76, -76, -76, 160, 164, -76, -76, 99,
721 164, 174, 166, 170, 171, 172, 176, 177, 178, 66, 729 13, 14, 15, 16, 17, 18, 19, 20, 91, 106,
722 114, 152, 85, 0, 0, 0, 0, 0, 0, 72 730 21, 22, 14, 15, 140, 17, 18, 19, 20, 168,
731 175, 21, 22, 177, 181, 182, 183, 32, 187, 167,
732 188, 169, 170, 171, 185, 189, 53, 51, 32, 176,
733 75, 178, 121, 0, 133, 162, 0, 0, 0, 0,
734 184
723}; 735};
724 736
725static const yytype_int16 yycheck[] = 737static const yytype_int16 yycheck[] =
726{ 738{
727 5, 6, 0, 8, 58, 59, 11, 86, 87, 4, 739 1, 67, 68, 10, 93, 94, 76, 3, 76, 14,
728 5, 6, 7, 8, 9, 10, 11, 30, 97, 14, 740 28, 81, 13, 81, 15, 104, 34, 18, 3, 32,
729 15, 27, 25, 26, 25, 26, 29, 33, 30, 83, 741 33, 23, 26, 27, 90, 91, 30, 32, 33, 31,
730 84, 34, 25, 67, 25, 30, 70, 30, 72, 0, 742 78, 35, 80, 0, 1, 31, 102, 4, 5, 6,
731 1, 95, 3, 4, 5, 6, 7, 8, 9, 10, 743 7, 8, 9, 10, 11, 12, 31, 14, 15, 16,
732 11, 12, 25, 14, 15, 16, 17, 18, 19, 20, 744 17, 18, 19, 20, 21, 22, 23, 24, 78, 26,
733 21, 22, 23, 30, 25, 25, 1, 146, 30, 30, 745 80, 26, 69, 133, 31, 133, 31, 156, 26, 27,
734 5, 6, 1, 8, 9, 10, 11, 12, 1, 14, 746 29, 0, 1, 32, 33, 4, 5, 6, 7, 8,
735 15, 16, 17, 18, 19, 20, 140, 30, 93, 67, 747 9, 10, 11, 12, 150, 14, 15, 16, 17, 18,
736 25, 30, 70, 30, 72, 30, 28, 25, 26, 31, 748 19, 20, 21, 22, 23, 24, 0, 26, 164, 100,
737 32, 155, 24, 108, 0, 1, 30, 3, 4, 5, 749 77, 78, 31, 80, 77, 78, 31, 80, 31, 32,
738 6, 7, 8, 9, 10, 11, 12, 30, 14, 15, 750 33, 0, 1, 31, 115, 4, 5, 6, 7, 8,
739 16, 17, 18, 19, 20, 21, 22, 23, 69, 25, 751 9, 10, 11, 26, 27, 14, 15, 16, 17, 18,
740 71, 30, 0, 1, 30, 3, 4, 5, 6, 7, 752 19, 20, 21, 22, 23, 31, 26, 26, 31, 0,
741 8, 9, 10, 11, 31, 32, 14, 15, 16, 17, 753 1, 26, 31, 4, 5, 6, 7, 8, 9, 10,
742 18, 19, 20, 21, 22, 5, 6, 25, 8, 9, 754 11, 26, 31, 14, 15, 16, 17, 18, 19, 20,
743 10, 11, 30, 30, 14, 15, 30, 0, 1, 174, 755 21, 22, 23, 1, 1, 26, 31, 32, 33, 31,
744 3, 4, 5, 6, 7, 8, 9, 10, 11, 30, 756 31, 0, 1, 31, 31, 4, 5, 6, 7, 8,
745 30, 14, 15, 16, 17, 18, 19, 20, 21, 22, 757 9, 10, 11, 31, 185, 14, 15, 16, 17, 18,
746 68, 69, 25, 71, 69, 1, 71, 30, 4, 5, 758 19, 20, 21, 22, 23, 31, 1, 26, 31, 31,
747 6, 7, 8, 9, 10, 11, 30, 30, 14, 15, 759 5, 6, 31, 8, 9, 10, 11, 12, 31, 14,
748 16, 14, 143, 144, 145, 68, 69, 30, 71, 25, 760 15, 16, 17, 18, 19, 20, 31, 31, 31, 25,
749 151, 25, 153, 1, 30, 30, 31, 32, 31, 32, 761 1, 26, 26, 13, 1, 26, 31, 4, 5, 6,
750 161, 30, 31, 32, 13, 30, 25, 14, 32, 30, 762 7, 8, 9, 10, 11, 31, 14, 14, 15, 16,
751 30, 33, 30, 30, 30, 30, 30, 30, 30, 29, 763 4, 5, 6, 7, 8, 9, 10, 11, 33, 26,
752 67, 109, 60, -1, -1, -1, -1, -1, -1, 40 764 14, 15, 5, 6, 31, 8, 9, 10, 11, 31,
765 31, 14, 15, 31, 31, 31, 31, 31, 31, 151,
766 31, 153, 154, 155, 34, 31, 7, 6, 31, 161,
767 37, 163, 76, -1, 79, 116, -1, -1, -1, -1,
768 172
753}; 769};
754 770
755/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 771/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
756 symbol of state STATE-NUM. */ 772 symbol of state STATE-NUM. */
757static const yytype_uint8 yystos[] = 773static const yytype_uint8 yystos[] =
758{ 774{
759 0, 36, 37, 0, 1, 3, 4, 5, 6, 7, 775 0, 3, 31, 37, 38, 39, 63, 81, 26, 27,
760 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 776 79, 0, 1, 4, 5, 6, 7, 8, 9, 10,
761 20, 21, 22, 25, 30, 38, 39, 41, 42, 43, 777 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
762 44, 50, 51, 53, 57, 59, 61, 62, 64, 66, 778 23, 26, 31, 40, 41, 43, 44, 45, 46, 52,
763 67, 68, 75, 30, 25, 26, 74, 74, 30, 74, 779 53, 55, 59, 61, 64, 65, 67, 69, 70, 71,
764 25, 80, 30, 74, 25, 25, 25, 26, 29, 34, 780 80, 39, 31, 38, 81, 31, 79, 31, 79, 26,
765 78, 79, 30, 1, 1, 45, 45, 54, 56, 60, 781 85, 31, 79, 26, 26, 26, 27, 30, 35, 83,
766 71, 65, 71, 30, 76, 30, 30, 30, 30, 30, 782 84, 31, 1, 1, 47, 47, 56, 58, 62, 76,
767 30, 78, 78, 31, 32, 76, 27, 33, 30, 30, 783 68, 74, 31, 31, 31, 31, 31, 31, 83, 83,
768 1, 12, 16, 18, 19, 20, 21, 22, 23, 25, 784 32, 33, 81, 28, 34, 31, 31, 1, 12, 16,
769 30, 40, 46, 47, 69, 70, 72, 17, 18, 19, 785 18, 19, 20, 21, 22, 24, 26, 31, 42, 48,
770 20, 30, 40, 55, 70, 72, 39, 52, 75, 39, 786 49, 72, 73, 75, 17, 18, 19, 20, 31, 42,
771 53, 58, 64, 75, 30, 40, 72, 39, 53, 63, 787 57, 73, 75, 41, 54, 80, 41, 55, 60, 67,
772 64, 75, 30, 28, 78, 78, 79, 79, 30, 30, 788 80, 23, 31, 74, 77, 41, 55, 66, 67, 80,
773 24, 74, 73, 74, 78, 25, 79, 48, 1, 13, 789 31, 42, 75, 29, 83, 83, 84, 84, 31, 31,
774 30, 74, 73, 25, 78, 14, 77, 30, 77, 77, 790 25, 79, 78, 79, 83, 26, 84, 50, 1, 13,
775 77, 79, 25, 30, 30, 77, 30, 77, 30, 78, 791 31, 79, 78, 26, 14, 82, 83, 82, 31, 82,
776 30, 30, 30, 77, 33, 49, 30, 30, 30, 74 792 82, 82, 84, 26, 31, 31, 82, 31, 82, 83,
793 31, 31, 31, 31, 82, 34, 51, 31, 31, 31,
794 79
777}; 795};
778 796
779#define yyerrok (yyerrstatus = 0) 797#define yyerrok (yyerrstatus = 0)
@@ -1284,7 +1302,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1284 1302
1285 switch (yytype) 1303 switch (yytype)
1286 { 1304 {
1287 case 51: /* "choice_entry" */ 1305 case 53: /* "choice_entry" */
1288 1306
1289 { 1307 {
1290 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1308 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1294,7 +1312,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1294}; 1312};
1295 1313
1296 break; 1314 break;
1297 case 57: /* "if_entry" */ 1315 case 59: /* "if_entry" */
1298 1316
1299 { 1317 {
1300 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1318 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1304,7 +1322,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1304}; 1322};
1305 1323
1306 break; 1324 break;
1307 case 62: /* "menu_entry" */ 1325 case 65: /* "menu_entry" */
1308 1326
1309 { 1327 {
1310 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1328 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1614,39 +1632,39 @@ yyreduce:
1614 YY_REDUCE_PRINT (yyn); 1632 YY_REDUCE_PRINT (yyn);
1615 switch (yyn) 1633 switch (yyn)
1616 { 1634 {
1617 case 8: 1635 case 10:
1618 1636
1619 { zconf_error("unexpected end statement"); ;} 1637 { zconf_error("unexpected end statement"); ;}
1620 break; 1638 break;
1621 1639
1622 case 9: 1640 case 11:
1623 1641
1624 { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;} 1642 { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;}
1625 break; 1643 break;
1626 1644
1627 case 10: 1645 case 12:
1628 1646
1629 { 1647 {
1630 zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name); 1648 zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name);
1631;} 1649;}
1632 break; 1650 break;
1633 1651
1634 case 11: 1652 case 13:
1635 1653
1636 { zconf_error("invalid statement"); ;} 1654 { zconf_error("invalid statement"); ;}
1637 break; 1655 break;
1638 1656
1639 case 25: 1657 case 28:
1640 1658
1641 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;} 1659 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;}
1642 break; 1660 break;
1643 1661
1644 case 26: 1662 case 29:
1645 1663
1646 { zconf_error("invalid option"); ;} 1664 { zconf_error("invalid option"); ;}
1647 break; 1665 break;
1648 1666
1649 case 27: 1667 case 30:
1650 1668
1651 { 1669 {
1652 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); 1670 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1656,7 +1674,7 @@ yyreduce:
1656;} 1674;}
1657 break; 1675 break;
1658 1676
1659 case 28: 1677 case 31:
1660 1678
1661 { 1679 {
1662 menu_end_entry(); 1680 menu_end_entry();
@@ -1664,7 +1682,7 @@ yyreduce:
1664;} 1682;}
1665 break; 1683 break;
1666 1684
1667 case 29: 1685 case 32:
1668 1686
1669 { 1687 {
1670 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); 1688 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1674,7 +1692,7 @@ yyreduce:
1674;} 1692;}
1675 break; 1693 break;
1676 1694
1677 case 30: 1695 case 33:
1678 1696
1679 { 1697 {
1680 if (current_entry->prompt) 1698 if (current_entry->prompt)
@@ -1686,7 +1704,7 @@ yyreduce:
1686;} 1704;}
1687 break; 1705 break;
1688 1706
1689 case 38: 1707 case 41:
1690 1708
1691 { 1709 {
1692 menu_set_type((yyvsp[(1) - (3)].id)->stype); 1710 menu_set_type((yyvsp[(1) - (3)].id)->stype);
@@ -1696,7 +1714,7 @@ yyreduce:
1696;} 1714;}
1697 break; 1715 break;
1698 1716
1699 case 39: 1717 case 42:
1700 1718
1701 { 1719 {
1702 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1720 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1704,7 +1722,7 @@ yyreduce:
1704;} 1722;}
1705 break; 1723 break;
1706 1724
1707 case 40: 1725 case 43:
1708 1726
1709 { 1727 {
1710 menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr)); 1728 menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr));
@@ -1716,7 +1734,7 @@ yyreduce:
1716;} 1734;}
1717 break; 1735 break;
1718 1736
1719 case 41: 1737 case 44:
1720 1738
1721 { 1739 {
1722 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); 1740 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
@@ -1724,7 +1742,7 @@ yyreduce:
1724;} 1742;}
1725 break; 1743 break;
1726 1744
1727 case 42: 1745 case 45:
1728 1746
1729 { 1747 {
1730 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); 1748 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
@@ -1732,7 +1750,7 @@ yyreduce:
1732;} 1750;}
1733 break; 1751 break;
1734 1752
1735 case 45: 1753 case 48:
1736 1754
1737 { 1755 {
1738 struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); 1756 struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
@@ -1744,17 +1762,17 @@ yyreduce:
1744;} 1762;}
1745 break; 1763 break;
1746 1764
1747 case 46: 1765 case 49:
1748 1766
1749 { (yyval.string) = NULL; ;} 1767 { (yyval.string) = NULL; ;}
1750 break; 1768 break;
1751 1769
1752 case 47: 1770 case 50:
1753 1771
1754 { (yyval.string) = (yyvsp[(2) - (2)].string); ;} 1772 { (yyval.string) = (yyvsp[(2) - (2)].string); ;}
1755 break; 1773 break;
1756 1774
1757 case 48: 1775 case 51:
1758 1776
1759 { 1777 {
1760 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); 1778 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE);
@@ -1765,14 +1783,14 @@ yyreduce:
1765;} 1783;}
1766 break; 1784 break;
1767 1785
1768 case 49: 1786 case 52:
1769 1787
1770 { 1788 {
1771 (yyval.menu) = menu_add_menu(); 1789 (yyval.menu) = menu_add_menu();
1772;} 1790;}
1773 break; 1791 break;
1774 1792
1775 case 50: 1793 case 53:
1776 1794
1777 { 1795 {
1778 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) { 1796 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) {
@@ -1782,7 +1800,7 @@ yyreduce:
1782;} 1800;}
1783 break; 1801 break;
1784 1802
1785 case 58: 1803 case 61:
1786 1804
1787 { 1805 {
1788 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1806 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1790,7 +1808,7 @@ yyreduce:
1790;} 1808;}
1791 break; 1809 break;
1792 1810
1793 case 59: 1811 case 62:
1794 1812
1795 { 1813 {
1796 if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) { 1814 if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) {
@@ -1803,7 +1821,7 @@ yyreduce:
1803;} 1821;}
1804 break; 1822 break;
1805 1823
1806 case 60: 1824 case 63:
1807 1825
1808 { 1826 {
1809 current_entry->sym->flags |= SYMBOL_OPTIONAL; 1827 current_entry->sym->flags |= SYMBOL_OPTIONAL;
@@ -1811,7 +1829,7 @@ yyreduce:
1811;} 1829;}
1812 break; 1830 break;
1813 1831
1814 case 61: 1832 case 64:
1815 1833
1816 { 1834 {
1817 if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) { 1835 if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) {
@@ -1823,7 +1841,7 @@ yyreduce:
1823;} 1841;}
1824 break; 1842 break;
1825 1843
1826 case 64: 1844 case 67:
1827 1845
1828 { 1846 {
1829 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 1847 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
@@ -1833,7 +1851,7 @@ yyreduce:
1833;} 1851;}
1834 break; 1852 break;
1835 1853
1836 case 65: 1854 case 68:
1837 1855
1838 { 1856 {
1839 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) { 1857 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) {
@@ -1843,7 +1861,14 @@ yyreduce:
1843;} 1861;}
1844 break; 1862 break;
1845 1863
1846 case 71: 1864 case 74:
1865
1866 {
1867 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
1868;}
1869 break;
1870
1871 case 75:
1847 1872
1848 { 1873 {
1849 menu_add_entry(NULL); 1874 menu_add_entry(NULL);
@@ -1852,14 +1877,14 @@ yyreduce:
1852;} 1877;}
1853 break; 1878 break;
1854 1879
1855 case 72: 1880 case 76:
1856 1881
1857 { 1882 {
1858 (yyval.menu) = menu_add_menu(); 1883 (yyval.menu) = menu_add_menu();
1859;} 1884;}
1860 break; 1885 break;
1861 1886
1862 case 73: 1887 case 77:
1863 1888
1864 { 1889 {
1865 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) { 1890 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) {
@@ -1869,7 +1894,7 @@ yyreduce:
1869;} 1894;}
1870 break; 1895 break;
1871 1896
1872 case 79: 1897 case 83:
1873 1898
1874 { 1899 {
1875 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); 1900 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
@@ -1877,7 +1902,7 @@ yyreduce:
1877;} 1902;}
1878 break; 1903 break;
1879 1904
1880 case 80: 1905 case 84:
1881 1906
1882 { 1907 {
1883 menu_add_entry(NULL); 1908 menu_add_entry(NULL);
@@ -1886,14 +1911,14 @@ yyreduce:
1886;} 1911;}
1887 break; 1912 break;
1888 1913
1889 case 81: 1914 case 85:
1890 1915
1891 { 1916 {
1892 menu_end_entry(); 1917 menu_end_entry();
1893;} 1918;}
1894 break; 1919 break;
1895 1920
1896 case 82: 1921 case 86:
1897 1922
1898 { 1923 {
1899 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); 1924 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
@@ -1901,14 +1926,14 @@ yyreduce:
1901;} 1926;}
1902 break; 1927 break;
1903 1928
1904 case 83: 1929 case 87:
1905 1930
1906 { 1931 {
1907 current_entry->help = (yyvsp[(2) - (2)].string); 1932 current_entry->help = (yyvsp[(2) - (2)].string);
1908;} 1933;}
1909 break; 1934 break;
1910 1935
1911 case 88: 1936 case 92:
1912 1937
1913 { 1938 {
1914 menu_add_dep((yyvsp[(3) - (4)].expr)); 1939 menu_add_dep((yyvsp[(3) - (4)].expr));
@@ -1916,84 +1941,91 @@ yyreduce:
1916;} 1941;}
1917 break; 1942 break;
1918 1943
1919 case 90: 1944 case 96:
1945
1946 {
1947 menu_add_visibility((yyvsp[(2) - (2)].expr));
1948;}
1949 break;
1950
1951 case 98:
1920 1952
1921 { 1953 {
1922 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); 1954 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
1923;} 1955;}
1924 break; 1956 break;
1925 1957
1926 case 93: 1958 case 101:
1927 1959
1928 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1960 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1929 break; 1961 break;
1930 1962
1931 case 94: 1963 case 102:
1932 1964
1933 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1965 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1934 break; 1966 break;
1935 1967
1936 case 95: 1968 case 103:
1937 1969
1938 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1970 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1939 break; 1971 break;
1940 1972
1941 case 98: 1973 case 106:
1942 1974
1943 { (yyval.expr) = NULL; ;} 1975 { (yyval.expr) = NULL; ;}
1944 break; 1976 break;
1945 1977
1946 case 99: 1978 case 107:
1947 1979
1948 { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} 1980 { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
1949 break; 1981 break;
1950 1982
1951 case 100: 1983 case 108:
1952 1984
1953 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} 1985 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;}
1954 break; 1986 break;
1955 1987
1956 case 101: 1988 case 109:
1957 1989
1958 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 1990 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
1959 break; 1991 break;
1960 1992
1961 case 102: 1993 case 110:
1962 1994
1963 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 1995 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
1964 break; 1996 break;
1965 1997
1966 case 103: 1998 case 111:
1967 1999
1968 { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} 2000 { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;}
1969 break; 2001 break;
1970 2002
1971 case 104: 2003 case 112:
1972 2004
1973 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} 2005 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;}
1974 break; 2006 break;
1975 2007
1976 case 105: 2008 case 113:
1977 2009
1978 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2010 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
1979 break; 2011 break;
1980 2012
1981 case 106: 2013 case 114:
1982 2014
1983 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2015 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
1984 break; 2016 break;
1985 2017
1986 case 107: 2018 case 115:
1987 2019
1988 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} 2020 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;}
1989 break; 2021 break;
1990 2022
1991 case 108: 2023 case 116:
1992 2024
1993 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} 2025 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;}
1994 break; 2026 break;
1995 2027
1996 case 109: 2028 case 117:
1997 2029
1998 { (yyval.string) = NULL; ;} 2030 { (yyval.string) = NULL; ;}
1999 break; 2031 break;
@@ -2239,6 +2271,10 @@ void conf_parse(const char *name)
2239 prop = prop_alloc(P_DEFAULT, modules_sym); 2271 prop = prop_alloc(P_DEFAULT, modules_sym);
2240 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); 2272 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
2241 } 2273 }
2274
2275 rootmenu.prompt->text = _(rootmenu.prompt->text);
2276 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
2277
2242 menu_finalize(&rootmenu); 2278 menu_finalize(&rootmenu);
2243 for_all_symbols(i, sym) { 2279 for_all_symbols(i, sym) {
2244 if (sym_check_deps(sym)) 2280 if (sym_check_deps(sym))
@@ -2259,6 +2295,7 @@ static const char *zconf_tokenname(int token)
2259 case T_IF: return "if"; 2295 case T_IF: return "if";
2260 case T_ENDIF: return "endif"; 2296 case T_ENDIF: return "endif";
2261 case T_DEPENDS: return "depends"; 2297 case T_DEPENDS: return "depends";
2298 case T_VISIBLE: return "visible";
2262 } 2299 }
2263 return "<token>"; 2300 return "<token>";
2264} 2301}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 23dfd3baa7a1..49fb4ab664c3 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -36,7 +36,7 @@ static struct menu *current_menu, *current_entry;
36#define YYERROR_VERBOSE 36#define YYERROR_VERBOSE
37#endif 37#endif
38%} 38%}
39%expect 26 39%expect 30
40 40
41%union 41%union
42{ 42{
@@ -68,6 +68,7 @@ static struct menu *current_menu, *current_entry;
68%token <id>T_DEFAULT 68%token <id>T_DEFAULT
69%token <id>T_SELECT 69%token <id>T_SELECT
70%token <id>T_RANGE 70%token <id>T_RANGE
71%token <id>T_VISIBLE
71%token <id>T_OPTION 72%token <id>T_OPTION
72%token <id>T_ON 73%token <id>T_ON
73%token <string> T_WORD 74%token <string> T_WORD
@@ -104,14 +105,15 @@ static struct menu *current_menu, *current_entry;
104%} 105%}
105 106
106%% 107%%
107input: stmt_list; 108input: nl start | start;
109
110start: mainmenu_stmt stmt_list | stmt_list;
108 111
109stmt_list: 112stmt_list:
110 /* empty */ 113 /* empty */
111 | stmt_list common_stmt 114 | stmt_list common_stmt
112 | stmt_list choice_stmt 115 | stmt_list choice_stmt
113 | stmt_list menu_stmt 116 | stmt_list menu_stmt
114 | stmt_list T_MAINMENU prompt nl
115 | stmt_list end { zconf_error("unexpected end statement"); } 117 | stmt_list end { zconf_error("unexpected end statement"); }
116 | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } 118 | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
117 | stmt_list option_name error T_EOL 119 | stmt_list option_name error T_EOL
@@ -122,7 +124,7 @@ stmt_list:
122; 124;
123 125
124option_name: 126option_name:
125 T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT 127 T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
126; 128;
127 129
128common_stmt: 130common_stmt:
@@ -342,6 +344,13 @@ if_block:
342 | if_block choice_stmt 344 | if_block choice_stmt
343; 345;
344 346
347/* mainmenu entry */
348
349mainmenu_stmt: T_MAINMENU prompt nl
350{
351 menu_add_prompt(P_MENU, $2, NULL);
352};
353
345/* menu entry */ 354/* menu entry */
346 355
347menu: T_MENU prompt T_EOL 356menu: T_MENU prompt T_EOL
@@ -351,7 +360,7 @@ menu: T_MENU prompt T_EOL
351 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 360 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
352}; 361};
353 362
354menu_entry: menu depends_list 363menu_entry: menu visibility_list depends_list
355{ 364{
356 $$ = menu_add_menu(); 365 $$ = menu_add_menu();
357}; 366};
@@ -422,6 +431,19 @@ depends: T_DEPENDS T_ON expr T_EOL
422 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 431 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
423}; 432};
424 433
434/* visibility option */
435
436visibility_list:
437 /* empty */
438 | visibility_list visible
439 | visibility_list T_EOL
440;
441
442visible: T_VISIBLE if_expr
443{
444 menu_add_visibility($2);
445};
446
425/* prompt statement */ 447/* prompt statement */
426 448
427prompt_stmt_opt: 449prompt_stmt_opt:
@@ -494,6 +516,10 @@ void conf_parse(const char *name)
494 prop = prop_alloc(P_DEFAULT, modules_sym); 516 prop = prop_alloc(P_DEFAULT, modules_sym);
495 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0)); 517 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
496 } 518 }
519
520 rootmenu.prompt->text = _(rootmenu.prompt->text);
521 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
522
497 menu_finalize(&rootmenu); 523 menu_finalize(&rootmenu);
498 for_all_symbols(i, sym) { 524 for_all_symbols(i, sym) {
499 if (sym_check_deps(sym)) 525 if (sym_check_deps(sym))
@@ -514,6 +540,7 @@ static const char *zconf_tokenname(int token)
514 case T_IF: return "if"; 540 case T_IF: return "if";
515 case T_ENDIF: return "endif"; 541 case T_ENDIF: return "endif";
516 case T_DEPENDS: return "depends"; 542 case T_DEPENDS: return "depends";
543 case T_VISIBLE: return "visible";
517 } 544 }
518 return "<token>"; 545 return "<token>";
519} 546}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cdb6dc1f6458..d793001929cf 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -5,7 +5,7 @@ use strict;
5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
7## Copyright (C) 2001 Simon Huggins ## 7## Copyright (C) 2001 Simon Huggins ##
8## Copyright (C) 2005-2009 Randy Dunlap ## 8## Copyright (C) 2005-2010 Randy Dunlap ##
9## ## 9## ##
10## #define enhancements by Armin Kuster <akuster@mvista.com> ## 10## #define enhancements by Armin Kuster <akuster@mvista.com> ##
11## Copyright (c) 2000 MontaVista Software, Inc. ## 11## Copyright (c) 2000 MontaVista Software, Inc. ##
@@ -155,6 +155,8 @@ use strict;
155# '@parameter' - name of a parameter 155# '@parameter' - name of a parameter
156# '%CONST' - name of a constant. 156# '%CONST' - name of a constant.
157 157
158## init lots of data
159
158my $errors = 0; 160my $errors = 0;
159my $warnings = 0; 161my $warnings = 0;
160my $anon_struct_union = 0; 162my $anon_struct_union = 0;
@@ -218,21 +220,14 @@ my %highlights_list = ( $type_constant, "\$1",
218 $type_param, "\$1" ); 220 $type_param, "\$1" );
219my $blankline_list = ""; 221my $blankline_list = "";
220 222
221sub usage {
222 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n";
223 print " [ -no-doc-sections ]\n";
224 print " [ -function funcname [ -function funcname ...] ]\n";
225 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
226 print " c source file(s) > outputfile\n";
227 print " -v : verbose output, more warnings & other info listed\n";
228 exit 1;
229}
230
231# read arguments 223# read arguments
232if ($#ARGV == -1) { 224if ($#ARGV == -1) {
233 usage(); 225 usage();
234} 226}
235 227
228my $kernelversion;
229my $dohighlight = "";
230
236my $verbose = 0; 231my $verbose = 0;
237my $output_mode = "man"; 232my $output_mode = "man";
238my $no_doc_sections = 0; 233my $no_doc_sections = 0;
@@ -245,7 +240,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
245 'November', 'December')[(localtime)[4]] . 240 'November', 'December')[(localtime)[4]] .
246 " " . ((localtime)[5]+1900); 241 " " . ((localtime)[5]+1900);
247 242
248# Essentially these are globals 243# Essentially these are globals.
249# They probably want to be tidied up, made more localised or something. 244# They probably want to be tidied up, made more localised or something.
250# CAVEAT EMPTOR! Some of the others I localised may not want to be, which 245# CAVEAT EMPTOR! Some of the others I localised may not want to be, which
251# could cause "use of undefined value" or other bugs. 246# could cause "use of undefined value" or other bugs.
@@ -353,6 +348,18 @@ while ($ARGV[0] =~ m/^-(.*)/) {
353 } 348 }
354} 349}
355 350
351# continue execution near EOF;
352
353sub usage {
354 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n";
355 print " [ -no-doc-sections ]\n";
356 print " [ -function funcname [ -function funcname ...] ]\n";
357 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
358 print " c source file(s) > outputfile\n";
359 print " -v : verbose output, more warnings & other info listed\n";
360 exit 1;
361}
362
356# get kernel version from env 363# get kernel version from env
357sub get_kernel_version() { 364sub get_kernel_version() {
358 my $version = 'unknown kernel version'; 365 my $version = 'unknown kernel version';
@@ -362,15 +369,6 @@ sub get_kernel_version() {
362 } 369 }
363 return $version; 370 return $version;
364} 371}
365my $kernelversion = get_kernel_version();
366
367# generate a sequence of code that will splice in highlighting information
368# using the s// operator.
369my $dohighlight = "";
370foreach my $pattern (keys %highlights) {
371# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
372 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
373}
374 372
375## 373##
376# dumps section contents to arrays/hashes intended for that purpose. 374# dumps section contents to arrays/hashes intended for that purpose.
@@ -453,7 +451,7 @@ sub output_highlight {
453 if ($output_mode eq "html" || $output_mode eq "xml") { 451 if ($output_mode eq "html" || $output_mode eq "xml") {
454 $contents = local_unescape($contents); 452 $contents = local_unescape($contents);
455 # convert data read & converted thru xml_escape() into &xyz; format: 453 # convert data read & converted thru xml_escape() into &xyz; format:
456 $contents =~ s/\\\\\\/&/g; 454 $contents =~ s/\\\\\\/\&/g;
457 } 455 }
458# print STDERR "contents b4:$contents\n"; 456# print STDERR "contents b4:$contents\n";
459 eval $dohighlight; 457 eval $dohighlight;
@@ -770,7 +768,11 @@ sub output_struct_xml(%) {
770 print $args{'type'} . " " . $args{'struct'} . " {\n"; 768 print $args{'type'} . " " . $args{'struct'} . " {\n";
771 foreach $parameter (@{$args{'parameterlist'}}) { 769 foreach $parameter (@{$args{'parameterlist'}}) {
772 if ($parameter =~ /^#/) { 770 if ($parameter =~ /^#/) {
773 print "$parameter\n"; 771 my $prm = $parameter;
772 # convert data read & converted thru xml_escape() into &xyz; format:
773 # This allows us to have #define macros interspersed in a struct.
774 $prm =~ s/\\\\\\/\&/g;
775 print "$prm\n";
774 next; 776 next;
775 } 777 }
776 778
@@ -1701,7 +1703,9 @@ sub push_parameter($$$) {
1701 } 1703 }
1702 } 1704 }
1703 1705
1704 # strip spaces from $param so that it is one continous string 1706 $param = xml_escape($param);
1707
1708 # strip spaces from $param so that it is one continuous string
1705 # on @parameterlist; 1709 # on @parameterlist;
1706 # this fixes a problem where check_sections() cannot find 1710 # this fixes a problem where check_sections() cannot find
1707 # a parameter like "addr[6 + 2]" because it actually appears 1711 # a parameter like "addr[6 + 2]" because it actually appears
@@ -1845,34 +1849,6 @@ sub dump_function($$) {
1845 }); 1849 });
1846} 1850}
1847 1851
1848sub process_file($);
1849
1850# Read the file that maps relative names to absolute names for
1851# separate source and object directories and for shadow trees.
1852if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
1853 my ($relname, $absname);
1854 while(<SOURCE_MAP>) {
1855 chop();
1856 ($relname, $absname) = (split())[0..1];
1857 $relname =~ s:^/+::;
1858 $source_map{$relname} = $absname;
1859 }
1860 close(SOURCE_MAP);
1861}
1862
1863foreach (@ARGV) {
1864 chomp;
1865 process_file($_);
1866}
1867if ($verbose && $errors) {
1868 print STDERR "$errors errors\n";
1869}
1870if ($verbose && $warnings) {
1871 print STDERR "$warnings warnings\n";
1872}
1873
1874exit($errors);
1875
1876sub reset_state { 1852sub reset_state {
1877 $function = ""; 1853 $function = "";
1878 %constants = (); 1854 %constants = ();
@@ -2279,3 +2255,39 @@ sub process_file($) {
2279 } 2255 }
2280 } 2256 }
2281} 2257}
2258
2259
2260$kernelversion = get_kernel_version();
2261
2262# generate a sequence of code that will splice in highlighting information
2263# using the s// operator.
2264foreach my $pattern (keys %highlights) {
2265# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
2266 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
2267}
2268
2269# Read the file that maps relative names to absolute names for
2270# separate source and object directories and for shadow trees.
2271if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
2272 my ($relname, $absname);
2273 while(<SOURCE_MAP>) {
2274 chop();
2275 ($relname, $absname) = (split())[0..1];
2276 $relname =~ s:^/+::;
2277 $source_map{$relname} = $absname;
2278 }
2279 close(SOURCE_MAP);
2280}
2281
2282foreach (@ARGV) {
2283 chomp;
2284 process_file($_);
2285}
2286if ($verbose && $errors) {
2287 print STDERR "$errors errors\n";
2288}
2289if ($verbose && $warnings) {
2290 print STDERR "$warnings warnings\n";
2291}
2292
2293exit($errors);
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 50ad317a4bf9..f221ddf69080 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -42,6 +42,16 @@ if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
42else 42else
43 TIMESTAMP=$KBUILD_BUILD_TIMESTAMP 43 TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
44fi 44fi
45if test -z "$KBUILD_BUILD_USER"; then
46 LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
47else
48 LINUX_COMPILE_BY=$KBUILD_BUILD_USER
49fi
50if test -z "$KBUILD_BUILD_HOST"; then
51 LINUX_COMPILE_HOST=`hostname`
52else
53 LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
54fi
45 55
46UTS_VERSION="#$VERSION" 56UTS_VERSION="#$VERSION"
47CONFIG_FLAGS="" 57CONFIG_FLAGS=""
@@ -63,20 +73,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
63 73
64 echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" 74 echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
65 75
66 echo \#define LINUX_COMPILE_TIME \"`date +%T`\" 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
67 echo \#define LINUX_COMPILE_BY \"`whoami`\" 77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
68 echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
69
70 domain=`dnsdomainname 2> /dev/null`
71 if [ -z "$domain" ]; then
72 domain=`domainname 2> /dev/null`
73 fi
74
75 if [ -n "$domain" ]; then
76 echo \#define LINUX_COMPILE_DOMAIN \"`echo $domain | $UTS_TRUNCATE`\"
77 else
78 echo \#define LINUX_COMPILE_DOMAIN
79 fi
80 78
81 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" 79 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
82) > .tmpcompile 80) > .tmpcompile
@@ -91,8 +89,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
91# first line. 89# first line.
92 90
93if [ -r $TARGET ] && \ 91if [ -r $TARGET ] && \
94 grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ 92 grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \
95 grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ 93 grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \
96 cmp -s .tmpver.1 .tmpver.2; then 94 cmp -s .tmpver.1 .tmpver.2; then
97 rm -f .tmpcompile 95 rm -f .tmpcompile
98else 96else
diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh
index 2e3d3cd916b8..446739c7843a 100755
--- a/scripts/mkuboot.sh
+++ b/scripts/mkuboot.sh
@@ -11,7 +11,7 @@ if [ -z "${MKIMAGE}" ]; then
11 if [ -z "${MKIMAGE}" ]; then 11 if [ -z "${MKIMAGE}" ]; then
12 # Doesn't exist 12 # Doesn't exist
13 echo '"mkimage" command not found - U-Boot images will not be built' >&2 13 echo '"mkimage" command not found - U-Boot images will not be built' >&2
14 exit 0; 14 exit 1;
15 fi 15 fi
16fi 16fi
17 17
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 88f3f07205f8..e26e2fb462d4 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -702,6 +702,24 @@ static int do_ssb_entry(const char *filename,
702 return 1; 702 return 1;
703} 703}
704 704
705/* Looks like: bcma:mNidNrevNclN. */
706static int do_bcma_entry(const char *filename,
707 struct bcma_device_id *id, char *alias)
708{
709 id->manuf = TO_NATIVE(id->manuf);
710 id->id = TO_NATIVE(id->id);
711 id->rev = TO_NATIVE(id->rev);
712 id->class = TO_NATIVE(id->class);
713
714 strcpy(alias, "bcma:");
715 ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf);
716 ADD(alias, "id", id->id != BCMA_ANY_ID, id->id);
717 ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev);
718 ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class);
719 add_wildcard(alias);
720 return 1;
721}
722
705/* Looks like: virtio:dNvN */ 723/* Looks like: virtio:dNvN */
706static int do_virtio_entry(const char *filename, struct virtio_device_id *id, 724static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
707 char *alias) 725 char *alias)
@@ -968,6 +986,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
968 do_table(symval, sym->st_size, 986 do_table(symval, sym->st_size,
969 sizeof(struct ssb_device_id), "ssb", 987 sizeof(struct ssb_device_id), "ssb",
970 do_ssb_entry, mod); 988 do_ssb_entry, mod);
989 else if (sym_is(symname, "__mod_bcma_device_table"))
990 do_table(symval, sym->st_size,
991 sizeof(struct bcma_device_id), "bcma",
992 do_bcma_entry, mod);
971 else if (sym_is(symname, "__mod_virtio_device_table")) 993 else if (sym_is(symname, "__mod_virtio_device_table"))
972 do_table(symval, sym->st_size, 994 do_table(symval, sym->st_size,
973 sizeof(struct virtio_device_id), "virtio", 995 sizeof(struct virtio_device_id), "virtio",
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 1ec7158b6c1f..413c53693e62 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -420,11 +420,10 @@ static int parse_elf(struct elf_info *info, const char *filename)
420 return 0; 420 return 0;
421 } 421 }
422 422
423 if (hdr->e_shnum == 0) { 423 if (hdr->e_shnum == SHN_UNDEF) {
424 /* 424 /*
425 * There are more than 64k sections, 425 * There are more than 64k sections,
426 * read count from .sh_size. 426 * read count from .sh_size.
427 * note: it doesn't need shndx2secindex()
428 */ 427 */
429 info->num_sections = TO_NATIVE(sechdrs[0].sh_size); 428 info->num_sections = TO_NATIVE(sechdrs[0].sh_size);
430 } 429 }
@@ -432,8 +431,7 @@ static int parse_elf(struct elf_info *info, const char *filename)
432 info->num_sections = hdr->e_shnum; 431 info->num_sections = hdr->e_shnum;
433 } 432 }
434 if (hdr->e_shstrndx == SHN_XINDEX) { 433 if (hdr->e_shstrndx == SHN_XINDEX) {
435 info->secindex_strings = 434 info->secindex_strings = TO_NATIVE(sechdrs[0].sh_link);
436 shndx2secindex(TO_NATIVE(sechdrs[0].sh_link));
437 } 435 }
438 else { 436 else {
439 info->secindex_strings = hdr->e_shstrndx; 437 info->secindex_strings = hdr->e_shstrndx;
@@ -489,7 +487,7 @@ static int parse_elf(struct elf_info *info, const char *filename)
489 sechdrs[i].sh_offset; 487 sechdrs[i].sh_offset;
490 info->symtab_stop = (void *)hdr + 488 info->symtab_stop = (void *)hdr +
491 sechdrs[i].sh_offset + sechdrs[i].sh_size; 489 sechdrs[i].sh_offset + sechdrs[i].sh_size;
492 sh_link_idx = shndx2secindex(sechdrs[i].sh_link); 490 sh_link_idx = sechdrs[i].sh_link;
493 info->strtab = (void *)hdr + 491 info->strtab = (void *)hdr +
494 sechdrs[sh_link_idx].sh_offset; 492 sechdrs[sh_link_idx].sh_offset;
495 } 493 }
@@ -516,11 +514,9 @@ static int parse_elf(struct elf_info *info, const char *filename)
516 514
517 if (symtab_shndx_idx != ~0U) { 515 if (symtab_shndx_idx != ~0U) {
518 Elf32_Word *p; 516 Elf32_Word *p;
519 if (symtab_idx != 517 if (symtab_idx != sechdrs[symtab_shndx_idx].sh_link)
520 shndx2secindex(sechdrs[symtab_shndx_idx].sh_link))
521 fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", 518 fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n",
522 filename, 519 filename, sechdrs[symtab_shndx_idx].sh_link,
523 shndx2secindex(sechdrs[symtab_shndx_idx].sh_link),
524 symtab_idx); 520 symtab_idx);
525 /* Fix endianness */ 521 /* Fix endianness */
526 for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; 522 for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop;
@@ -790,6 +786,7 @@ static const char *section_white_list[] =
790{ 786{
791 ".comment*", 787 ".comment*",
792 ".debug*", 788 ".debug*",
789 ".zdebug*", /* Compressed debug sections. */
793 ".GCC-command-line", /* mn10300 */ 790 ".GCC-command-line", /* mn10300 */
794 ".mdebug*", /* alpha, score, mips etc. */ 791 ".mdebug*", /* alpha, score, mips etc. */
795 ".pdr", /* alpha, score, mips etc. */ 792 ".pdr", /* alpha, score, mips etc. */
@@ -1208,6 +1205,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
1208 * .cpuinit.data => __cpudata 1205 * .cpuinit.data => __cpudata
1209 * .memexitconst => __memconst 1206 * .memexitconst => __memconst
1210 * etc. 1207 * etc.
1208 *
1209 * The memory of returned value has been allocated on a heap. The user of this
1210 * method should free it after usage.
1211*/ 1211*/
1212static char *sec2annotation(const char *s) 1212static char *sec2annotation(const char *s)
1213{ 1213{
@@ -1230,7 +1230,7 @@ static char *sec2annotation(const char *s)
1230 strcat(p, "data "); 1230 strcat(p, "data ");
1231 else 1231 else
1232 strcat(p, " "); 1232 strcat(p, " ");
1233 return r; /* we leak her but we do not care */ 1233 return r;
1234 } else { 1234 } else {
1235 return strdup(""); 1235 return strdup("");
1236 } 1236 }
@@ -1244,6 +1244,19 @@ static int is_function(Elf_Sym *sym)
1244 return -1; 1244 return -1;
1245} 1245}
1246 1246
1247static void print_section_list(const char * const list[20])
1248{
1249 const char *const *s = list;
1250
1251 while (*s) {
1252 fprintf(stderr, "%s", *s);
1253 s++;
1254 if (*s)
1255 fprintf(stderr, ", ");
1256 }
1257 fprintf(stderr, "\n");
1258}
1259
1247/* 1260/*
1248 * Print a warning about a section mismatch. 1261 * Print a warning about a section mismatch.
1249 * Try to find symbols near it so user can find it. 1262 * Try to find symbols near it so user can find it.
@@ -1300,7 +1313,6 @@ static void report_sec_mismatch(const char *modname,
1300 break; 1313 break;
1301 case DATA_TO_ANY_INIT: { 1314 case DATA_TO_ANY_INIT: {
1302 prl_to = sec2annotation(tosec); 1315 prl_to = sec2annotation(tosec);
1303 const char *const *s = mismatch->symbol_white_list;
1304 fprintf(stderr, 1316 fprintf(stderr,
1305 "The variable %s references\n" 1317 "The variable %s references\n"
1306 "the %s %s%s%s\n" 1318 "the %s %s%s%s\n"
@@ -1308,9 +1320,7 @@ static void report_sec_mismatch(const char *modname,
1308 "variable with __init* or __refdata (see linux/init.h) " 1320 "variable with __init* or __refdata (see linux/init.h) "
1309 "or name the variable:\n", 1321 "or name the variable:\n",
1310 fromsym, to, prl_to, tosym, to_p); 1322 fromsym, to, prl_to, tosym, to_p);
1311 while (*s) 1323 print_section_list(mismatch->symbol_white_list);
1312 fprintf(stderr, "%s, ", *s++);
1313 fprintf(stderr, "\n");
1314 free(prl_to); 1324 free(prl_to);
1315 break; 1325 break;
1316 } 1326 }
@@ -1325,7 +1335,6 @@ static void report_sec_mismatch(const char *modname,
1325 break; 1335 break;
1326 case DATA_TO_ANY_EXIT: { 1336 case DATA_TO_ANY_EXIT: {
1327 prl_to = sec2annotation(tosec); 1337 prl_to = sec2annotation(tosec);
1328 const char *const *s = mismatch->symbol_white_list;
1329 fprintf(stderr, 1338 fprintf(stderr,
1330 "The variable %s references\n" 1339 "The variable %s references\n"
1331 "the %s %s%s%s\n" 1340 "the %s %s%s%s\n"
@@ -1333,9 +1342,7 @@ static void report_sec_mismatch(const char *modname,
1333 "variable with __exit* (see linux/init.h) or " 1342 "variable with __exit* (see linux/init.h) or "
1334 "name the variable:\n", 1343 "name the variable:\n",
1335 fromsym, to, prl_to, tosym, to_p); 1344 fromsym, to, prl_to, tosym, to_p);
1336 while (*s) 1345 print_section_list(mismatch->symbol_white_list);
1337 fprintf(stderr, "%s, ", *s++);
1338 fprintf(stderr, "\n");
1339 free(prl_to); 1346 free(prl_to);
1340 break; 1347 break;
1341 } 1348 }
@@ -1435,10 +1442,10 @@ static unsigned int *reloc_location(struct elf_info *elf,
1435 Elf_Shdr *sechdr, Elf_Rela *r) 1442 Elf_Shdr *sechdr, Elf_Rela *r)
1436{ 1443{
1437 Elf_Shdr *sechdrs = elf->sechdrs; 1444 Elf_Shdr *sechdrs = elf->sechdrs;
1438 int section = shndx2secindex(sechdr->sh_info); 1445 int section = sechdr->sh_info;
1439 1446
1440 return (void *)elf->hdr + sechdrs[section].sh_offset + 1447 return (void *)elf->hdr + sechdrs[section].sh_offset +
1441 r->r_offset - sechdrs[section].sh_addr; 1448 r->r_offset;
1442} 1449}
1443 1450
1444static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1451static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
@@ -1611,7 +1618,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
1611 * A module includes a number of sections that are discarded 1618 * A module includes a number of sections that are discarded
1612 * either when loaded or when used as built-in. 1619 * either when loaded or when used as built-in.
1613 * For loaded modules all functions marked __init and all data 1620 * For loaded modules all functions marked __init and all data
1614 * marked __initdata will be discarded when the module has been intialized. 1621 * marked __initdata will be discarded when the module has been initialized.
1615 * Likewise for modules used built-in the sections marked __exit 1622 * Likewise for modules used built-in the sections marked __exit
1616 * are discarded because __exit marked function are supposed to be called 1623 * are discarded because __exit marked function are supposed to be called
1617 * only when a module is unloaded which never happens for built-in modules. 1624 * only when a module is unloaded which never happens for built-in modules.
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 0388cfccac8d..2031119080dc 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -145,33 +145,22 @@ static inline int is_shndx_special(unsigned int i)
145 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; 145 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
146} 146}
147 147
148/* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: 148/*
149 * shndx == 0 <=> sechdrs[0] 149 * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
150 * ...... 150 * the way to -256..-1, to avoid conflicting with real section
151 * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] 151 * indices.
152 * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE]
153 * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1]
154 * ......
155 * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff,
156 * so basically we map 0000..feff -> 0000..feff
157 * ff00..ffff -> (you are a bad boy, dont do it)
158 * 10000..xxxx -> ff00..(xxxx-0x100)
159 */ 152 */
160static inline unsigned int shndx2secindex(unsigned int i) 153#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
161{
162 if (i <= SHN_HIRESERVE)
163 return i;
164 return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE);
165}
166 154
167/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ 155/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
168static inline unsigned int get_secindex(const struct elf_info *info, 156static inline unsigned int get_secindex(const struct elf_info *info,
169 const Elf_Sym *sym) 157 const Elf_Sym *sym)
170{ 158{
159 if (is_shndx_special(sym->st_shndx))
160 return SPECIAL(sym->st_shndx);
171 if (sym->st_shndx != SHN_XINDEX) 161 if (sym->st_shndx != SHN_XINDEX)
172 return sym->st_shndx; 162 return sym->st_shndx;
173 return shndx2secindex(info->symtab_shndx_start[sym - 163 return info->symtab_shndx_start[sym - info->symtab_start];
174 info->symtab_start]);
175} 164}
176 165
177/* file2alias.c */ 166/* file2alias.c */
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index ecf9c7dc1825..9dfcd6d988da 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -300,8 +300,8 @@ static int is_static_library(const char *objfile)
300 return 0; 300 return 0;
301} 301}
302 302
303/* We have dir/file.o. Open dir/.file.o.cmd, look for deps_ line to 303/* We have dir/file.o. Open dir/.file.o.cmd, look for source_ and deps_ line
304 * figure out source file. */ 304 * to figure out source files. */
305static int parse_source_files(const char *objfile, struct md4_ctx *md) 305static int parse_source_files(const char *objfile, struct md4_ctx *md)
306{ 306{
307 char *cmd, *file, *line, *dir; 307 char *cmd, *file, *line, *dir;
@@ -340,6 +340,21 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
340 */ 340 */
341 while ((line = get_next_line(&pos, file, flen)) != NULL) { 341 while ((line = get_next_line(&pos, file, flen)) != NULL) {
342 char* p = line; 342 char* p = line;
343
344 if (strncmp(line, "source_", sizeof("source_")-1) == 0) {
345 p = strrchr(line, ' ');
346 if (!p) {
347 warn("malformed line: %s\n", line);
348 goto out_file;
349 }
350 p++;
351 if (!parse_file(p, md)) {
352 warn("could not open %s: %s\n",
353 p, strerror(errno));
354 goto out_file;
355 }
356 continue;
357 }
343 if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) { 358 if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
344 check_files = 1; 359 check_files = 1;
345 continue; 360 continue;
diff --git a/scripts/module-common.lds b/scripts/module-common.lds
index 47a1f9ae0ede..0865b3e752be 100644
--- a/scripts/module-common.lds
+++ b/scripts/module-common.lds
@@ -5,4 +5,15 @@
5 */ 5 */
6SECTIONS { 6SECTIONS {
7 /DISCARD/ : { *(.discard) } 7 /DISCARD/ : { *(.discard) }
8
9 __ksymtab : { *(SORT(___ksymtab+*)) }
10 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
11 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
12 __ksymtab_unused_gpl : { *(SORT(___ksymtab_unused_gpl+*)) }
13 __ksymtab_gpl_future : { *(SORT(___ksymtab_gpl_future+*)) }
14 __kcrctab : { *(SORT(___kcrctab+*)) }
15 __kcrctab_gpl : { *(SORT(___kcrctab_gpl+*)) }
16 __kcrctab_unused : { *(SORT(___kcrctab_unused+*)) }
17 __kcrctab_unused_gpl : { *(SORT(___kcrctab_unused_gpl+*)) }
18 __kcrctab_gpl_future : { *(SORT(___kcrctab_gpl_future+*)) }
8} 19}
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index 361d0f71184b..a71be6b7cdec 100755
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -84,6 +84,64 @@ my %ksymtab = (); # names that appear in __ksymtab_
84my %ref = (); # $ref{$name} exists if there is a true external reference to $name 84my %ref = (); # $ref{$name} exists if there is a true external reference to $name
85my %export = (); # $export{$name} exists if there is an EXPORT_... of $name 85my %export = (); # $export{$name} exists if there is an EXPORT_... of $name
86 86
87my %nmexception = (
88 'fs/ext3/bitmap' => 1,
89 'fs/ext4/bitmap' => 1,
90 'arch/x86/lib/thunk_32' => 1,
91 'arch/x86/lib/cmpxchg' => 1,
92 'arch/x86/vdso/vdso32/note' => 1,
93 'lib/irq_regs' => 1,
94 'usr/initramfs_data' => 1,
95 'drivers/scsi/aic94xx/aic94xx_dump' => 1,
96 'drivers/scsi/libsas/sas_dump' => 1,
97 'lib/dec_and_lock' => 1,
98 'drivers/ide/ide-probe-mini' => 1,
99 'usr/initramfs_data' => 1,
100 'drivers/acpi/acpia/exdump' => 1,
101 'drivers/acpi/acpia/rsdump' => 1,
102 'drivers/acpi/acpia/nsdumpdv' => 1,
103 'drivers/acpi/acpia/nsdump' => 1,
104 'arch/ia64/sn/kernel/sn2/io' => 1,
105 'arch/ia64/kernel/gate-data' => 1,
106 'security/capability' => 1,
107 'fs/ntfs/sysctl' => 1,
108 'fs/jfs/jfs_debug' => 1,
109);
110
111my %nameexception = (
112 'mod_use_count_' => 1,
113 '__initramfs_end' => 1,
114 '__initramfs_start' => 1,
115 '_einittext' => 1,
116 '_sinittext' => 1,
117 'kallsyms_names' => 1,
118 'kallsyms_num_syms' => 1,
119 'kallsyms_addresses'=> 1,
120 '__this_module' => 1,
121 '_etext' => 1,
122 '_edata' => 1,
123 '_end' => 1,
124 '__bss_start' => 1,
125 '_text' => 1,
126 '_stext' => 1,
127 '__gp' => 1,
128 'ia64_unw_start' => 1,
129 'ia64_unw_end' => 1,
130 '__init_begin' => 1,
131 '__init_end' => 1,
132 '__bss_stop' => 1,
133 '__nosave_begin' => 1,
134 '__nosave_end' => 1,
135 'pg0' => 1,
136 'vdso_enabled' => 1,
137 '__stack_chk_fail' => 1,
138 'VDSO32_PRELINK' => 1,
139 'VDSO32_vsyscall' => 1,
140 'VDSO32_rt_sigreturn'=>1,
141 'VDSO32_sigreturn' => 1,
142);
143
144
87&find(\&linux_objects, '.'); # find the objects and do_nm on them 145&find(\&linux_objects, '.'); # find the objects and do_nm on them
88&list_multiply_defined(); 146&list_multiply_defined();
89&resolve_external_references(); 147&resolve_external_references();
@@ -105,7 +163,8 @@ sub linux_objects
105 if (/.*\.o$/ && 163 if (/.*\.o$/ &&
106 ! ( 164 ! (
107 m:/built-in.o$: 165 m:/built-in.o$:
108 || m:arch/x86/kernel/vsyscall-syms.o$: 166 || m:arch/x86/vdso/:
167 || m:arch/x86/boot/:
109 || m:arch/ia64/ia32/ia32.o$: 168 || m:arch/ia64/ia32/ia32.o$:
110 || m:arch/ia64/kernel/gate-syms.o$: 169 || m:arch/ia64/kernel/gate-syms.o$:
111 || m:arch/ia64/lib/__divdi3.o$: 170 || m:arch/ia64/lib/__divdi3.o$:
@@ -148,6 +207,7 @@ sub linux_objects
148 || m:^.*/\.tmp_: 207 || m:^.*/\.tmp_:
149 || m:^\.tmp_: 208 || m:^\.tmp_:
150 || m:/vmlinux-obj.o$: 209 || m:/vmlinux-obj.o$:
210 || m:^tools/:
151 ) 211 )
152 ) { 212 ) {
153 do_nm($basename, $_); 213 do_nm($basename, $_);
@@ -167,11 +227,11 @@ sub do_nm
167 printf STDERR "$fullname is not an object file\n"; 227 printf STDERR "$fullname is not an object file\n";
168 return; 228 return;
169 } 229 }
170 ($source = $fullname) =~ s/\.o$//; 230 ($source = $basename) =~ s/\.o$//;
171 if (-e "$objtree$source.c" || -e "$objtree$source.S") { 231 if (-e "$source.c" || -e "$source.S") {
172 $source = "$objtree$source"; 232 $source = "$objtree$File::Find::dir/$source";
173 } else { 233 } else {
174 $source = "$srctree$source"; 234 $source = "$srctree$File::Find::dir/$source";
175 } 235 }
176 if (! -e "$source.c" && ! -e "$source.S") { 236 if (! -e "$source.c" && ! -e "$source.S") {
177 # No obvious source, exclude the object if it is conglomerate 237 # No obvious source, exclude the object if it is conglomerate
@@ -214,6 +274,7 @@ sub do_nm
214 # T global label/procedure 274 # T global label/procedure
215 # U external reference 275 # U external reference
216 # W weak external reference to text that has been resolved 276 # W weak external reference to text that has been resolved
277 # V similar to W, but the value of the weak symbol becomes zero with no error.
217 # a assembler equate 278 # a assembler equate
218 # b static variable, uninitialised 279 # b static variable, uninitialised
219 # d static variable, initialised 280 # d static variable, initialised
@@ -222,8 +283,9 @@ sub do_nm
222 # s static variable, uninitialised, small bss 283 # s static variable, uninitialised, small bss
223 # t static label/procedures 284 # t static label/procedures
224 # w weak external reference to text that has not been resolved 285 # w weak external reference to text that has not been resolved
286 # v similar to w
225 # ? undefined type, used a lot by modules 287 # ? undefined type, used a lot by modules
226 if ($type !~ /^[ABCDGRSTUWabdgrstw?]$/) { 288 if ($type !~ /^[ABCDGRSTUWVabdgrstwv?]$/) {
227 printf STDERR "nm output for $fullname contains unknown type '$_'\n"; 289 printf STDERR "nm output for $fullname contains unknown type '$_'\n";
228 } 290 }
229 elsif ($name =~ /\./) { 291 elsif ($name =~ /\./) {
@@ -234,7 +296,7 @@ sub do_nm
234 # binutils keeps changing the type for exported symbols, force it to R 296 # binutils keeps changing the type for exported symbols, force it to R
235 $type = 'R' if ($name =~ /^__ksymtab/ || $name =~ /^__kstrtab/); 297 $type = 'R' if ($name =~ /^__ksymtab/ || $name =~ /^__kstrtab/);
236 $name =~ s/_R[a-f0-9]{8}$//; # module versions adds this 298 $name =~ s/_R[a-f0-9]{8}$//; # module versions adds this
237 if ($type =~ /[ABCDGRSTW]/ && 299 if ($type =~ /[ABCDGRSTWV]/ &&
238 $name ne 'init_module' && 300 $name ne 'init_module' &&
239 $name ne 'cleanup_module' && 301 $name ne 'cleanup_module' &&
240 $name ne 'Using_Versions' && 302 $name ne 'Using_Versions' &&
@@ -270,27 +332,9 @@ sub do_nm
270 close($nmdata); 332 close($nmdata);
271 333
272 if ($#nmdata < 0) { 334 if ($#nmdata < 0) {
273 if ( 335 printf "No nm data for $fullname\n"
274 $fullname ne "lib/brlock.o" 336 unless $nmexception{$fullname};
275 && $fullname ne "lib/dec_and_lock.o" 337 return;
276 && $fullname ne "fs/xfs/xfs_macros.o"
277 && $fullname ne "drivers/ide/ide-probe-mini.o"
278 && $fullname ne "usr/initramfs_data.o"
279 && $fullname ne "drivers/acpi/executer/exdump.o"
280 && $fullname ne "drivers/acpi/resources/rsdump.o"
281 && $fullname ne "drivers/acpi/namespace/nsdumpdv.o"
282 && $fullname ne "drivers/acpi/namespace/nsdump.o"
283 && $fullname ne "arch/ia64/sn/kernel/sn2/io.o"
284 && $fullname ne "arch/ia64/kernel/gate-data.o"
285 && $fullname ne "drivers/ieee1394/oui.o"
286 && $fullname ne "security/capability.o"
287 && $fullname ne "sound/core/wrappers.o"
288 && $fullname ne "fs/ntfs/sysctl.o"
289 && $fullname ne "fs/jfs/jfs_debug.o"
290 ) {
291 printf "No nm data for $fullname\n";
292 }
293 return;
294 } 338 }
295 $nmdata{$fullname} = \@nmdata; 339 $nmdata{$fullname} = \@nmdata;
296} 340}
@@ -319,18 +363,14 @@ sub list_multiply_defined
319 foreach my $name (keys(%def)) { 363 foreach my $name (keys(%def)) {
320 if ($#{$def{$name}} > 0) { 364 if ($#{$def{$name}} > 0) {
321 # Special case for cond_syscall 365 # Special case for cond_syscall
322 if ($#{$def{$name}} == 1 && $name =~ /^sys_/ && 366 if ($#{$def{$name}} == 1 &&
323 ($def{$name}[0] eq "kernel/sys.o" || 367 ($name =~ /^sys_/ || $name =~ /^compat_sys_/ ||
324 $def{$name}[1] eq "kernel/sys.o")) { 368 $name =~ /^sys32_/)) {
325 &drop_def("kernel/sys.o", $name); 369 if($def{$name}[0] eq "kernel/sys_ni.o" ||
326 next; 370 $def{$name}[1] eq "kernel/sys_ni.o") {
327 } 371 &drop_def("kernel/sys_ni.o", $name);
328 # Special case for i386 entry code 372 next;
329 if ($#{$def{$name}} == 1 && $name =~ /^__kernel_/ && 373 }
330 $def{$name}[0] eq "arch/x86/kernel/vsyscall-int80_32.o" &&
331 $def{$name}[1] eq "arch/x86/kernel/vsyscall-sysenter_32.o") {
332 &drop_def("arch/x86/kernel/vsyscall-sysenter_32.o", $name);
333 next;
334 } 374 }
335 375
336 printf "$name is multiply defined in :-\n"; 376 printf "$name is multiply defined in :-\n";
@@ -372,31 +412,7 @@ sub resolve_external_references
372 $ref{$name} = "" 412 $ref{$name} = ""
373 } 413 }
374 } 414 }
375 elsif ( $name ne "mod_use_count_" 415 elsif ( ! $nameexception{$name}
376 && $name ne "__initramfs_end"
377 && $name ne "__initramfs_start"
378 && $name ne "_einittext"
379 && $name ne "_sinittext"
380 && $name ne "kallsyms_names"
381 && $name ne "kallsyms_num_syms"
382 && $name ne "kallsyms_addresses"
383 && $name ne "__this_module"
384 && $name ne "_etext"
385 && $name ne "_edata"
386 && $name ne "_end"
387 && $name ne "__bss_start"
388 && $name ne "_text"
389 && $name ne "_stext"
390 && $name ne "__gp"
391 && $name ne "ia64_unw_start"
392 && $name ne "ia64_unw_end"
393 && $name ne "__init_begin"
394 && $name ne "__init_end"
395 && $name ne "__bss_stop"
396 && $name ne "__nosave_begin"
397 && $name ne "__nosave_end"
398 && $name ne "pg0"
399 && $name ne "__module_text_address"
400 && $name !~ /^__sched_text_/ 416 && $name !~ /^__sched_text_/
401 && $name !~ /^__start_/ 417 && $name !~ /^__start_/
402 && $name !~ /^__end_/ 418 && $name !~ /^__end_/
@@ -407,7 +423,6 @@ sub resolve_external_references
407 && $name !~ /^__.*per_cpu_end/ 423 && $name !~ /^__.*per_cpu_end/
408 && $name !~ /^__alt_instructions/ 424 && $name !~ /^__alt_instructions/
409 && $name !~ /^__setup_/ 425 && $name !~ /^__setup_/
410 && $name !~ /^jiffies/
411 && $name !~ /^__mod_timer/ 426 && $name !~ /^__mod_timer/
412 && $name !~ /^__mod_page_state/ 427 && $name !~ /^__mod_page_state/
413 && $name !~ /^init_module/ 428 && $name !~ /^init_module/
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index d0b931b994fc..006960ebbce9 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -26,9 +26,9 @@ RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
26 else echo rpm; fi) 26 else echo rpm; fi)
27 27
28# Remove hyphens since they have special meaning in RPM filenames 28# Remove hyphens since they have special meaning in RPM filenames
29KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE)) 29KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
30MKSPEC := $(srctree)/scripts/package/mkspec 30MKSPEC := $(srctree)/scripts/package/mkspec
31PREV := set -e; cd ..; 31PREV := set -e; cd -P ..;
32 32
33# rpm-pkg 33# rpm-pkg
34# --------------------------------------------------------------------------- 34# ---------------------------------------------------------------------------
@@ -127,7 +127,8 @@ rm -r $(perf-tar); \
127$(if $(findstring tar-src,$@),, \ 127$(if $(findstring tar-src,$@),, \
128$(if $(findstring bz2,$@),bzip2, \ 128$(if $(findstring bz2,$@),bzip2, \
129$(if $(findstring gz,$@),gzip, \ 129$(if $(findstring gz,$@),gzip, \
130$(error unknown target $@))) \ 130$(if $(findstring xz,$@),xz, \
131$(error unknown target $@)))) \
131 -f -9 $(perf-tar).tar) 132 -f -9 $(perf-tar).tar)
132 133
133perf-%pkg: FORCE 134perf-%pkg: FORCE
@@ -142,7 +143,9 @@ help: FORCE
142 @echo ' tar-pkg - Build the kernel as an uncompressed tarball' 143 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
143 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' 144 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
144 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' 145 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
146 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
145 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' 147 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
146 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' 148 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
147 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' 149 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
150 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
148 151
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 5f1e2fc7f171..f6cbc3ddb68b 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -25,8 +25,44 @@ create_package() {
25 chown -R root:root "$pdir" 25 chown -R root:root "$pdir"
26 chmod -R go-w "$pdir" 26 chmod -R go-w "$pdir"
27 27
28 # Attempt to find the correct Debian architecture
29 local forcearch="" debarch=""
30 case "$UTS_MACHINE" in
31 i386|ia64|alpha)
32 debarch="$UTS_MACHINE" ;;
33 x86_64)
34 debarch=amd64 ;;
35 sparc*)
36 debarch=sparc ;;
37 s390*)
38 debarch=s390 ;;
39 ppc*)
40 debarch=powerpc ;;
41 parisc*)
42 debarch=hppa ;;
43 mips*)
44 debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;;
45 arm*)
46 debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;;
47 *)
48 echo "" >&2
49 echo "** ** ** WARNING ** ** **" >&2
50 echo "" >&2
51 echo "Your architecture doesn't have it's equivalent" >&2
52 echo "Debian userspace architecture defined!" >&2
53 echo "Falling back to using your current userspace instead!" >&2
54 echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
55 echo "" >&2
56 esac
57 if [ -n "$KBUILD_DEBARCH" ] ; then
58 debarch="$KBUILD_DEBARCH"
59 fi
60 if [ -n "$debarch" ] ; then
61 forcearch="-DArchitecture=$debarch"
62 fi
63
28 # Create the package 64 # Create the package
29 dpkg-gencontrol -isp -p$pname -P"$pdir" 65 dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir"
30 dpkg --build "$pdir" .. 66 dpkg --build "$pdir" ..
31} 67}
32 68
@@ -40,17 +76,27 @@ else
40fi 76fi
41tmpdir="$objtree/debian/tmp" 77tmpdir="$objtree/debian/tmp"
42fwdir="$objtree/debian/fwtmp" 78fwdir="$objtree/debian/fwtmp"
79kernel_headers_dir="$objtree/debian/hdrtmp"
80libc_headers_dir="$objtree/debian/headertmp"
43packagename=linux-image-$version 81packagename=linux-image-$version
44fwpackagename=linux-firmware-image 82fwpackagename=linux-firmware-image
83kernel_headers_packagename=linux-headers-$version
84libc_headers_packagename=linux-libc-dev
45 85
46if [ "$ARCH" = "um" ] ; then 86if [ "$ARCH" = "um" ] ; then
47 packagename=user-mode-linux-$version 87 packagename=user-mode-linux-$version
48fi 88fi
49 89
50# Setup the directory structure 90# Setup the directory structure
51rm -rf "$tmpdir" "$fwdir" 91rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir"
52mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" 92mkdir -m 755 -p "$tmpdir/DEBIAN"
53mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" 93mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
94mkdir -m 755 -p "$fwdir/DEBIAN"
95mkdir -p "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename"
96mkdir -m 755 -p "$libc_headers_dir/DEBIAN"
97mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename"
98mkdir -m 755 -p "$kernel_headers_dir/DEBIAN"
99mkdir -p "$kernel_headers_dir/usr/share/doc/$kernel_headers_packagename"
54if [ "$ARCH" = "um" ] ; then 100if [ "$ARCH" = "um" ] ; then
55 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" 101 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin"
56fi 102fi
@@ -66,7 +112,9 @@ else
66 cp System.map "$tmpdir/boot/System.map-$version" 112 cp System.map "$tmpdir/boot/System.map-$version"
67 cp .config "$tmpdir/boot/config-$version" 113 cp .config "$tmpdir/boot/config-$version"
68 # Not all arches include the boot path in KBUILD_IMAGE 114 # Not all arches include the boot path in KBUILD_IMAGE
69 if ! cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"; then 115 if [ -e $KBUILD_IMAGE ]; then
116 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
117 else
70 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" 118 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
71 fi 119 fi
72fi 120fi
@@ -79,6 +127,9 @@ if grep -q '^CONFIG_MODULES=y' .config ; then
79 fi 127 fi
80fi 128fi
81 129
130make headers_check
131make headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr"
132
82# Install the maintainer scripts 133# Install the maintainer scripts
83# Note: hook scripts under /etc/kernel are also executed by official Debian 134# Note: hook scripts under /etc/kernel are also executed by official Debian
84# kernel packages, as well as kernel packages built using make-kpkg 135# kernel packages, as well as kernel packages built using make-kpkg
@@ -186,6 +237,30 @@ EOF
186 237
187fi 238fi
188 239
240# Build header package
241(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > /tmp/files$$)
242(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> /tmp/files$$)
243(cd $objtree; find .config Module.symvers include scripts -type f >> /tmp/objfiles$$)
244destdir=$kernel_headers_dir/usr/src/linux-headers-$version
245mkdir -p "$destdir"
246(cd $srctree; tar -c -f - -T /tmp/files$$) | (cd $destdir; tar -xf -)
247(cd $objtree; tar -c -f - -T /tmp/objfiles$$) | (cd $destdir; tar -xf -)
248rm -f /tmp/files$$ /tmp/objfiles$$
249arch=$(dpkg --print-architecture)
250
251cat <<EOF >> debian/control
252
253Package: $kernel_headers_packagename
254Provides: linux-headers, linux-headers-2.6
255Architecture: $arch
256Description: Linux kernel headers for $KERNELRELEASE on $arch
257 This package provides kernel header files for $KERNELRELEASE on $arch
258 .
259 This is useful for people who need to build external modules
260EOF
261
262create_package "$kernel_headers_packagename" "$kernel_headers_dir"
263
189# Do we have firmware? Move it out of the way and build it into a package. 264# Do we have firmware? Move it out of the way and build it into a package.
190if [ -e "$tmpdir/lib/firmware" ]; then 265if [ -e "$tmpdir/lib/firmware" ]; then
191 mv "$tmpdir/lib/firmware" "$fwdir/lib/" 266 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
@@ -201,6 +276,18 @@ EOF
201 create_package "$fwpackagename" "$fwdir" 276 create_package "$fwpackagename" "$fwdir"
202fi 277fi
203 278
279cat <<EOF >> debian/control
280
281Package: $libc_headers_packagename
282Section: devel
283Provides: linux-kernel-headers
284Architecture: any
285Description: Linux support headers for userspace development
286 This package provides userspaces headers from the Linux kernel. These headers
287 are used by the installed headers for GNU glibc and other system libraries.
288EOF
289
290create_package "$libc_headers_packagename" "$libc_headers_dir"
204create_package "$packagename" "$tmpdir" 291create_package "$packagename" "$tmpdir"
205 292
206exit 0 293exit 0
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 51b2aa0acb82..8a7b15598ea9 100644
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -35,6 +35,10 @@ case "${1}" in
35 compress="bzip2 -c9" 35 compress="bzip2 -c9"
36 file_ext=".bz2" 36 file_ext=".bz2"
37 ;; 37 ;;
38 tarxz-pkg)
39 compress="xz -c9"
40 file_ext=".xz"
41 ;;
38 *) 42 *)
39 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2 43 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
40 exit 1 44 exit 1
@@ -88,7 +92,7 @@ case "${ARCH}" in
88 echo "" >&2 92 echo "" >&2
89 echo '** ** ** WARNING ** ** **' >&2 93 echo '** ** ** WARNING ** ** **' >&2
90 echo "" >&2 94 echo "" >&2
91 echo "Your architecture did not define any architecture-dependant files" >&2 95 echo "Your architecture did not define any architecture-dependent files" >&2
92 echo "to be placed into the tarball. Please add those to ${0} ..." >&2 96 echo "to be placed into the tarball. Please add those to ${0} ..." >&2
93 echo "" >&2 97 echo "" >&2
94 sleep 5 98 sleep 5
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 15440f55aef6..4bf17ddf7c7f 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -22,7 +22,7 @@ if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
22fi 22fi
23 23
24PROVIDES="$PROVIDES kernel-$KERNELRELEASE" 24PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-//g"` 25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
26 26
27echo "Name: kernel" 27echo "Name: kernel"
28echo "Summary: The Linux Kernel" 28echo "Summary: The Linux Kernel"
@@ -47,6 +47,18 @@ echo ""
47echo "%description" 47echo "%description"
48echo "The Linux Kernel, the operating system core itself" 48echo "The Linux Kernel, the operating system core itself"
49echo "" 49echo ""
50echo "%package headers"
51echo "Summary: Header files for the Linux kernel for use by glibc"
52echo "Group: Development/System"
53echo "Obsoletes: kernel-headers"
54echo "Provides: kernel-headers = %{version}"
55echo "%description headers"
56echo "Kernel-headers includes the C header files that specify the interface"
57echo "between the Linux kernel and userspace libraries and programs. The"
58echo "header files define structures and constants that are needed for"
59echo "building most standard programs and are also needed for rebuilding the"
60echo "glibc package."
61echo ""
50 62
51if ! $PREBUILT; then 63if ! $PREBUILT; then
52echo "%prep" 64echo "%prep"
@@ -70,7 +82,7 @@ echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
70echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' 82echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'
71echo "%endif" 83echo "%endif"
72 84
73echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} KBUILD_SRC= modules_install' 85echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install'
74echo "%ifarch ia64" 86echo "%ifarch ia64"
75echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" 87echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
76echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" 88echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
@@ -83,6 +95,7 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
83echo "%endif" 95echo "%endif"
84echo "%endif" 96echo "%endif"
85 97
98echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install'
86echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" 99echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
87 100
88echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" 101echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
@@ -105,3 +118,7 @@ echo "/lib/modules/$KERNELRELEASE"
105echo "/lib/firmware" 118echo "/lib/firmware"
106echo "/boot/*" 119echo "/boot/*"
107echo "" 120echo ""
121echo "%files headers"
122echo '%defattr (-, root, root)'
123echo "/usr/include"
124echo ""
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 46a59cae3a0a..20fb25c23382 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -250,7 +250,7 @@ while : # incrementing SUBLEVEL (s in v.p.s)
250do 250do
251 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 251 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
252 EXTRAVER= 252 EXTRAVER=
253 if [ $STOPFULLVERSION = $CURRENTFULLVERSION ]; then 253 if [ x$STOPFULLVERSION = x$CURRENTFULLVERSION ]; then
254 echo "Stopping at $CURRENTFULLVERSION base as requested." 254 echo "Stopping at $CURRENTFULLVERSION base as requested."
255 break 255 break
256 fi 256 fi
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
new file mode 100644
index 000000000000..ee52cb8e17ad
--- /dev/null
+++ b/scripts/recordmcount.c
@@ -0,0 +1,471 @@
1/*
2 * recordmcount.c: construct a table of the locations of calls to 'mcount'
3 * so that ftrace can find them quickly.
4 * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved.
5 * Licensed under the GNU General Public License, version 2 (GPLv2).
6 *
7 * Restructured to fit Linux format, as well as other updates:
8 * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
9 */
10
11/*
12 * Strategy: alter the .o file in-place.
13 *
14 * Append a new STRTAB that has the new section names, followed by a new array
15 * ElfXX_Shdr[] that has the new section headers, followed by the section
16 * contents for __mcount_loc and its relocations. The old shstrtab strings,
17 * and the old ElfXX_Shdr[] array, remain as "garbage" (commonly, a couple
18 * kilobytes.) Subsequent processing by /bin/ld (or the kernel module loader)
19 * will ignore the garbage regions, because they are not designated by the
20 * new .e_shoff nor the new ElfXX_Shdr[]. [In order to remove the garbage,
21 * then use "ld -r" to create a new file that omits the garbage.]
22 */
23
24#include <sys/types.h>
25#include <sys/mman.h>
26#include <sys/stat.h>
27#include <getopt.h>
28#include <elf.h>
29#include <fcntl.h>
30#include <setjmp.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <unistd.h>
35
36static int fd_map; /* File descriptor for file being modified. */
37static int mmap_failed; /* Boolean flag. */
38static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
39static char gpfx; /* prefix for global symbol name (sometimes '_') */
40static struct stat sb; /* Remember .st_size, etc. */
41static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */
42static const char *altmcount; /* alternate mcount symbol name */
43static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */
44
45/* setjmp() return values */
46enum {
47 SJ_SETJMP = 0, /* hardwired first return */
48 SJ_FAIL,
49 SJ_SUCCEED
50};
51
52/* Per-file resource cleanup when multiple files. */
53static void
54cleanup(void)
55{
56 if (!mmap_failed)
57 munmap(ehdr_curr, sb.st_size);
58 else
59 free(ehdr_curr);
60 close(fd_map);
61}
62
63static void __attribute__((noreturn))
64fail_file(void)
65{
66 cleanup();
67 longjmp(jmpenv, SJ_FAIL);
68}
69
70static void __attribute__((noreturn))
71succeed_file(void)
72{
73 cleanup();
74 longjmp(jmpenv, SJ_SUCCEED);
75}
76
77/* ulseek, uread, ...: Check return value for errors. */
78
79static off_t
80ulseek(int const fd, off_t const offset, int const whence)
81{
82 off_t const w = lseek(fd, offset, whence);
83 if (w == (off_t)-1) {
84 perror("lseek");
85 fail_file();
86 }
87 return w;
88}
89
90static size_t
91uread(int const fd, void *const buf, size_t const count)
92{
93 size_t const n = read(fd, buf, count);
94 if (n != count) {
95 perror("read");
96 fail_file();
97 }
98 return n;
99}
100
101static size_t
102uwrite(int const fd, void const *const buf, size_t const count)
103{
104 size_t const n = write(fd, buf, count);
105 if (n != count) {
106 perror("write");
107 fail_file();
108 }
109 return n;
110}
111
112static void *
113umalloc(size_t size)
114{
115 void *const addr = malloc(size);
116 if (addr == 0) {
117 fprintf(stderr, "malloc failed: %zu bytes\n", size);
118 fail_file();
119 }
120 return addr;
121}
122
123static unsigned char ideal_nop5_x86_64[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
124static unsigned char ideal_nop5_x86_32[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
125static unsigned char *ideal_nop;
126
127static char rel_type_nop;
128
129static int (*make_nop)(void *map, size_t const offset);
130
131static int make_nop_x86(void *map, size_t const offset)
132{
133 uint32_t *ptr;
134 unsigned char *op;
135
136 /* Confirm we have 0xe8 0x0 0x0 0x0 0x0 */
137 ptr = map + offset;
138 if (*ptr != 0)
139 return -1;
140
141 op = map + offset - 1;
142 if (*op != 0xe8)
143 return -1;
144
145 /* convert to nop */
146 ulseek(fd_map, offset - 1, SEEK_SET);
147 uwrite(fd_map, ideal_nop, 5);
148 return 0;
149}
150
151/*
152 * Get the whole file as a programming convenience in order to avoid
153 * malloc+lseek+read+free of many pieces. If successful, then mmap
154 * avoids copying unused pieces; else just read the whole file.
155 * Open for both read and write; new info will be appended to the file.
156 * Use MAP_PRIVATE so that a few changes to the in-memory ElfXX_Ehdr
157 * do not propagate to the file until an explicit overwrite at the last.
158 * This preserves most aspects of consistency (all except .st_size)
159 * for simultaneous readers of the file while we are appending to it.
160 * However, multiple writers still are bad. We choose not to use
161 * locking because it is expensive and the use case of kernel build
162 * makes multiple writers unlikely.
163 */
164static void *mmap_file(char const *fname)
165{
166 void *addr;
167
168 fd_map = open(fname, O_RDWR);
169 if (fd_map < 0 || fstat(fd_map, &sb) < 0) {
170 perror(fname);
171 fail_file();
172 }
173 if (!S_ISREG(sb.st_mode)) {
174 fprintf(stderr, "not a regular file: %s\n", fname);
175 fail_file();
176 }
177 addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
178 fd_map, 0);
179 mmap_failed = 0;
180 if (addr == MAP_FAILED) {
181 mmap_failed = 1;
182 addr = umalloc(sb.st_size);
183 uread(fd_map, addr, sb.st_size);
184 }
185 return addr;
186}
187
188/* w8rev, w8nat, ...: Handle endianness. */
189
190static uint64_t w8rev(uint64_t const x)
191{
192 return ((0xff & (x >> (0 * 8))) << (7 * 8))
193 | ((0xff & (x >> (1 * 8))) << (6 * 8))
194 | ((0xff & (x >> (2 * 8))) << (5 * 8))
195 | ((0xff & (x >> (3 * 8))) << (4 * 8))
196 | ((0xff & (x >> (4 * 8))) << (3 * 8))
197 | ((0xff & (x >> (5 * 8))) << (2 * 8))
198 | ((0xff & (x >> (6 * 8))) << (1 * 8))
199 | ((0xff & (x >> (7 * 8))) << (0 * 8));
200}
201
202static uint32_t w4rev(uint32_t const x)
203{
204 return ((0xff & (x >> (0 * 8))) << (3 * 8))
205 | ((0xff & (x >> (1 * 8))) << (2 * 8))
206 | ((0xff & (x >> (2 * 8))) << (1 * 8))
207 | ((0xff & (x >> (3 * 8))) << (0 * 8));
208}
209
210static uint32_t w2rev(uint16_t const x)
211{
212 return ((0xff & (x >> (0 * 8))) << (1 * 8))
213 | ((0xff & (x >> (1 * 8))) << (0 * 8));
214}
215
216static uint64_t w8nat(uint64_t const x)
217{
218 return x;
219}
220
221static uint32_t w4nat(uint32_t const x)
222{
223 return x;
224}
225
226static uint32_t w2nat(uint16_t const x)
227{
228 return x;
229}
230
231static uint64_t (*w8)(uint64_t);
232static uint32_t (*w)(uint32_t);
233static uint32_t (*w2)(uint16_t);
234
235/* Names of the sections that could contain calls to mcount. */
236static int
237is_mcounted_section_name(char const *const txtname)
238{
239 return strcmp(".text", txtname) == 0 ||
240 strcmp(".ref.text", txtname) == 0 ||
241 strcmp(".sched.text", txtname) == 0 ||
242 strcmp(".spinlock.text", txtname) == 0 ||
243 strcmp(".irqentry.text", txtname) == 0 ||
244 strcmp(".kprobes.text", txtname) == 0 ||
245 strcmp(".text.unlikely", txtname) == 0;
246}
247
248/* 32 bit and 64 bit are very similar */
249#include "recordmcount.h"
250#define RECORD_MCOUNT_64
251#include "recordmcount.h"
252
253/* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
254 * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
255 * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40]
256 * to imply the order of the members; the spec does not say so.
257 * typedef unsigned char Elf64_Byte;
258 * fails on MIPS64 because their <elf.h> already has it!
259 */
260
261typedef uint8_t myElf64_Byte; /* Type for a 8-bit quantity. */
262
263union mips_r_info {
264 Elf64_Xword r_info;
265 struct {
266 Elf64_Word r_sym; /* Symbol index. */
267 myElf64_Byte r_ssym; /* Special symbol. */
268 myElf64_Byte r_type3; /* Third relocation. */
269 myElf64_Byte r_type2; /* Second relocation. */
270 myElf64_Byte r_type; /* First relocation. */
271 } r_mips;
272};
273
274static uint64_t MIPS64_r_sym(Elf64_Rel const *rp)
275{
276 return w(((union mips_r_info){ .r_info = rp->r_info }).r_mips.r_sym);
277}
278
279static void MIPS64_r_info(Elf64_Rel *const rp, unsigned sym, unsigned type)
280{
281 rp->r_info = ((union mips_r_info){
282 .r_mips = { .r_sym = w(sym), .r_type = type }
283 }).r_info;
284}
285
286static void
287do_file(char const *const fname)
288{
289 Elf32_Ehdr *const ehdr = mmap_file(fname);
290 unsigned int reltype = 0;
291
292 ehdr_curr = ehdr;
293 w = w4nat;
294 w2 = w2nat;
295 w8 = w8nat;
296 switch (ehdr->e_ident[EI_DATA]) {
297 static unsigned int const endian = 1;
298 default:
299 fprintf(stderr, "unrecognized ELF data encoding %d: %s\n",
300 ehdr->e_ident[EI_DATA], fname);
301 fail_file();
302 break;
303 case ELFDATA2LSB:
304 if (*(unsigned char const *)&endian != 1) {
305 /* main() is big endian, file.o is little endian. */
306 w = w4rev;
307 w2 = w2rev;
308 w8 = w8rev;
309 }
310 break;
311 case ELFDATA2MSB:
312 if (*(unsigned char const *)&endian != 0) {
313 /* main() is little endian, file.o is big endian. */
314 w = w4rev;
315 w2 = w2rev;
316 w8 = w8rev;
317 }
318 break;
319 } /* end switch */
320 if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
321 || w2(ehdr->e_type) != ET_REL
322 || ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
323 fprintf(stderr, "unrecognized ET_REL file %s\n", fname);
324 fail_file();
325 }
326
327 gpfx = 0;
328 switch (w2(ehdr->e_machine)) {
329 default:
330 fprintf(stderr, "unrecognized e_machine %d %s\n",
331 w2(ehdr->e_machine), fname);
332 fail_file();
333 break;
334 case EM_386:
335 reltype = R_386_32;
336 make_nop = make_nop_x86;
337 ideal_nop = ideal_nop5_x86_32;
338 mcount_adjust_32 = -1;
339 break;
340 case EM_ARM: reltype = R_ARM_ABS32;
341 altmcount = "__gnu_mcount_nc";
342 break;
343 case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break;
344 case EM_MIPS: /* reltype: e_class */ gpfx = '_'; break;
345 case EM_PPC: reltype = R_PPC_ADDR32; gpfx = '_'; break;
346 case EM_PPC64: reltype = R_PPC64_ADDR64; gpfx = '_'; break;
347 case EM_S390: /* reltype: e_class */ gpfx = '_'; break;
348 case EM_SH: reltype = R_SH_DIR32; break;
349 case EM_SPARCV9: reltype = R_SPARC_64; gpfx = '_'; break;
350 case EM_X86_64:
351 make_nop = make_nop_x86;
352 ideal_nop = ideal_nop5_x86_64;
353 reltype = R_X86_64_64;
354 mcount_adjust_64 = -1;
355 break;
356 } /* end switch */
357
358 switch (ehdr->e_ident[EI_CLASS]) {
359 default:
360 fprintf(stderr, "unrecognized ELF class %d %s\n",
361 ehdr->e_ident[EI_CLASS], fname);
362 fail_file();
363 break;
364 case ELFCLASS32:
365 if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
366 || w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
367 fprintf(stderr,
368 "unrecognized ET_REL file: %s\n", fname);
369 fail_file();
370 }
371 if (w2(ehdr->e_machine) == EM_S390) {
372 reltype = R_390_32;
373 mcount_adjust_32 = -4;
374 }
375 if (w2(ehdr->e_machine) == EM_MIPS) {
376 reltype = R_MIPS_32;
377 is_fake_mcount32 = MIPS32_is_fake_mcount;
378 }
379 do32(ehdr, fname, reltype);
380 break;
381 case ELFCLASS64: {
382 Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr;
383 if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
384 || w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
385 fprintf(stderr,
386 "unrecognized ET_REL file: %s\n", fname);
387 fail_file();
388 }
389 if (w2(ghdr->e_machine) == EM_S390) {
390 reltype = R_390_64;
391 mcount_adjust_64 = -8;
392 }
393 if (w2(ghdr->e_machine) == EM_MIPS) {
394 reltype = R_MIPS_64;
395 Elf64_r_sym = MIPS64_r_sym;
396 Elf64_r_info = MIPS64_r_info;
397 is_fake_mcount64 = MIPS64_is_fake_mcount;
398 }
399 do64(ghdr, fname, reltype);
400 break;
401 }
402 } /* end switch */
403
404 cleanup();
405}
406
407int
408main(int argc, char *argv[])
409{
410 const char ftrace[] = "/ftrace.o";
411 int ftrace_size = sizeof(ftrace) - 1;
412 int n_error = 0; /* gcc-4.3.0 false positive complaint */
413 int c;
414 int i;
415
416 while ((c = getopt(argc, argv, "w")) >= 0) {
417 switch (c) {
418 case 'w':
419 warn_on_notrace_sect = 1;
420 break;
421 default:
422 fprintf(stderr, "usage: recordmcount [-w] file.o...\n");
423 return 0;
424 }
425 }
426
427 if ((argc - optind) < 1) {
428 fprintf(stderr, "usage: recordmcount [-w] file.o...\n");
429 return 0;
430 }
431
432 /* Process each file in turn, allowing deep failure. */
433 for (i = optind; i < argc; i++) {
434 char *file = argv[i];
435 int const sjval = setjmp(jmpenv);
436 int len;
437
438 /*
439 * The file kernel/trace/ftrace.o references the mcount
440 * function but does not call it. Since ftrace.o should
441 * not be traced anyway, we just skip it.
442 */
443 len = strlen(file);
444 if (len >= ftrace_size &&
445 strcmp(file + (len - ftrace_size), ftrace) == 0)
446 continue;
447
448 switch (sjval) {
449 default:
450 fprintf(stderr, "internal error: %s\n", file);
451 exit(1);
452 break;
453 case SJ_SETJMP: /* normal sequence */
454 /* Avoid problems if early cleanup() */
455 fd_map = -1;
456 ehdr_curr = NULL;
457 mmap_failed = 1;
458 do_file(file);
459 break;
460 case SJ_FAIL: /* error in do_file or below */
461 ++n_error;
462 break;
463 case SJ_SUCCEED: /* premature success */
464 /* do nothing */
465 break;
466 } /* end switch */
467 }
468 return !!n_error;
469}
470
471
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
new file mode 100644
index 000000000000..f40a6af6bf40
--- /dev/null
+++ b/scripts/recordmcount.h
@@ -0,0 +1,553 @@
1/*
2 * recordmcount.h
3 *
4 * This code was taken out of recordmcount.c written by
5 * Copyright 2009 John F. Reiser <jreiser@BitWagon.com>. All rights reserved.
6 *
7 * The original code had the same algorithms for both 32bit
8 * and 64bit ELF files, but the code was duplicated to support
9 * the difference in structures that were used. This
10 * file creates a macro of everything that is different between
11 * the 64 and 32 bit code, such that by including this header
12 * twice we can create both sets of functions by including this
13 * header once with RECORD_MCOUNT_64 undefined, and again with
14 * it defined.
15 *
16 * This conversion to macros was done by:
17 * Copyright 2010 Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
18 *
19 * Licensed under the GNU General Public License, version 2 (GPLv2).
20 */
21#undef append_func
22#undef is_fake_mcount
23#undef fn_is_fake_mcount
24#undef MIPS_is_fake_mcount
25#undef mcount_adjust
26#undef sift_rel_mcount
27#undef nop_mcount
28#undef find_secsym_ndx
29#undef __has_rel_mcount
30#undef has_rel_mcount
31#undef tot_relsize
32#undef get_mcountsym
33#undef get_sym_str_and_relp
34#undef do_func
35#undef Elf_Addr
36#undef Elf_Ehdr
37#undef Elf_Shdr
38#undef Elf_Rel
39#undef Elf_Rela
40#undef Elf_Sym
41#undef ELF_R_SYM
42#undef Elf_r_sym
43#undef ELF_R_INFO
44#undef Elf_r_info
45#undef ELF_ST_BIND
46#undef ELF_ST_TYPE
47#undef fn_ELF_R_SYM
48#undef fn_ELF_R_INFO
49#undef uint_t
50#undef _w
51#undef _align
52#undef _size
53
54#ifdef RECORD_MCOUNT_64
55# define append_func append64
56# define sift_rel_mcount sift64_rel_mcount
57# define nop_mcount nop_mcount_64
58# define find_secsym_ndx find64_secsym_ndx
59# define __has_rel_mcount __has64_rel_mcount
60# define has_rel_mcount has64_rel_mcount
61# define tot_relsize tot64_relsize
62# define get_sym_str_and_relp get_sym_str_and_relp_64
63# define do_func do64
64# define get_mcountsym get_mcountsym_64
65# define is_fake_mcount is_fake_mcount64
66# define fn_is_fake_mcount fn_is_fake_mcount64
67# define MIPS_is_fake_mcount MIPS64_is_fake_mcount
68# define mcount_adjust mcount_adjust_64
69# define Elf_Addr Elf64_Addr
70# define Elf_Ehdr Elf64_Ehdr
71# define Elf_Shdr Elf64_Shdr
72# define Elf_Rel Elf64_Rel
73# define Elf_Rela Elf64_Rela
74# define Elf_Sym Elf64_Sym
75# define ELF_R_SYM ELF64_R_SYM
76# define Elf_r_sym Elf64_r_sym
77# define ELF_R_INFO ELF64_R_INFO
78# define Elf_r_info Elf64_r_info
79# define ELF_ST_BIND ELF64_ST_BIND
80# define ELF_ST_TYPE ELF64_ST_TYPE
81# define fn_ELF_R_SYM fn_ELF64_R_SYM
82# define fn_ELF_R_INFO fn_ELF64_R_INFO
83# define uint_t uint64_t
84# define _w w8
85# define _align 7u
86# define _size 8
87#else
88# define append_func append32
89# define sift_rel_mcount sift32_rel_mcount
90# define nop_mcount nop_mcount_32
91# define find_secsym_ndx find32_secsym_ndx
92# define __has_rel_mcount __has32_rel_mcount
93# define has_rel_mcount has32_rel_mcount
94# define tot_relsize tot32_relsize
95# define get_sym_str_and_relp get_sym_str_and_relp_32
96# define do_func do32
97# define get_mcountsym get_mcountsym_32
98# define is_fake_mcount is_fake_mcount32
99# define fn_is_fake_mcount fn_is_fake_mcount32
100# define MIPS_is_fake_mcount MIPS32_is_fake_mcount
101# define mcount_adjust mcount_adjust_32
102# define Elf_Addr Elf32_Addr
103# define Elf_Ehdr Elf32_Ehdr
104# define Elf_Shdr Elf32_Shdr
105# define Elf_Rel Elf32_Rel
106# define Elf_Rela Elf32_Rela
107# define Elf_Sym Elf32_Sym
108# define ELF_R_SYM ELF32_R_SYM
109# define Elf_r_sym Elf32_r_sym
110# define ELF_R_INFO ELF32_R_INFO
111# define Elf_r_info Elf32_r_info
112# define ELF_ST_BIND ELF32_ST_BIND
113# define ELF_ST_TYPE ELF32_ST_TYPE
114# define fn_ELF_R_SYM fn_ELF32_R_SYM
115# define fn_ELF_R_INFO fn_ELF32_R_INFO
116# define uint_t uint32_t
117# define _w w
118# define _align 3u
119# define _size 4
120#endif
121
122/* Functions and pointers that do_file() may override for specific e_machine. */
123static int fn_is_fake_mcount(Elf_Rel const *rp)
124{
125 return 0;
126}
127static int (*is_fake_mcount)(Elf_Rel const *rp) = fn_is_fake_mcount;
128
129static uint_t fn_ELF_R_SYM(Elf_Rel const *rp)
130{
131 return ELF_R_SYM(_w(rp->r_info));
132}
133static uint_t (*Elf_r_sym)(Elf_Rel const *rp) = fn_ELF_R_SYM;
134
135static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
136{
137 rp->r_info = _w(ELF_R_INFO(sym, type));
138}
139static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
140
141static int mcount_adjust = 0;
142
143/*
144 * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st
145 * _mcount symbol is needed for dynamic function tracer, with it, to disable
146 * tracing(ftrace_make_nop), the instruction in the position is replaced with
147 * the "b label" instruction, to enable tracing(ftrace_make_call), replace the
148 * instruction back. So, here, we set the 2nd one as fake and filter it.
149 *
150 * c: 3c030000 lui v1,0x0 <--> b label
151 * c: R_MIPS_HI16 _mcount
152 * c: R_MIPS_NONE *ABS*
153 * c: R_MIPS_NONE *ABS*
154 * 10: 64630000 daddiu v1,v1,0
155 * 10: R_MIPS_LO16 _mcount
156 * 10: R_MIPS_NONE *ABS*
157 * 10: R_MIPS_NONE *ABS*
158 * 14: 03e0082d move at,ra
159 * 18: 0060f809 jalr v1
160 * label:
161 */
162#define MIPS_FAKEMCOUNT_OFFSET 4
163
164static int MIPS_is_fake_mcount(Elf_Rel const *rp)
165{
166 static Elf_Addr old_r_offset;
167 Elf_Addr current_r_offset = _w(rp->r_offset);
168 int is_fake;
169
170 is_fake = old_r_offset &&
171 (current_r_offset - old_r_offset == MIPS_FAKEMCOUNT_OFFSET);
172 old_r_offset = current_r_offset;
173
174 return is_fake;
175}
176
177/* Append the new shstrtab, Elf_Shdr[], __mcount_loc and its relocations. */
178static void append_func(Elf_Ehdr *const ehdr,
179 Elf_Shdr *const shstr,
180 uint_t const *const mloc0,
181 uint_t const *const mlocp,
182 Elf_Rel const *const mrel0,
183 Elf_Rel const *const mrelp,
184 unsigned int const rel_entsize,
185 unsigned int const symsec_sh_link)
186{
187 /* Begin constructing output file */
188 Elf_Shdr mcsec;
189 char const *mc_name = (sizeof(Elf_Rela) == rel_entsize)
190 ? ".rela__mcount_loc"
191 : ".rel__mcount_loc";
192 unsigned const old_shnum = w2(ehdr->e_shnum);
193 uint_t const old_shoff = _w(ehdr->e_shoff);
194 uint_t const old_shstr_sh_size = _w(shstr->sh_size);
195 uint_t const old_shstr_sh_offset = _w(shstr->sh_offset);
196 uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size);
197 uint_t new_e_shoff;
198
199 shstr->sh_size = _w(t);
200 shstr->sh_offset = _w(sb.st_size);
201 t += sb.st_size;
202 t += (_align & -t); /* word-byte align */
203 new_e_shoff = t;
204
205 /* body for new shstrtab */
206 ulseek(fd_map, sb.st_size, SEEK_SET);
207 uwrite(fd_map, old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size);
208 uwrite(fd_map, mc_name, 1 + strlen(mc_name));
209
210 /* old(modified) Elf_Shdr table, word-byte aligned */
211 ulseek(fd_map, t, SEEK_SET);
212 t += sizeof(Elf_Shdr) * old_shnum;
213 uwrite(fd_map, old_shoff + (void *)ehdr,
214 sizeof(Elf_Shdr) * old_shnum);
215
216 /* new sections __mcount_loc and .rel__mcount_loc */
217 t += 2*sizeof(mcsec);
218 mcsec.sh_name = w((sizeof(Elf_Rela) == rel_entsize) + strlen(".rel")
219 + old_shstr_sh_size);
220 mcsec.sh_type = w(SHT_PROGBITS);
221 mcsec.sh_flags = _w(SHF_ALLOC);
222 mcsec.sh_addr = 0;
223 mcsec.sh_offset = _w(t);
224 mcsec.sh_size = _w((void *)mlocp - (void *)mloc0);
225 mcsec.sh_link = 0;
226 mcsec.sh_info = 0;
227 mcsec.sh_addralign = _w(_size);
228 mcsec.sh_entsize = _w(_size);
229 uwrite(fd_map, &mcsec, sizeof(mcsec));
230
231 mcsec.sh_name = w(old_shstr_sh_size);
232 mcsec.sh_type = (sizeof(Elf_Rela) == rel_entsize)
233 ? w(SHT_RELA)
234 : w(SHT_REL);
235 mcsec.sh_flags = 0;
236 mcsec.sh_addr = 0;
237 mcsec.sh_offset = _w((void *)mlocp - (void *)mloc0 + t);
238 mcsec.sh_size = _w((void *)mrelp - (void *)mrel0);
239 mcsec.sh_link = w(symsec_sh_link);
240 mcsec.sh_info = w(old_shnum);
241 mcsec.sh_addralign = _w(_size);
242 mcsec.sh_entsize = _w(rel_entsize);
243 uwrite(fd_map, &mcsec, sizeof(mcsec));
244
245 uwrite(fd_map, mloc0, (void *)mlocp - (void *)mloc0);
246 uwrite(fd_map, mrel0, (void *)mrelp - (void *)mrel0);
247
248 ehdr->e_shoff = _w(new_e_shoff);
249 ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */
250 ulseek(fd_map, 0, SEEK_SET);
251 uwrite(fd_map, ehdr, sizeof(*ehdr));
252}
253
254static unsigned get_mcountsym(Elf_Sym const *const sym0,
255 Elf_Rel const *relp,
256 char const *const str0)
257{
258 unsigned mcountsym = 0;
259
260 Elf_Sym const *const symp =
261 &sym0[Elf_r_sym(relp)];
262 char const *symname = &str0[w(symp->st_name)];
263 char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
264
265 if (symname[0] == '.')
266 ++symname; /* ppc64 hack */
267 if (strcmp(mcount, symname) == 0 ||
268 (altmcount && strcmp(altmcount, symname) == 0))
269 mcountsym = Elf_r_sym(relp);
270
271 return mcountsym;
272}
273
274static void get_sym_str_and_relp(Elf_Shdr const *const relhdr,
275 Elf_Ehdr const *const ehdr,
276 Elf_Sym const **sym0,
277 char const **str0,
278 Elf_Rel const **relp)
279{
280 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
281 + (void *)ehdr);
282 unsigned const symsec_sh_link = w(relhdr->sh_link);
283 Elf_Shdr const *const symsec = &shdr0[symsec_sh_link];
284 Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)];
285 Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset)
286 + (void *)ehdr);
287
288 *sym0 = (Elf_Sym const *)(_w(symsec->sh_offset)
289 + (void *)ehdr);
290
291 *str0 = (char const *)(_w(strsec->sh_offset)
292 + (void *)ehdr);
293
294 *relp = rel0;
295}
296
297/*
298 * Look at the relocations in order to find the calls to mcount.
299 * Accumulate the section offsets that are found, and their relocation info,
300 * onto the end of the existing arrays.
301 */
302static uint_t *sift_rel_mcount(uint_t *mlocp,
303 unsigned const offbase,
304 Elf_Rel **const mrelpp,
305 Elf_Shdr const *const relhdr,
306 Elf_Ehdr const *const ehdr,
307 unsigned const recsym,
308 uint_t const recval,
309 unsigned const reltype)
310{
311 uint_t *const mloc0 = mlocp;
312 Elf_Rel *mrelp = *mrelpp;
313 Elf_Sym const *sym0;
314 char const *str0;
315 Elf_Rel const *relp;
316 unsigned rel_entsize = _w(relhdr->sh_entsize);
317 unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
318 unsigned mcountsym = 0;
319 unsigned t;
320
321 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp);
322
323 for (t = nrel; t; --t) {
324 if (!mcountsym)
325 mcountsym = get_mcountsym(sym0, relp, str0);
326
327 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
328 uint_t const addend =
329 _w(_w(relp->r_offset) - recval + mcount_adjust);
330 mrelp->r_offset = _w(offbase
331 + ((void *)mlocp - (void *)mloc0));
332 Elf_r_info(mrelp, recsym, reltype);
333 if (rel_entsize == sizeof(Elf_Rela)) {
334 ((Elf_Rela *)mrelp)->r_addend = addend;
335 *mlocp++ = 0;
336 } else
337 *mlocp++ = addend;
338
339 mrelp = (Elf_Rel *)(rel_entsize + (void *)mrelp);
340 }
341 relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
342 }
343 *mrelpp = mrelp;
344 return mlocp;
345}
346
347/*
348 * Read the relocation table again, but this time its called on sections
349 * that are not going to be traced. The mcount calls here will be converted
350 * into nops.
351 */
352static void nop_mcount(Elf_Shdr const *const relhdr,
353 Elf_Ehdr const *const ehdr,
354 const char *const txtname)
355{
356 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
357 + (void *)ehdr);
358 Elf_Sym const *sym0;
359 char const *str0;
360 Elf_Rel const *relp;
361 Elf_Shdr const *const shdr = &shdr0[w(relhdr->sh_info)];
362 unsigned rel_entsize = _w(relhdr->sh_entsize);
363 unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
364 unsigned mcountsym = 0;
365 unsigned t;
366 int once = 0;
367
368 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp);
369
370 for (t = nrel; t; --t) {
371 int ret = -1;
372
373 if (!mcountsym)
374 mcountsym = get_mcountsym(sym0, relp, str0);
375
376 if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) {
377 if (make_nop)
378 ret = make_nop((void *)ehdr, shdr->sh_offset + relp->r_offset);
379 if (warn_on_notrace_sect && !once) {
380 printf("Section %s has mcount callers being ignored\n",
381 txtname);
382 once = 1;
383 /* just warn? */
384 if (!make_nop)
385 return;
386 }
387 }
388
389 /*
390 * If we successfully removed the mcount, mark the relocation
391 * as a nop (don't do anything with it).
392 */
393 if (!ret) {
394 Elf_Rel rel;
395 rel = *(Elf_Rel *)relp;
396 Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop);
397 ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
398 uwrite(fd_map, &rel, sizeof(rel));
399 }
400 relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
401 }
402}
403
404
405/*
406 * Find a symbol in the given section, to be used as the base for relocating
407 * the table of offsets of calls to mcount. A local or global symbol suffices,
408 * but avoid a Weak symbol because it may be overridden; the change in value
409 * would invalidate the relocations of the offsets of the calls to mcount.
410 * Often the found symbol will be the unnamed local symbol generated by
411 * GNU 'as' for the start of each section. For example:
412 * Num: Value Size Type Bind Vis Ndx Name
413 * 2: 00000000 0 SECTION LOCAL DEFAULT 1
414 */
415static unsigned find_secsym_ndx(unsigned const txtndx,
416 char const *const txtname,
417 uint_t *const recvalp,
418 Elf_Shdr const *const symhdr,
419 Elf_Ehdr const *const ehdr)
420{
421 Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symhdr->sh_offset)
422 + (void *)ehdr);
423 unsigned const nsym = _w(symhdr->sh_size) / _w(symhdr->sh_entsize);
424 Elf_Sym const *symp;
425 unsigned t;
426
427 for (symp = sym0, t = nsym; t; --t, ++symp) {
428 unsigned int const st_bind = ELF_ST_BIND(symp->st_info);
429
430 if (txtndx == w2(symp->st_shndx)
431 /* avoid STB_WEAK */
432 && (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) {
433 /* function symbols on ARM have quirks, avoid them */
434 if (w2(ehdr->e_machine) == EM_ARM
435 && ELF_ST_TYPE(symp->st_info) == STT_FUNC)
436 continue;
437
438 *recvalp = _w(symp->st_value);
439 return symp - sym0;
440 }
441 }
442 fprintf(stderr, "Cannot find symbol for section %d: %s.\n",
443 txtndx, txtname);
444 fail_file();
445}
446
447
448/* Evade ISO C restriction: no declaration after statement in has_rel_mcount. */
449static char const *
450__has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
451 Elf_Shdr const *const shdr0,
452 char const *const shstrtab,
453 char const *const fname)
454{
455 /* .sh_info depends on .sh_type == SHT_REL[,A] */
456 Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)];
457 char const *const txtname = &shstrtab[w(txthdr->sh_name)];
458
459 if (strcmp("__mcount_loc", txtname) == 0) {
460 fprintf(stderr, "warning: __mcount_loc already exists: %s\n",
461 fname);
462 succeed_file();
463 }
464 if (w(txthdr->sh_type) != SHT_PROGBITS ||
465 !(w(txthdr->sh_flags) & SHF_EXECINSTR))
466 return NULL;
467 return txtname;
468}
469
470static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
471 Elf_Shdr const *const shdr0,
472 char const *const shstrtab,
473 char const *const fname)
474{
475 if (w(relhdr->sh_type) != SHT_REL && w(relhdr->sh_type) != SHT_RELA)
476 return NULL;
477 return __has_rel_mcount(relhdr, shdr0, shstrtab, fname);
478}
479
480
481static unsigned tot_relsize(Elf_Shdr const *const shdr0,
482 unsigned nhdr,
483 const char *const shstrtab,
484 const char *const fname)
485{
486 unsigned totrelsz = 0;
487 Elf_Shdr const *shdrp = shdr0;
488 char const *txtname;
489
490 for (; nhdr; --nhdr, ++shdrp) {
491 txtname = has_rel_mcount(shdrp, shdr0, shstrtab, fname);
492 if (txtname && is_mcounted_section_name(txtname))
493 totrelsz += _w(shdrp->sh_size);
494 }
495 return totrelsz;
496}
497
498
499/* Overall supervision for Elf32 ET_REL file. */
500static void
501do_func(Elf_Ehdr *const ehdr, char const *const fname, unsigned const reltype)
502{
503 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff)
504 + (void *)ehdr);
505 unsigned const nhdr = w2(ehdr->e_shnum);
506 Elf_Shdr *const shstr = &shdr0[w2(ehdr->e_shstrndx)];
507 char const *const shstrtab = (char const *)(_w(shstr->sh_offset)
508 + (void *)ehdr);
509
510 Elf_Shdr const *relhdr;
511 unsigned k;
512
513 /* Upper bound on space: assume all relevant relocs are for mcount. */
514 unsigned const totrelsz = tot_relsize(shdr0, nhdr, shstrtab, fname);
515 Elf_Rel *const mrel0 = umalloc(totrelsz);
516 Elf_Rel * mrelp = mrel0;
517
518 /* 2*sizeof(address) <= sizeof(Elf_Rel) */
519 uint_t *const mloc0 = umalloc(totrelsz>>1);
520 uint_t * mlocp = mloc0;
521
522 unsigned rel_entsize = 0;
523 unsigned symsec_sh_link = 0;
524
525 for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) {
526 char const *const txtname = has_rel_mcount(relhdr, shdr0,
527 shstrtab, fname);
528 if (txtname && is_mcounted_section_name(txtname)) {
529 uint_t recval = 0;
530 unsigned const recsym = find_secsym_ndx(
531 w(relhdr->sh_info), txtname, &recval,
532 &shdr0[symsec_sh_link = w(relhdr->sh_link)],
533 ehdr);
534
535 rel_entsize = _w(relhdr->sh_entsize);
536 mlocp = sift_rel_mcount(mlocp,
537 (void *)mlocp - (void *)mloc0, &mrelp,
538 relhdr, ehdr, recsym, recval, reltype);
539 } else if (txtname && (warn_on_notrace_sect || make_nop)) {
540 /*
541 * This section is ignored by ftrace, but still
542 * has mcount calls. Convert them to nops now.
543 */
544 nop_mcount(relhdr, ehdr, txtname);
545 }
546 }
547 if (mloc0 != mlocp) {
548 append_func(ehdr, shstr, mloc0, mlocp, mrel0, mrelp,
549 rel_entsize, symsec_sh_link);
550 }
551 free(mrel0);
552 free(mloc0);
553}
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index e67f05486087..858966ab019c 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -130,9 +130,11 @@ if ($inputfile =~ m,kernel/trace/ftrace\.o$,) {
130# Acceptable sections to record. 130# Acceptable sections to record.
131my %text_sections = ( 131my %text_sections = (
132 ".text" => 1, 132 ".text" => 1,
133 ".ref.text" => 1,
133 ".sched.text" => 1, 134 ".sched.text" => 1,
134 ".spinlock.text" => 1, 135 ".spinlock.text" => 1,
135 ".irqentry.text" => 1, 136 ".irqentry.text" => 1,
137 ".kprobes.text" => 1,
136 ".text.unlikely" => 1, 138 ".text.unlikely" => 1,
137); 139);
138 140
@@ -221,6 +223,7 @@ if ($arch eq "x86_64") {
221 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; 223 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$";
222 $type = ".quad"; 224 $type = ".quad";
223 $alignment = 8; 225 $alignment = 8;
226 $mcount_adjust = -1;
224 227
225 # force flags for this arch 228 # force flags for this arch
226 $ld .= " -m elf_x86_64"; 229 $ld .= " -m elf_x86_64";
@@ -230,6 +233,7 @@ if ($arch eq "x86_64") {
230 233
231} elsif ($arch eq "i386") { 234} elsif ($arch eq "i386") {
232 $alignment = 4; 235 $alignment = 4;
236 $mcount_adjust = -1;
233 237
234 # force flags for this arch 238 # force flags for this arch
235 $ld .= " -m elf_i386"; 239 $ld .= " -m elf_i386";
@@ -239,12 +243,14 @@ if ($arch eq "x86_64") {
239 243
240} elsif ($arch eq "s390" && $bits == 32) { 244} elsif ($arch eq "s390" && $bits == 32) {
241 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_32\\s+_mcount\$"; 245 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_32\\s+_mcount\$";
246 $mcount_adjust = -4;
242 $alignment = 4; 247 $alignment = 4;
243 $ld .= " -m elf_s390"; 248 $ld .= " -m elf_s390";
244 $cc .= " -m31"; 249 $cc .= " -m31";
245 250
246} elsif ($arch eq "s390" && $bits == 64) { 251} elsif ($arch eq "s390" && $bits == 64) {
247 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$"; 252 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$";
253 $mcount_adjust = -8;
248 $alignment = 8; 254 $alignment = 8;
249 $type = ".quad"; 255 $type = ".quad";
250 $ld .= " -m elf64_s390"; 256 $ld .= " -m elf64_s390";
@@ -270,6 +276,8 @@ if ($arch eq "x86_64") {
270} elsif ($arch eq "arm") { 276} elsif ($arch eq "arm") {
271 $alignment = 2; 277 $alignment = 2;
272 $section_type = '%progbits'; 278 $section_type = '%progbits';
279 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
280 "\\s+(__gnu_mcount_nc|mcount)\$";
273 281
274} elsif ($arch eq "ia64") { 282} elsif ($arch eq "ia64") {
275 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 283 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
diff --git a/scripts/rt-tester/rt-tester.py b/scripts/rt-tester/rt-tester.py
index 44423b4dcb82..34186cac1d2f 100644
--- a/scripts/rt-tester/rt-tester.py
+++ b/scripts/rt-tester/rt-tester.py
@@ -33,8 +33,6 @@ cmd_opcodes = {
33 "lockintnowait" : "6", 33 "lockintnowait" : "6",
34 "lockcont" : "7", 34 "lockcont" : "7",
35 "unlock" : "8", 35 "unlock" : "8",
36 "lockbkl" : "9",
37 "unlockbkl" : "10",
38 "signal" : "11", 36 "signal" : "11",
39 "resetevent" : "98", 37 "resetevent" : "98",
40 "reset" : "99", 38 "reset" : "99",
@@ -182,7 +180,7 @@ while 1:
182 for s in stat: 180 for s in stat:
183 s = s.strip() 181 s = s.strip()
184 if s.startswith(testop[0]): 182 if s.startswith(testop[0]):
185 # Seperate status value 183 # Separate status value
186 val = s[2:].strip() 184 val = s[2:].strip()
187 query = analyse(val, testop, dat) 185 query = analyse(val, testop, dat)
188 break 186 break
diff --git a/scripts/rt-tester/t2-l1-2rt-sameprio.tst b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
index 8821f27cc8be..3710c8b2090d 100644
--- a/scripts/rt-tester/t2-l1-2rt-sameprio.tst
+++ b/scripts/rt-tester/t2-l1-2rt-sameprio.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0 22# signal 0
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t2-l1-pi.tst b/scripts/rt-tester/t2-l1-pi.tst
index cde1f189a02b..b4cc95975adb 100644
--- a/scripts/rt-tester/t2-l1-pi.tst
+++ b/scripts/rt-tester/t2-l1-pi.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0 22# signal 0
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t2-l1-signal.tst b/scripts/rt-tester/t2-l1-signal.tst
index 3ab0bfc49950..1b57376cc1f7 100644
--- a/scripts/rt-tester/t2-l1-signal.tst
+++ b/scripts/rt-tester/t2-l1-signal.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0 22# signal 0
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t2-l2-2rt-deadlock.tst b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
index f4b5d5d6215f..68b10629b6f4 100644
--- a/scripts/rt-tester/t2-l2-2rt-deadlock.tst
+++ b/scripts/rt-tester/t2-l2-2rt-deadlock.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal 0 22# signal 0
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l1-pi-1rt.tst b/scripts/rt-tester/t3-l1-pi-1rt.tst
index 63440ca2cce9..8e6c8b11ae56 100644
--- a/scripts/rt-tester/t3-l1-pi-1rt.tst
+++ b/scripts/rt-tester/t3-l1-pi-1rt.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l1-pi-2rt.tst b/scripts/rt-tester/t3-l1-pi-2rt.tst
index e5816fe67df3..69c2212fc520 100644
--- a/scripts/rt-tester/t3-l1-pi-2rt.tst
+++ b/scripts/rt-tester/t3-l1-pi-2rt.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l1-pi-3rt.tst b/scripts/rt-tester/t3-l1-pi-3rt.tst
index 718b82b5d3bb..9b0f1eb26a88 100644
--- a/scripts/rt-tester/t3-l1-pi-3rt.tst
+++ b/scripts/rt-tester/t3-l1-pi-3rt.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l1-pi-signal.tst b/scripts/rt-tester/t3-l1-pi-signal.tst
index c6e213563498..39ec74ab06ee 100644
--- a/scripts/rt-tester/t3-l1-pi-signal.tst
+++ b/scripts/rt-tester/t3-l1-pi-signal.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l1-pi-steal.tst b/scripts/rt-tester/t3-l1-pi-steal.tst
index f53749d59d79..e03db7e010fa 100644
--- a/scripts/rt-tester/t3-l1-pi-steal.tst
+++ b/scripts/rt-tester/t3-l1-pi-steal.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t3-l2-pi.tst b/scripts/rt-tester/t3-l2-pi.tst
index cdc3e4fd7bac..7b59100d3e48 100644
--- a/scripts/rt-tester/t3-l2-pi.tst
+++ b/scripts/rt-tester/t3-l2-pi.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t4-l2-pi-deboost.tst b/scripts/rt-tester/t4-l2-pi-deboost.tst
index baa14137f473..2f0e049d6443 100644
--- a/scripts/rt-tester/t4-l2-pi-deboost.tst
+++ b/scripts/rt-tester/t4-l2-pi-deboost.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst b/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
index e6ec0c81b54d..04f4034ff895 100644
--- a/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
+++ b/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/rt-tester/t5-l4-pi-boost-deboost.tst b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
index ca64f8bbf4bc..a48a6ee29ddc 100644
--- a/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
+++ b/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
@@ -19,8 +19,6 @@
19# lockintnowait lock nr (0-7) 19# lockintnowait lock nr (0-7)
20# lockcont lock nr (0-7) 20# lockcont lock nr (0-7)
21# unlock lock nr (0-7) 21# unlock lock nr (0-7)
22# lockbkl lock nr (0-7)
23# unlockbkl lock nr (0-7)
24# signal thread to signal (0-7) 22# signal thread to signal (0-7)
25# reset 0 23# reset 0
26# resetevent 0 24# resetevent 0
@@ -39,9 +37,6 @@
39# blocked lock nr (0-7) 37# blocked lock nr (0-7)
40# blockedwake lock nr (0-7) 38# blockedwake lock nr (0-7)
41# unlocked lock nr (0-7) 39# unlocked lock nr (0-7)
42# lockedbkl dont care
43# blockedbkl dont care
44# unlockedbkl dont care
45# opcodeeq command opcode or number 40# opcodeeq command opcode or number
46# opcodelt number 41# opcodelt number
47# opcodegt number 42# opcodegt number
diff --git a/scripts/selinux/README b/scripts/selinux/README
index a936315ba2c8..4d020ecb7524 100644
--- a/scripts/selinux/README
+++ b/scripts/selinux/README
@@ -1,2 +1,2 @@
1Please see Documentation/SELinux.txt for information on 1Please see Documentation/security/SELinux.txt for information on
2installing a dummy SELinux policy. 2installing a dummy SELinux policy.
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c
index 58a12c278706..539855ff31f9 100644
--- a/scripts/selinux/genheaders/genheaders.c
+++ b/scripts/selinux/genheaders/genheaders.c
@@ -43,6 +43,8 @@ int main(int argc, char *argv[])
43 int i, j, k; 43 int i, j, k;
44 int isids_len; 44 int isids_len;
45 FILE *fout; 45 FILE *fout;
46 const char *needle = "SOCKET";
47 char *substr;
46 48
47 progname = argv[0]; 49 progname = argv[0];
48 50
@@ -88,6 +90,24 @@ int main(int argc, char *argv[])
88 fprintf(fout, "%2d\n", i); 90 fprintf(fout, "%2d\n", i);
89 } 91 }
90 fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1); 92 fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1);
93 fprintf(fout, "\nstatic inline bool security_is_socket_class(u16 kern_tclass)\n");
94 fprintf(fout, "{\n");
95 fprintf(fout, "\tbool sock = false;\n\n");
96 fprintf(fout, "\tswitch (kern_tclass) {\n");
97 for (i = 0; secclass_map[i].name; i++) {
98 struct security_class_mapping *map = &secclass_map[i];
99 substr = strstr(map->name, needle);
100 if (substr && strcmp(substr, needle) == 0)
101 fprintf(fout, "\tcase SECCLASS_%s:\n", map->name);
102 }
103 fprintf(fout, "\t\tsock = true;\n");
104 fprintf(fout, "\t\tbreak;\n");
105 fprintf(fout, "\tdefault:\n");
106 fprintf(fout, "\t\tbreak;\n");
107 fprintf(fout, "\t}\n\n");
108 fprintf(fout, "\treturn sock;\n");
109 fprintf(fout, "}\n");
110
91 fprintf(fout, "\n#endif\n"); 111 fprintf(fout, "\n#endif\n");
92 fclose(fout); 112 fclose(fout);
93 113
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 057b6b3c5dfb..4d403844e137 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -86,12 +86,16 @@ scm_version()
86 86
87 # Check for mercurial and a mercurial repo. 87 # Check for mercurial and a mercurial repo.
88 if test -d .hg && hgid=`hg id 2>/dev/null`; then 88 if test -d .hg && hgid=`hg id 2>/dev/null`; then
89 tag=`printf '%s' "$hgid" | cut -s -d' ' -f2` 89 # Do we have an tagged version? If so, latesttagdistance == 1
90 90 if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
91 # Do we have an untagged version? 91 id=`hg log -r . --template '{latesttag}'`
92 if [ -z "$tag" -o "$tag" = tip ]; then
93 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
94 printf '%s%s' -hg "$id" 92 printf '%s%s' -hg "$id"
93 else
94 tag=`printf '%s' "$hgid" | cut -d' ' -f2`
95 if [ -z "$tag" -o "$tag" = tip ]; then
96 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
97 printf '%s%s' -hg "$id"
98 fi
95 fi 99 fi
96 100
97 # Are there uncommitted changes? 101 # Are there uncommitted changes?
@@ -160,8 +164,10 @@ if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
160 # full scm version string 164 # full scm version string
161 res="$res$(scm_version)" 165 res="$res$(scm_version)"
162else 166else
163 # apped a plus sign if the repository is not in a clean tagged 167 # append a plus sign if the repository is not in a clean
164 # state and LOCALVERSION= is not specified 168 # annotated or signed tagged state (as git describe only
169 # looks at signed or annotated tags - git tag -a/-s) and
170 # LOCALVERSION= is not specified
165 if test "${LOCALVERSION+set}" != "set"; then 171 if test "${LOCALVERSION+set}" != "set"; then
166 scm=$(scm_version --short) 172 scm=$(scm_version --short)
167 res="$res${scm:++}" 173 res="$res${scm:++}"
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 8509bb512935..75c5d24f1993 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -114,6 +114,11 @@ docscope()
114 cscope -b -f cscope.out 114 cscope -b -f cscope.out
115} 115}
116 116
117dogtags()
118{
119 all_sources | gtags -f -
120}
121
117exuberant() 122exuberant()
118{ 123{
119 all_sources | xargs $1 -a \ 124 all_sources | xargs $1 -a \
@@ -123,9 +128,11 @@ exuberant()
123 -I ____cacheline_internodealigned_in_smp \ 128 -I ____cacheline_internodealigned_in_smp \
124 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 129 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
125 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ 130 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
126 --extra=+f --c-kinds=-px \ 131 --extra=+f --c-kinds=+px \
127 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ 132 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
128 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' 133 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \
134 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \
135 --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/'
129 136
130 all_kconfigs | xargs $1 -a \ 137 all_kconfigs | xargs $1 -a \
131 --langdef=kconfig --language-force=kconfig \ 138 --langdef=kconfig --language-force=kconfig \
@@ -145,7 +152,9 @@ emacs()
145{ 152{
146 all_sources | xargs $1 -a \ 153 all_sources | xargs $1 -a \
147 --regex='/^ENTRY(\([^)]*\)).*/\1/' \ 154 --regex='/^ENTRY(\([^)]*\)).*/\1/' \
148 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' 155 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \
156 --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \
157 --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/'
149 158
150 all_kconfigs | xargs $1 -a \ 159 all_kconfigs | xargs $1 -a \
151 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' 160 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
@@ -185,6 +194,10 @@ case "$1" in
185 docscope 194 docscope
186 ;; 195 ;;
187 196
197 "gtags")
198 dogtags
199 ;;
200
188 "tags") 201 "tags")
189 rm -f tags 202 rm -f tags
190 xtags ctags 203 xtags ctags
diff --git a/scripts/unifdef.c b/scripts/unifdef.c
index 44d39785e50d..7493c0ee51cc 100644
--- a/scripts/unifdef.c
+++ b/scripts/unifdef.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2002 - 2009 Tony Finch <dot@dotat.at> 2 * Copyright (c) 2002 - 2011 Tony Finch <dot@dotat.at>
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
@@ -24,23 +24,14 @@
24 */ 24 */
25 25
26/* 26/*
27 * unifdef - remove ifdef'ed lines
28 *
27 * This code was derived from software contributed to Berkeley by Dave Yost. 29 * This code was derived from software contributed to Berkeley by Dave Yost.
28 * It was rewritten to support ANSI C by Tony Finch. The original version 30 * It was rewritten to support ANSI C by Tony Finch. The original version
29 * of unifdef carried the 4-clause BSD copyright licence. None of its code 31 * of unifdef carried the 4-clause BSD copyright licence. None of its code
30 * remains in this version (though some of the names remain) so it now 32 * remains in this version (though some of the names remain) so it now
31 * carries a more liberal licence. 33 * carries a more liberal licence.
32 * 34 *
33 * The latest version is available from http://dotat.at/prog/unifdef
34 */
35
36static const char * const copyright[] = {
37 "@(#) Copyright (c) 2002 - 2009 Tony Finch <dot@dotat.at>\n",
38 "$dotat: unifdef/unifdef.c,v 1.190 2009/11/27 17:21:26 fanf2 Exp $",
39};
40
41/*
42 * unifdef - remove ifdef'ed lines
43 *
44 * Wishlist: 35 * Wishlist:
45 * provide an option which will append the name of the 36 * provide an option which will append the name of the
46 * appropriate symbol after #else's and #endif's 37 * appropriate symbol after #else's and #endif's
@@ -48,12 +39,16 @@ static const char * const copyright[] = {
48 * #else's and #endif's to see that they match their 39 * #else's and #endif's to see that they match their
49 * corresponding #ifdef or #ifndef 40 * corresponding #ifdef or #ifndef
50 * 41 *
51 * The first two items above require better buffer handling, which would 42 * These require better buffer handling, which would also make
52 * also make it possible to handle all "dodgy" directives correctly. 43 * it possible to handle all "dodgy" directives correctly.
53 */ 44 */
54 45
46#include <sys/types.h>
47#include <sys/stat.h>
48
55#include <ctype.h> 49#include <ctype.h>
56#include <err.h> 50#include <err.h>
51#include <errno.h>
57#include <stdarg.h> 52#include <stdarg.h>
58#include <stdbool.h> 53#include <stdbool.h>
59#include <stdio.h> 54#include <stdio.h>
@@ -61,6 +56,12 @@ static const char * const copyright[] = {
61#include <string.h> 56#include <string.h>
62#include <unistd.h> 57#include <unistd.h>
63 58
59const char copyright[] =
60 "@(#) $Version: unifdef-2.5 $\n"
61 "@(#) $Author: Tony Finch (dot@dotat.at) $\n"
62 "@(#) $URL: http://dotat.at/prog/unifdef $\n"
63;
64
64/* types of input lines: */ 65/* types of input lines: */
65typedef enum { 66typedef enum {
66 LT_TRUEI, /* a true #if with ignore flag */ 67 LT_TRUEI, /* a true #if with ignore flag */
@@ -153,6 +154,11 @@ static char const * const linestate_name[] = {
153#define EDITSLOP 10 154#define EDITSLOP 10
154 155
155/* 156/*
157 * For temporary filenames
158 */
159#define TEMPLATE "unifdef.XXXXXX"
160
161/*
156 * Globals. 162 * Globals.
157 */ 163 */
158 164
@@ -165,6 +171,7 @@ static bool strictlogic; /* -K: keep ambiguous #ifs */
165static bool killconsts; /* -k: eval constant #ifs */ 171static bool killconsts; /* -k: eval constant #ifs */
166static bool lnnum; /* -n: add #line directives */ 172static bool lnnum; /* -n: add #line directives */
167static bool symlist; /* -s: output symbol list */ 173static bool symlist; /* -s: output symbol list */
174static bool symdepth; /* -S: output symbol depth */
168static bool text; /* -t: this is a text file */ 175static bool text; /* -t: this is a text file */
169 176
170static const char *symname[MAXSYMS]; /* symbol name */ 177static const char *symname[MAXSYMS]; /* symbol name */
@@ -175,10 +182,18 @@ static int nsyms; /* number of symbols */
175static FILE *input; /* input file pointer */ 182static FILE *input; /* input file pointer */
176static const char *filename; /* input file name */ 183static const char *filename; /* input file name */
177static int linenum; /* current line number */ 184static int linenum; /* current line number */
185static FILE *output; /* output file pointer */
186static const char *ofilename; /* output file name */
187static bool overwriting; /* output overwrites input */
188static char tempname[FILENAME_MAX]; /* used when overwriting */
178 189
179static char tline[MAXLINE+EDITSLOP];/* input buffer plus space */ 190static char tline[MAXLINE+EDITSLOP];/* input buffer plus space */
180static char *keyword; /* used for editing #elif's */ 191static char *keyword; /* used for editing #elif's */
181 192
193static const char *newline; /* input file format */
194static const char newline_unix[] = "\n";
195static const char newline_crlf[] = "\r\n";
196
182static Comment_state incomment; /* comment parser state */ 197static Comment_state incomment; /* comment parser state */
183static Line_state linestate; /* #if line parser state */ 198static Line_state linestate; /* #if line parser state */
184static Ifstate ifstate[MAXDEPTH]; /* #if processor state */ 199static Ifstate ifstate[MAXDEPTH]; /* #if processor state */
@@ -189,10 +204,13 @@ static int delcount; /* count of deleted lines */
189static unsigned blankcount; /* count of blank lines */ 204static unsigned blankcount; /* count of blank lines */
190static unsigned blankmax; /* maximum recent blankcount */ 205static unsigned blankmax; /* maximum recent blankcount */
191static bool constexpr; /* constant #if expression */ 206static bool constexpr; /* constant #if expression */
207static bool zerosyms = true; /* to format symdepth output */
208static bool firstsym; /* ditto */
192 209
193static int exitstat; /* program exit status */ 210static int exitstat; /* program exit status */
194 211
195static void addsym(bool, bool, char *); 212static void addsym(bool, bool, char *);
213static void closeout(void);
196static void debug(const char *, ...); 214static void debug(const char *, ...);
197static void done(void); 215static void done(void);
198static void error(const char *); 216static void error(const char *);
@@ -212,6 +230,7 @@ static void state(Ifstate);
212static int strlcmp(const char *, const char *, size_t); 230static int strlcmp(const char *, const char *, size_t);
213static void unnest(void); 231static void unnest(void);
214static void usage(void); 232static void usage(void);
233static void version(void);
215 234
216#define endsym(c) (!isalnum((unsigned char)c) && c != '_') 235#define endsym(c) (!isalnum((unsigned char)c) && c != '_')
217 236
@@ -223,7 +242,7 @@ main(int argc, char *argv[])
223{ 242{
224 int opt; 243 int opt;
225 244
226 while ((opt = getopt(argc, argv, "i:D:U:I:BbcdeKklnst")) != -1) 245 while ((opt = getopt(argc, argv, "i:D:U:I:o:bBcdeKklnsStV")) != -1)
227 switch (opt) { 246 switch (opt) {
228 case 'i': /* treat stuff controlled by these symbols as text */ 247 case 'i': /* treat stuff controlled by these symbols as text */
229 /* 248 /*
@@ -245,16 +264,15 @@ main(int argc, char *argv[])
245 case 'U': /* undef a symbol */ 264 case 'U': /* undef a symbol */
246 addsym(false, false, optarg); 265 addsym(false, false, optarg);
247 break; 266 break;
248 case 'I': 267 case 'I': /* no-op for compatibility with cpp */
249 /* no-op for compatibility with cpp */
250 break;
251 case 'B': /* compress blank lines around removed section */
252 compblank = true;
253 break; 268 break;
254 case 'b': /* blank deleted lines instead of omitting them */ 269 case 'b': /* blank deleted lines instead of omitting them */
255 case 'l': /* backwards compatibility */ 270 case 'l': /* backwards compatibility */
256 lnblank = true; 271 lnblank = true;
257 break; 272 break;
273 case 'B': /* compress blank lines around removed section */
274 compblank = true;
275 break;
258 case 'c': /* treat -D as -U and vice versa */ 276 case 'c': /* treat -D as -U and vice versa */
259 complement = true; 277 complement = true;
260 break; 278 break;
@@ -273,12 +291,20 @@ main(int argc, char *argv[])
273 case 'n': /* add #line directive after deleted lines */ 291 case 'n': /* add #line directive after deleted lines */
274 lnnum = true; 292 lnnum = true;
275 break; 293 break;
294 case 'o': /* output to a file */
295 ofilename = optarg;
296 break;
276 case 's': /* only output list of symbols that control #ifs */ 297 case 's': /* only output list of symbols that control #ifs */
277 symlist = true; 298 symlist = true;
278 break; 299 break;
300 case 'S': /* list symbols with their nesting depth */
301 symlist = symdepth = true;
302 break;
279 case 't': /* don't parse C comments */ 303 case 't': /* don't parse C comments */
280 text = true; 304 text = true;
281 break; 305 break;
306 case 'V': /* print version */
307 version();
282 default: 308 default:
283 usage(); 309 usage();
284 } 310 }
@@ -290,21 +316,68 @@ main(int argc, char *argv[])
290 errx(2, "can only do one file"); 316 errx(2, "can only do one file");
291 } else if (argc == 1 && strcmp(*argv, "-") != 0) { 317 } else if (argc == 1 && strcmp(*argv, "-") != 0) {
292 filename = *argv; 318 filename = *argv;
293 input = fopen(filename, "r"); 319 input = fopen(filename, "rb");
294 if (input == NULL) 320 if (input == NULL)
295 err(2, "can't open %s", filename); 321 err(2, "can't open %s", filename);
296 } else { 322 } else {
297 filename = "[stdin]"; 323 filename = "[stdin]";
298 input = stdin; 324 input = stdin;
299 } 325 }
326 if (ofilename == NULL) {
327 ofilename = "[stdout]";
328 output = stdout;
329 } else {
330 struct stat ist, ost;
331 if (stat(ofilename, &ost) == 0 &&
332 fstat(fileno(input), &ist) == 0)
333 overwriting = (ist.st_dev == ost.st_dev
334 && ist.st_ino == ost.st_ino);
335 if (overwriting) {
336 const char *dirsep;
337 int ofd;
338
339 dirsep = strrchr(ofilename, '/');
340 if (dirsep != NULL)
341 snprintf(tempname, sizeof(tempname),
342 "%.*s/" TEMPLATE,
343 (int)(dirsep - ofilename), ofilename);
344 else
345 snprintf(tempname, sizeof(tempname),
346 TEMPLATE);
347 ofd = mkstemp(tempname);
348 if (ofd != -1)
349 output = fdopen(ofd, "wb+");
350 if (output == NULL)
351 err(2, "can't create temporary file");
352 fchmod(ofd, ist.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO));
353 } else {
354 output = fopen(ofilename, "wb");
355 if (output == NULL)
356 err(2, "can't open %s", ofilename);
357 }
358 }
300 process(); 359 process();
301 abort(); /* bug */ 360 abort(); /* bug */
302} 361}
303 362
304static void 363static void
364version(void)
365{
366 const char *c = copyright;
367 for (;;) {
368 while (*++c != '$')
369 if (*c == '\0')
370 exit(0);
371 while (*++c != '$')
372 putc(*c, stderr);
373 putc('\n', stderr);
374 }
375}
376
377static void
305usage(void) 378usage(void)
306{ 379{
307 fprintf(stderr, "usage: unifdef [-BbcdeKknst] [-Ipath]" 380 fprintf(stderr, "usage: unifdef [-bBcdeKknsStV] [-Ipath]"
308 " [-Dsym[=val]] [-Usym] [-iDsym[=val]] [-iUsym] ... [file]\n"); 381 " [-Dsym[=val]] [-Usym] [-iDsym[=val]] [-iUsym] ... [file]\n");
309 exit(2); 382 exit(2);
310} 383}
@@ -322,7 +395,8 @@ usage(void)
322 * When we have processed a group that starts off with a known-false 395 * When we have processed a group that starts off with a known-false
323 * #if/#elif sequence (which has therefore been deleted) followed by a 396 * #if/#elif sequence (which has therefore been deleted) followed by a
324 * #elif that we don't understand and therefore must keep, we edit the 397 * #elif that we don't understand and therefore must keep, we edit the
325 * latter into a #if to keep the nesting correct. 398 * latter into a #if to keep the nesting correct. We use strncpy() to
399 * overwrite the 4 byte token "elif" with "if " without a '\0' byte.
326 * 400 *
327 * When we find a true #elif in a group, the following block will 401 * When we find a true #elif in a group, the following block will
328 * always be kept and the rest of the sequence after the next #elif or 402 * always be kept and the rest of the sequence after the next #elif or
@@ -375,11 +449,11 @@ static void Oelif (void) { if (!iocccok) Eioccc(); Pelif(); }
375static void Idrop (void) { Fdrop(); ignoreon(); } 449static void Idrop (void) { Fdrop(); ignoreon(); }
376static void Itrue (void) { Ftrue(); ignoreon(); } 450static void Itrue (void) { Ftrue(); ignoreon(); }
377static void Ifalse(void) { Ffalse(); ignoreon(); } 451static void Ifalse(void) { Ffalse(); ignoreon(); }
378/* edit this line */ 452/* modify this line */
379static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); } 453static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); }
380static void Mtrue (void) { keywordedit("else\n"); state(IS_TRUE_MIDDLE); } 454static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); }
381static void Melif (void) { keywordedit("endif\n"); state(IS_FALSE_TRAILER); } 455static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); }
382static void Melse (void) { keywordedit("endif\n"); state(IS_FALSE_ELSE); } 456static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }
383 457
384static state_fn * const trans_table[IS_COUNT][LT_COUNT] = { 458static state_fn * const trans_table[IS_COUNT][LT_COUNT] = {
385/* IS_OUTSIDE */ 459/* IS_OUTSIDE */
@@ -431,13 +505,6 @@ static state_fn * const trans_table[IS_COUNT][LT_COUNT] = {
431 * State machine utility functions 505 * State machine utility functions
432 */ 506 */
433static void 507static void
434done(void)
435{
436 if (incomment)
437 error("EOF in comment");
438 exit(exitstat);
439}
440static void
441ignoreoff(void) 508ignoreoff(void)
442{ 509{
443 if (depth == 0) 510 if (depth == 0)
@@ -452,14 +519,8 @@ ignoreon(void)
452static void 519static void
453keywordedit(const char *replacement) 520keywordedit(const char *replacement)
454{ 521{
455 size_t size = tline + sizeof(tline) - keyword; 522 snprintf(keyword, tline + sizeof(tline) - keyword,
456 char *dst = keyword; 523 "%s%s", replacement, newline);
457 const char *src = replacement;
458 if (size != 0) {
459 while ((--size != 0) && (*src != '\0'))
460 *dst++ = *src++;
461 *dst = '\0';
462 }
463 print(); 524 print();
464} 525}
465static void 526static void
@@ -494,24 +555,26 @@ flushline(bool keep)
494 if (symlist) 555 if (symlist)
495 return; 556 return;
496 if (keep ^ complement) { 557 if (keep ^ complement) {
497 bool blankline = tline[strspn(tline, " \t\n")] == '\0'; 558 bool blankline = tline[strspn(tline, " \t\r\n")] == '\0';
498 if (blankline && compblank && blankcount != blankmax) { 559 if (blankline && compblank && blankcount != blankmax) {
499 delcount += 1; 560 delcount += 1;
500 blankcount += 1; 561 blankcount += 1;
501 } else { 562 } else {
502 if (lnnum && delcount > 0) 563 if (lnnum && delcount > 0)
503 printf("#line %d\n", linenum); 564 printf("#line %d%s", linenum, newline);
504 fputs(tline, stdout); 565 fputs(tline, output);
505 delcount = 0; 566 delcount = 0;
506 blankmax = blankcount = blankline ? blankcount + 1 : 0; 567 blankmax = blankcount = blankline ? blankcount + 1 : 0;
507 } 568 }
508 } else { 569 } else {
509 if (lnblank) 570 if (lnblank)
510 putc('\n', stdout); 571 fputs(newline, output);
511 exitstat = 1; 572 exitstat = 1;
512 delcount += 1; 573 delcount += 1;
513 blankcount = 0; 574 blankcount = 0;
514 } 575 }
576 if (debugging)
577 fflush(output);
515} 578}
516 579
517/* 580/*
@@ -520,22 +583,55 @@ flushline(bool keep)
520static void 583static void
521process(void) 584process(void)
522{ 585{
523 Linetype lineval;
524
525 /* When compressing blank lines, act as if the file 586 /* When compressing blank lines, act as if the file
526 is preceded by a large number of blank lines. */ 587 is preceded by a large number of blank lines. */
527 blankmax = blankcount = 1000; 588 blankmax = blankcount = 1000;
528 for (;;) { 589 for (;;) {
529 linenum++; 590 Linetype lineval = parseline();
530 lineval = parseline();
531 trans_table[ifstate[depth]][lineval](); 591 trans_table[ifstate[depth]][lineval]();
532 debug("process %s -> %s depth %d", 592 debug("process line %d %s -> %s depth %d",
533 linetype_name[lineval], 593 linenum, linetype_name[lineval],
534 ifstate_name[ifstate[depth]], depth); 594 ifstate_name[ifstate[depth]], depth);
535 } 595 }
536} 596}
537 597
538/* 598/*
599 * Flush the output and handle errors.
600 */
601static void
602closeout(void)
603{
604 if (symdepth && !zerosyms)
605 printf("\n");
606 if (fclose(output) == EOF) {
607 warn("couldn't write to %s", ofilename);
608 if (overwriting) {
609 unlink(tempname);
610 errx(2, "%s unchanged", filename);
611 } else {
612 exit(2);
613 }
614 }
615}
616
617/*
618 * Clean up and exit.
619 */
620static void
621done(void)
622{
623 if (incomment)
624 error("EOF in comment");
625 closeout();
626 if (overwriting && rename(tempname, ofilename) == -1) {
627 warn("couldn't rename temporary file");
628 unlink(tempname);
629 errx(2, "%s unchanged", ofilename);
630 }
631 exit(exitstat);
632}
633
634/*
539 * Parse a line and determine its type. We keep the preprocessor line 635 * Parse a line and determine its type. We keep the preprocessor line
540 * parser state between calls in the global variable linestate, with 636 * parser state between calls in the global variable linestate, with
541 * help from skipcomment(). 637 * help from skipcomment().
@@ -549,14 +645,22 @@ parseline(void)
549 Linetype retval; 645 Linetype retval;
550 Comment_state wascomment; 646 Comment_state wascomment;
551 647
648 linenum++;
552 if (fgets(tline, MAXLINE, input) == NULL) 649 if (fgets(tline, MAXLINE, input) == NULL)
553 return (LT_EOF); 650 return (LT_EOF);
651 if (newline == NULL) {
652 if (strrchr(tline, '\n') == strrchr(tline, '\r') + 1)
653 newline = newline_crlf;
654 else
655 newline = newline_unix;
656 }
554 retval = LT_PLAIN; 657 retval = LT_PLAIN;
555 wascomment = incomment; 658 wascomment = incomment;
556 cp = skipcomment(tline); 659 cp = skipcomment(tline);
557 if (linestate == LS_START) { 660 if (linestate == LS_START) {
558 if (*cp == '#') { 661 if (*cp == '#') {
559 linestate = LS_HASH; 662 linestate = LS_HASH;
663 firstsym = true;
560 cp = skipcomment(cp + 1); 664 cp = skipcomment(cp + 1);
561 } else if (*cp != '\0') 665 } else if (*cp != '\0')
562 linestate = LS_DIRTY; 666 linestate = LS_DIRTY;
@@ -566,7 +670,8 @@ parseline(void)
566 cp = skipsym(cp); 670 cp = skipsym(cp);
567 kwlen = cp - keyword; 671 kwlen = cp - keyword;
568 /* no way can we deal with a continuation inside a keyword */ 672 /* no way can we deal with a continuation inside a keyword */
569 if (strncmp(cp, "\\\n", 2) == 0) 673 if (strncmp(cp, "\\\r\n", 3) == 0 ||
674 strncmp(cp, "\\\n", 2) == 0)
570 Eioccc(); 675 Eioccc();
571 if (strlcmp("ifdef", keyword, kwlen) == 0 || 676 if (strlcmp("ifdef", keyword, kwlen) == 0 ||
572 strlcmp("ifndef", keyword, kwlen) == 0) { 677 strlcmp("ifndef", keyword, kwlen) == 0) {
@@ -617,9 +722,8 @@ parseline(void)
617 size_t len = cp - tline; 722 size_t len = cp - tline;
618 if (fgets(tline + len, MAXLINE - len, input) == NULL) { 723 if (fgets(tline + len, MAXLINE - len, input) == NULL) {
619 /* append the missing newline */ 724 /* append the missing newline */
620 tline[len+0] = '\n'; 725 strcpy(tline + len, newline);
621 tline[len+1] = '\0'; 726 cp += strlen(newline);
622 cp++;
623 linestate = LS_START; 727 linestate = LS_START;
624 } else { 728 } else {
625 linestate = LS_DIRTY; 729 linestate = LS_DIRTY;
@@ -630,7 +734,7 @@ parseline(void)
630 while (*cp != '\0') 734 while (*cp != '\0')
631 cp = skipcomment(cp + 1); 735 cp = skipcomment(cp + 1);
632 } 736 }
633 debug("parser %s comment %s line", 737 debug("parser line %d state %s comment %s line", linenum,
634 comment_name[incomment], linestate_name[linestate]); 738 comment_name[incomment], linestate_name[linestate]);
635 return (retval); 739 return (retval);
636} 740}
@@ -875,11 +979,16 @@ skipcomment(const char *cp)
875 } 979 }
876 while (*cp != '\0') 980 while (*cp != '\0')
877 /* don't reset to LS_START after a line continuation */ 981 /* don't reset to LS_START after a line continuation */
878 if (strncmp(cp, "\\\n", 2) == 0) 982 if (strncmp(cp, "\\\r\n", 3) == 0)
983 cp += 3;
984 else if (strncmp(cp, "\\\n", 2) == 0)
879 cp += 2; 985 cp += 2;
880 else switch (incomment) { 986 else switch (incomment) {
881 case NO_COMMENT: 987 case NO_COMMENT:
882 if (strncmp(cp, "/\\\n", 3) == 0) { 988 if (strncmp(cp, "/\\\r\n", 4) == 0) {
989 incomment = STARTING_COMMENT;
990 cp += 4;
991 } else if (strncmp(cp, "/\\\n", 3) == 0) {
883 incomment = STARTING_COMMENT; 992 incomment = STARTING_COMMENT;
884 cp += 3; 993 cp += 3;
885 } else if (strncmp(cp, "/*", 2) == 0) { 994 } else if (strncmp(cp, "/*", 2) == 0) {
@@ -899,7 +1008,7 @@ skipcomment(const char *cp)
899 } else if (strncmp(cp, "\n", 1) == 0) { 1008 } else if (strncmp(cp, "\n", 1) == 0) {
900 linestate = LS_START; 1009 linestate = LS_START;
901 cp += 1; 1010 cp += 1;
902 } else if (strchr(" \t", *cp) != NULL) { 1011 } else if (strchr(" \r\t", *cp) != NULL) {
903 cp += 1; 1012 cp += 1;
904 } else 1013 } else
905 return (cp); 1014 return (cp);
@@ -931,7 +1040,10 @@ skipcomment(const char *cp)
931 cp += 1; 1040 cp += 1;
932 continue; 1041 continue;
933 case C_COMMENT: 1042 case C_COMMENT:
934 if (strncmp(cp, "*\\\n", 3) == 0) { 1043 if (strncmp(cp, "*\\\r\n", 4) == 0) {
1044 incomment = FINISHING_COMMENT;
1045 cp += 4;
1046 } else if (strncmp(cp, "*\\\n", 3) == 0) {
935 incomment = FINISHING_COMMENT; 1047 incomment = FINISHING_COMMENT;
936 cp += 3; 1048 cp += 3;
937 } else if (strncmp(cp, "*/", 2) == 0) { 1049 } else if (strncmp(cp, "*/", 2) == 0) {
@@ -1015,7 +1127,13 @@ findsym(const char *str)
1015 if (cp == str) 1127 if (cp == str)
1016 return (-1); 1128 return (-1);
1017 if (symlist) { 1129 if (symlist) {
1018 printf("%.*s\n", (int)(cp-str), str); 1130 if (symdepth && firstsym)
1131 printf("%s%3d", zerosyms ? "" : "\n", depth);
1132 firstsym = zerosyms = false;
1133 printf("%s%.*s%s",
1134 symdepth ? " " : "",
1135 (int)(cp-str), str,
1136 symdepth ? "" : "\n");
1019 /* we don't care about the value of the symbol */ 1137 /* we don't care about the value of the symbol */
1020 return (0); 1138 return (0);
1021 } 1139 }
@@ -1052,7 +1170,7 @@ addsym(bool ignorethis, bool definethis, char *sym)
1052 value[symind] = val+1; 1170 value[symind] = val+1;
1053 *val = '\0'; 1171 *val = '\0';
1054 } else if (*val == '\0') 1172 } else if (*val == '\0')
1055 value[symind] = ""; 1173 value[symind] = "1";
1056 else 1174 else
1057 usage(); 1175 usage();
1058 } else { 1176 } else {
@@ -1060,6 +1178,8 @@ addsym(bool ignorethis, bool definethis, char *sym)
1060 usage(); 1178 usage();
1061 value[symind] = NULL; 1179 value[symind] = NULL;
1062 } 1180 }
1181 debug("addsym %s=%s", symname[symind],
1182 value[symind] ? value[symind] : "undef");
1063} 1183}
1064 1184
1065/* 1185/*
@@ -1100,5 +1220,6 @@ error(const char *msg)
1100 else 1220 else
1101 warnx("%s: %d: %s (#if line %d depth %d)", 1221 warnx("%s: %d: %s (#if line %d depth %d)",
1102 filename, linenum, msg, stifline[depth], depth); 1222 filename, linenum, msg, stifline[depth], depth);
1223 closeout();
1103 errx(2, "output may be truncated"); 1224 errx(2, "output may be truncated");
1104} 1225}
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
new file mode 100644
index 000000000000..17a5798c29da
--- /dev/null
+++ b/scripts/xz_wrap.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2#
3# This is a wrapper for xz to compress the kernel image using appropriate
4# compression options depending on the architecture.
5#
6# Author: Lasse Collin <lasse.collin@tukaani.org>
7#
8# This file has been put into the public domain.
9# You can do whatever you want with this file.
10#
11
12BCJ=
13LZMA2OPTS=
14
15case $ARCH in
16 x86|x86_64) BCJ=--x86 ;;
17 powerpc) BCJ=--powerpc ;;
18 ia64) BCJ=--ia64; LZMA2OPTS=pb=4 ;;
19 arm) BCJ=--arm ;;
20 sparc) BCJ=--sparc ;;
21esac
22
23exec xz --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB