diff options
Diffstat (limited to 'scripts')
118 files changed, 2874 insertions, 11017 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a8046f..50cee534fd64 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -10,6 +10,7 @@ space := $(empty) $(empty) | |||
| 10 | space_escape := _-_SPACE_-_ | 10 | space_escape := _-_SPACE_-_ |
| 11 | right_paren := ) | 11 | right_paren := ) |
| 12 | left_paren := ( | 12 | left_paren := ( |
| 13 | pound := \# | ||
| 13 | 14 | ||
| 14 | ### | 15 | ### |
| 15 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o | 16 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o |
| @@ -237,9 +238,7 @@ cc-ldoption = $(call try-run-cached,\ | |||
| 237 | 238 | ||
| 238 | # ld-option | 239 | # ld-option |
| 239 | # Usage: LDFLAGS += $(call ld-option, -X) | 240 | # Usage: LDFLAGS += $(call ld-option, -X) |
| 240 | ld-option = $(call try-run-cached,\ | 241 | ld-option = $(call try-run-cached, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2)) |
| 241 | $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \ | ||
| 242 | $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) | ||
| 243 | 242 | ||
| 244 | # ar-option | 243 | # ar-option |
| 245 | # Usage: KBUILD_ARFLAGS := $(call ar-option,D) | 244 | # Usage: KBUILD_ARFLAGS := $(call ar-option,D) |
| @@ -324,11 +323,11 @@ endif | |||
| 324 | 323 | ||
| 325 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file | 324 | # Replace >$< with >$$< to preserve $ when reloading the .cmd file |
| 326 | # (needed for make) | 325 | # (needed for make) |
| 327 | # Replace >#< with >\#< to avoid starting a comment in the .cmd file | 326 | # Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file |
| 328 | # (needed for make) | 327 | # (needed for make) |
| 329 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' | 328 | # Replace >'< with >'\''< to be able to enclose the whole string in '...' |
| 330 | # (needed for the shell) | 329 | # (needed for the shell) |
| 331 | make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | 330 | make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) |
| 332 | 331 | ||
| 333 | # Find any prerequisites that is newer than target or that does not exist. | 332 | # Find any prerequisites that is newer than target or that does not exist. |
| 334 | # PHONY targets skipped in both cases. | 333 | # PHONY targets skipped in both cases. |
| @@ -368,7 +367,7 @@ ksym_dep_filter = \ | |||
| 368 | $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ | 367 | $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ |
| 369 | boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \ | 368 | boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \ |
| 370 | *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ | 369 | *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ |
| 371 | esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' | 370 | esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p' |
| 372 | 371 | ||
| 373 | cmd_and_fixdep = \ | 372 | cmd_and_fixdep = \ |
| 374 | $(echo-cmd) $(cmd_$(1)); \ | 373 | $(echo-cmd) $(cmd_$(1)); \ |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 4f2b25d43ec9..8bdb1dc4072c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
| @@ -73,11 +73,11 @@ endif | |||
| 73 | 73 | ||
| 74 | ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) | 74 | ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) |
| 75 | lib-target := $(obj)/lib.a | 75 | lib-target := $(obj)/lib.a |
| 76 | obj-y += $(obj)/lib-ksyms.o | 76 | real-obj-y += $(obj)/lib-ksyms.o |
| 77 | endif | 77 | endif |
| 78 | 78 | ||
| 79 | ifneq ($(strip $(obj-y) $(need-builtin)),) | 79 | ifneq ($(strip $(real-obj-y) $(need-builtin)),) |
| 80 | builtin-target := $(obj)/built-in.o | 80 | builtin-target := $(obj)/built-in.a |
| 81 | endif | 81 | endif |
| 82 | 82 | ||
| 83 | modorder-target := $(obj)/modules.order | 83 | modorder-target := $(obj)/modules.order |
| @@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) | |||
| 104 | cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; | 104 | cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; |
| 105 | endif | 105 | endif |
| 106 | 106 | ||
| 107 | # Do section mismatch analysis for each module/built-in.o | 107 | # Do section mismatch analysis for each module/built-in.a |
| 108 | ifdef CONFIG_DEBUG_SECTION_MISMATCH | 108 | ifdef CONFIG_DEBUG_SECTION_MISMATCH |
| 109 | cmd_secanalysis = ; scripts/mod/modpost $@ | 109 | cmd_secanalysis = ; scripts/mod/modpost $@ |
| 110 | endif | 110 | endif |
| @@ -119,29 +119,17 @@ modkern_cflags = \ | |||
| 119 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) | 119 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) |
| 120 | quiet_modtag := $(empty) $(empty) | 120 | quiet_modtag := $(empty) $(empty) |
| 121 | 121 | ||
| 122 | $(real-objs-m) : part-of-module := y | 122 | $(real-obj-m) : part-of-module := y |
| 123 | $(real-objs-m:.o=.i) : part-of-module := y | 123 | $(real-obj-m:.o=.i) : part-of-module := y |
| 124 | $(real-objs-m:.o=.s) : part-of-module := y | 124 | $(real-obj-m:.o=.s) : part-of-module := y |
| 125 | $(real-objs-m:.o=.lst): part-of-module := y | 125 | $(real-obj-m:.o=.lst): part-of-module := y |
| 126 | 126 | ||
| 127 | $(real-objs-m) : quiet_modtag := [M] | 127 | $(real-obj-m) : quiet_modtag := [M] |
| 128 | $(real-objs-m:.o=.i) : quiet_modtag := [M] | 128 | $(real-obj-m:.o=.i) : quiet_modtag := [M] |
| 129 | $(real-objs-m:.o=.s) : quiet_modtag := [M] | 129 | $(real-obj-m:.o=.s) : quiet_modtag := [M] |
| 130 | $(real-objs-m:.o=.lst): quiet_modtag := [M] | 130 | $(real-obj-m:.o=.lst): quiet_modtag := [M] |
| 131 | 131 | ||
| 132 | $(obj-m) : quiet_modtag := [M] | 132 | $(obj-m) : quiet_modtag := [M] |
| 133 | |||
| 134 | # Default for not multi-part modules | ||
| 135 | modname = $(basetarget) | ||
| 136 | |||
| 137 | $(multi-objs-m) : modname = $(modname-multi) | ||
| 138 | $(multi-objs-m:.o=.i) : modname = $(modname-multi) | ||
| 139 | $(multi-objs-m:.o=.s) : modname = $(modname-multi) | ||
| 140 | $(multi-objs-m:.o=.lst) : modname = $(modname-multi) | ||
| 141 | $(multi-objs-y) : modname = $(modname-multi) | ||
| 142 | $(multi-objs-y:.o=.i) : modname = $(modname-multi) | ||
| 143 | $(multi-objs-y:.o=.s) : modname = $(modname-multi) | ||
| 144 | $(multi-objs-y:.o=.lst) : modname = $(modname-multi) | ||
| 145 | 133 | ||
| 146 | quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ | 134 | quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ |
| 147 | cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< | 135 | cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< |
| @@ -314,7 +302,7 @@ endef | |||
| 314 | 302 | ||
| 315 | # List module undefined symbols (or empty line if not enabled) | 303 | # List module undefined symbols (or empty line if not enabled) |
| 316 | ifdef CONFIG_TRIM_UNUSED_KSYMS | 304 | ifdef CONFIG_TRIM_UNUSED_KSYMS |
| 317 | cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo | 305 | cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo |
| 318 | else | 306 | else |
| 319 | cmd_undef_syms = echo | 307 | cmd_undef_syms = echo |
| 320 | endif | 308 | endif |
| @@ -345,8 +333,8 @@ $(obj)/%.lst: $(src)/%.c FORCE | |||
| 345 | 333 | ||
| 346 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) | 334 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) |
| 347 | 335 | ||
| 348 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 336 | $(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 349 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 337 | $(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 350 | 338 | ||
| 351 | # .S file exports must have their C prototypes defined in asm/asm-prototypes.h | 339 | # .S file exports must have their C prototypes defined in asm/asm-prototypes.h |
| 352 | # or a file that it includes, in order to get versioned symbols. We build a | 340 | # or a file that it includes, in order to get versioned symbols. We build a |
| @@ -424,7 +412,7 @@ endif | |||
| 424 | $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE | 412 | $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE |
| 425 | $(call if_changed_rule,as_o_S) | 413 | $(call if_changed_rule,as_o_S) |
| 426 | 414 | ||
| 427 | targets += $(real-objs-y) $(real-objs-m) $(lib-y) | 415 | targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) |
| 428 | targets += $(extra-y) $(MAKECMDGOALS) $(always) | 416 | targets += $(extra-y) $(MAKECMDGOALS) $(always) |
| 429 | 417 | ||
| 430 | # Linker scripts preprocessor (.lds.S -> .lds) | 418 | # Linker scripts preprocessor (.lds.S -> .lds) |
| @@ -442,9 +430,7 @@ quiet_cmd_asn1_compiler = ASN.1 $@ | |||
| 442 | cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ | 430 | cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ |
| 443 | $(subst .h,.c,$@) $(subst .c,.h,$@) | 431 | $(subst .h,.c,$@) $(subst .c,.h,$@) |
| 444 | 432 | ||
| 445 | .PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h | 433 | $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler |
| 446 | |||
| 447 | $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler | ||
| 448 | $(call cmd,asn1_compiler) | 434 | $(call cmd,asn1_compiler) |
| 449 | 435 | ||
| 450 | # Build the compiled-in targets | 436 | # Build the compiled-in targets |
| @@ -458,24 +444,16 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; | |||
| 458 | # | 444 | # |
| 459 | ifdef builtin-target | 445 | ifdef builtin-target |
| 460 | 446 | ||
| 461 | ifdef CONFIG_THIN_ARCHIVES | 447 | # built-in.a archives are made with no symbol table or index which |
| 462 | cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) | 448 | # makes them small and fast, but unable to be used by the linker. |
| 463 | cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) | 449 | # scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol |
| 464 | quiet_cmd_link_o_target = AR $@ | 450 | # table and index. |
| 465 | else | 451 | quiet_cmd_ar_builtin = AR $@ |
| 466 | cmd_make_builtin = $(LD) $(ld_flags) -r -o | 452 | cmd_ar_builtin = rm -f $@; \ |
| 467 | cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) | 453 | $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^) |
| 468 | quiet_cmd_link_o_target = LD $@ | ||
| 469 | endif | ||
| 470 | |||
| 471 | # If the list of objects to link is empty, just create an empty built-in.o | ||
| 472 | cmd_link_o_target = $(if $(strip $(obj-y)),\ | ||
| 473 | $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \ | ||
| 474 | $(cmd_secanalysis),\ | ||
| 475 | $(cmd_make_empty_builtin) $@) | ||
| 476 | 454 | ||
| 477 | $(builtin-target): $(obj-y) FORCE | 455 | $(builtin-target): $(real-obj-y) FORCE |
| 478 | $(call if_changed,link_o_target) | 456 | $(call if_changed,ar_builtin) |
| 479 | 457 | ||
| 480 | targets += $(builtin-target) | 458 | targets += $(builtin-target) |
| 481 | endif # builtin-target | 459 | endif # builtin-target |
| @@ -499,11 +477,8 @@ $(modorder-target): $(subdir-ym) FORCE | |||
| 499 | ifdef lib-target | 477 | ifdef lib-target |
| 500 | quiet_cmd_link_l_target = AR $@ | 478 | quiet_cmd_link_l_target = AR $@ |
| 501 | 479 | ||
| 502 | ifdef CONFIG_THIN_ARCHIVES | 480 | # lib target archives do get a symbol table and index |
| 503 | cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) | 481 | cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) |
| 504 | else | ||
| 505 | cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) | ||
| 506 | endif | ||
| 507 | 482 | ||
| 508 | $(lib-target): $(lib-y) FORCE | 483 | $(lib-target): $(lib-y) FORCE |
| 509 | $(call if_changed,link_l_target) | 484 | $(call if_changed,link_l_target) |
| @@ -549,22 +524,8 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \ | |||
| 549 | $($(subst $(obj)/,,$(@:.o=-y))) \ | 524 | $($(subst $(obj)/,,$(@:.o=-y))) \ |
| 550 | $($(subst $(obj)/,,$(@:.o=-m)))), $^) | 525 | $($(subst $(obj)/,,$(@:.o=-m)))), $^) |
| 551 | 526 | ||
| 552 | cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) | ||
| 553 | |||
| 554 | ifdef CONFIG_THIN_ARCHIVES | ||
| 555 | quiet_cmd_link_multi-y = AR $@ | ||
| 556 | cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps) | ||
| 557 | else | ||
| 558 | quiet_cmd_link_multi-y = LD $@ | ||
| 559 | cmd_link_multi-y = $(cmd_link_multi-link) | ||
| 560 | endif | ||
| 561 | |||
| 562 | quiet_cmd_link_multi-m = LD [M] $@ | 527 | quiet_cmd_link_multi-m = LD [M] $@ |
| 563 | cmd_link_multi-m = $(cmd_link_multi-link) | 528 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) |
| 564 | |||
| 565 | $(multi-used-y): FORCE | ||
| 566 | $(call if_changed,link_multi-y) | ||
| 567 | $(call multi_depend, $(multi-used-y), .o, -objs -y) | ||
| 568 | 529 | ||
| 569 | $(multi-used-m): FORCE | 530 | $(multi-used-m): FORCE |
| 570 | $(call if_changed,link_multi-m) | 531 | $(call if_changed,link_multi-m) |
| @@ -572,9 +533,24 @@ $(multi-used-m): FORCE | |||
| 572 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | 533 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) |
| 573 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) | 534 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) |
| 574 | 535 | ||
| 575 | targets += $(multi-used-y) $(multi-used-m) | 536 | targets += $(multi-used-m) |
| 576 | targets := $(filter-out $(PHONY), $(targets)) | 537 | targets := $(filter-out $(PHONY), $(targets)) |
| 577 | 538 | ||
| 539 | # Add intermediate targets: | ||
| 540 | # When building objects with specific suffix patterns, add intermediate | ||
| 541 | # targets that the final targets are derived from. | ||
| 542 | intermediate_targets = $(foreach sfx, $(2), \ | ||
| 543 | $(patsubst %$(strip $(1)),%$(sfx), \ | ||
| 544 | $(filter %$(strip $(1)), $(targets)))) | ||
| 545 | # %.asn1.o <- %.asn1.[ch] <- %.asn1 | ||
| 546 | # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts | ||
| 547 | # %.lex.o <- %.lex.c <- %.l | ||
| 548 | # %.tab.o <- %.tab.[ch] <- %.y | ||
| 549 | targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ | ||
| 550 | $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \ | ||
| 551 | $(call intermediate_targets, .lex.o, .lex.c) \ | ||
| 552 | $(call intermediate_targets, .tab.o, .tab.c .tab.h) | ||
| 553 | |||
| 578 | # Descending | 554 | # Descending |
| 579 | # --------------------------------------------------------------------------- | 555 | # --------------------------------------------------------------------------- |
| 580 | 556 | ||
| @@ -611,6 +587,10 @@ $(shell mkdir -p $(obj-dirs)) | |||
| 611 | endif | 587 | endif |
| 612 | endif | 588 | endif |
| 613 | 589 | ||
| 590 | # Some files contained in $(targets) are intermediate artifacts. | ||
| 591 | # We never want them to be removed automatically. | ||
| 592 | .SECONDARY: $(targets) | ||
| 593 | |||
| 614 | # Declare the contents of the .PHONY variable as phony. We keep that | 594 | # Declare the contents of the .PHONY variable as phony. We keep that |
| 615 | # information in a variable se we can use it in if_changed and friends. | 595 | # information in a variable se we can use it in if_changed and friends. |
| 616 | 596 | ||
diff --git a/scripts/Makefile.host b/scripts/Makefile.host index e6dc6ae2d7c4..aa971cc3f339 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host | |||
| @@ -84,7 +84,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) | |||
| 84 | # Create executable from a single .c file | 84 | # Create executable from a single .c file |
| 85 | # host-csingle -> Executable | 85 | # host-csingle -> Executable |
| 86 | quiet_cmd_host-csingle = HOSTCC $@ | 86 | quiet_cmd_host-csingle = HOSTCC $@ |
| 87 | cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ | 87 | cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOSTLDFLAGS) -o $@ $< \ |
| 88 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | 88 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) |
| 89 | $(host-csingle): $(obj)/%: $(src)/%.c FORCE | 89 | $(host-csingle): $(obj)/%: $(src)/%.c FORCE |
| 90 | $(call if_changed_dep,host-csingle) | 90 | $(call if_changed_dep,host-csingle) |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index a6f538b31ad6..07d07409f16f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -27,7 +27,7 @@ modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko | |||
| 27 | 27 | ||
| 28 | # Handle objects in subdirs | 28 | # Handle objects in subdirs |
| 29 | # --------------------------------------------------------------------------- | 29 | # --------------------------------------------------------------------------- |
| 30 | # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o | 30 | # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a |
| 31 | # and add the directory to the list of dirs to descend into: $(subdir-y) | 31 | # and add the directory to the list of dirs to descend into: $(subdir-y) |
| 32 | # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) | 32 | # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) |
| 33 | # and add the directory to the list of dirs to descend into: $(subdir-m) | 33 | # and add the directory to the list of dirs to descend into: $(subdir-m) |
| @@ -35,7 +35,7 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) | |||
| 35 | subdir-y += $(__subdir-y) | 35 | subdir-y += $(__subdir-y) |
| 36 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) | 36 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) |
| 37 | subdir-m += $(__subdir-m) | 37 | subdir-m += $(__subdir-m) |
| 38 | obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) | 38 | obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
| 39 | obj-m := $(filter-out %/, $(obj-m)) | 39 | obj-m := $(filter-out %/, $(obj-m)) |
| 40 | 40 | ||
| 41 | # Subdirectories we need to descend into | 41 | # Subdirectories we need to descend into |
| @@ -47,18 +47,14 @@ multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m | |||
| 47 | multi-used := $(multi-used-y) $(multi-used-m) | 47 | multi-used := $(multi-used-y) $(multi-used-m) |
| 48 | single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) | 48 | single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) |
| 49 | 49 | ||
| 50 | # Build list of the parts of our composite objects, our composite | ||
| 51 | # objects depend on those (obviously) | ||
| 52 | multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) | ||
| 53 | multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) | ||
| 54 | |||
| 55 | # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to | 50 | # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to |
| 56 | # tell kbuild to descend | 51 | # tell kbuild to descend |
| 57 | subdir-obj-y := $(filter %/built-in.o, $(obj-y)) | 52 | subdir-obj-y := $(filter %/built-in.a, $(obj-y)) |
| 58 | 53 | ||
| 59 | # Replace multi-part objects by their individual parts, look at local dir only | 54 | # Replace multi-part objects by their individual parts, |
| 60 | real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) | 55 | # including built-in.a from subdirectories |
| 61 | real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) | 56 | real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) |
| 57 | real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) | ||
| 62 | 58 | ||
| 63 | # DTB | 59 | # DTB |
| 64 | # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built | 60 | # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built |
| @@ -71,29 +67,29 @@ extra-y := $(addprefix $(obj)/,$(extra-y)) | |||
| 71 | always := $(addprefix $(obj)/,$(always)) | 67 | always := $(addprefix $(obj)/,$(always)) |
| 72 | targets := $(addprefix $(obj)/,$(targets)) | 68 | targets := $(addprefix $(obj)/,$(targets)) |
| 73 | modorder := $(addprefix $(obj)/,$(modorder)) | 69 | modorder := $(addprefix $(obj)/,$(modorder)) |
| 74 | obj-y := $(addprefix $(obj)/,$(obj-y)) | ||
| 75 | obj-m := $(addprefix $(obj)/,$(obj-m)) | 70 | obj-m := $(addprefix $(obj)/,$(obj-m)) |
| 76 | lib-y := $(addprefix $(obj)/,$(lib-y)) | 71 | lib-y := $(addprefix $(obj)/,$(lib-y)) |
| 77 | subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) | 72 | subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) |
| 78 | real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) | 73 | real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) |
| 79 | real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) | 74 | real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) |
| 80 | single-used-m := $(addprefix $(obj)/,$(single-used-m)) | 75 | single-used-m := $(addprefix $(obj)/,$(single-used-m)) |
| 81 | multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) | ||
| 82 | multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) | 76 | multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) |
| 83 | multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) | ||
| 84 | multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) | ||
| 85 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | 77 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
| 86 | 78 | ||
| 79 | # Finds the multi-part object the current object will be linked into. | ||
| 80 | # If the object belongs to two or more multi-part objects, all of them are | ||
| 81 | # concatenated with a colon separator. | ||
| 82 | modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ | ||
| 83 | $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) | ||
| 84 | |||
| 85 | modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) | ||
| 86 | |||
| 87 | # These flags are needed for modversions and compiling, so we define them here | 87 | # These flags are needed for modversions and compiling, so we define them here |
| 88 | # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will | 88 | # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will |
| 89 | # end up in (or would, if it gets compiled in) | 89 | # end up in (or would, if it gets compiled in) |
| 90 | # Note: Files that end up in two or more modules are compiled without the | ||
| 91 | # KBUILD_MODNAME definition. The reason is that any made-up name would | ||
| 92 | # differ in different configs. | ||
| 93 | name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) | 90 | name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) |
| 94 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) | 91 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) |
| 95 | modname_flags = $(if $(filter 1,$(words $(modname))),\ | 92 | modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) |
| 96 | -DKBUILD_MODNAME=$(call name-fix,$(modname))) | ||
| 97 | 93 | ||
| 98 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ | 94 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ |
| 99 | $(ccflags-y) $(CFLAGS_$(basetarget).o) | 95 | $(ccflags-y) $(CFLAGS_$(basetarget).o) |
| @@ -156,6 +152,7 @@ __cpp_flags = $(call flags,_cpp_flags) | |||
| 156 | endif | 152 | endif |
| 157 | 153 | ||
| 158 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 154 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 155 | -include $(srctree)/include/linux/compiler_types.h \ | ||
| 159 | $(__c_flags) $(modkern_cflags) \ | 156 | $(__c_flags) $(modkern_cflags) \ |
| 160 | $(basename_flags) $(modname_flags) | 157 | $(basename_flags) $(modname_flags) |
| 161 | 158 | ||
| @@ -173,10 +170,6 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ | |||
| 173 | $(addprefix -I,$(DTC_INCLUDE)) \ | 170 | $(addprefix -I,$(DTC_INCLUDE)) \ |
| 174 | -undef -D__DTS__ | 171 | -undef -D__DTS__ |
| 175 | 172 | ||
| 176 | # Finds the multi-part object the current object will be linked into | ||
| 177 | modname-multi = $(sort $(foreach m,$(multi-used),\ | ||
| 178 | $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) | ||
| 179 | |||
| 180 | # Useful for describing the dependency of composite objects | 173 | # Useful for describing the dependency of composite objects |
| 181 | # Usage: | 174 | # Usage: |
| 182 | # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) | 175 | # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) |
| @@ -191,14 +184,7 @@ endef | |||
| 191 | quiet_cmd_flex = LEX $@ | 184 | quiet_cmd_flex = LEX $@ |
| 192 | cmd_flex = $(LEX) -o$@ -L $< | 185 | cmd_flex = $(LEX) -o$@ -L $< |
| 193 | 186 | ||
| 194 | ifdef REGENERATE_PARSERS | 187 | $(obj)/%.lex.c: $(src)/%.l FORCE |
| 195 | .PRECIOUS: $(src)/%.lex.c_shipped | ||
| 196 | $(src)/%.lex.c_shipped: $(src)/%.l | ||
| 197 | $(call cmd,flex) | ||
| 198 | endif | ||
| 199 | |||
| 200 | .PRECIOUS: $(obj)/%.lex.c | ||
| 201 | $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE | ||
| 202 | $(call if_changed,flex) | 188 | $(call if_changed,flex) |
| 203 | 189 | ||
| 204 | # YACC | 190 | # YACC |
| @@ -206,27 +192,13 @@ $(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE | |||
| 206 | quiet_cmd_bison = YACC $@ | 192 | quiet_cmd_bison = YACC $@ |
| 207 | cmd_bison = $(YACC) -o$@ -t -l $< | 193 | cmd_bison = $(YACC) -o$@ -t -l $< |
| 208 | 194 | ||
| 209 | ifdef REGENERATE_PARSERS | 195 | $(obj)/%.tab.c: $(src)/%.y FORCE |
| 210 | .PRECIOUS: $(src)/%.tab.c_shipped | ||
| 211 | $(src)/%.tab.c_shipped: $(src)/%.y | ||
| 212 | $(call cmd,bison) | ||
| 213 | endif | ||
| 214 | |||
| 215 | .PRECIOUS: $(obj)/%.tab.c | ||
| 216 | $(filter %.tab.c,$(targets)): $(obj)/%.tab.c: $(src)/%.y FORCE | ||
| 217 | $(call if_changed,bison) | 196 | $(call if_changed,bison) |
| 218 | 197 | ||
| 219 | quiet_cmd_bison_h = YACC $@ | 198 | quiet_cmd_bison_h = YACC $@ |
| 220 | cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< | 199 | cmd_bison_h = bison -o/dev/null --defines=$@ -t -l $< |
| 221 | |||
| 222 | ifdef REGENERATE_PARSERS | ||
| 223 | .PRECIOUS: $(src)/%.tab.h_shipped | ||
| 224 | $(src)/%.tab.h_shipped: $(src)/%.y | ||
| 225 | $(call cmd,bison_h) | ||
| 226 | endif | ||
| 227 | 200 | ||
| 228 | .PRECIOUS: $(obj)/%.tab.h | 201 | $(obj)/%.tab.h: $(src)/%.y FORCE |
| 229 | $(filter %.tab.h,$(targets)): $(obj)/%.tab.h: $(src)/%.y FORCE | ||
| 230 | $(call if_changed,bison_h) | 202 | $(call if_changed,bison_h) |
| 231 | 203 | ||
| 232 | # Shipped files | 204 | # Shipped files |
| @@ -276,10 +248,9 @@ DTC ?= $(objtree)/scripts/dtc/dtc | |||
| 276 | # Disable noisy checks by default | 248 | # Disable noisy checks by default |
| 277 | ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) | 249 | ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) |
| 278 | DTC_FLAGS += -Wno-unit_address_vs_reg \ | 250 | DTC_FLAGS += -Wno-unit_address_vs_reg \ |
| 279 | -Wno-simple_bus_reg \ | ||
| 280 | -Wno-unit_address_format \ | 251 | -Wno-unit_address_format \ |
| 281 | -Wno-pci_bridge \ | 252 | -Wno-avoid_unnecessary_addr_size \ |
| 282 | -Wno-pci_device_bus_num \ | 253 | -Wno-alias_paths \ |
| 283 | -Wno-pci_device_reg | 254 | -Wno-pci_device_reg |
| 284 | endif | 255 | endif |
| 285 | 256 | ||
| @@ -305,8 +276,8 @@ cmd_dt_S_dtb= \ | |||
| 305 | echo '.balign STRUCT_ALIGNMENT'; \ | 276 | echo '.balign STRUCT_ALIGNMENT'; \ |
| 306 | ) > $@ | 277 | ) > $@ |
| 307 | 278 | ||
| 308 | $(obj)/%.dtb.S: $(obj)/%.dtb | 279 | $(obj)/%.dtb.S: $(obj)/%.dtb FORCE |
| 309 | $(call cmd,dt_S_dtb) | 280 | $(call if_changed,dt_S_dtb) |
| 310 | 281 | ||
| 311 | quiet_cmd_dtc = DTC $@ | 282 | quiet_cmd_dtc = DTC $@ |
| 312 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ | 283 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
| @@ -316,7 +287,7 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ | |||
| 316 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ | 287 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
| 317 | cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) | 288 | cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) |
| 318 | 289 | ||
| 319 | $(obj)/%.dtb: $(src)/%.dts FORCE | 290 | $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE |
| 320 | $(call if_changed_dep,dtc) | 291 | $(call if_changed_dep,dtc) |
| 321 | 292 | ||
| 322 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) | 293 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) |
| @@ -329,7 +300,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) | |||
| 329 | size_append = printf $(shell \ | 300 | size_append = printf $(shell \ |
| 330 | dec_size=0; \ | 301 | dec_size=0; \ |
| 331 | for F in $1; do \ | 302 | for F in $1; do \ |
| 332 | fsize=$$(stat -c "%s" $$F); \ | 303 | fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ |
| 333 | dec_size=$$(expr $$dec_size + $$fsize); \ | 304 | dec_size=$$(expr $$dec_size + $$fsize); \ |
| 334 | done; \ | 305 | done; \ |
| 335 | printf "%08x\n" $$dec_size | \ | 306 | printf "%08x\n" $$dec_size | \ |
diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 513da1a4a2da..016b3c48a4ec 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh | |||
| @@ -48,9 +48,6 @@ case "${KCONFIG_CONFIG}" in | |||
| 48 | . "./${KCONFIG_CONFIG}" | 48 | . "./${KCONFIG_CONFIG}" |
| 49 | esac | 49 | esac |
| 50 | 50 | ||
| 51 | # In case it doesn't exist yet... | ||
| 52 | if [ -e "$cur_ksyms_file" ]; then touch "$cur_ksyms_file"; fi | ||
| 53 | |||
| 54 | # Generate a new ksym list file with symbols needed by the current | 51 | # Generate a new ksym list file with symbols needed by the current |
| 55 | # set of modules. | 52 | # set of modules. |
| 56 | cat > "$new_ksyms_file" << EOT | 53 | cat > "$new_ksyms_file" << EOT |
| @@ -60,7 +57,9 @@ cat > "$new_ksyms_file" << EOT | |||
| 60 | 57 | ||
| 61 | EOT | 58 | EOT |
| 62 | [ "$(ls -A "$MODVERDIR")" ] && | 59 | [ "$(ls -A "$MODVERDIR")" ] && |
| 63 | sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u | | 60 | for mod in "$MODVERDIR"/*.mod; do |
| 61 | sed -n -e '3{s/ /\n/g;/^$/!p;}' "$mod" | ||
| 62 | done | sort -u | | ||
| 64 | while read sym; do | 63 | while read sym; do |
| 65 | if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then | 64 | if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then |
| 66 | sym="${sym#_}" | 65 | sym="${sym#_}" |
| @@ -81,9 +80,16 @@ sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u | | |||
| 81 | sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | | 80 | sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | |
| 82 | while read sympath; do | 81 | while read sympath; do |
| 83 | if [ -z "$sympath" ]; then continue; fi | 82 | if [ -z "$sympath" ]; then continue; fi |
| 84 | depfile="include/config/ksym/${sympath}.h" | 83 | depfile="include/ksym/${sympath}.h" |
| 85 | mkdir -p "$(dirname "$depfile")" | 84 | mkdir -p "$(dirname "$depfile")" |
| 86 | touch "$depfile" | 85 | touch "$depfile" |
| 86 | # Filesystems with coarse time precision may create timestamps | ||
| 87 | # equal to the one from a file that was very recently built and that | ||
| 88 | # needs to be rebuild. Let's guard against that by making sure our | ||
| 89 | # dep files are always newer than the first file we created here. | ||
| 90 | while [ ! "$depfile" -nt "$new_ksyms_file" ]; do | ||
| 91 | touch "$depfile" | ||
| 92 | done | ||
| 87 | echo $((count += 1)) | 93 | echo $((count += 1)) |
| 88 | done | tail -1 ) | 94 | done | tail -1 ) |
| 89 | changed=${changed:-0} | 95 | changed=${changed:-0} |
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index c1b7ef3e24c1..c146020fc783 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c | |||
| @@ -1319,7 +1319,7 @@ static void render(FILE *out, FILE *hdr) | |||
| 1319 | fprintf(out, " * ASN.1 parser for %s\n", grammar_name); | 1319 | fprintf(out, " * ASN.1 parser for %s\n", grammar_name); |
| 1320 | fprintf(out, " */\n"); | 1320 | fprintf(out, " */\n"); |
| 1321 | fprintf(out, "#include <linux/asn1_ber_bytecode.h>\n"); | 1321 | fprintf(out, "#include <linux/asn1_ber_bytecode.h>\n"); |
| 1322 | fprintf(out, "#include \"%s-asn1.h\"\n", grammar_name); | 1322 | fprintf(out, "#include \"%s.asn1.h\"\n", grammar_name); |
| 1323 | fprintf(out, "\n"); | 1323 | fprintf(out, "\n"); |
| 1324 | if (ferror(out)) { | 1324 | if (ferror(out)) { |
| 1325 | perror(outputname); | 1325 | perror(outputname); |
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 449b68c4c90c..f387538c58bc 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
| @@ -113,11 +113,11 @@ static void usage(void) | |||
| 113 | /* | 113 | /* |
| 114 | * Print out a dependency path from a symbol name | 114 | * Print out a dependency path from a symbol name |
| 115 | */ | 115 | */ |
| 116 | static void print_config(const char *m, int slen) | 116 | static void print_dep(const char *m, int slen, const char *dir) |
| 117 | { | 117 | { |
| 118 | int c, i; | 118 | int c, i; |
| 119 | 119 | ||
| 120 | printf(" $(wildcard include/config/"); | 120 | printf(" $(wildcard %s/", dir); |
| 121 | for (i = 0; i < slen; i++) { | 121 | for (i = 0; i < slen; i++) { |
| 122 | c = m[i]; | 122 | c = m[i]; |
| 123 | if (c == '_') | 123 | if (c == '_') |
| @@ -140,7 +140,7 @@ static void do_extra_deps(void) | |||
| 140 | fprintf(stderr, "fixdep: bad data on stdin\n"); | 140 | fprintf(stderr, "fixdep: bad data on stdin\n"); |
| 141 | exit(1); | 141 | exit(1); |
| 142 | } | 142 | } |
| 143 | print_config(buf, len - 1); | 143 | print_dep(buf, len - 1, "include/ksym"); |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| @@ -208,7 +208,7 @@ static void use_config(const char *m, int slen) | |||
| 208 | return; | 208 | return; |
| 209 | 209 | ||
| 210 | define_config(m, slen, hash); | 210 | define_config(m, slen, hash); |
| 211 | print_config(m, slen); | 211 | print_dep(m, slen, "include/config"); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | /* test if s ends in sub */ | 214 | /* test if s ends in sub */ |
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index d84a5674e95e..a923f05edb36 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
| @@ -30,8 +30,8 @@ def getsizes(file, format): | |||
| 30 | if type in format: | 30 | if type in format: |
| 31 | # strip generated symbols | 31 | # strip generated symbols |
| 32 | if name.startswith("__mod_"): continue | 32 | if name.startswith("__mod_"): continue |
| 33 | if name.startswith("SyS_"): continue | 33 | if name.startswith("__se_sys"): continue |
| 34 | if name.startswith("compat_SyS_"): continue | 34 | if name.startswith("__se_compat_sys"): continue |
| 35 | if name == "linux_banner": continue | 35 | if name == "linux_banner": continue |
| 36 | # statics and some other optimizations adds random .NUMBER | 36 | # statics and some other optimizations adds random .NUMBER |
| 37 | name = re_NUMBER.sub('', name) | 37 | name = re_NUMBER.sub('', name) |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3d4040322ae1..e16d6713f236 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -791,7 +791,8 @@ our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)}; | |||
| 791 | our $declaration_macros = qr{(?x: | 791 | our $declaration_macros = qr{(?x: |
| 792 | (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(| | 792 | (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(| |
| 793 | (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(| | 793 | (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(| |
| 794 | (?:$Storage\s+)?${Type}\s+uninitialized_var\s*\( | 794 | (?:$Storage\s+)?${Type}\s+uninitialized_var\s*\(| |
| 795 | (?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\( | ||
| 795 | )}; | 796 | )}; |
| 796 | 797 | ||
| 797 | sub deparenthesize { | 798 | sub deparenthesize { |
| @@ -1075,7 +1076,7 @@ sub parse_email { | |||
| 1075 | } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) { | 1076 | } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) { |
| 1076 | $address = $1; | 1077 | $address = $1; |
| 1077 | $comment = $2 if defined $2; | 1078 | $comment = $2 if defined $2; |
| 1078 | $formatted_email =~ s/$address.*$//; | 1079 | $formatted_email =~ s/\Q$address\E.*$//; |
| 1079 | $name = $formatted_email; | 1080 | $name = $formatted_email; |
| 1080 | $name = trim($name); | 1081 | $name = trim($name); |
| 1081 | $name =~ s/^\"|\"$//g; | 1082 | $name =~ s/^\"|\"$//g; |
| @@ -1217,7 +1218,7 @@ sub sanitise_line { | |||
| 1217 | for ($off = 1; $off < length($line); $off++) { | 1218 | for ($off = 1; $off < length($line); $off++) { |
| 1218 | $c = substr($line, $off, 1); | 1219 | $c = substr($line, $off, 1); |
| 1219 | 1220 | ||
| 1220 | # Comments we are wacking completly including the begin | 1221 | # Comments we are whacking completely including the begin |
| 1221 | # and end, all to $;. | 1222 | # and end, all to $;. |
| 1222 | if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') { | 1223 | if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') { |
| 1223 | $sanitise_quote = '*/'; | 1224 | $sanitise_quote = '*/'; |
| @@ -1297,6 +1298,7 @@ sub sanitise_line { | |||
| 1297 | sub get_quoted_string { | 1298 | sub get_quoted_string { |
| 1298 | my ($line, $rawline) = @_; | 1299 | my ($line, $rawline) = @_; |
| 1299 | 1300 | ||
| 1301 | return "" if (!defined($line) || !defined($rawline)); | ||
| 1300 | return "" if ($line !~ m/($String)/g); | 1302 | return "" if ($line !~ m/($String)/g); |
| 1301 | return substr($rawline, $-[0], $+[0] - $-[0]); | 1303 | return substr($rawline, $-[0], $+[0] - $-[0]); |
| 1302 | } | 1304 | } |
| @@ -1644,6 +1646,28 @@ sub raw_line { | |||
| 1644 | return $line; | 1646 | return $line; |
| 1645 | } | 1647 | } |
| 1646 | 1648 | ||
| 1649 | sub get_stat_real { | ||
| 1650 | my ($linenr, $lc) = @_; | ||
| 1651 | |||
| 1652 | my $stat_real = raw_line($linenr, 0); | ||
| 1653 | for (my $count = $linenr + 1; $count <= $lc; $count++) { | ||
| 1654 | $stat_real = $stat_real . "\n" . raw_line($count, 0); | ||
| 1655 | } | ||
| 1656 | |||
| 1657 | return $stat_real; | ||
| 1658 | } | ||
| 1659 | |||
| 1660 | sub get_stat_here { | ||
| 1661 | my ($linenr, $cnt, $here) = @_; | ||
| 1662 | |||
| 1663 | my $herectx = $here . "\n"; | ||
| 1664 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 1665 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 1666 | } | ||
| 1667 | |||
| 1668 | return $herectx; | ||
| 1669 | } | ||
| 1670 | |||
| 1647 | sub cat_vet { | 1671 | sub cat_vet { |
| 1648 | my ($vet) = @_; | 1672 | my ($vet) = @_; |
| 1649 | my ($res, $coded); | 1673 | my ($res, $coded); |
| @@ -2257,6 +2281,8 @@ sub process { | |||
| 2257 | 2281 | ||
| 2258 | my $camelcase_file_seeded = 0; | 2282 | my $camelcase_file_seeded = 0; |
| 2259 | 2283 | ||
| 2284 | my $checklicenseline = 1; | ||
| 2285 | |||
| 2260 | sanitise_line_reset(); | 2286 | sanitise_line_reset(); |
| 2261 | my $line; | 2287 | my $line; |
| 2262 | foreach my $rawline (@rawlines) { | 2288 | foreach my $rawline (@rawlines) { |
| @@ -2448,6 +2474,7 @@ sub process { | |||
| 2448 | } else { | 2474 | } else { |
| 2449 | $check = $check_orig; | 2475 | $check = $check_orig; |
| 2450 | } | 2476 | } |
| 2477 | $checklicenseline = 1; | ||
| 2451 | next; | 2478 | next; |
| 2452 | } | 2479 | } |
| 2453 | 2480 | ||
| @@ -2797,7 +2824,10 @@ sub process { | |||
| 2797 | # Only applies when adding the entry originally, after that we do not have | 2824 | # Only applies when adding the entry originally, after that we do not have |
| 2798 | # sufficient context to determine whether it is indeed long enough. | 2825 | # sufficient context to determine whether it is indeed long enough. |
| 2799 | if ($realfile =~ /Kconfig/ && | 2826 | if ($realfile =~ /Kconfig/ && |
| 2800 | $line =~ /^\+\s*config\s+/) { | 2827 | # 'choice' is usually the last thing on the line (though |
| 2828 | # Kconfig supports named choices), so use a word boundary | ||
| 2829 | # (\b) rather than a whitespace character (\s) | ||
| 2830 | $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) { | ||
| 2801 | my $length = 0; | 2831 | my $length = 0; |
| 2802 | my $cnt = $realcnt; | 2832 | my $cnt = $realcnt; |
| 2803 | my $ln = $linenr + 1; | 2833 | my $ln = $linenr + 1; |
| @@ -2812,9 +2842,13 @@ sub process { | |||
| 2812 | next if ($f =~ /^-/); | 2842 | next if ($f =~ /^-/); |
| 2813 | last if (!$file && $f =~ /^\@\@/); | 2843 | last if (!$file && $f =~ /^\@\@/); |
| 2814 | 2844 | ||
| 2815 | if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate)\s*\"/) { | 2845 | if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) { |
| 2816 | $is_start = 1; | 2846 | $is_start = 1; |
| 2817 | } elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) { | 2847 | } elsif ($lines[$ln - 1] =~ /^\+\s*(?:help|---help---)\s*$/) { |
| 2848 | if ($lines[$ln - 1] =~ "---help---") { | ||
| 2849 | WARN("CONFIG_DESCRIPTION", | ||
| 2850 | "prefer 'help' over '---help---' for new help texts\n" . $herecurr); | ||
| 2851 | } | ||
| 2818 | $length = -1; | 2852 | $length = -1; |
| 2819 | } | 2853 | } |
| 2820 | 2854 | ||
| @@ -2822,7 +2856,13 @@ sub process { | |||
| 2822 | $f =~ s/#.*//; | 2856 | $f =~ s/#.*//; |
| 2823 | $f =~ s/^\s+//; | 2857 | $f =~ s/^\s+//; |
| 2824 | next if ($f =~ /^$/); | 2858 | next if ($f =~ /^$/); |
| 2825 | if ($f =~ /^\s*config\s/) { | 2859 | |
| 2860 | # This only checks context lines in the patch | ||
| 2861 | # and so hopefully shouldn't trigger false | ||
| 2862 | # positives, even though some of these are | ||
| 2863 | # common words in help texts | ||
| 2864 | if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice| | ||
| 2865 | if|endif|menu|endmenu|source)\b/x) { | ||
| 2826 | $is_end = 1; | 2866 | $is_end = 1; |
| 2827 | last; | 2867 | last; |
| 2828 | } | 2868 | } |
| @@ -2898,6 +2938,30 @@ sub process { | |||
| 2898 | } | 2938 | } |
| 2899 | } | 2939 | } |
| 2900 | 2940 | ||
| 2941 | # check for using SPDX license tag at beginning of files | ||
| 2942 | if ($realline == $checklicenseline) { | ||
| 2943 | if ($rawline =~ /^[ \+]\s*\#\!\s*\//) { | ||
| 2944 | $checklicenseline = 2; | ||
| 2945 | } elsif ($rawline =~ /^\+/) { | ||
| 2946 | my $comment = ""; | ||
| 2947 | if ($realfile =~ /\.(h|s|S)$/) { | ||
| 2948 | $comment = '/*'; | ||
| 2949 | } elsif ($realfile =~ /\.(c|dts|dtsi)$/) { | ||
| 2950 | $comment = '//'; | ||
| 2951 | } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc)$/) { | ||
| 2952 | $comment = '#'; | ||
| 2953 | } elsif ($realfile =~ /\.rst$/) { | ||
| 2954 | $comment = '..'; | ||
| 2955 | } | ||
| 2956 | |||
| 2957 | if ($comment !~ /^$/ && | ||
| 2958 | $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) { | ||
| 2959 | WARN("SPDX_LICENSE_TAG", | ||
| 2960 | "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); | ||
| 2961 | } | ||
| 2962 | } | ||
| 2963 | } | ||
| 2964 | |||
| 2901 | # check we are in a valid source file if not then ignore this hunk | 2965 | # check we are in a valid source file if not then ignore this hunk |
| 2902 | next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); | 2966 | next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); |
| 2903 | 2967 | ||
| @@ -2969,20 +3033,6 @@ sub process { | |||
| 2969 | "adding a line without newline at end of file\n" . $herecurr); | 3033 | "adding a line without newline at end of file\n" . $herecurr); |
| 2970 | } | 3034 | } |
| 2971 | 3035 | ||
| 2972 | # Blackfin: use hi/lo macros | ||
| 2973 | if ($realfile =~ m@arch/blackfin/.*\.S$@) { | ||
| 2974 | if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) { | ||
| 2975 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | ||
| 2976 | ERROR("LO_MACRO", | ||
| 2977 | "use the LO() macro, not (... & 0xFFFF)\n" . $herevet); | ||
| 2978 | } | ||
| 2979 | if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) { | ||
| 2980 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | ||
| 2981 | ERROR("HI_MACRO", | ||
| 2982 | "use the HI() macro, not (... >> 16)\n" . $herevet); | ||
| 2983 | } | ||
| 2984 | } | ||
| 2985 | |||
| 2986 | # check we are in a valid source file C or perl if not then ignore this hunk | 3036 | # check we are in a valid source file C or perl if not then ignore this hunk |
| 2987 | next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/); | 3037 | next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/); |
| 2988 | 3038 | ||
| @@ -3012,6 +3062,12 @@ sub process { | |||
| 3012 | } | 3062 | } |
| 3013 | } | 3063 | } |
| 3014 | 3064 | ||
| 3065 | # check for assignments on the start of a line | ||
| 3066 | if ($sline =~ /^\+\s+($Assignment)[^=]/) { | ||
| 3067 | CHK("ASSIGNMENT_CONTINUATIONS", | ||
| 3068 | "Assignment operator '$1' should be on the previous line\n" . $hereprev); | ||
| 3069 | } | ||
| 3070 | |||
| 3015 | # check for && or || at the start of a line | 3071 | # check for && or || at the start of a line |
| 3016 | if ($rawline =~ /^\+\s*(&&|\|\|)/) { | 3072 | if ($rawline =~ /^\+\s*(&&|\|\|)/) { |
| 3017 | CHK("LOGICAL_CONTINUATIONS", | 3073 | CHK("LOGICAL_CONTINUATIONS", |
| @@ -3269,18 +3325,6 @@ sub process { | |||
| 3269 | "CVS style keyword markers, these will _not_ be updated\n". $herecurr); | 3325 | "CVS style keyword markers, these will _not_ be updated\n". $herecurr); |
| 3270 | } | 3326 | } |
| 3271 | 3327 | ||
| 3272 | # Blackfin: don't use __builtin_bfin_[cs]sync | ||
| 3273 | if ($line =~ /__builtin_bfin_csync/) { | ||
| 3274 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | ||
| 3275 | ERROR("CSYNC", | ||
| 3276 | "use the CSYNC() macro in asm/blackfin.h\n" . $herevet); | ||
| 3277 | } | ||
| 3278 | if ($line =~ /__builtin_bfin_ssync/) { | ||
| 3279 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | ||
| 3280 | ERROR("SSYNC", | ||
| 3281 | "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); | ||
| 3282 | } | ||
| 3283 | |||
| 3284 | # check for old HOTPLUG __dev<foo> section markings | 3328 | # check for old HOTPLUG __dev<foo> section markings |
| 3285 | if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) { | 3329 | if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) { |
| 3286 | WARN("HOTPLUG_SECTION", | 3330 | WARN("HOTPLUG_SECTION", |
| @@ -4045,7 +4089,7 @@ sub process { | |||
| 4045 | my ($where, $prefix) = ($-[1], $1); | 4089 | my ($where, $prefix) = ($-[1], $1); |
| 4046 | if ($prefix !~ /$Type\s+$/ && | 4090 | if ($prefix !~ /$Type\s+$/ && |
| 4047 | ($where != 0 || $prefix !~ /^.\s+$/) && | 4091 | ($where != 0 || $prefix !~ /^.\s+$/) && |
| 4048 | $prefix !~ /[{,]\s+$/) { | 4092 | $prefix !~ /[{,:]\s+$/) { |
| 4049 | if (ERROR("BRACKET_SPACE", | 4093 | if (ERROR("BRACKET_SPACE", |
| 4050 | "space prohibited before open square bracket '['\n" . $herecurr) && | 4094 | "space prohibited before open square bracket '['\n" . $herecurr) && |
| 4051 | $fix) { | 4095 | $fix) { |
| @@ -4941,12 +4985,8 @@ sub process { | |||
| 4941 | #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; | 4985 | #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; |
| 4942 | 4986 | ||
| 4943 | $ctx =~ s/\n*$//; | 4987 | $ctx =~ s/\n*$//; |
| 4944 | my $herectx = $here . "\n"; | ||
| 4945 | my $stmt_cnt = statement_rawlines($ctx); | 4988 | my $stmt_cnt = statement_rawlines($ctx); |
| 4946 | 4989 | my $herectx = get_stat_here($linenr, $stmt_cnt, $here); | |
| 4947 | for (my $n = 0; $n < $stmt_cnt; $n++) { | ||
| 4948 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 4949 | } | ||
| 4950 | 4990 | ||
| 4951 | if ($dstat ne '' && | 4991 | if ($dstat ne '' && |
| 4952 | $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), | 4992 | $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), |
| @@ -5018,12 +5058,9 @@ sub process { | |||
| 5018 | # check for macros with flow control, but without ## concatenation | 5058 | # check for macros with flow control, but without ## concatenation |
| 5019 | # ## concatenation is commonly a macro that defines a function so ignore those | 5059 | # ## concatenation is commonly a macro that defines a function so ignore those |
| 5020 | if ($has_flow_statement && !$has_arg_concat) { | 5060 | if ($has_flow_statement && !$has_arg_concat) { |
| 5021 | my $herectx = $here . "\n"; | ||
| 5022 | my $cnt = statement_rawlines($ctx); | 5061 | my $cnt = statement_rawlines($ctx); |
| 5062 | my $herectx = get_stat_here($linenr, $cnt, $here); | ||
| 5023 | 5063 | ||
| 5024 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 5025 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 5026 | } | ||
| 5027 | WARN("MACRO_WITH_FLOW_CONTROL", | 5064 | WARN("MACRO_WITH_FLOW_CONTROL", |
| 5028 | "Macros with flow control statements should be avoided\n" . "$herectx"); | 5065 | "Macros with flow control statements should be avoided\n" . "$herectx"); |
| 5029 | } | 5066 | } |
| @@ -5063,11 +5100,7 @@ sub process { | |||
| 5063 | 5100 | ||
| 5064 | $ctx =~ s/\n*$//; | 5101 | $ctx =~ s/\n*$//; |
| 5065 | my $cnt = statement_rawlines($ctx); | 5102 | my $cnt = statement_rawlines($ctx); |
| 5066 | my $herectx = $here . "\n"; | 5103 | my $herectx = get_stat_here($linenr, $cnt, $here); |
| 5067 | |||
| 5068 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 5069 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 5070 | } | ||
| 5071 | 5104 | ||
| 5072 | if (($stmts =~ tr/;/;/) == 1 && | 5105 | if (($stmts =~ tr/;/;/) == 1 && |
| 5073 | $stmts !~ /^\s*(if|while|for|switch)\b/) { | 5106 | $stmts !~ /^\s*(if|while|for|switch)\b/) { |
| @@ -5081,11 +5114,7 @@ sub process { | |||
| 5081 | } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) { | 5114 | } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) { |
| 5082 | $ctx =~ s/\n*$//; | 5115 | $ctx =~ s/\n*$//; |
| 5083 | my $cnt = statement_rawlines($ctx); | 5116 | my $cnt = statement_rawlines($ctx); |
| 5084 | my $herectx = $here . "\n"; | 5117 | my $herectx = get_stat_here($linenr, $cnt, $here); |
| 5085 | |||
| 5086 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 5087 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 5088 | } | ||
| 5089 | 5118 | ||
| 5090 | WARN("TRAILING_SEMICOLON", | 5119 | WARN("TRAILING_SEMICOLON", |
| 5091 | "macros should not use a trailing semicolon\n" . "$herectx"); | 5120 | "macros should not use a trailing semicolon\n" . "$herectx"); |
| @@ -5208,12 +5237,8 @@ sub process { | |||
| 5208 | } | 5237 | } |
| 5209 | } | 5238 | } |
| 5210 | if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { | 5239 | if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { |
| 5211 | my $herectx = $here . "\n"; | ||
| 5212 | my $cnt = statement_rawlines($block); | 5240 | my $cnt = statement_rawlines($block); |
| 5213 | 5241 | my $herectx = get_stat_here($linenr, $cnt, $here); | |
| 5214 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 5215 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 5216 | } | ||
| 5217 | 5242 | ||
| 5218 | WARN("BRACES", | 5243 | WARN("BRACES", |
| 5219 | "braces {} are not necessary for single statement blocks\n" . $herectx); | 5244 | "braces {} are not necessary for single statement blocks\n" . $herectx); |
| @@ -5789,36 +5814,50 @@ sub process { | |||
| 5789 | } | 5814 | } |
| 5790 | } | 5815 | } |
| 5791 | 5816 | ||
| 5792 | # check for vsprintf extension %p<foo> misuses | 5817 | # check for vsprintf extension %p<foo> misuses |
| 5793 | if ($^V && $^V ge 5.10.0 && | 5818 | if ($^V && $^V ge 5.10.0 && |
| 5794 | defined $stat && | 5819 | defined $stat && |
| 5795 | $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s && | 5820 | $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s && |
| 5796 | $1 !~ /^_*volatile_*$/) { | 5821 | $1 !~ /^_*volatile_*$/) { |
| 5797 | my $bad_extension = ""; | 5822 | my $specifier; |
| 5823 | my $extension; | ||
| 5824 | my $bad_specifier = ""; | ||
| 5825 | my $stat_real; | ||
| 5826 | |||
| 5798 | my $lc = $stat =~ tr@\n@@; | 5827 | my $lc = $stat =~ tr@\n@@; |
| 5799 | $lc = $lc + $linenr; | 5828 | $lc = $lc + $linenr; |
| 5800 | for (my $count = $linenr; $count <= $lc; $count++) { | 5829 | for (my $count = $linenr; $count <= $lc; $count++) { |
| 5801 | my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); | 5830 | my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); |
| 5802 | $fmt =~ s/%%//g; | 5831 | $fmt =~ s/%%//g; |
| 5803 | if ($fmt =~ /(\%[\*\d\.]*p(?![\WSsBKRraEhMmIiUDdgVCbGNOx]).)/) { | 5832 | |
| 5804 | $bad_extension = $1; | 5833 | while ($fmt =~ /(\%[\*\d\.]*p(\w))/g) { |
| 5805 | last; | 5834 | $specifier = $1; |
| 5806 | } | 5835 | $extension = $2; |
| 5807 | } | 5836 | if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOx]/) { |
| 5808 | if ($bad_extension ne "") { | 5837 | $bad_specifier = $specifier; |
| 5809 | my $stat_real = raw_line($linenr, 0); | 5838 | last; |
| 5810 | my $ext_type = "Invalid"; | 5839 | } |
| 5811 | my $use = ""; | 5840 | if ($extension eq "x" && !defined($stat_real)) { |
| 5812 | for (my $count = $linenr + 1; $count <= $lc; $count++) { | 5841 | if (!defined($stat_real)) { |
| 5813 | $stat_real = $stat_real . "\n" . raw_line($count, 0); | 5842 | $stat_real = get_stat_real($linenr, $lc); |
| 5843 | } | ||
| 5844 | WARN("VSPRINTF_SPECIFIER_PX", | ||
| 5845 | "Using vsprintf specifier '\%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '\%p'.\n" . "$here\n$stat_real\n"); | ||
| 5846 | } | ||
| 5814 | } | 5847 | } |
| 5815 | if ($bad_extension =~ /p[Ff]/) { | 5848 | if ($bad_specifier ne "") { |
| 5816 | $ext_type = "Deprecated"; | 5849 | my $stat_real = get_stat_real($linenr, $lc); |
| 5817 | $use = " - use %pS instead"; | 5850 | my $ext_type = "Invalid"; |
| 5818 | $use =~ s/pS/ps/ if ($bad_extension =~ /pf/); | 5851 | my $use = ""; |
| 5852 | if ($bad_specifier =~ /p[Ff]/) { | ||
| 5853 | $ext_type = "Deprecated"; | ||
| 5854 | $use = " - use %pS instead"; | ||
| 5855 | $use =~ s/pS/ps/ if ($bad_specifier =~ /pf/); | ||
| 5856 | } | ||
| 5857 | |||
| 5858 | WARN("VSPRINTF_POINTER_EXTENSION", | ||
| 5859 | "$ext_type vsprintf pointer extension '$bad_specifier'$use\n" . "$here\n$stat_real\n"); | ||
| 5819 | } | 5860 | } |
| 5820 | WARN("VSPRINTF_POINTER_EXTENSION", | ||
| 5821 | "$ext_type vsprintf pointer extension '$bad_extension'$use\n" . "$here\n$stat_real\n"); | ||
| 5822 | } | 5861 | } |
| 5823 | } | 5862 | } |
| 5824 | 5863 | ||
| @@ -5931,10 +5970,7 @@ sub process { | |||
| 5931 | $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) { | 5970 | $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) { |
| 5932 | my $lc = $stat =~ tr@\n@@; | 5971 | my $lc = $stat =~ tr@\n@@; |
| 5933 | $lc = $lc + $linenr; | 5972 | $lc = $lc + $linenr; |
| 5934 | my $stat_real = raw_line($linenr, 0); | 5973 | my $stat_real = get_stat_real($linenr, $lc); |
| 5935 | for (my $count = $linenr + 1; $count <= $lc; $count++) { | ||
| 5936 | $stat_real = $stat_real . "\n" . raw_line($count, 0); | ||
| 5937 | } | ||
| 5938 | WARN("NAKED_SSCANF", | 5974 | WARN("NAKED_SSCANF", |
| 5939 | "unchecked sscanf return value\n" . "$here\n$stat_real\n"); | 5975 | "unchecked sscanf return value\n" . "$here\n$stat_real\n"); |
| 5940 | } | 5976 | } |
| @@ -5945,10 +5981,7 @@ sub process { | |||
| 5945 | $line =~ /\bsscanf\b/) { | 5981 | $line =~ /\bsscanf\b/) { |
| 5946 | my $lc = $stat =~ tr@\n@@; | 5982 | my $lc = $stat =~ tr@\n@@; |
| 5947 | $lc = $lc + $linenr; | 5983 | $lc = $lc + $linenr; |
| 5948 | my $stat_real = raw_line($linenr, 0); | 5984 | my $stat_real = get_stat_real($linenr, $lc); |
| 5949 | for (my $count = $linenr + 1; $count <= $lc; $count++) { | ||
| 5950 | $stat_real = $stat_real . "\n" . raw_line($count, 0); | ||
| 5951 | } | ||
| 5952 | if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) { | 5985 | if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) { |
| 5953 | my $format = $6; | 5986 | my $format = $6; |
| 5954 | my $count = $format =~ tr@%@%@; | 5987 | my $count = $format =~ tr@%@%@; |
| @@ -6078,12 +6111,9 @@ sub process { | |||
| 6078 | } | 6111 | } |
| 6079 | if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ && | 6112 | if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ && |
| 6080 | !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) { | 6113 | !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) { |
| 6081 | my $ctx = ''; | ||
| 6082 | my $herectx = $here . "\n"; | ||
| 6083 | my $cnt = statement_rawlines($stat); | 6114 | my $cnt = statement_rawlines($stat); |
| 6084 | for (my $n = 0; $n < $cnt; $n++) { | 6115 | my $herectx = get_stat_here($linenr, $cnt, $here); |
| 6085 | $herectx .= raw_line($linenr, $n) . "\n"; | 6116 | |
| 6086 | } | ||
| 6087 | if (WARN("ALLOC_WITH_MULTIPLY", | 6117 | if (WARN("ALLOC_WITH_MULTIPLY", |
| 6088 | "Prefer $newfunc over $oldfunc with multiply\n" . $herectx) && | 6118 | "Prefer $newfunc over $oldfunc with multiply\n" . $herectx) && |
| 6089 | $cnt == 1 && | 6119 | $cnt == 1 && |
| @@ -6166,12 +6196,9 @@ sub process { | |||
| 6166 | if ($^V && $^V ge 5.10.0 && | 6196 | if ($^V && $^V ge 5.10.0 && |
| 6167 | defined $stat && | 6197 | defined $stat && |
| 6168 | $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) { | 6198 | $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) { |
| 6169 | my $ctx = ''; | ||
| 6170 | my $herectx = $here . "\n"; | ||
| 6171 | my $cnt = statement_rawlines($stat); | 6199 | my $cnt = statement_rawlines($stat); |
| 6172 | for (my $n = 0; $n < $cnt; $n++) { | 6200 | my $herectx = get_stat_here($linenr, $cnt, $here); |
| 6173 | $herectx .= raw_line($linenr, $n) . "\n"; | 6201 | |
| 6174 | } | ||
| 6175 | WARN("DEFAULT_NO_BREAK", | 6202 | WARN("DEFAULT_NO_BREAK", |
| 6176 | "switch default: should use break\n" . $herectx); | 6203 | "switch default: should use break\n" . $herectx); |
| 6177 | } | 6204 | } |
| @@ -6224,6 +6251,12 @@ sub process { | |||
| 6224 | } | 6251 | } |
| 6225 | } | 6252 | } |
| 6226 | 6253 | ||
| 6254 | # check for bool bitfields | ||
| 6255 | if ($sline =~ /^.\s+bool\s*$Ident\s*:\s*\d+\s*;/) { | ||
| 6256 | WARN("BOOL_BITFIELD", | ||
| 6257 | "Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr); | ||
| 6258 | } | ||
| 6259 | |||
| 6227 | # check for semaphores initialized locked | 6260 | # check for semaphores initialized locked |
| 6228 | if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { | 6261 | if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { |
| 6229 | WARN("CONSIDER_COMPLETION", | 6262 | WARN("CONSIDER_COMPLETION", |
| @@ -6382,10 +6415,7 @@ sub process { | |||
| 6382 | 6415 | ||
| 6383 | my $lc = $stat =~ tr@\n@@; | 6416 | my $lc = $stat =~ tr@\n@@; |
| 6384 | $lc = $lc + $linenr; | 6417 | $lc = $lc + $linenr; |
| 6385 | my $stat_real = raw_line($linenr, 0); | 6418 | my $stat_real = get_stat_real($linenr, $lc); |
| 6386 | for (my $count = $linenr + 1; $count <= $lc; $count++) { | ||
| 6387 | $stat_real = $stat_real . "\n" . raw_line($count, 0); | ||
| 6388 | } | ||
| 6389 | 6419 | ||
| 6390 | my $skip_args = ""; | 6420 | my $skip_args = ""; |
| 6391 | if ($arg_pos > 1) { | 6421 | if ($arg_pos > 1) { |
| @@ -6411,7 +6441,7 @@ sub process { | |||
| 6411 | } | 6441 | } |
| 6412 | 6442 | ||
| 6413 | # check for uses of S_<PERMS> that could be octal for readability | 6443 | # check for uses of S_<PERMS> that could be octal for readability |
| 6414 | if ($line =~ /\b($multi_mode_perms_string_search)\b/) { | 6444 | while ($line =~ m{\b($multi_mode_perms_string_search)\b}g) { |
| 6415 | my $oval = $1; | 6445 | my $oval = $1; |
| 6416 | my $octal = perms_to_octal($oval); | 6446 | my $octal = perms_to_octal($oval); |
| 6417 | if (WARN("SYMBOLIC_PERMS", | 6447 | if (WARN("SYMBOLIC_PERMS", |
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index cb993801e4b2..cbdf0dfd4c22 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
| @@ -64,10 +64,6 @@ my (@stack, $re, $dre, $x, $xs, $funcre); | |||
| 64 | # 2b6c: 4e56 fb70 linkw %fp,#-1168 | 64 | # 2b6c: 4e56 fb70 linkw %fp,#-1168 |
| 65 | # 1df770: defc ffe4 addaw #-28,%sp | 65 | # 1df770: defc ffe4 addaw #-28,%sp |
| 66 | $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o; | 66 | $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o; |
| 67 | } elsif ($arch eq 'metag') { | ||
| 68 | #400026fc: 40 00 00 82 ADD A0StP,A0StP,#0x8 | ||
| 69 | $re = qr/.*ADD.*A0StP,A0StP,\#(0x$x{1,8})/o; | ||
| 70 | $funcre = qr/^$x* <[^\$](.*)>:$/; | ||
| 71 | } elsif ($arch eq 'mips64') { | 67 | } elsif ($arch eq 'mips64') { |
| 72 | #8800402c: 67bdfff0 daddiu sp,sp,-16 | 68 | #8800402c: 67bdfff0 daddiu sp,sp,-16 |
| 73 | $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o; | 69 | $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o; |
| @@ -102,9 +98,6 @@ my (@stack, $re, $dre, $x, $xs, $funcre); | |||
| 102 | # pair for larger users. -- PFM. | 98 | # pair for larger users. -- PFM. |
| 103 | #a00048e0: d4fc40f0 addi.l r15,-240,r15 | 99 | #a00048e0: d4fc40f0 addi.l r15,-240,r15 |
| 104 | $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o; | 100 | $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o; |
| 105 | } elsif ($arch =~ /^blackfin$/) { | ||
| 106 | # 0: 00 e8 38 01 LINK 0x4e0; | ||
| 107 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; | ||
| 108 | } elsif ($arch eq 'sparc' || $arch eq 'sparc64') { | 101 | } elsif ($arch eq 'sparc' || $arch eq 'sparc64') { |
| 109 | # f0019d10: 9d e3 bf 90 save %sp, -112, %sp | 102 | # f0019d10: 9d e3 bf 90 save %sp, -112, %sp |
| 110 | $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o; | 103 | $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o; |
diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh new file mode 100755 index 000000000000..9780efa56980 --- /dev/null +++ b/scripts/clang-version.sh | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # SPDX-License-Identifier: GPL-2.0 | ||
| 3 | # | ||
| 4 | # clang-version [-p] clang-command | ||
| 5 | # | ||
| 6 | # Prints the compiler version of `clang-command' in a canonical 4-digit form | ||
| 7 | # such as `0500' for clang-5.0 etc. | ||
| 8 | # | ||
| 9 | # With the -p option, prints the patchlevel as well, for example `050001' for | ||
| 10 | # clang-5.0.1 etc. | ||
| 11 | # | ||
| 12 | |||
| 13 | if [ "$1" = "-p" ] ; then | ||
| 14 | with_patchlevel=1; | ||
| 15 | shift; | ||
| 16 | fi | ||
| 17 | |||
| 18 | compiler="$*" | ||
| 19 | |||
| 20 | if [ ${#compiler} -eq 0 ]; then | ||
| 21 | echo "Error: No compiler specified." | ||
| 22 | printf "Usage:\n\t$0 <clang-command>\n" | ||
| 23 | exit 1 | ||
| 24 | fi | ||
| 25 | |||
| 26 | MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) | ||
| 27 | MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) | ||
| 28 | if [ "x$with_patchlevel" != "x" ] ; then | ||
| 29 | PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) | ||
| 30 | printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | ||
| 31 | else | ||
| 32 | printf "%02d%02d\\n" $MAJOR $MINOR | ||
| 33 | fi | ||
diff --git a/scripts/coccinelle/api/drm-get-put.cocci b/scripts/coccinelle/api/drm-get-put.cocci index 91fceb8f1fa2..ceb71ea7f61c 100644 --- a/scripts/coccinelle/api/drm-get-put.cocci +++ b/scripts/coccinelle/api/drm-get-put.cocci | |||
| @@ -16,12 +16,6 @@ expression object; | |||
| 16 | @@ | 16 | @@ |
| 17 | 17 | ||
| 18 | ( | 18 | ( |
| 19 | - drm_mode_object_reference(object) | ||
| 20 | + drm_mode_object_get(object) | ||
| 21 | | | ||
| 22 | - drm_mode_object_unreference(object) | ||
| 23 | + drm_mode_object_put(object) | ||
| 24 | | | ||
| 25 | - drm_connector_reference(object) | 19 | - drm_connector_reference(object) |
| 26 | + drm_connector_get(object) | 20 | + drm_connector_get(object) |
| 27 | | | 21 | | |
| @@ -62,10 +56,6 @@ position p; | |||
| 62 | @@ | 56 | @@ |
| 63 | 57 | ||
| 64 | ( | 58 | ( |
| 65 | drm_mode_object_unreference@p(object) | ||
| 66 | | | ||
| 67 | drm_mode_object_reference@p(object) | ||
| 68 | | | ||
| 69 | drm_connector_unreference@p(object) | 59 | drm_connector_unreference@p(object) |
| 70 | | | 60 | | |
| 71 | drm_connector_reference@p(object) | 61 | drm_connector_reference@p(object) |
diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore index cdabdc95a6e7..2e6e60d64ede 100644 --- a/scripts/dtc/.gitignore +++ b/scripts/dtc/.gitignore | |||
| @@ -1,4 +1 @@ | |||
| 1 | dtc | dtc | |
| 2 | dtc-lexer.lex.c | ||
| 3 | dtc-parser.tab.c | ||
| 4 | dtc-parser.tab.h | ||
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 0dc922bb7aea..9cac65b7419c 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile | |||
| @@ -27,6 +27,3 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) | |||
| 27 | 27 | ||
| 28 | # dependencies on generated files need to be listed explicitly | 28 | # dependencies on generated files need to be listed explicitly |
| 29 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h | 29 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h |
| 30 | |||
| 31 | # generated files need to be cleaned explicitly | ||
| 32 | clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h | ||
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c index e66138449886..c07ba4da9e36 100644 --- a/scripts/dtc/checks.c +++ b/scripts/dtc/checks.c | |||
| @@ -53,26 +53,28 @@ struct check { | |||
| 53 | struct check **prereq; | 53 | struct check **prereq; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | #define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \ | 56 | #define CHECK_ENTRY(nm_, fn_, d_, w_, e_, ...) \ |
| 57 | static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \ | 57 | static struct check *nm_##_prereqs[] = { __VA_ARGS__ }; \ |
| 58 | static struct check _nm = { \ | 58 | static struct check nm_ = { \ |
| 59 | .name = #_nm, \ | 59 | .name = #nm_, \ |
| 60 | .fn = (_fn), \ | 60 | .fn = (fn_), \ |
| 61 | .data = (_d), \ | 61 | .data = (d_), \ |
| 62 | .warn = (_w), \ | 62 | .warn = (w_), \ |
| 63 | .error = (_e), \ | 63 | .error = (e_), \ |
| 64 | .status = UNCHECKED, \ | 64 | .status = UNCHECKED, \ |
| 65 | .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \ | 65 | .num_prereqs = ARRAY_SIZE(nm_##_prereqs), \ |
| 66 | .prereq = _nm##_prereqs, \ | 66 | .prereq = nm_##_prereqs, \ |
| 67 | }; | 67 | }; |
| 68 | #define WARNING(_nm, _fn, _d, ...) \ | 68 | #define WARNING(nm_, fn_, d_, ...) \ |
| 69 | CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__) | 69 | CHECK_ENTRY(nm_, fn_, d_, true, false, __VA_ARGS__) |
| 70 | #define ERROR(_nm, _fn, _d, ...) \ | 70 | #define ERROR(nm_, fn_, d_, ...) \ |
| 71 | CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__) | 71 | CHECK_ENTRY(nm_, fn_, d_, false, true, __VA_ARGS__) |
| 72 | #define CHECK(_nm, _fn, _d, ...) \ | 72 | #define CHECK(nm_, fn_, d_, ...) \ |
| 73 | CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) | 73 | CHECK_ENTRY(nm_, fn_, d_, false, false, __VA_ARGS__) |
| 74 | 74 | ||
| 75 | static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, | 75 | static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti, |
| 76 | struct node *node, | ||
| 77 | struct property *prop, | ||
| 76 | const char *fmt, ...) | 78 | const char *fmt, ...) |
| 77 | { | 79 | { |
| 78 | va_list ap; | 80 | va_list ap; |
| @@ -83,19 +85,33 @@ static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, | |||
| 83 | fprintf(stderr, "%s: %s (%s): ", | 85 | fprintf(stderr, "%s: %s (%s): ", |
| 84 | strcmp(dti->outname, "-") ? dti->outname : "<stdout>", | 86 | strcmp(dti->outname, "-") ? dti->outname : "<stdout>", |
| 85 | (c->error) ? "ERROR" : "Warning", c->name); | 87 | (c->error) ? "ERROR" : "Warning", c->name); |
| 88 | if (node) { | ||
| 89 | fprintf(stderr, "%s", node->fullpath); | ||
| 90 | if (prop) | ||
| 91 | fprintf(stderr, ":%s", prop->name); | ||
| 92 | fputs(": ", stderr); | ||
| 93 | } | ||
| 86 | vfprintf(stderr, fmt, ap); | 94 | vfprintf(stderr, fmt, ap); |
| 87 | fprintf(stderr, "\n"); | 95 | fprintf(stderr, "\n"); |
| 88 | } | 96 | } |
| 89 | va_end(ap); | 97 | va_end(ap); |
| 90 | } | 98 | } |
| 91 | 99 | ||
| 92 | #define FAIL(c, dti, ...) \ | 100 | #define FAIL(c, dti, node, ...) \ |
| 101 | do { \ | ||
| 102 | TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ | ||
| 103 | (c)->status = FAILED; \ | ||
| 104 | check_msg((c), dti, node, NULL, __VA_ARGS__); \ | ||
| 105 | } while (0) | ||
| 106 | |||
| 107 | #define FAIL_PROP(c, dti, node, prop, ...) \ | ||
| 93 | do { \ | 108 | do { \ |
| 94 | TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ | 109 | TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ |
| 95 | (c)->status = FAILED; \ | 110 | (c)->status = FAILED; \ |
| 96 | check_msg((c), dti, __VA_ARGS__); \ | 111 | check_msg((c), dti, node, prop, __VA_ARGS__); \ |
| 97 | } while (0) | 112 | } while (0) |
| 98 | 113 | ||
| 114 | |||
| 99 | static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) | 115 | static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) |
| 100 | { | 116 | { |
| 101 | struct node *child; | 117 | struct node *child; |
| @@ -126,7 +142,7 @@ static bool run_check(struct check *c, struct dt_info *dti) | |||
| 126 | error = error || run_check(prq, dti); | 142 | error = error || run_check(prq, dti); |
| 127 | if (prq->status != PASSED) { | 143 | if (prq->status != PASSED) { |
| 128 | c->status = PREREQ; | 144 | c->status = PREREQ; |
| 129 | check_msg(c, dti, "Failed prerequisite '%s'", | 145 | check_msg(c, dti, NULL, NULL, "Failed prerequisite '%s'", |
| 130 | c->prereq[i]->name); | 146 | c->prereq[i]->name); |
| 131 | } | 147 | } |
| 132 | } | 148 | } |
| @@ -156,7 +172,7 @@ out: | |||
| 156 | static inline void check_always_fail(struct check *c, struct dt_info *dti, | 172 | static inline void check_always_fail(struct check *c, struct dt_info *dti, |
| 157 | struct node *node) | 173 | struct node *node) |
| 158 | { | 174 | { |
| 159 | FAIL(c, dti, "always_fail check"); | 175 | FAIL(c, dti, node, "always_fail check"); |
| 160 | } | 176 | } |
| 161 | CHECK(always_fail, check_always_fail, NULL); | 177 | CHECK(always_fail, check_always_fail, NULL); |
| 162 | 178 | ||
| @@ -171,14 +187,42 @@ static void check_is_string(struct check *c, struct dt_info *dti, | |||
| 171 | return; /* Not present, assumed ok */ | 187 | return; /* Not present, assumed ok */ |
| 172 | 188 | ||
| 173 | if (!data_is_one_string(prop->val)) | 189 | if (!data_is_one_string(prop->val)) |
| 174 | FAIL(c, dti, "\"%s\" property in %s is not a string", | 190 | FAIL_PROP(c, dti, node, prop, "property is not a string"); |
| 175 | propname, node->fullpath); | ||
| 176 | } | 191 | } |
| 177 | #define WARNING_IF_NOT_STRING(nm, propname) \ | 192 | #define WARNING_IF_NOT_STRING(nm, propname) \ |
| 178 | WARNING(nm, check_is_string, (propname)) | 193 | WARNING(nm, check_is_string, (propname)) |
| 179 | #define ERROR_IF_NOT_STRING(nm, propname) \ | 194 | #define ERROR_IF_NOT_STRING(nm, propname) \ |
| 180 | ERROR(nm, check_is_string, (propname)) | 195 | ERROR(nm, check_is_string, (propname)) |
| 181 | 196 | ||
| 197 | static void check_is_string_list(struct check *c, struct dt_info *dti, | ||
| 198 | struct node *node) | ||
| 199 | { | ||
| 200 | int rem, l; | ||
| 201 | struct property *prop; | ||
| 202 | char *propname = c->data; | ||
| 203 | char *str; | ||
| 204 | |||
| 205 | prop = get_property(node, propname); | ||
| 206 | if (!prop) | ||
| 207 | return; /* Not present, assumed ok */ | ||
| 208 | |||
| 209 | str = prop->val.val; | ||
| 210 | rem = prop->val.len; | ||
| 211 | while (rem > 0) { | ||
| 212 | l = strnlen(str, rem); | ||
| 213 | if (l == rem) { | ||
| 214 | FAIL_PROP(c, dti, node, prop, "property is not a string list"); | ||
| 215 | break; | ||
| 216 | } | ||
| 217 | rem -= l + 1; | ||
| 218 | str += l + 1; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | #define WARNING_IF_NOT_STRING_LIST(nm, propname) \ | ||
| 222 | WARNING(nm, check_is_string_list, (propname)) | ||
| 223 | #define ERROR_IF_NOT_STRING_LIST(nm, propname) \ | ||
| 224 | ERROR(nm, check_is_string_list, (propname)) | ||
| 225 | |||
| 182 | static void check_is_cell(struct check *c, struct dt_info *dti, | 226 | static void check_is_cell(struct check *c, struct dt_info *dti, |
| 183 | struct node *node) | 227 | struct node *node) |
| 184 | { | 228 | { |
| @@ -190,8 +234,7 @@ static void check_is_cell(struct check *c, struct dt_info *dti, | |||
| 190 | return; /* Not present, assumed ok */ | 234 | return; /* Not present, assumed ok */ |
| 191 | 235 | ||
| 192 | if (prop->val.len != sizeof(cell_t)) | 236 | if (prop->val.len != sizeof(cell_t)) |
| 193 | FAIL(c, dti, "\"%s\" property in %s is not a single cell", | 237 | FAIL_PROP(c, dti, node, prop, "property is not a single cell"); |
| 194 | propname, node->fullpath); | ||
| 195 | } | 238 | } |
| 196 | #define WARNING_IF_NOT_CELL(nm, propname) \ | 239 | #define WARNING_IF_NOT_CELL(nm, propname) \ |
| 197 | WARNING(nm, check_is_cell, (propname)) | 240 | WARNING(nm, check_is_cell, (propname)) |
| @@ -212,8 +255,7 @@ static void check_duplicate_node_names(struct check *c, struct dt_info *dti, | |||
| 212 | child2; | 255 | child2; |
| 213 | child2 = child2->next_sibling) | 256 | child2 = child2->next_sibling) |
| 214 | if (streq(child->name, child2->name)) | 257 | if (streq(child->name, child2->name)) |
| 215 | FAIL(c, dti, "Duplicate node name %s", | 258 | FAIL(c, dti, node, "Duplicate node name"); |
| 216 | child->fullpath); | ||
| 217 | } | 259 | } |
| 218 | ERROR(duplicate_node_names, check_duplicate_node_names, NULL); | 260 | ERROR(duplicate_node_names, check_duplicate_node_names, NULL); |
| 219 | 261 | ||
| @@ -227,8 +269,7 @@ static void check_duplicate_property_names(struct check *c, struct dt_info *dti, | |||
| 227 | if (prop2->deleted) | 269 | if (prop2->deleted) |
| 228 | continue; | 270 | continue; |
| 229 | if (streq(prop->name, prop2->name)) | 271 | if (streq(prop->name, prop2->name)) |
| 230 | FAIL(c, dti, "Duplicate property name %s in %s", | 272 | FAIL_PROP(c, dti, node, prop, "Duplicate property name"); |
| 231 | prop->name, node->fullpath); | ||
| 232 | } | 273 | } |
| 233 | } | 274 | } |
| 234 | } | 275 | } |
| @@ -246,8 +287,8 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti, | |||
| 246 | int n = strspn(node->name, c->data); | 287 | int n = strspn(node->name, c->data); |
| 247 | 288 | ||
| 248 | if (n < strlen(node->name)) | 289 | if (n < strlen(node->name)) |
| 249 | FAIL(c, dti, "Bad character '%c' in node %s", | 290 | FAIL(c, dti, node, "Bad character '%c' in node name", |
| 250 | node->name[n], node->fullpath); | 291 | node->name[n]); |
| 251 | } | 292 | } |
| 252 | ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); | 293 | ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); |
| 253 | 294 | ||
| @@ -257,8 +298,8 @@ static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, | |||
| 257 | int n = strspn(node->name, c->data); | 298 | int n = strspn(node->name, c->data); |
| 258 | 299 | ||
| 259 | if (n < node->basenamelen) | 300 | if (n < node->basenamelen) |
| 260 | FAIL(c, dti, "Character '%c' not recommended in node %s", | 301 | FAIL(c, dti, node, "Character '%c' not recommended in node name", |
| 261 | node->name[n], node->fullpath); | 302 | node->name[n]); |
| 262 | } | 303 | } |
| 263 | CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT); | 304 | CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT); |
| 264 | 305 | ||
| @@ -266,8 +307,7 @@ static void check_node_name_format(struct check *c, struct dt_info *dti, | |||
| 266 | struct node *node) | 307 | struct node *node) |
| 267 | { | 308 | { |
| 268 | if (strchr(get_unitname(node), '@')) | 309 | if (strchr(get_unitname(node), '@')) |
| 269 | FAIL(c, dti, "Node %s has multiple '@' characters in name", | 310 | FAIL(c, dti, node, "multiple '@' characters in node name"); |
| 270 | node->fullpath); | ||
| 271 | } | 311 | } |
| 272 | ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); | 312 | ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); |
| 273 | 313 | ||
| @@ -285,12 +325,10 @@ static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, | |||
| 285 | 325 | ||
| 286 | if (prop) { | 326 | if (prop) { |
| 287 | if (!unitname[0]) | 327 | if (!unitname[0]) |
| 288 | FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name", | 328 | FAIL(c, dti, node, "node has a reg or ranges property, but no unit name"); |
| 289 | node->fullpath); | ||
| 290 | } else { | 329 | } else { |
| 291 | if (unitname[0]) | 330 | if (unitname[0]) |
| 292 | FAIL(c, dti, "Node %s has a unit name, but no reg property", | 331 | FAIL(c, dti, node, "node has a unit name, but no reg property"); |
| 293 | node->fullpath); | ||
| 294 | } | 332 | } |
| 295 | } | 333 | } |
| 296 | WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL); | 334 | WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL); |
| @@ -304,8 +342,8 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti, | |||
| 304 | int n = strspn(prop->name, c->data); | 342 | int n = strspn(prop->name, c->data); |
| 305 | 343 | ||
| 306 | if (n < strlen(prop->name)) | 344 | if (n < strlen(prop->name)) |
| 307 | FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s", | 345 | FAIL_PROP(c, dti, node, prop, "Bad character '%c' in property name", |
| 308 | prop->name[n], prop->name, node->fullpath); | 346 | prop->name[n]); |
| 309 | } | 347 | } |
| 310 | } | 348 | } |
| 311 | ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); | 349 | ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); |
| @@ -336,8 +374,8 @@ static void check_property_name_chars_strict(struct check *c, | |||
| 336 | n = strspn(name, c->data); | 374 | n = strspn(name, c->data); |
| 337 | } | 375 | } |
| 338 | if (n < strlen(name)) | 376 | if (n < strlen(name)) |
| 339 | FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s", | 377 | FAIL_PROP(c, dti, node, prop, "Character '%c' not recommended in property name", |
| 340 | name[n], prop->name, node->fullpath); | 378 | name[n]); |
| 341 | } | 379 | } |
| 342 | } | 380 | } |
| 343 | CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); | 381 | CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); |
| @@ -370,7 +408,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti, | |||
| 370 | return; | 408 | return; |
| 371 | 409 | ||
| 372 | if ((othernode != node) || (otherprop != prop) || (othermark != mark)) | 410 | if ((othernode != node) || (otherprop != prop) || (othermark != mark)) |
| 373 | FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT | 411 | FAIL(c, dti, node, "Duplicate label '%s' on " DESCLABEL_FMT |
| 374 | " and " DESCLABEL_FMT, | 412 | " and " DESCLABEL_FMT, |
| 375 | label, DESCLABEL_ARGS(node, prop, mark), | 413 | label, DESCLABEL_ARGS(node, prop, mark), |
| 376 | DESCLABEL_ARGS(othernode, otherprop, othermark)); | 414 | DESCLABEL_ARGS(othernode, otherprop, othermark)); |
| @@ -410,8 +448,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, | |||
| 410 | return 0; | 448 | return 0; |
| 411 | 449 | ||
| 412 | if (prop->val.len != sizeof(cell_t)) { | 450 | if (prop->val.len != sizeof(cell_t)) { |
| 413 | FAIL(c, dti, "%s has bad length (%d) %s property", | 451 | FAIL_PROP(c, dti, node, prop, "bad length (%d) %s property", |
| 414 | node->fullpath, prop->val.len, prop->name); | 452 | prop->val.len, prop->name); |
| 415 | return 0; | 453 | return 0; |
| 416 | } | 454 | } |
| 417 | 455 | ||
| @@ -422,8 +460,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, | |||
| 422 | /* "Set this node's phandle equal to some | 460 | /* "Set this node's phandle equal to some |
| 423 | * other node's phandle". That's nonsensical | 461 | * other node's phandle". That's nonsensical |
| 424 | * by construction. */ { | 462 | * by construction. */ { |
| 425 | FAIL(c, dti, "%s in %s is a reference to another node", | 463 | FAIL(c, dti, node, "%s is a reference to another node", |
| 426 | prop->name, node->fullpath); | 464 | prop->name); |
| 427 | } | 465 | } |
| 428 | /* But setting this node's phandle equal to its own | 466 | /* But setting this node's phandle equal to its own |
| 429 | * phandle is allowed - that means allocate a unique | 467 | * phandle is allowed - that means allocate a unique |
| @@ -436,8 +474,8 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, | |||
| 436 | phandle = propval_cell(prop); | 474 | phandle = propval_cell(prop); |
| 437 | 475 | ||
| 438 | if ((phandle == 0) || (phandle == -1)) { | 476 | if ((phandle == 0) || (phandle == -1)) { |
| 439 | FAIL(c, dti, "%s has bad value (0x%x) in %s property", | 477 | FAIL_PROP(c, dti, node, prop, "bad value (0x%x) in %s property", |
| 440 | node->fullpath, phandle, prop->name); | 478 | phandle, prop->name); |
| 441 | return 0; | 479 | return 0; |
| 442 | } | 480 | } |
| 443 | 481 | ||
| @@ -463,16 +501,16 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti, | |||
| 463 | return; | 501 | return; |
| 464 | 502 | ||
| 465 | if (linux_phandle && phandle && (phandle != linux_phandle)) | 503 | if (linux_phandle && phandle && (phandle != linux_phandle)) |
| 466 | FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'" | 504 | FAIL(c, dti, node, "mismatching 'phandle' and 'linux,phandle'" |
| 467 | " properties", node->fullpath); | 505 | " properties"); |
| 468 | 506 | ||
| 469 | if (linux_phandle && !phandle) | 507 | if (linux_phandle && !phandle) |
| 470 | phandle = linux_phandle; | 508 | phandle = linux_phandle; |
| 471 | 509 | ||
| 472 | other = get_node_by_phandle(root, phandle); | 510 | other = get_node_by_phandle(root, phandle); |
| 473 | if (other && (other != node)) { | 511 | if (other && (other != node)) { |
| 474 | FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)", | 512 | FAIL(c, dti, node, "duplicated phandle 0x%x (seen before at %s)", |
| 475 | node->fullpath, phandle, other->fullpath); | 513 | phandle, other->fullpath); |
| 476 | return; | 514 | return; |
| 477 | } | 515 | } |
| 478 | 516 | ||
| @@ -496,8 +534,8 @@ static void check_name_properties(struct check *c, struct dt_info *dti, | |||
| 496 | 534 | ||
| 497 | if ((prop->val.len != node->basenamelen+1) | 535 | if ((prop->val.len != node->basenamelen+1) |
| 498 | || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { | 536 | || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { |
| 499 | FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead" | 537 | FAIL(c, dti, node, "\"name\" property is incorrect (\"%s\" instead" |
| 500 | " of base node name)", node->fullpath, prop->val.val); | 538 | " of base node name)", prop->val.val); |
| 501 | } else { | 539 | } else { |
| 502 | /* The name property is correct, and therefore redundant. | 540 | /* The name property is correct, and therefore redundant. |
| 503 | * Delete it */ | 541 | * Delete it */ |
| @@ -531,7 +569,7 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti, | |||
| 531 | refnode = get_node_by_ref(dt, m->ref); | 569 | refnode = get_node_by_ref(dt, m->ref); |
| 532 | if (! refnode) { | 570 | if (! refnode) { |
| 533 | if (!(dti->dtsflags & DTSF_PLUGIN)) | 571 | if (!(dti->dtsflags & DTSF_PLUGIN)) |
| 534 | FAIL(c, dti, "Reference to non-existent node or " | 572 | FAIL(c, dti, node, "Reference to non-existent node or " |
| 535 | "label \"%s\"\n", m->ref); | 573 | "label \"%s\"\n", m->ref); |
| 536 | else /* mark the entry as unresolved */ | 574 | else /* mark the entry as unresolved */ |
| 537 | *((fdt32_t *)(prop->val.val + m->offset)) = | 575 | *((fdt32_t *)(prop->val.val + m->offset)) = |
| @@ -563,7 +601,7 @@ static void fixup_path_references(struct check *c, struct dt_info *dti, | |||
| 563 | 601 | ||
| 564 | refnode = get_node_by_ref(dt, m->ref); | 602 | refnode = get_node_by_ref(dt, m->ref); |
| 565 | if (!refnode) { | 603 | if (!refnode) { |
| 566 | FAIL(c, dti, "Reference to non-existent node or label \"%s\"\n", | 604 | FAIL(c, dti, node, "Reference to non-existent node or label \"%s\"\n", |
| 567 | m->ref); | 605 | m->ref); |
| 568 | continue; | 606 | continue; |
| 569 | } | 607 | } |
| @@ -586,6 +624,45 @@ WARNING_IF_NOT_CELL(interrupt_cells_is_cell, "#interrupt-cells"); | |||
| 586 | WARNING_IF_NOT_STRING(device_type_is_string, "device_type"); | 624 | WARNING_IF_NOT_STRING(device_type_is_string, "device_type"); |
| 587 | WARNING_IF_NOT_STRING(model_is_string, "model"); | 625 | WARNING_IF_NOT_STRING(model_is_string, "model"); |
| 588 | WARNING_IF_NOT_STRING(status_is_string, "status"); | 626 | WARNING_IF_NOT_STRING(status_is_string, "status"); |
| 627 | WARNING_IF_NOT_STRING(label_is_string, "label"); | ||
| 628 | |||
| 629 | WARNING_IF_NOT_STRING_LIST(compatible_is_string_list, "compatible"); | ||
| 630 | |||
| 631 | static void check_names_is_string_list(struct check *c, struct dt_info *dti, | ||
| 632 | struct node *node) | ||
| 633 | { | ||
| 634 | struct property *prop; | ||
| 635 | |||
| 636 | for_each_property(node, prop) { | ||
| 637 | const char *s = strrchr(prop->name, '-'); | ||
| 638 | if (!s || !streq(s, "-names")) | ||
| 639 | continue; | ||
| 640 | |||
| 641 | c->data = prop->name; | ||
| 642 | check_is_string_list(c, dti, node); | ||
| 643 | } | ||
| 644 | } | ||
| 645 | WARNING(names_is_string_list, check_names_is_string_list, NULL); | ||
| 646 | |||
| 647 | static void check_alias_paths(struct check *c, struct dt_info *dti, | ||
| 648 | struct node *node) | ||
| 649 | { | ||
| 650 | struct property *prop; | ||
| 651 | |||
| 652 | if (!streq(node->name, "aliases")) | ||
| 653 | return; | ||
| 654 | |||
| 655 | for_each_property(node, prop) { | ||
| 656 | if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) { | ||
| 657 | FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)", | ||
| 658 | prop->val.val); | ||
| 659 | continue; | ||
| 660 | } | ||
| 661 | if (strspn(prop->name, LOWERCASE DIGITS "-") != strlen(prop->name)) | ||
| 662 | FAIL(c, dti, node, "aliases property name must include only lowercase and '-'"); | ||
| 663 | } | ||
| 664 | } | ||
| 665 | WARNING(alias_paths, check_alias_paths, NULL); | ||
| 589 | 666 | ||
| 590 | static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, | 667 | static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, |
| 591 | struct node *node) | 668 | struct node *node) |
| @@ -622,21 +699,21 @@ static void check_reg_format(struct check *c, struct dt_info *dti, | |||
| 622 | return; /* No "reg", that's fine */ | 699 | return; /* No "reg", that's fine */ |
| 623 | 700 | ||
| 624 | if (!node->parent) { | 701 | if (!node->parent) { |
| 625 | FAIL(c, dti, "Root node has a \"reg\" property"); | 702 | FAIL(c, dti, node, "Root node has a \"reg\" property"); |
| 626 | return; | 703 | return; |
| 627 | } | 704 | } |
| 628 | 705 | ||
| 629 | if (prop->val.len == 0) | 706 | if (prop->val.len == 0) |
| 630 | FAIL(c, dti, "\"reg\" property in %s is empty", node->fullpath); | 707 | FAIL_PROP(c, dti, node, prop, "property is empty"); |
| 631 | 708 | ||
| 632 | addr_cells = node_addr_cells(node->parent); | 709 | addr_cells = node_addr_cells(node->parent); |
| 633 | size_cells = node_size_cells(node->parent); | 710 | size_cells = node_size_cells(node->parent); |
| 634 | entrylen = (addr_cells + size_cells) * sizeof(cell_t); | 711 | entrylen = (addr_cells + size_cells) * sizeof(cell_t); |
| 635 | 712 | ||
| 636 | if (!entrylen || (prop->val.len % entrylen) != 0) | 713 | if (!entrylen || (prop->val.len % entrylen) != 0) |
| 637 | FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) " | 714 | FAIL_PROP(c, dti, node, prop, "property has invalid length (%d bytes) " |
| 638 | "(#address-cells == %d, #size-cells == %d)", | 715 | "(#address-cells == %d, #size-cells == %d)", |
| 639 | node->fullpath, prop->val.len, addr_cells, size_cells); | 716 | prop->val.len, addr_cells, size_cells); |
| 640 | } | 717 | } |
| 641 | WARNING(reg_format, check_reg_format, NULL, &addr_size_cells); | 718 | WARNING(reg_format, check_reg_format, NULL, &addr_size_cells); |
| 642 | 719 | ||
| @@ -651,7 +728,7 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, | |||
| 651 | return; | 728 | return; |
| 652 | 729 | ||
| 653 | if (!node->parent) { | 730 | if (!node->parent) { |
| 654 | FAIL(c, dti, "Root node has a \"ranges\" property"); | 731 | FAIL_PROP(c, dti, node, prop, "Root node has a \"ranges\" property"); |
| 655 | return; | 732 | return; |
| 656 | } | 733 | } |
| 657 | 734 | ||
| @@ -663,20 +740,20 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, | |||
| 663 | 740 | ||
| 664 | if (prop->val.len == 0) { | 741 | if (prop->val.len == 0) { |
| 665 | if (p_addr_cells != c_addr_cells) | 742 | if (p_addr_cells != c_addr_cells) |
| 666 | FAIL(c, dti, "%s has empty \"ranges\" property but its " | 743 | FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its " |
| 667 | "#address-cells (%d) differs from %s (%d)", | 744 | "#address-cells (%d) differs from %s (%d)", |
| 668 | node->fullpath, c_addr_cells, node->parent->fullpath, | 745 | c_addr_cells, node->parent->fullpath, |
| 669 | p_addr_cells); | 746 | p_addr_cells); |
| 670 | if (p_size_cells != c_size_cells) | 747 | if (p_size_cells != c_size_cells) |
| 671 | FAIL(c, dti, "%s has empty \"ranges\" property but its " | 748 | FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its " |
| 672 | "#size-cells (%d) differs from %s (%d)", | 749 | "#size-cells (%d) differs from %s (%d)", |
| 673 | node->fullpath, c_size_cells, node->parent->fullpath, | 750 | c_size_cells, node->parent->fullpath, |
| 674 | p_size_cells); | 751 | p_size_cells); |
| 675 | } else if ((prop->val.len % entrylen) != 0) { | 752 | } else if ((prop->val.len % entrylen) != 0) { |
| 676 | FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) " | 753 | FAIL_PROP(c, dti, node, prop, "\"ranges\" property has invalid length (%d bytes) " |
| 677 | "(parent #address-cells == %d, child #address-cells == %d, " | 754 | "(parent #address-cells == %d, child #address-cells == %d, " |
| 678 | "#size-cells == %d)", node->fullpath, prop->val.len, | 755 | "#size-cells == %d)", prop->val.len, |
| 679 | p_addr_cells, c_addr_cells, c_size_cells); | 756 | p_addr_cells, c_addr_cells, c_size_cells); |
| 680 | } | 757 | } |
| 681 | } | 758 | } |
| 682 | WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); | 759 | WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); |
| @@ -696,41 +773,33 @@ static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node * | |||
| 696 | 773 | ||
| 697 | node->bus = &pci_bus; | 774 | node->bus = &pci_bus; |
| 698 | 775 | ||
| 699 | if (!strneq(node->name, "pci", node->basenamelen) && | 776 | if (!strprefixeq(node->name, node->basenamelen, "pci") && |
| 700 | !strneq(node->name, "pcie", node->basenamelen)) | 777 | !strprefixeq(node->name, node->basenamelen, "pcie")) |
| 701 | FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"", | 778 | FAIL(c, dti, node, "node name is not \"pci\" or \"pcie\""); |
| 702 | node->fullpath); | ||
| 703 | 779 | ||
| 704 | prop = get_property(node, "ranges"); | 780 | prop = get_property(node, "ranges"); |
| 705 | if (!prop) | 781 | if (!prop) |
| 706 | FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)", | 782 | FAIL(c, dti, node, "missing ranges for PCI bridge (or not a bridge)"); |
| 707 | node->fullpath); | ||
| 708 | 783 | ||
| 709 | if (node_addr_cells(node) != 3) | 784 | if (node_addr_cells(node) != 3) |
| 710 | FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge", | 785 | FAIL(c, dti, node, "incorrect #address-cells for PCI bridge"); |
| 711 | node->fullpath); | ||
| 712 | if (node_size_cells(node) != 2) | 786 | if (node_size_cells(node) != 2) |
| 713 | FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge", | 787 | FAIL(c, dti, node, "incorrect #size-cells for PCI bridge"); |
| 714 | node->fullpath); | ||
| 715 | 788 | ||
| 716 | prop = get_property(node, "bus-range"); | 789 | prop = get_property(node, "bus-range"); |
| 717 | if (!prop) { | 790 | if (!prop) { |
| 718 | FAIL(c, dti, "Node %s missing bus-range for PCI bridge", | 791 | FAIL(c, dti, node, "missing bus-range for PCI bridge"); |
| 719 | node->fullpath); | ||
| 720 | return; | 792 | return; |
| 721 | } | 793 | } |
| 722 | if (prop->val.len != (sizeof(cell_t) * 2)) { | 794 | if (prop->val.len != (sizeof(cell_t) * 2)) { |
| 723 | FAIL(c, dti, "Node %s bus-range must be 2 cells", | 795 | FAIL_PROP(c, dti, node, prop, "value must be 2 cells"); |
| 724 | node->fullpath); | ||
| 725 | return; | 796 | return; |
| 726 | } | 797 | } |
| 727 | cells = (cell_t *)prop->val.val; | 798 | cells = (cell_t *)prop->val.val; |
| 728 | if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1])) | 799 | if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1])) |
| 729 | FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell", | 800 | FAIL_PROP(c, dti, node, prop, "1st cell must be less than or equal to 2nd cell"); |
| 730 | node->fullpath); | ||
| 731 | if (fdt32_to_cpu(cells[1]) > 0xff) | 801 | if (fdt32_to_cpu(cells[1]) > 0xff) |
| 732 | FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256", | 802 | FAIL_PROP(c, dti, node, prop, "maximum bus number must be less than 256"); |
| 733 | node->fullpath); | ||
| 734 | } | 803 | } |
| 735 | WARNING(pci_bridge, check_pci_bridge, NULL, | 804 | WARNING(pci_bridge, check_pci_bridge, NULL, |
| 736 | &device_type_is_string, &addr_size_cells); | 805 | &device_type_is_string, &addr_size_cells); |
| @@ -760,8 +829,8 @@ static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struc | |||
| 760 | max_bus = fdt32_to_cpu(cells[0]); | 829 | max_bus = fdt32_to_cpu(cells[0]); |
| 761 | } | 830 | } |
| 762 | if ((bus_num < min_bus) || (bus_num > max_bus)) | 831 | if ((bus_num < min_bus) || (bus_num > max_bus)) |
| 763 | FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)", | 832 | FAIL_PROP(c, dti, node, prop, "PCI bus number %d out of range, expected (%d - %d)", |
| 764 | node->fullpath, bus_num, min_bus, max_bus); | 833 | bus_num, min_bus, max_bus); |
| 765 | } | 834 | } |
| 766 | WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, ®_format, &pci_bridge); | 835 | WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, ®_format, &pci_bridge); |
| 767 | 836 | ||
| @@ -778,25 +847,22 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no | |||
| 778 | 847 | ||
| 779 | prop = get_property(node, "reg"); | 848 | prop = get_property(node, "reg"); |
| 780 | if (!prop) { | 849 | if (!prop) { |
| 781 | FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath); | 850 | FAIL(c, dti, node, "missing PCI reg property"); |
| 782 | return; | 851 | return; |
| 783 | } | 852 | } |
| 784 | 853 | ||
| 785 | cells = (cell_t *)prop->val.val; | 854 | cells = (cell_t *)prop->val.val; |
| 786 | if (cells[1] || cells[2]) | 855 | if (cells[1] || cells[2]) |
| 787 | FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0", | 856 | FAIL_PROP(c, dti, node, prop, "PCI reg config space address cells 2 and 3 must be 0"); |
| 788 | node->fullpath); | ||
| 789 | 857 | ||
| 790 | reg = fdt32_to_cpu(cells[0]); | 858 | reg = fdt32_to_cpu(cells[0]); |
| 791 | dev = (reg & 0xf800) >> 11; | 859 | dev = (reg & 0xf800) >> 11; |
| 792 | func = (reg & 0x700) >> 8; | 860 | func = (reg & 0x700) >> 8; |
| 793 | 861 | ||
| 794 | if (reg & 0xff000000) | 862 | if (reg & 0xff000000) |
| 795 | FAIL(c, dti, "Node %s PCI reg address is not configuration space", | 863 | FAIL_PROP(c, dti, node, prop, "PCI reg address is not configuration space"); |
| 796 | node->fullpath); | ||
| 797 | if (reg & 0x000000ff) | 864 | if (reg & 0x000000ff) |
| 798 | FAIL(c, dti, "Node %s PCI reg config space address register number must be 0", | 865 | FAIL_PROP(c, dti, node, prop, "PCI reg config space address register number must be 0"); |
| 799 | node->fullpath); | ||
| 800 | 866 | ||
| 801 | if (func == 0) { | 867 | if (func == 0) { |
| 802 | snprintf(unit_addr, sizeof(unit_addr), "%x", dev); | 868 | snprintf(unit_addr, sizeof(unit_addr), "%x", dev); |
| @@ -808,8 +874,8 @@ static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct no | |||
| 808 | if (streq(unitname, unit_addr)) | 874 | if (streq(unitname, unit_addr)) |
| 809 | return; | 875 | return; |
| 810 | 876 | ||
| 811 | FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"", | 877 | FAIL(c, dti, node, "PCI unit address format error, expected \"%s\"", |
| 812 | node->fullpath, unit_addr); | 878 | unit_addr); |
| 813 | } | 879 | } |
| 814 | WARNING(pci_device_reg, check_pci_device_reg, NULL, ®_format, &pci_bridge); | 880 | WARNING(pci_device_reg, check_pci_device_reg, NULL, ®_format, &pci_bridge); |
| 815 | 881 | ||
| @@ -828,7 +894,7 @@ static bool node_is_compatible(struct node *node, const char *compat) | |||
| 828 | 894 | ||
| 829 | for (str = prop->val.val, end = str + prop->val.len; str < end; | 895 | for (str = prop->val.val, end = str + prop->val.len; str < end; |
| 830 | str += strnlen(str, end - str) + 1) { | 896 | str += strnlen(str, end - str) + 1) { |
| 831 | if (strneq(str, compat, end - str)) | 897 | if (strprefixeq(str, end - str, compat)) |
| 832 | return true; | 898 | return true; |
| 833 | } | 899 | } |
| 834 | return false; | 900 | return false; |
| @@ -865,7 +931,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no | |||
| 865 | 931 | ||
| 866 | if (!cells) { | 932 | if (!cells) { |
| 867 | if (node->parent->parent && !(node->bus == &simple_bus)) | 933 | if (node->parent->parent && !(node->bus == &simple_bus)) |
| 868 | FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath); | 934 | FAIL(c, dti, node, "missing or empty reg/ranges property"); |
| 869 | return; | 935 | return; |
| 870 | } | 936 | } |
| 871 | 937 | ||
| @@ -875,8 +941,8 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no | |||
| 875 | 941 | ||
| 876 | snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg); | 942 | snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg); |
| 877 | if (!streq(unitname, unit_addr)) | 943 | if (!streq(unitname, unit_addr)) |
| 878 | FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"", | 944 | FAIL(c, dti, node, "simple-bus unit address format error, expected \"%s\"", |
| 879 | node->fullpath, unit_addr); | 945 | unit_addr); |
| 880 | } | 946 | } |
| 881 | WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); | 947 | WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); |
| 882 | 948 | ||
| @@ -892,14 +958,12 @@ static void check_unit_address_format(struct check *c, struct dt_info *dti, | |||
| 892 | return; | 958 | return; |
| 893 | 959 | ||
| 894 | if (!strncmp(unitname, "0x", 2)) { | 960 | if (!strncmp(unitname, "0x", 2)) { |
| 895 | FAIL(c, dti, "Node %s unit name should not have leading \"0x\"", | 961 | FAIL(c, dti, node, "unit name should not have leading \"0x\""); |
| 896 | node->fullpath); | ||
| 897 | /* skip over 0x for next test */ | 962 | /* skip over 0x for next test */ |
| 898 | unitname += 2; | 963 | unitname += 2; |
| 899 | } | 964 | } |
| 900 | if (unitname[0] == '0' && isxdigit(unitname[1])) | 965 | if (unitname[0] == '0' && isxdigit(unitname[1])) |
| 901 | FAIL(c, dti, "Node %s unit name should not have leading 0s", | 966 | FAIL(c, dti, node, "unit name should not have leading 0s"); |
| 902 | node->fullpath); | ||
| 903 | } | 967 | } |
| 904 | WARNING(unit_address_format, check_unit_address_format, NULL, | 968 | WARNING(unit_address_format, check_unit_address_format, NULL, |
| 905 | &node_name_format, &pci_bridge, &simple_bus_bridge); | 969 | &node_name_format, &pci_bridge, &simple_bus_bridge); |
| @@ -922,16 +986,38 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti, | |||
| 922 | return; | 986 | return; |
| 923 | 987 | ||
| 924 | if (node->parent->addr_cells == -1) | 988 | if (node->parent->addr_cells == -1) |
| 925 | FAIL(c, dti, "Relying on default #address-cells value for %s", | 989 | FAIL(c, dti, node, "Relying on default #address-cells value"); |
| 926 | node->fullpath); | ||
| 927 | 990 | ||
| 928 | if (node->parent->size_cells == -1) | 991 | if (node->parent->size_cells == -1) |
| 929 | FAIL(c, dti, "Relying on default #size-cells value for %s", | 992 | FAIL(c, dti, node, "Relying on default #size-cells value"); |
| 930 | node->fullpath); | ||
| 931 | } | 993 | } |
| 932 | WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, | 994 | WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, |
| 933 | &addr_size_cells); | 995 | &addr_size_cells); |
| 934 | 996 | ||
| 997 | static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *dti, | ||
| 998 | struct node *node) | ||
| 999 | { | ||
| 1000 | struct property *prop; | ||
| 1001 | struct node *child; | ||
| 1002 | bool has_reg = false; | ||
| 1003 | |||
| 1004 | if (!node->parent || node->addr_cells < 0 || node->size_cells < 0) | ||
| 1005 | return; | ||
| 1006 | |||
| 1007 | if (get_property(node, "ranges") || !node->children) | ||
| 1008 | return; | ||
| 1009 | |||
| 1010 | for_each_child(node, child) { | ||
| 1011 | prop = get_property(child, "reg"); | ||
| 1012 | if (prop) | ||
| 1013 | has_reg = true; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | if (!has_reg) | ||
| 1017 | FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" property"); | ||
| 1018 | } | ||
| 1019 | WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size); | ||
| 1020 | |||
| 935 | static void check_obsolete_chosen_interrupt_controller(struct check *c, | 1021 | static void check_obsolete_chosen_interrupt_controller(struct check *c, |
| 936 | struct dt_info *dti, | 1022 | struct dt_info *dti, |
| 937 | struct node *node) | 1023 | struct node *node) |
| @@ -950,12 +1036,61 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, | |||
| 950 | 1036 | ||
| 951 | prop = get_property(chosen, "interrupt-controller"); | 1037 | prop = get_property(chosen, "interrupt-controller"); |
| 952 | if (prop) | 1038 | if (prop) |
| 953 | FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" " | 1039 | FAIL_PROP(c, dti, node, prop, |
| 954 | "property"); | 1040 | "/chosen has obsolete \"interrupt-controller\" property"); |
| 955 | } | 1041 | } |
| 956 | WARNING(obsolete_chosen_interrupt_controller, | 1042 | WARNING(obsolete_chosen_interrupt_controller, |
| 957 | check_obsolete_chosen_interrupt_controller, NULL); | 1043 | check_obsolete_chosen_interrupt_controller, NULL); |
| 958 | 1044 | ||
| 1045 | static void check_chosen_node_is_root(struct check *c, struct dt_info *dti, | ||
| 1046 | struct node *node) | ||
| 1047 | { | ||
| 1048 | if (!streq(node->name, "chosen")) | ||
| 1049 | return; | ||
| 1050 | |||
| 1051 | if (node->parent != dti->dt) | ||
| 1052 | FAIL(c, dti, node, "chosen node must be at root node"); | ||
| 1053 | } | ||
| 1054 | WARNING(chosen_node_is_root, check_chosen_node_is_root, NULL); | ||
| 1055 | |||
| 1056 | static void check_chosen_node_bootargs(struct check *c, struct dt_info *dti, | ||
| 1057 | struct node *node) | ||
| 1058 | { | ||
| 1059 | struct property *prop; | ||
| 1060 | |||
| 1061 | if (!streq(node->name, "chosen")) | ||
| 1062 | return; | ||
| 1063 | |||
| 1064 | prop = get_property(node, "bootargs"); | ||
| 1065 | if (!prop) | ||
| 1066 | return; | ||
| 1067 | |||
| 1068 | c->data = prop->name; | ||
| 1069 | check_is_string(c, dti, node); | ||
| 1070 | } | ||
| 1071 | WARNING(chosen_node_bootargs, check_chosen_node_bootargs, NULL); | ||
| 1072 | |||
| 1073 | static void check_chosen_node_stdout_path(struct check *c, struct dt_info *dti, | ||
| 1074 | struct node *node) | ||
| 1075 | { | ||
| 1076 | struct property *prop; | ||
| 1077 | |||
| 1078 | if (!streq(node->name, "chosen")) | ||
| 1079 | return; | ||
| 1080 | |||
| 1081 | prop = get_property(node, "stdout-path"); | ||
| 1082 | if (!prop) { | ||
| 1083 | prop = get_property(node, "linux,stdout-path"); | ||
| 1084 | if (!prop) | ||
| 1085 | return; | ||
| 1086 | FAIL_PROP(c, dti, node, prop, "Use 'stdout-path' instead"); | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | c->data = prop->name; | ||
| 1090 | check_is_string(c, dti, node); | ||
| 1091 | } | ||
| 1092 | WARNING(chosen_node_stdout_path, check_chosen_node_stdout_path, NULL); | ||
| 1093 | |||
| 959 | struct provider { | 1094 | struct provider { |
| 960 | const char *prop_name; | 1095 | const char *prop_name; |
| 961 | const char *cell_name; | 1096 | const char *cell_name; |
| @@ -972,8 +1107,9 @@ static void check_property_phandle_args(struct check *c, | |||
| 972 | int cell, cellsize = 0; | 1107 | int cell, cellsize = 0; |
| 973 | 1108 | ||
| 974 | if (prop->val.len % sizeof(cell_t)) { | 1109 | if (prop->val.len % sizeof(cell_t)) { |
| 975 | FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s", | 1110 | FAIL_PROP(c, dti, node, prop, |
| 976 | prop->name, prop->val.len, sizeof(cell_t), node->fullpath); | 1111 | "property size (%d) is invalid, expected multiple of %zu", |
| 1112 | prop->val.len, sizeof(cell_t)); | ||
| 977 | return; | 1113 | return; |
| 978 | } | 1114 | } |
| 979 | 1115 | ||
| @@ -1004,14 +1140,16 @@ static void check_property_phandle_args(struct check *c, | |||
| 1004 | break; | 1140 | break; |
| 1005 | } | 1141 | } |
| 1006 | if (!m) | 1142 | if (!m) |
| 1007 | FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s", | 1143 | FAIL_PROP(c, dti, node, prop, |
| 1008 | prop->name, cell, node->fullpath); | 1144 | "cell %d is not a phandle reference", |
| 1145 | cell); | ||
| 1009 | } | 1146 | } |
| 1010 | 1147 | ||
| 1011 | provider_node = get_node_by_phandle(root, phandle); | 1148 | provider_node = get_node_by_phandle(root, phandle); |
| 1012 | if (!provider_node) { | 1149 | if (!provider_node) { |
| 1013 | FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)", | 1150 | FAIL_PROP(c, dti, node, prop, |
| 1014 | node->fullpath, prop->name, cell); | 1151 | "Could not get phandle node for (cell %d)", |
| 1152 | cell); | ||
| 1015 | break; | 1153 | break; |
| 1016 | } | 1154 | } |
| 1017 | 1155 | ||
| @@ -1021,16 +1159,17 @@ static void check_property_phandle_args(struct check *c, | |||
| 1021 | } else if (provider->optional) { | 1159 | } else if (provider->optional) { |
| 1022 | cellsize = 0; | 1160 | cellsize = 0; |
| 1023 | } else { | 1161 | } else { |
| 1024 | FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])", | 1162 | FAIL(c, dti, node, "Missing property '%s' in node %s or bad phandle (referred from %s[%d])", |
| 1025 | provider->cell_name, | 1163 | provider->cell_name, |
| 1026 | provider_node->fullpath, | 1164 | provider_node->fullpath, |
| 1027 | node->fullpath, prop->name, cell); | 1165 | prop->name, cell); |
| 1028 | break; | 1166 | break; |
| 1029 | } | 1167 | } |
| 1030 | 1168 | ||
| 1031 | if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) { | 1169 | if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) { |
| 1032 | FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s", | 1170 | FAIL_PROP(c, dti, node, prop, |
| 1033 | prop->name, prop->val.len, cellsize, node->fullpath); | 1171 | "property size (%d) too small for cell size %d", |
| 1172 | prop->val.len, cellsize); | ||
| 1034 | } | 1173 | } |
| 1035 | } | 1174 | } |
| 1036 | } | 1175 | } |
| @@ -1066,7 +1205,7 @@ WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells"); | |||
| 1066 | WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells"); | 1205 | WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells"); |
| 1067 | WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells"); | 1206 | WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells"); |
| 1068 | WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells"); | 1207 | WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells"); |
| 1069 | WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells"); | 1208 | WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells"); |
| 1070 | WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells"); | 1209 | WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells"); |
| 1071 | 1210 | ||
| 1072 | static bool prop_is_gpio(struct property *prop) | 1211 | static bool prop_is_gpio(struct property *prop) |
| @@ -1132,8 +1271,8 @@ static void check_deprecated_gpio_property(struct check *c, | |||
| 1132 | if (!streq(str, "gpio")) | 1271 | if (!streq(str, "gpio")) |
| 1133 | continue; | 1272 | continue; |
| 1134 | 1273 | ||
| 1135 | FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s", | 1274 | FAIL_PROP(c, dti, node, prop, |
| 1136 | node->fullpath, prop->name); | 1275 | "'[*-]gpio' is deprecated, use '[*-]gpios' instead"); |
| 1137 | } | 1276 | } |
| 1138 | 1277 | ||
| 1139 | } | 1278 | } |
| @@ -1167,9 +1306,8 @@ static void check_interrupts_property(struct check *c, | |||
| 1167 | return; | 1306 | return; |
| 1168 | 1307 | ||
| 1169 | if (irq_prop->val.len % sizeof(cell_t)) | 1308 | if (irq_prop->val.len % sizeof(cell_t)) |
| 1170 | FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s", | 1309 | FAIL_PROP(c, dti, node, irq_prop, "size (%d) is invalid, expected multiple of %zu", |
| 1171 | irq_prop->name, irq_prop->val.len, sizeof(cell_t), | 1310 | irq_prop->val.len, sizeof(cell_t)); |
| 1172 | node->fullpath); | ||
| 1173 | 1311 | ||
| 1174 | while (parent && !prop) { | 1312 | while (parent && !prop) { |
| 1175 | if (parent != node && node_is_interrupt_provider(parent)) { | 1313 | if (parent != node && node_is_interrupt_provider(parent)) { |
| @@ -1187,14 +1325,12 @@ static void check_interrupts_property(struct check *c, | |||
| 1187 | 1325 | ||
| 1188 | irq_node = get_node_by_phandle(root, phandle); | 1326 | irq_node = get_node_by_phandle(root, phandle); |
| 1189 | if (!irq_node) { | 1327 | if (!irq_node) { |
| 1190 | FAIL(c, dti, "Bad interrupt-parent phandle for %s", | 1328 | FAIL_PROP(c, dti, parent, prop, "Bad phandle"); |
| 1191 | node->fullpath); | ||
| 1192 | return; | 1329 | return; |
| 1193 | } | 1330 | } |
| 1194 | if (!node_is_interrupt_provider(irq_node)) | 1331 | if (!node_is_interrupt_provider(irq_node)) |
| 1195 | FAIL(c, dti, | 1332 | FAIL(c, dti, irq_node, |
| 1196 | "Missing interrupt-controller or interrupt-map property in %s", | 1333 | "Missing interrupt-controller or interrupt-map property"); |
| 1197 | irq_node->fullpath); | ||
| 1198 | 1334 | ||
| 1199 | break; | 1335 | break; |
| 1200 | } | 1336 | } |
| @@ -1203,23 +1339,21 @@ static void check_interrupts_property(struct check *c, | |||
| 1203 | } | 1339 | } |
| 1204 | 1340 | ||
| 1205 | if (!irq_node) { | 1341 | if (!irq_node) { |
| 1206 | FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath); | 1342 | FAIL(c, dti, node, "Missing interrupt-parent"); |
| 1207 | return; | 1343 | return; |
| 1208 | } | 1344 | } |
| 1209 | 1345 | ||
| 1210 | prop = get_property(irq_node, "#interrupt-cells"); | 1346 | prop = get_property(irq_node, "#interrupt-cells"); |
| 1211 | if (!prop) { | 1347 | if (!prop) { |
| 1212 | FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s", | 1348 | FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent"); |
| 1213 | irq_node->fullpath); | ||
| 1214 | return; | 1349 | return; |
| 1215 | } | 1350 | } |
| 1216 | 1351 | ||
| 1217 | irq_cells = propval_cell(prop); | 1352 | irq_cells = propval_cell(prop); |
| 1218 | if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) { | 1353 | if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) { |
| 1219 | FAIL(c, dti, | 1354 | FAIL_PROP(c, dti, node, prop, |
| 1220 | "interrupts size is (%d), expected multiple of %d in %s", | 1355 | "size is (%d), expected multiple of %d", |
| 1221 | irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)), | 1356 | irq_prop->val.len, (int)(irq_cells * sizeof(cell_t))); |
| 1222 | node->fullpath); | ||
| 1223 | } | 1357 | } |
| 1224 | } | 1358 | } |
| 1225 | WARNING(interrupts_property, check_interrupts_property, &phandle_references); | 1359 | WARNING(interrupts_property, check_interrupts_property, &phandle_references); |
| @@ -1236,6 +1370,9 @@ static struct check *check_table[] = { | |||
| 1236 | 1370 | ||
| 1237 | &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, | 1371 | &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, |
| 1238 | &device_type_is_string, &model_is_string, &status_is_string, | 1372 | &device_type_is_string, &model_is_string, &status_is_string, |
| 1373 | &label_is_string, | ||
| 1374 | |||
| 1375 | &compatible_is_string_list, &names_is_string_list, | ||
| 1239 | 1376 | ||
| 1240 | &property_name_chars_strict, | 1377 | &property_name_chars_strict, |
| 1241 | &node_name_chars_strict, | 1378 | &node_name_chars_strict, |
| @@ -1253,7 +1390,9 @@ static struct check *check_table[] = { | |||
| 1253 | &simple_bus_reg, | 1390 | &simple_bus_reg, |
| 1254 | 1391 | ||
| 1255 | &avoid_default_addr_size, | 1392 | &avoid_default_addr_size, |
| 1393 | &avoid_unnecessary_addr_size, | ||
| 1256 | &obsolete_chosen_interrupt_controller, | 1394 | &obsolete_chosen_interrupt_controller, |
| 1395 | &chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path, | ||
| 1257 | 1396 | ||
| 1258 | &clocks_property, | 1397 | &clocks_property, |
| 1259 | &cooling_device_property, | 1398 | &cooling_device_property, |
| @@ -1269,13 +1408,15 @@ static struct check *check_table[] = { | |||
| 1269 | &power_domains_property, | 1408 | &power_domains_property, |
| 1270 | &pwms_property, | 1409 | &pwms_property, |
| 1271 | &resets_property, | 1410 | &resets_property, |
| 1272 | &sound_dais_property, | 1411 | &sound_dai_property, |
| 1273 | &thermal_sensors_property, | 1412 | &thermal_sensors_property, |
| 1274 | 1413 | ||
| 1275 | &deprecated_gpio_property, | 1414 | &deprecated_gpio_property, |
| 1276 | &gpios_property, | 1415 | &gpios_property, |
| 1277 | &interrupts_property, | 1416 | &interrupts_property, |
| 1278 | 1417 | ||
| 1418 | &alias_paths, | ||
| 1419 | |||
| 1279 | &always_fail, | 1420 | &always_fail, |
| 1280 | }; | 1421 | }; |
| 1281 | 1422 | ||
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped deleted file mode 100644 index 011bb9632ff2..000000000000 --- a/scripts/dtc/dtc-lexer.lex.c_shipped +++ /dev/null | |||
| @@ -1,2259 +0,0 @@ | |||
| 1 | #line 2 "dtc-lexer.lex.c" | ||
| 2 | |||
| 3 | #line 4 "dtc-lexer.lex.c" | ||
| 4 | |||
| 5 | #define YY_INT_ALIGNED short int | ||
| 6 | |||
| 7 | /* A lexical scanner generated by flex */ | ||
| 8 | |||
| 9 | #define FLEX_SCANNER | ||
| 10 | #define YY_FLEX_MAJOR_VERSION 2 | ||
| 11 | #define YY_FLEX_MINOR_VERSION 6 | ||
| 12 | #define YY_FLEX_SUBMINOR_VERSION 1 | ||
| 13 | #if YY_FLEX_SUBMINOR_VERSION > 0 | ||
| 14 | #define FLEX_BETA | ||
| 15 | #endif | ||
| 16 | |||
| 17 | /* First, we deal with platform-specific or compiler-specific issues. */ | ||
| 18 | |||
| 19 | /* begin standard C headers. */ | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <string.h> | ||
| 22 | #include <errno.h> | ||
| 23 | #include <stdlib.h> | ||
| 24 | |||
| 25 | /* end standard C headers. */ | ||
| 26 | |||
| 27 | /* flex integer type definitions */ | ||
| 28 | |||
| 29 | #ifndef FLEXINT_H | ||
| 30 | #define FLEXINT_H | ||
| 31 | |||
| 32 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ | ||
| 33 | |||
| 34 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
| 35 | |||
| 36 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, | ||
| 37 | * if you want the limit (max/min) macros for int types. | ||
| 38 | */ | ||
| 39 | #ifndef __STDC_LIMIT_MACROS | ||
| 40 | #define __STDC_LIMIT_MACROS 1 | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #include <inttypes.h> | ||
| 44 | typedef int8_t flex_int8_t; | ||
| 45 | typedef uint8_t flex_uint8_t; | ||
| 46 | typedef int16_t flex_int16_t; | ||
| 47 | typedef uint16_t flex_uint16_t; | ||
| 48 | typedef int32_t flex_int32_t; | ||
| 49 | typedef uint32_t flex_uint32_t; | ||
| 50 | #else | ||
| 51 | typedef signed char flex_int8_t; | ||
| 52 | typedef short int flex_int16_t; | ||
| 53 | typedef int flex_int32_t; | ||
| 54 | typedef unsigned char flex_uint8_t; | ||
| 55 | typedef unsigned short int flex_uint16_t; | ||
| 56 | typedef unsigned int flex_uint32_t; | ||
| 57 | |||
| 58 | /* Limits of integral types. */ | ||
| 59 | #ifndef INT8_MIN | ||
| 60 | #define INT8_MIN (-128) | ||
| 61 | #endif | ||
| 62 | #ifndef INT16_MIN | ||
| 63 | #define INT16_MIN (-32767-1) | ||
| 64 | #endif | ||
| 65 | #ifndef INT32_MIN | ||
| 66 | #define INT32_MIN (-2147483647-1) | ||
| 67 | #endif | ||
| 68 | #ifndef INT8_MAX | ||
| 69 | #define INT8_MAX (127) | ||
| 70 | #endif | ||
| 71 | #ifndef INT16_MAX | ||
| 72 | #define INT16_MAX (32767) | ||
| 73 | #endif | ||
| 74 | #ifndef INT32_MAX | ||
| 75 | #define INT32_MAX (2147483647) | ||
| 76 | #endif | ||
| 77 | #ifndef UINT8_MAX | ||
| 78 | #define UINT8_MAX (255U) | ||
| 79 | #endif | ||
| 80 | #ifndef UINT16_MAX | ||
| 81 | #define UINT16_MAX (65535U) | ||
| 82 | #endif | ||
| 83 | #ifndef UINT32_MAX | ||
| 84 | #define UINT32_MAX (4294967295U) | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #endif /* ! C99 */ | ||
| 88 | |||
| 89 | #endif /* ! FLEXINT_H */ | ||
| 90 | |||
| 91 | /* TODO: this is always defined, so inline it */ | ||
| 92 | #define yyconst const | ||
| 93 | |||
| 94 | #if defined(__GNUC__) && __GNUC__ >= 3 | ||
| 95 | #define yynoreturn __attribute__((__noreturn__)) | ||
| 96 | #else | ||
| 97 | #define yynoreturn | ||
| 98 | #endif | ||
| 99 | |||
| 100 | /* Returned upon end-of-file. */ | ||
| 101 | #define YY_NULL 0 | ||
| 102 | |||
| 103 | /* Promotes a possibly negative, possibly signed char to an unsigned | ||
| 104 | * integer for use as an array index. If the signed char is negative, | ||
| 105 | * we want to instead treat it as an 8-bit unsigned char, hence the | ||
| 106 | * double cast. | ||
| 107 | */ | ||
| 108 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | ||
| 109 | |||
| 110 | /* Enter a start condition. This macro really ought to take a parameter, | ||
| 111 | * but we do it the disgusting crufty way forced on us by the ()-less | ||
| 112 | * definition of BEGIN. | ||
| 113 | */ | ||
| 114 | #define BEGIN (yy_start) = 1 + 2 * | ||
| 115 | |||
| 116 | /* Translate the current start state into a value that can be later handed | ||
| 117 | * to BEGIN to return to the state. The YYSTATE alias is for lex | ||
| 118 | * compatibility. | ||
| 119 | */ | ||
| 120 | #define YY_START (((yy_start) - 1) / 2) | ||
| 121 | #define YYSTATE YY_START | ||
| 122 | |||
| 123 | /* Action number for EOF rule of a given start state. */ | ||
| 124 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | ||
| 125 | |||
| 126 | /* Special action meaning "start processing a new file". */ | ||
| 127 | #define YY_NEW_FILE yyrestart(yyin ) | ||
| 128 | |||
| 129 | #define YY_END_OF_BUFFER_CHAR 0 | ||
| 130 | |||
| 131 | /* Size of default input buffer. */ | ||
| 132 | #ifndef YY_BUF_SIZE | ||
| 133 | #ifdef __ia64__ | ||
| 134 | /* On IA-64, the buffer size is 16k, not 8k. | ||
| 135 | * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. | ||
| 136 | * Ditto for the __ia64__ case accordingly. | ||
| 137 | */ | ||
| 138 | #define YY_BUF_SIZE 32768 | ||
| 139 | #else | ||
| 140 | #define YY_BUF_SIZE 16384 | ||
| 141 | #endif /* __ia64__ */ | ||
| 142 | #endif | ||
| 143 | |||
| 144 | /* The state buf must be large enough to hold one state per character in the main buffer. | ||
| 145 | */ | ||
| 146 | #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) | ||
| 147 | |||
| 148 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE | ||
| 149 | #define YY_TYPEDEF_YY_BUFFER_STATE | ||
| 150 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
| 151 | #endif | ||
| 152 | |||
| 153 | #ifndef YY_TYPEDEF_YY_SIZE_T | ||
| 154 | #define YY_TYPEDEF_YY_SIZE_T | ||
| 155 | typedef size_t yy_size_t; | ||
| 156 | #endif | ||
| 157 | |||
| 158 | extern int yyleng; | ||
| 159 | |||
| 160 | extern FILE *yyin, *yyout; | ||
| 161 | |||
| 162 | #define EOB_ACT_CONTINUE_SCAN 0 | ||
| 163 | #define EOB_ACT_END_OF_FILE 1 | ||
| 164 | #define EOB_ACT_LAST_MATCH 2 | ||
| 165 | |||
| 166 | #define YY_LESS_LINENO(n) | ||
| 167 | #define YY_LINENO_REWIND_TO(ptr) | ||
| 168 | |||
| 169 | /* Return all but the first "n" matched characters back to the input stream. */ | ||
| 170 | #define yyless(n) \ | ||
| 171 | do \ | ||
| 172 | { \ | ||
| 173 | /* Undo effects of setting up yytext. */ \ | ||
| 174 | int yyless_macro_arg = (n); \ | ||
| 175 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
| 176 | *yy_cp = (yy_hold_char); \ | ||
| 177 | YY_RESTORE_YY_MORE_OFFSET \ | ||
| 178 | (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ | ||
| 179 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ | ||
| 180 | } \ | ||
| 181 | while ( 0 ) | ||
| 182 | |||
| 183 | #define unput(c) yyunput( c, (yytext_ptr) ) | ||
| 184 | |||
| 185 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
| 186 | #define YY_STRUCT_YY_BUFFER_STATE | ||
| 187 | struct yy_buffer_state | ||
| 188 | { | ||
| 189 | FILE *yy_input_file; | ||
| 190 | |||
| 191 | char *yy_ch_buf; /* input buffer */ | ||
| 192 | char *yy_buf_pos; /* current position in input buffer */ | ||
| 193 | |||
| 194 | /* Size of input buffer in bytes, not including room for EOB | ||
| 195 | * characters. | ||
| 196 | */ | ||
| 197 | int yy_buf_size; | ||
| 198 | |||
| 199 | /* Number of characters read into yy_ch_buf, not including EOB | ||
| 200 | * characters. | ||
| 201 | */ | ||
| 202 | int yy_n_chars; | ||
| 203 | |||
| 204 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
| 205 | * and can realloc() it to grow it, and should free() it to | ||
| 206 | * delete it. | ||
| 207 | */ | ||
| 208 | int yy_is_our_buffer; | ||
| 209 | |||
| 210 | /* Whether this is an "interactive" input source; if so, and | ||
| 211 | * if we're using stdio for input, then we want to use getc() | ||
| 212 | * instead of fread(), to make sure we stop fetching input after | ||
| 213 | * each newline. | ||
| 214 | */ | ||
| 215 | int yy_is_interactive; | ||
| 216 | |||
| 217 | /* Whether we're considered to be at the beginning of a line. | ||
| 218 | * If so, '^' rules will be active on the next match, otherwise | ||
| 219 | * not. | ||
| 220 | */ | ||
| 221 | int yy_at_bol; | ||
| 222 | |||
| 223 | int yy_bs_lineno; /**< The line count. */ | ||
| 224 | int yy_bs_column; /**< The column count. */ | ||
| 225 | |||
| 226 | /* Whether to try to fill the input buffer when we reach the | ||
| 227 | * end of it. | ||
| 228 | */ | ||
| 229 | int yy_fill_buffer; | ||
| 230 | |||
| 231 | int yy_buffer_status; | ||
| 232 | |||
| 233 | #define YY_BUFFER_NEW 0 | ||
| 234 | #define YY_BUFFER_NORMAL 1 | ||
| 235 | /* When an EOF's been seen but there's still some text to process | ||
| 236 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | ||
| 237 | * shouldn't try reading from the input source any more. We might | ||
| 238 | * still have a bunch of tokens to match, though, because of | ||
| 239 | * possible backing-up. | ||
| 240 | * | ||
| 241 | * When we actually see the EOF, we change the status to "new" | ||
| 242 | * (via yyrestart()), so that the user can continue scanning by | ||
| 243 | * just pointing yyin at a new input file. | ||
| 244 | */ | ||
| 245 | #define YY_BUFFER_EOF_PENDING 2 | ||
| 246 | |||
| 247 | }; | ||
| 248 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ | ||
| 249 | |||
| 250 | /* Stack of input buffers. */ | ||
| 251 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | ||
| 252 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | ||
| 253 | static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ | ||
| 254 | |||
| 255 | /* We provide macros for accessing buffer states in case in the | ||
| 256 | * future we want to put the buffer states in a more general | ||
| 257 | * "scanner state". | ||
| 258 | * | ||
| 259 | * Returns the top of the stack, or NULL. | ||
| 260 | */ | ||
| 261 | #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ | ||
| 262 | ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ | ||
| 263 | : NULL) | ||
| 264 | |||
| 265 | /* Same as previous macro, but useful when we know that the buffer stack is not | ||
| 266 | * NULL or when we need an lvalue. For internal use only. | ||
| 267 | */ | ||
| 268 | #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] | ||
| 269 | |||
| 270 | /* yy_hold_char holds the character lost when yytext is formed. */ | ||
| 271 | static char yy_hold_char; | ||
| 272 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
| 273 | int yyleng; | ||
| 274 | |||
| 275 | /* Points to current character in buffer. */ | ||
| 276 | static char *yy_c_buf_p = NULL; | ||
| 277 | static int yy_init = 0; /* whether we need to initialize */ | ||
| 278 | static int yy_start = 0; /* start state number */ | ||
| 279 | |||
| 280 | /* Flag which is used to allow yywrap()'s to do buffer switches | ||
| 281 | * instead of setting up a fresh yyin. A bit of a hack ... | ||
| 282 | */ | ||
| 283 | static int yy_did_buffer_switch_on_eof; | ||
| 284 | |||
| 285 | void yyrestart (FILE *input_file ); | ||
| 286 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
| 287 | YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); | ||
| 288 | void yy_delete_buffer (YY_BUFFER_STATE b ); | ||
| 289 | void yy_flush_buffer (YY_BUFFER_STATE b ); | ||
| 290 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
| 291 | void yypop_buffer_state (void ); | ||
| 292 | |||
| 293 | static void yyensure_buffer_stack (void ); | ||
| 294 | static void yy_load_buffer_state (void ); | ||
| 295 | static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); | ||
| 296 | |||
| 297 | #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) | ||
| 298 | |||
| 299 | YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); | ||
| 300 | YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); | ||
| 301 | YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); | ||
| 302 | |||
| 303 | void *yyalloc (yy_size_t ); | ||
| 304 | void *yyrealloc (void *,yy_size_t ); | ||
| 305 | void yyfree (void * ); | ||
| 306 | |||
| 307 | #define yy_new_buffer yy_create_buffer | ||
| 308 | |||
| 309 | #define yy_set_interactive(is_interactive) \ | ||
| 310 | { \ | ||
| 311 | if ( ! YY_CURRENT_BUFFER ){ \ | ||
| 312 | yyensure_buffer_stack (); \ | ||
| 313 | YY_CURRENT_BUFFER_LVALUE = \ | ||
| 314 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ | ||
| 315 | } \ | ||
| 316 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ | ||
| 317 | } | ||
| 318 | |||
| 319 | #define yy_set_bol(at_bol) \ | ||
| 320 | { \ | ||
| 321 | if ( ! YY_CURRENT_BUFFER ){\ | ||
| 322 | yyensure_buffer_stack (); \ | ||
| 323 | YY_CURRENT_BUFFER_LVALUE = \ | ||
| 324 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ | ||
| 325 | } \ | ||
| 326 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ | ||
| 327 | } | ||
| 328 | |||
| 329 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) | ||
| 330 | |||
| 331 | /* Begin user sect3 */ | ||
| 332 | |||
| 333 | #define yywrap() (/*CONSTCOND*/1) | ||
| 334 | #define YY_SKIP_YYWRAP | ||
| 335 | |||
| 336 | typedef unsigned char YY_CHAR; | ||
| 337 | |||
| 338 | FILE *yyin = NULL, *yyout = NULL; | ||
| 339 | |||
| 340 | typedef int yy_state_type; | ||
| 341 | |||
| 342 | extern int yylineno; | ||
| 343 | |||
| 344 | int yylineno = 1; | ||
| 345 | |||
| 346 | extern char *yytext; | ||
| 347 | #ifdef yytext_ptr | ||
| 348 | #undef yytext_ptr | ||
| 349 | #endif | ||
| 350 | #define yytext_ptr yytext | ||
| 351 | |||
| 352 | static yy_state_type yy_get_previous_state (void ); | ||
| 353 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | ||
| 354 | static int yy_get_next_buffer (void ); | ||
| 355 | static void yynoreturn yy_fatal_error (yyconst char* msg ); | ||
| 356 | |||
| 357 | /* Done after the current pattern has been matched and before the | ||
| 358 | * corresponding action - sets up yytext. | ||
| 359 | */ | ||
| 360 | #define YY_DO_BEFORE_ACTION \ | ||
| 361 | (yytext_ptr) = yy_bp; \ | ||
| 362 | yyleng = (int) (yy_cp - yy_bp); \ | ||
| 363 | (yy_hold_char) = *yy_cp; \ | ||
| 364 | *yy_cp = '\0'; \ | ||
| 365 | (yy_c_buf_p) = yy_cp; | ||
| 366 | |||
| 367 | #define YY_NUM_RULES 31 | ||
| 368 | #define YY_END_OF_BUFFER 32 | ||
| 369 | /* This struct is not used in this scanner, | ||
| 370 | but its presence is necessary. */ | ||
| 371 | struct yy_trans_info | ||
| 372 | { | ||
| 373 | flex_int32_t yy_verify; | ||
| 374 | flex_int32_t yy_nxt; | ||
| 375 | }; | ||
| 376 | static yyconst flex_int16_t yy_accept[166] = | ||
| 377 | { 0, | ||
| 378 | 0, 0, 0, 0, 0, 0, 0, 0, 32, 30, | ||
| 379 | 19, 19, 30, 30, 30, 30, 30, 30, 30, 30, | ||
| 380 | 30, 30, 30, 30, 30, 30, 16, 17, 17, 30, | ||
| 381 | 17, 11, 11, 19, 27, 0, 3, 0, 28, 13, | ||
| 382 | 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, | ||
| 383 | 0, 22, 24, 26, 25, 23, 0, 10, 29, 0, | ||
| 384 | 0, 0, 15, 15, 17, 17, 17, 11, 11, 11, | ||
| 385 | 0, 13, 0, 12, 0, 0, 0, 21, 0, 0, | ||
| 386 | 0, 0, 0, 0, 0, 0, 0, 17, 11, 11, | ||
| 387 | 11, 0, 14, 20, 0, 0, 0, 0, 0, 0, | ||
| 388 | |||
| 389 | 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, | ||
| 390 | 0, 0, 0, 0, 0, 17, 7, 0, 0, 0, | ||
| 391 | 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, | ||
| 392 | 0, 0, 0, 0, 4, 18, 0, 0, 5, 2, | ||
| 393 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 394 | 0, 0, 1, 0, 0, 0, 0, 6, 9, 0, | ||
| 395 | 0, 0, 0, 8, 0 | ||
| 396 | } ; | ||
| 397 | |||
| 398 | static yyconst YY_CHAR yy_ec[256] = | ||
| 399 | { 0, | ||
| 400 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | ||
| 401 | 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, | ||
| 402 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 403 | 1, 2, 5, 6, 7, 1, 1, 8, 9, 1, | ||
| 404 | 1, 10, 11, 11, 12, 11, 13, 14, 15, 16, | ||
| 405 | 16, 16, 16, 16, 16, 16, 16, 17, 1, 18, | ||
| 406 | 19, 20, 11, 11, 21, 21, 21, 21, 21, 21, | ||
| 407 | 22, 22, 22, 22, 22, 23, 22, 22, 22, 22, | ||
| 408 | 22, 22, 22, 22, 24, 22, 22, 25, 22, 22, | ||
| 409 | 1, 26, 27, 1, 22, 1, 21, 28, 29, 30, | ||
| 410 | |||
| 411 | 31, 21, 32, 22, 33, 22, 22, 34, 35, 36, | ||
| 412 | 37, 38, 22, 39, 40, 41, 42, 43, 22, 25, | ||
| 413 | 44, 22, 45, 46, 47, 1, 1, 1, 1, 1, | ||
| 414 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 415 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 416 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 417 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 418 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 419 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 420 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 421 | |||
| 422 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 423 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 424 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 425 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 426 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 427 | 1, 1, 1, 1, 1 | ||
| 428 | } ; | ||
| 429 | |||
| 430 | static yyconst YY_CHAR yy_meta[48] = | ||
| 431 | { 0, | ||
| 432 | 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, | ||
| 433 | 2, 2, 4, 5, 5, 5, 6, 1, 1, 1, | ||
| 434 | 7, 8, 8, 8, 8, 1, 1, 7, 7, 7, | ||
| 435 | 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, | ||
| 436 | 8, 8, 8, 8, 3, 1, 4 | ||
| 437 | } ; | ||
| 438 | |||
| 439 | static yyconst flex_uint16_t yy_base[180] = | ||
| 440 | { 0, | ||
| 441 | 0, 393, 35, 392, 66, 391, 38, 107, 397, 401, | ||
| 442 | 55, 113, 377, 112, 111, 111, 114, 42, 376, 106, | ||
| 443 | 377, 347, 126, 120, 0, 147, 401, 0, 124, 0, | ||
| 444 | 137, 158, 170, 163, 401, 153, 401, 389, 401, 0, | ||
| 445 | 378, 120, 401, 131, 380, 386, 355, 139, 351, 355, | ||
| 446 | 351, 401, 401, 401, 401, 401, 367, 401, 401, 185, | ||
| 447 | 350, 346, 401, 364, 0, 185, 347, 189, 356, 355, | ||
| 448 | 0, 0, 330, 180, 366, 141, 372, 361, 332, 338, | ||
| 449 | 331, 341, 334, 326, 205, 331, 337, 329, 401, 341, | ||
| 450 | 167, 316, 401, 349, 348, 320, 328, 346, 180, 318, | ||
| 451 | |||
| 452 | 324, 209, 324, 320, 322, 342, 338, 309, 306, 315, | ||
| 453 | 305, 315, 312, 192, 342, 341, 401, 293, 306, 282, | ||
| 454 | 268, 252, 255, 203, 285, 282, 272, 268, 252, 233, | ||
| 455 | 232, 239, 208, 107, 401, 401, 238, 211, 401, 211, | ||
| 456 | 212, 208, 228, 203, 215, 207, 233, 222, 212, 211, | ||
| 457 | 203, 227, 401, 237, 225, 204, 185, 401, 401, 149, | ||
| 458 | 128, 88, 42, 401, 401, 253, 259, 267, 271, 275, | ||
| 459 | 281, 288, 292, 300, 308, 312, 318, 326, 334 | ||
| 460 | } ; | ||
| 461 | |||
| 462 | static yyconst flex_int16_t yy_def[180] = | ||
| 463 | { 0, | ||
| 464 | 165, 1, 1, 3, 165, 5, 1, 1, 165, 165, | ||
| 465 | 165, 165, 165, 166, 167, 168, 165, 165, 165, 165, | ||
| 466 | 169, 165, 165, 165, 170, 169, 165, 171, 172, 171, | ||
| 467 | 171, 165, 165, 165, 165, 166, 165, 166, 165, 173, | ||
| 468 | 165, 168, 165, 168, 174, 175, 165, 165, 165, 165, | ||
| 469 | 165, 165, 165, 165, 165, 165, 169, 165, 165, 165, | ||
| 470 | 165, 165, 165, 169, 171, 172, 171, 165, 165, 165, | ||
| 471 | 176, 173, 177, 168, 174, 174, 175, 165, 165, 165, | ||
| 472 | 165, 165, 165, 165, 165, 165, 165, 171, 165, 165, | ||
| 473 | 176, 177, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 474 | |||
| 475 | 165, 165, 165, 165, 171, 165, 165, 165, 165, 165, | ||
| 476 | 165, 165, 165, 178, 165, 171, 165, 165, 165, 165, | ||
| 477 | 165, 165, 165, 178, 165, 178, 165, 165, 165, 165, | ||
| 478 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 479 | 165, 165, 165, 165, 165, 165, 165, 179, 165, 165, | ||
| 480 | 165, 179, 165, 179, 165, 165, 165, 165, 165, 165, | ||
| 481 | 165, 165, 165, 165, 0, 165, 165, 165, 165, 165, | ||
| 482 | 165, 165, 165, 165, 165, 165, 165, 165, 165 | ||
| 483 | } ; | ||
| 484 | |||
| 485 | static yyconst flex_uint16_t yy_nxt[449] = | ||
| 486 | { 0, | ||
| 487 | 10, 11, 12, 11, 13, 14, 10, 15, 16, 10, | ||
| 488 | 10, 10, 17, 10, 10, 10, 10, 18, 19, 20, | ||
| 489 | 21, 21, 21, 21, 21, 10, 10, 21, 21, 21, | ||
| 490 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, | ||
| 491 | 21, 21, 21, 21, 10, 22, 10, 24, 25, 25, | ||
| 492 | 25, 32, 33, 33, 164, 26, 34, 34, 34, 52, | ||
| 493 | 53, 27, 26, 26, 26, 26, 10, 11, 12, 11, | ||
| 494 | 13, 14, 28, 15, 16, 28, 28, 28, 24, 28, | ||
| 495 | 28, 28, 10, 18, 19, 20, 29, 29, 29, 29, | ||
| 496 | 29, 30, 10, 29, 29, 29, 29, 29, 29, 29, | ||
| 497 | |||
| 498 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, | ||
| 499 | 10, 22, 10, 23, 34, 34, 34, 37, 39, 43, | ||
| 500 | 32, 33, 33, 45, 55, 56, 46, 60, 43, 45, | ||
| 501 | 65, 163, 46, 65, 65, 65, 44, 38, 60, 74, | ||
| 502 | 58, 47, 141, 48, 142, 44, 49, 47, 50, 48, | ||
| 503 | 76, 51, 62, 94, 50, 41, 44, 51, 37, 61, | ||
| 504 | 64, 64, 64, 58, 34, 34, 34, 64, 162, 80, | ||
| 505 | 67, 68, 68, 68, 64, 64, 64, 64, 38, 81, | ||
| 506 | 69, 70, 71, 68, 68, 68, 60, 161, 43, 69, | ||
| 507 | 70, 65, 69, 70, 65, 65, 65, 125, 85, 85, | ||
| 508 | |||
| 509 | 85, 58, 68, 68, 68, 44, 102, 110, 125, 133, | ||
| 510 | 102, 69, 70, 111, 114, 160, 159, 126, 85, 85, | ||
| 511 | 85, 140, 140, 140, 140, 140, 140, 153, 126, 147, | ||
| 512 | 147, 147, 153, 148, 147, 147, 147, 158, 148, 165, | ||
| 513 | 157, 156, 155, 151, 150, 149, 146, 154, 145, 144, | ||
| 514 | 143, 139, 154, 36, 36, 36, 36, 36, 36, 36, | ||
| 515 | 36, 40, 138, 137, 136, 40, 40, 42, 42, 42, | ||
| 516 | 42, 42, 42, 42, 42, 57, 57, 57, 57, 63, | ||
| 517 | 135, 63, 65, 134, 165, 65, 133, 65, 65, 66, | ||
| 518 | 132, 131, 66, 66, 66, 66, 72, 130, 72, 72, | ||
| 519 | |||
| 520 | 75, 75, 75, 75, 75, 75, 75, 75, 77, 77, | ||
| 521 | 77, 77, 77, 77, 77, 77, 91, 129, 91, 92, | ||
| 522 | 128, 92, 92, 127, 92, 92, 124, 124, 124, 124, | ||
| 523 | 124, 124, 124, 124, 152, 152, 152, 152, 152, 152, | ||
| 524 | 152, 152, 60, 60, 123, 122, 121, 120, 119, 118, | ||
| 525 | 117, 45, 116, 111, 115, 113, 112, 109, 108, 107, | ||
| 526 | 46, 106, 93, 89, 105, 104, 103, 101, 100, 99, | ||
| 527 | 98, 97, 96, 95, 78, 76, 93, 90, 89, 88, | ||
| 528 | 58, 87, 86, 58, 84, 83, 82, 79, 78, 76, | ||
| 529 | 73, 165, 59, 58, 54, 35, 165, 31, 23, 23, | ||
| 530 | |||
| 531 | 9, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 532 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 533 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 534 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 535 | 165, 165, 165, 165, 165, 165, 165, 165 | ||
| 536 | } ; | ||
| 537 | |||
| 538 | static yyconst flex_int16_t yy_chk[449] = | ||
| 539 | { 0, | ||
| 540 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 541 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 542 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 543 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 544 | 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, | ||
| 545 | 3, 7, 7, 7, 163, 3, 11, 11, 11, 18, | ||
| 546 | 18, 3, 3, 3, 3, 3, 5, 5, 5, 5, | ||
| 547 | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
| 548 | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
| 549 | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
| 550 | |||
| 551 | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
| 552 | 5, 5, 5, 8, 12, 12, 12, 14, 15, 16, | ||
| 553 | 8, 8, 8, 17, 20, 20, 17, 23, 42, 24, | ||
| 554 | 29, 162, 24, 29, 29, 29, 16, 14, 31, 44, | ||
| 555 | 29, 17, 134, 17, 134, 42, 17, 24, 17, 24, | ||
| 556 | 76, 17, 24, 76, 24, 15, 44, 24, 36, 23, | ||
| 557 | 26, 26, 26, 26, 34, 34, 34, 26, 161, 48, | ||
| 558 | 31, 32, 32, 32, 26, 26, 26, 26, 36, 48, | ||
| 559 | 32, 32, 32, 33, 33, 33, 60, 160, 74, 91, | ||
| 560 | 91, 66, 33, 33, 66, 66, 66, 114, 60, 60, | ||
| 561 | |||
| 562 | 60, 66, 68, 68, 68, 74, 85, 99, 124, 133, | ||
| 563 | 102, 68, 68, 99, 102, 157, 156, 114, 85, 85, | ||
| 564 | 85, 133, 133, 133, 140, 140, 140, 148, 124, 143, | ||
| 565 | 143, 143, 152, 143, 147, 147, 147, 155, 147, 154, | ||
| 566 | 151, 150, 149, 146, 145, 144, 142, 148, 141, 138, | ||
| 567 | 137, 132, 152, 166, 166, 166, 166, 166, 166, 166, | ||
| 568 | 166, 167, 131, 130, 129, 167, 167, 168, 168, 168, | ||
| 569 | 168, 168, 168, 168, 168, 169, 169, 169, 169, 170, | ||
| 570 | 128, 170, 171, 127, 126, 171, 125, 171, 171, 172, | ||
| 571 | 123, 122, 172, 172, 172, 172, 173, 121, 173, 173, | ||
| 572 | |||
| 573 | 174, 174, 174, 174, 174, 174, 174, 174, 175, 175, | ||
| 574 | 175, 175, 175, 175, 175, 175, 176, 120, 176, 177, | ||
| 575 | 119, 177, 177, 118, 177, 177, 178, 178, 178, 178, | ||
| 576 | 178, 178, 178, 178, 179, 179, 179, 179, 179, 179, | ||
| 577 | 179, 179, 116, 115, 113, 112, 111, 110, 109, 108, | ||
| 578 | 107, 106, 105, 104, 103, 101, 100, 98, 97, 96, | ||
| 579 | 95, 94, 92, 90, 88, 87, 86, 84, 83, 82, | ||
| 580 | 81, 80, 79, 78, 77, 75, 73, 70, 69, 67, | ||
| 581 | 64, 62, 61, 57, 51, 50, 49, 47, 46, 45, | ||
| 582 | 41, 38, 22, 21, 19, 13, 9, 6, 4, 2, | ||
| 583 | |||
| 584 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 585 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 586 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 587 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, | ||
| 588 | 165, 165, 165, 165, 165, 165, 165, 165 | ||
| 589 | } ; | ||
| 590 | |||
| 591 | static yy_state_type yy_last_accepting_state; | ||
| 592 | static char *yy_last_accepting_cpos; | ||
| 593 | |||
| 594 | extern int yy_flex_debug; | ||
| 595 | int yy_flex_debug = 0; | ||
| 596 | |||
| 597 | /* The intent behind this definition is that it'll catch | ||
| 598 | * any uses of REJECT which flex missed. | ||
| 599 | */ | ||
| 600 | #define REJECT reject_used_but_not_detected | ||
| 601 | #define yymore() yymore_used_but_not_detected | ||
| 602 | #define YY_MORE_ADJ 0 | ||
| 603 | #define YY_RESTORE_YY_MORE_OFFSET | ||
| 604 | char *yytext; | ||
| 605 | #line 1 "dtc-lexer.l" | ||
| 606 | /* | ||
| 607 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. | ||
| 608 | * | ||
| 609 | * | ||
| 610 | * This program is free software; you can redistribute it and/or | ||
| 611 | * modify it under the terms of the GNU General Public License as | ||
| 612 | * published by the Free Software Foundation; either version 2 of the | ||
| 613 | * License, or (at your option) any later version. | ||
| 614 | * | ||
| 615 | * This program is distributed in the hope that it will be useful, | ||
| 616 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 617 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 618 | * General Public License for more details. | ||
| 619 | * | ||
| 620 | * You should have received a copy of the GNU General Public License | ||
| 621 | * along with this program; if not, write to the Free Software | ||
| 622 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
| 623 | * USA | ||
| 624 | */ | ||
| 625 | #define YY_NO_INPUT 1 | ||
| 626 | |||
| 627 | |||
| 628 | |||
| 629 | #line 37 "dtc-lexer.l" | ||
| 630 | #include "dtc.h" | ||
| 631 | #include "srcpos.h" | ||
| 632 | #include "dtc-parser.tab.h" | ||
| 633 | |||
| 634 | YYLTYPE yylloc; | ||
| 635 | extern bool treesource_error; | ||
| 636 | |||
| 637 | /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ | ||
| 638 | #define YY_USER_ACTION \ | ||
| 639 | { \ | ||
| 640 | srcpos_update(&yylloc, yytext, yyleng); \ | ||
| 641 | } | ||
| 642 | |||
| 643 | /*#define LEXDEBUG 1*/ | ||
| 644 | |||
| 645 | #ifdef LEXDEBUG | ||
| 646 | #define DPRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) | ||
| 647 | #else | ||
| 648 | #define DPRINT(fmt, ...) do { } while (0) | ||
| 649 | #endif | ||
| 650 | |||
| 651 | static int dts_version = 1; | ||
| 652 | |||
| 653 | #define BEGIN_DEFAULT() DPRINT("<V1>\n"); \ | ||
| 654 | BEGIN(V1); \ | ||
| 655 | |||
| 656 | static void push_input_file(const char *filename); | ||
| 657 | static bool pop_input_file(void); | ||
| 658 | static void PRINTF(1, 2) lexical_error(const char *fmt, ...); | ||
| 659 | |||
| 660 | #line 661 "dtc-lexer.lex.c" | ||
| 661 | |||
| 662 | #define INITIAL 0 | ||
| 663 | #define BYTESTRING 1 | ||
| 664 | #define PROPNODENAME 2 | ||
| 665 | #define V1 3 | ||
| 666 | |||
| 667 | #ifndef YY_NO_UNISTD_H | ||
| 668 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | ||
| 669 | * down here because we want the user's section 1 to have been scanned first. | ||
| 670 | * The user has a chance to override it with an option. | ||
| 671 | */ | ||
| 672 | #include <unistd.h> | ||
| 673 | #endif | ||
| 674 | |||
| 675 | #ifndef YY_EXTRA_TYPE | ||
| 676 | #define YY_EXTRA_TYPE void * | ||
| 677 | #endif | ||
| 678 | |||
| 679 | static int yy_init_globals (void ); | ||
| 680 | |||
| 681 | /* Accessor methods to globals. | ||
| 682 | These are made visible to non-reentrant scanners for convenience. */ | ||
| 683 | |||
| 684 | int yylex_destroy (void ); | ||
| 685 | |||
| 686 | int yyget_debug (void ); | ||
| 687 | |||
| 688 | void yyset_debug (int debug_flag ); | ||
| 689 | |||
| 690 | YY_EXTRA_TYPE yyget_extra (void ); | ||
| 691 | |||
| 692 | void yyset_extra (YY_EXTRA_TYPE user_defined ); | ||
| 693 | |||
| 694 | FILE *yyget_in (void ); | ||
| 695 | |||
| 696 | void yyset_in (FILE * _in_str ); | ||
| 697 | |||
| 698 | FILE *yyget_out (void ); | ||
| 699 | |||
| 700 | void yyset_out (FILE * _out_str ); | ||
| 701 | |||
| 702 | int yyget_leng (void ); | ||
| 703 | |||
| 704 | char *yyget_text (void ); | ||
| 705 | |||
| 706 | int yyget_lineno (void ); | ||
| 707 | |||
| 708 | void yyset_lineno (int _line_number ); | ||
| 709 | |||
| 710 | /* Macros after this point can all be overridden by user definitions in | ||
| 711 | * section 1. | ||
| 712 | */ | ||
| 713 | |||
| 714 | #ifndef YY_SKIP_YYWRAP | ||
| 715 | #ifdef __cplusplus | ||
| 716 | extern "C" int yywrap (void ); | ||
| 717 | #else | ||
| 718 | extern int yywrap (void ); | ||
| 719 | #endif | ||
| 720 | #endif | ||
| 721 | |||
| 722 | #ifndef YY_NO_UNPUT | ||
| 723 | |||
| 724 | #endif | ||
| 725 | |||
| 726 | #ifndef yytext_ptr | ||
| 727 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
| 728 | #endif | ||
| 729 | |||
| 730 | #ifdef YY_NEED_STRLEN | ||
| 731 | static int yy_flex_strlen (yyconst char * ); | ||
| 732 | #endif | ||
| 733 | |||
| 734 | #ifndef YY_NO_INPUT | ||
| 735 | |||
| 736 | #ifdef __cplusplus | ||
| 737 | static int yyinput (void ); | ||
| 738 | #else | ||
| 739 | static int input (void ); | ||
| 740 | #endif | ||
| 741 | |||
| 742 | #endif | ||
| 743 | |||
| 744 | /* Amount of stuff to slurp up with each read. */ | ||
| 745 | #ifndef YY_READ_BUF_SIZE | ||
| 746 | #ifdef __ia64__ | ||
| 747 | /* On IA-64, the buffer size is 16k, not 8k */ | ||
| 748 | #define YY_READ_BUF_SIZE 16384 | ||
| 749 | #else | ||
| 750 | #define YY_READ_BUF_SIZE 8192 | ||
| 751 | #endif /* __ia64__ */ | ||
| 752 | #endif | ||
| 753 | |||
| 754 | /* Copy whatever the last rule matched to the standard output. */ | ||
| 755 | #ifndef ECHO | ||
| 756 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
| 757 | * we now use fwrite(). | ||
| 758 | */ | ||
| 759 | #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) | ||
| 760 | #endif | ||
| 761 | |||
| 762 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
| 763 | * is returned in "result". | ||
| 764 | */ | ||
| 765 | #ifndef YY_INPUT | ||
| 766 | #define YY_INPUT(buf,result,max_size) \ | ||
| 767 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | ||
| 768 | { \ | ||
| 769 | int c = '*'; \ | ||
| 770 | size_t n; \ | ||
| 771 | for ( n = 0; n < max_size && \ | ||
| 772 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ | ||
| 773 | buf[n] = (char) c; \ | ||
| 774 | if ( c == '\n' ) \ | ||
| 775 | buf[n++] = (char) c; \ | ||
| 776 | if ( c == EOF && ferror( yyin ) ) \ | ||
| 777 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
| 778 | result = n; \ | ||
| 779 | } \ | ||
| 780 | else \ | ||
| 781 | { \ | ||
| 782 | errno=0; \ | ||
| 783 | while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ | ||
| 784 | { \ | ||
| 785 | if( errno != EINTR) \ | ||
| 786 | { \ | ||
| 787 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
| 788 | break; \ | ||
| 789 | } \ | ||
| 790 | errno=0; \ | ||
| 791 | clearerr(yyin); \ | ||
| 792 | } \ | ||
| 793 | }\ | ||
| 794 | \ | ||
| 795 | |||
| 796 | #endif | ||
| 797 | |||
| 798 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
| 799 | * we don't want an extra ';' after the "return" because that will cause | ||
| 800 | * some compilers to complain about unreachable statements. | ||
| 801 | */ | ||
| 802 | #ifndef yyterminate | ||
| 803 | #define yyterminate() return YY_NULL | ||
| 804 | #endif | ||
| 805 | |||
| 806 | /* Number of entries by which start-condition stack grows. */ | ||
| 807 | #ifndef YY_START_STACK_INCR | ||
| 808 | #define YY_START_STACK_INCR 25 | ||
| 809 | #endif | ||
| 810 | |||
| 811 | /* Report a fatal error. */ | ||
| 812 | #ifndef YY_FATAL_ERROR | ||
| 813 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
| 814 | #endif | ||
| 815 | |||
| 816 | /* end tables serialization structures and prototypes */ | ||
| 817 | |||
| 818 | /* Default declaration of generated scanner - a define so the user can | ||
| 819 | * easily add parameters. | ||
| 820 | */ | ||
| 821 | #ifndef YY_DECL | ||
| 822 | #define YY_DECL_IS_OURS 1 | ||
| 823 | |||
| 824 | extern int yylex (void); | ||
| 825 | |||
| 826 | #define YY_DECL int yylex (void) | ||
| 827 | #endif /* !YY_DECL */ | ||
| 828 | |||
| 829 | /* Code executed at the beginning of each rule, after yytext and yyleng | ||
| 830 | * have been set up. | ||
| 831 | */ | ||
| 832 | #ifndef YY_USER_ACTION | ||
| 833 | #define YY_USER_ACTION | ||
| 834 | #endif | ||
| 835 | |||
| 836 | /* Code executed at the end of each rule. */ | ||
| 837 | #ifndef YY_BREAK | ||
| 838 | #define YY_BREAK /*LINTED*/break; | ||
| 839 | #endif | ||
| 840 | |||
| 841 | #define YY_RULE_SETUP \ | ||
| 842 | if ( yyleng > 0 ) \ | ||
| 843 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ | ||
| 844 | (yytext[yyleng - 1] == '\n'); \ | ||
| 845 | YY_USER_ACTION | ||
| 846 | |||
| 847 | /** The main scanner function which does all the work. | ||
| 848 | */ | ||
| 849 | YY_DECL | ||
| 850 | { | ||
| 851 | yy_state_type yy_current_state; | ||
| 852 | char *yy_cp, *yy_bp; | ||
| 853 | int yy_act; | ||
| 854 | |||
| 855 | if ( !(yy_init) ) | ||
| 856 | { | ||
| 857 | (yy_init) = 1; | ||
| 858 | |||
| 859 | #ifdef YY_USER_INIT | ||
| 860 | YY_USER_INIT; | ||
| 861 | #endif | ||
| 862 | |||
| 863 | if ( ! (yy_start) ) | ||
| 864 | (yy_start) = 1; /* first start state */ | ||
| 865 | |||
| 866 | if ( ! yyin ) | ||
| 867 | yyin = stdin; | ||
| 868 | |||
| 869 | if ( ! yyout ) | ||
| 870 | yyout = stdout; | ||
| 871 | |||
| 872 | if ( ! YY_CURRENT_BUFFER ) { | ||
| 873 | yyensure_buffer_stack (); | ||
| 874 | YY_CURRENT_BUFFER_LVALUE = | ||
| 875 | yy_create_buffer(yyin,YY_BUF_SIZE ); | ||
| 876 | } | ||
| 877 | |||
| 878 | yy_load_buffer_state( ); | ||
| 879 | } | ||
| 880 | |||
| 881 | { | ||
| 882 | #line 69 "dtc-lexer.l" | ||
| 883 | |||
| 884 | #line 885 "dtc-lexer.lex.c" | ||
| 885 | |||
| 886 | while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ | ||
| 887 | { | ||
| 888 | yy_cp = (yy_c_buf_p); | ||
| 889 | |||
| 890 | /* Support of yytext. */ | ||
| 891 | *yy_cp = (yy_hold_char); | ||
| 892 | |||
| 893 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
| 894 | * the current run. | ||
| 895 | */ | ||
| 896 | yy_bp = yy_cp; | ||
| 897 | |||
| 898 | yy_current_state = (yy_start); | ||
| 899 | yy_current_state += YY_AT_BOL(); | ||
| 900 | yy_match: | ||
| 901 | do | ||
| 902 | { | ||
| 903 | YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; | ||
| 904 | if ( yy_accept[yy_current_state] ) | ||
| 905 | { | ||
| 906 | (yy_last_accepting_state) = yy_current_state; | ||
| 907 | (yy_last_accepting_cpos) = yy_cp; | ||
| 908 | } | ||
| 909 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 910 | { | ||
| 911 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 912 | if ( yy_current_state >= 166 ) | ||
| 913 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 914 | } | ||
| 915 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; | ||
| 916 | ++yy_cp; | ||
| 917 | } | ||
| 918 | while ( yy_current_state != 165 ); | ||
| 919 | yy_cp = (yy_last_accepting_cpos); | ||
| 920 | yy_current_state = (yy_last_accepting_state); | ||
| 921 | |||
| 922 | yy_find_action: | ||
| 923 | yy_act = yy_accept[yy_current_state]; | ||
| 924 | |||
| 925 | YY_DO_BEFORE_ACTION; | ||
| 926 | |||
| 927 | do_action: /* This label is used only to access EOF actions. */ | ||
| 928 | |||
| 929 | switch ( yy_act ) | ||
| 930 | { /* beginning of action switch */ | ||
| 931 | case 0: /* must back up */ | ||
| 932 | /* undo the effects of YY_DO_BEFORE_ACTION */ | ||
| 933 | *yy_cp = (yy_hold_char); | ||
| 934 | yy_cp = (yy_last_accepting_cpos); | ||
| 935 | yy_current_state = (yy_last_accepting_state); | ||
| 936 | goto yy_find_action; | ||
| 937 | |||
| 938 | case 1: | ||
| 939 | /* rule 1 can match eol */ | ||
| 940 | YY_RULE_SETUP | ||
| 941 | #line 70 "dtc-lexer.l" | ||
| 942 | { | ||
| 943 | char *name = strchr(yytext, '\"') + 1; | ||
| 944 | yytext[yyleng-1] = '\0'; | ||
| 945 | push_input_file(name); | ||
| 946 | } | ||
| 947 | YY_BREAK | ||
| 948 | case 2: | ||
| 949 | /* rule 2 can match eol */ | ||
| 950 | YY_RULE_SETUP | ||
| 951 | #line 76 "dtc-lexer.l" | ||
| 952 | { | ||
| 953 | char *line, *fnstart, *fnend; | ||
| 954 | struct data fn; | ||
| 955 | /* skip text before line # */ | ||
| 956 | line = yytext; | ||
| 957 | while (!isdigit((unsigned char)*line)) | ||
| 958 | line++; | ||
| 959 | |||
| 960 | /* regexp ensures that first and list " | ||
| 961 | * in the whole yytext are those at | ||
| 962 | * beginning and end of the filename string */ | ||
| 963 | fnstart = memchr(yytext, '"', yyleng); | ||
| 964 | for (fnend = yytext + yyleng - 1; | ||
| 965 | *fnend != '"'; fnend--) | ||
| 966 | ; | ||
| 967 | assert(fnstart && fnend && (fnend > fnstart)); | ||
| 968 | |||
| 969 | fn = data_copy_escape_string(fnstart + 1, | ||
| 970 | fnend - fnstart - 1); | ||
| 971 | |||
| 972 | /* Don't allow nuls in filenames */ | ||
| 973 | if (memchr(fn.val, '\0', fn.len - 1)) | ||
| 974 | lexical_error("nul in line number directive"); | ||
| 975 | |||
| 976 | /* -1 since #line is the number of the next line */ | ||
| 977 | srcpos_set_line(xstrdup(fn.val), atoi(line) - 1); | ||
| 978 | data_free(fn); | ||
| 979 | } | ||
| 980 | YY_BREAK | ||
| 981 | case YY_STATE_EOF(INITIAL): | ||
| 982 | case YY_STATE_EOF(BYTESTRING): | ||
| 983 | case YY_STATE_EOF(PROPNODENAME): | ||
| 984 | case YY_STATE_EOF(V1): | ||
| 985 | #line 105 "dtc-lexer.l" | ||
| 986 | { | ||
| 987 | if (!pop_input_file()) { | ||
| 988 | yyterminate(); | ||
| 989 | } | ||
| 990 | } | ||
| 991 | YY_BREAK | ||
| 992 | case 3: | ||
| 993 | /* rule 3 can match eol */ | ||
| 994 | YY_RULE_SETUP | ||
| 995 | #line 111 "dtc-lexer.l" | ||
| 996 | { | ||
| 997 | DPRINT("String: %s\n", yytext); | ||
| 998 | yylval.data = data_copy_escape_string(yytext+1, | ||
| 999 | yyleng-2); | ||
| 1000 | return DT_STRING; | ||
| 1001 | } | ||
| 1002 | YY_BREAK | ||
| 1003 | case 4: | ||
| 1004 | YY_RULE_SETUP | ||
| 1005 | #line 118 "dtc-lexer.l" | ||
| 1006 | { | ||
| 1007 | DPRINT("Keyword: /dts-v1/\n"); | ||
| 1008 | dts_version = 1; | ||
| 1009 | BEGIN_DEFAULT(); | ||
| 1010 | return DT_V1; | ||
| 1011 | } | ||
| 1012 | YY_BREAK | ||
| 1013 | case 5: | ||
| 1014 | YY_RULE_SETUP | ||
| 1015 | #line 125 "dtc-lexer.l" | ||
| 1016 | { | ||
| 1017 | DPRINT("Keyword: /plugin/\n"); | ||
| 1018 | return DT_PLUGIN; | ||
| 1019 | } | ||
| 1020 | YY_BREAK | ||
| 1021 | case 6: | ||
| 1022 | YY_RULE_SETUP | ||
| 1023 | #line 130 "dtc-lexer.l" | ||
| 1024 | { | ||
| 1025 | DPRINT("Keyword: /memreserve/\n"); | ||
| 1026 | BEGIN_DEFAULT(); | ||
| 1027 | return DT_MEMRESERVE; | ||
| 1028 | } | ||
| 1029 | YY_BREAK | ||
| 1030 | case 7: | ||
| 1031 | YY_RULE_SETUP | ||
| 1032 | #line 136 "dtc-lexer.l" | ||
| 1033 | { | ||
| 1034 | DPRINT("Keyword: /bits/\n"); | ||
| 1035 | BEGIN_DEFAULT(); | ||
| 1036 | return DT_BITS; | ||
| 1037 | } | ||
| 1038 | YY_BREAK | ||
| 1039 | case 8: | ||
| 1040 | YY_RULE_SETUP | ||
| 1041 | #line 142 "dtc-lexer.l" | ||
| 1042 | { | ||
| 1043 | DPRINT("Keyword: /delete-property/\n"); | ||
| 1044 | DPRINT("<PROPNODENAME>\n"); | ||
| 1045 | BEGIN(PROPNODENAME); | ||
| 1046 | return DT_DEL_PROP; | ||
| 1047 | } | ||
| 1048 | YY_BREAK | ||
| 1049 | case 9: | ||
| 1050 | YY_RULE_SETUP | ||
| 1051 | #line 149 "dtc-lexer.l" | ||
| 1052 | { | ||
| 1053 | DPRINT("Keyword: /delete-node/\n"); | ||
| 1054 | DPRINT("<PROPNODENAME>\n"); | ||
| 1055 | BEGIN(PROPNODENAME); | ||
| 1056 | return DT_DEL_NODE; | ||
| 1057 | } | ||
| 1058 | YY_BREAK | ||
| 1059 | case 10: | ||
| 1060 | YY_RULE_SETUP | ||
| 1061 | #line 156 "dtc-lexer.l" | ||
| 1062 | { | ||
| 1063 | DPRINT("Label: %s\n", yytext); | ||
| 1064 | yylval.labelref = xstrdup(yytext); | ||
| 1065 | yylval.labelref[yyleng-1] = '\0'; | ||
| 1066 | return DT_LABEL; | ||
| 1067 | } | ||
| 1068 | YY_BREAK | ||
| 1069 | case 11: | ||
| 1070 | YY_RULE_SETUP | ||
| 1071 | #line 163 "dtc-lexer.l" | ||
| 1072 | { | ||
| 1073 | char *e; | ||
| 1074 | DPRINT("Integer Literal: '%s'\n", yytext); | ||
| 1075 | |||
| 1076 | errno = 0; | ||
| 1077 | yylval.integer = strtoull(yytext, &e, 0); | ||
| 1078 | |||
| 1079 | if (*e && e[strspn(e, "UL")]) { | ||
| 1080 | lexical_error("Bad integer literal '%s'", | ||
| 1081 | yytext); | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | if (errno == ERANGE) | ||
| 1085 | lexical_error("Integer literal '%s' out of range", | ||
| 1086 | yytext); | ||
| 1087 | else | ||
| 1088 | /* ERANGE is the only strtoull error triggerable | ||
| 1089 | * by strings matching the pattern */ | ||
| 1090 | assert(errno == 0); | ||
| 1091 | return DT_LITERAL; | ||
| 1092 | } | ||
| 1093 | YY_BREAK | ||
| 1094 | case 12: | ||
| 1095 | /* rule 12 can match eol */ | ||
| 1096 | YY_RULE_SETUP | ||
| 1097 | #line 185 "dtc-lexer.l" | ||
| 1098 | { | ||
| 1099 | struct data d; | ||
| 1100 | DPRINT("Character literal: %s\n", yytext); | ||
| 1101 | |||
| 1102 | d = data_copy_escape_string(yytext+1, yyleng-2); | ||
| 1103 | if (d.len == 1) { | ||
| 1104 | lexical_error("Empty character literal"); | ||
| 1105 | yylval.integer = 0; | ||
| 1106 | } else { | ||
| 1107 | yylval.integer = (unsigned char)d.val[0]; | ||
| 1108 | |||
| 1109 | if (d.len > 2) | ||
| 1110 | lexical_error("Character literal has %d" | ||
| 1111 | " characters instead of 1", | ||
| 1112 | d.len - 1); | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | data_free(d); | ||
| 1116 | return DT_CHAR_LITERAL; | ||
| 1117 | } | ||
| 1118 | YY_BREAK | ||
| 1119 | case 13: | ||
| 1120 | YY_RULE_SETUP | ||
| 1121 | #line 206 "dtc-lexer.l" | ||
| 1122 | { /* label reference */ | ||
| 1123 | DPRINT("Ref: %s\n", yytext+1); | ||
| 1124 | yylval.labelref = xstrdup(yytext+1); | ||
| 1125 | return DT_REF; | ||
| 1126 | } | ||
| 1127 | YY_BREAK | ||
| 1128 | case 14: | ||
| 1129 | YY_RULE_SETUP | ||
| 1130 | #line 212 "dtc-lexer.l" | ||
| 1131 | { /* new-style path reference */ | ||
| 1132 | yytext[yyleng-1] = '\0'; | ||
| 1133 | DPRINT("Ref: %s\n", yytext+2); | ||
| 1134 | yylval.labelref = xstrdup(yytext+2); | ||
| 1135 | return DT_REF; | ||
| 1136 | } | ||
| 1137 | YY_BREAK | ||
| 1138 | case 15: | ||
| 1139 | YY_RULE_SETUP | ||
| 1140 | #line 219 "dtc-lexer.l" | ||
| 1141 | { | ||
| 1142 | yylval.byte = strtol(yytext, NULL, 16); | ||
| 1143 | DPRINT("Byte: %02x\n", (int)yylval.byte); | ||
| 1144 | return DT_BYTE; | ||
| 1145 | } | ||
| 1146 | YY_BREAK | ||
| 1147 | case 16: | ||
| 1148 | YY_RULE_SETUP | ||
| 1149 | #line 225 "dtc-lexer.l" | ||
| 1150 | { | ||
| 1151 | DPRINT("/BYTESTRING\n"); | ||
| 1152 | BEGIN_DEFAULT(); | ||
| 1153 | return ']'; | ||
| 1154 | } | ||
| 1155 | YY_BREAK | ||
| 1156 | case 17: | ||
| 1157 | YY_RULE_SETUP | ||
| 1158 | #line 231 "dtc-lexer.l" | ||
| 1159 | { | ||
| 1160 | DPRINT("PropNodeName: %s\n", yytext); | ||
| 1161 | yylval.propnodename = xstrdup((yytext[0] == '\\') ? | ||
| 1162 | yytext + 1 : yytext); | ||
| 1163 | BEGIN_DEFAULT(); | ||
| 1164 | return DT_PROPNODENAME; | ||
| 1165 | } | ||
| 1166 | YY_BREAK | ||
| 1167 | case 18: | ||
| 1168 | YY_RULE_SETUP | ||
| 1169 | #line 239 "dtc-lexer.l" | ||
| 1170 | { | ||
| 1171 | DPRINT("Binary Include\n"); | ||
| 1172 | return DT_INCBIN; | ||
| 1173 | } | ||
| 1174 | YY_BREAK | ||
| 1175 | case 19: | ||
| 1176 | /* rule 19 can match eol */ | ||
| 1177 | YY_RULE_SETUP | ||
| 1178 | #line 244 "dtc-lexer.l" | ||
| 1179 | /* eat whitespace */ | ||
| 1180 | YY_BREAK | ||
| 1181 | case 20: | ||
| 1182 | /* rule 20 can match eol */ | ||
| 1183 | YY_RULE_SETUP | ||
| 1184 | #line 245 "dtc-lexer.l" | ||
| 1185 | /* eat C-style comments */ | ||
| 1186 | YY_BREAK | ||
| 1187 | case 21: | ||
| 1188 | /* rule 21 can match eol */ | ||
| 1189 | YY_RULE_SETUP | ||
| 1190 | #line 246 "dtc-lexer.l" | ||
| 1191 | /* eat C++-style comments */ | ||
| 1192 | YY_BREAK | ||
| 1193 | case 22: | ||
| 1194 | YY_RULE_SETUP | ||
| 1195 | #line 248 "dtc-lexer.l" | ||
| 1196 | { return DT_LSHIFT; }; | ||
| 1197 | YY_BREAK | ||
| 1198 | case 23: | ||
| 1199 | YY_RULE_SETUP | ||
| 1200 | #line 249 "dtc-lexer.l" | ||
| 1201 | { return DT_RSHIFT; }; | ||
| 1202 | YY_BREAK | ||
| 1203 | case 24: | ||
| 1204 | YY_RULE_SETUP | ||
| 1205 | #line 250 "dtc-lexer.l" | ||
| 1206 | { return DT_LE; }; | ||
| 1207 | YY_BREAK | ||
| 1208 | case 25: | ||
| 1209 | YY_RULE_SETUP | ||
| 1210 | #line 251 "dtc-lexer.l" | ||
| 1211 | { return DT_GE; }; | ||
| 1212 | YY_BREAK | ||
| 1213 | case 26: | ||
| 1214 | YY_RULE_SETUP | ||
| 1215 | #line 252 "dtc-lexer.l" | ||
| 1216 | { return DT_EQ; }; | ||
| 1217 | YY_BREAK | ||
| 1218 | case 27: | ||
| 1219 | YY_RULE_SETUP | ||
| 1220 | #line 253 "dtc-lexer.l" | ||
| 1221 | { return DT_NE; }; | ||
| 1222 | YY_BREAK | ||
| 1223 | case 28: | ||
| 1224 | YY_RULE_SETUP | ||
| 1225 | #line 254 "dtc-lexer.l" | ||
| 1226 | { return DT_AND; }; | ||
| 1227 | YY_BREAK | ||
| 1228 | case 29: | ||
| 1229 | YY_RULE_SETUP | ||
| 1230 | #line 255 "dtc-lexer.l" | ||
| 1231 | { return DT_OR; }; | ||
| 1232 | YY_BREAK | ||
| 1233 | case 30: | ||
| 1234 | YY_RULE_SETUP | ||
| 1235 | #line 257 "dtc-lexer.l" | ||
| 1236 | { | ||
| 1237 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], | ||
| 1238 | (unsigned)yytext[0]); | ||
| 1239 | if (yytext[0] == '[') { | ||
| 1240 | DPRINT("<BYTESTRING>\n"); | ||
| 1241 | BEGIN(BYTESTRING); | ||
| 1242 | } | ||
| 1243 | if ((yytext[0] == '{') | ||
| 1244 | || (yytext[0] == ';')) { | ||
| 1245 | DPRINT("<PROPNODENAME>\n"); | ||
| 1246 | BEGIN(PROPNODENAME); | ||
| 1247 | } | ||
| 1248 | return yytext[0]; | ||
| 1249 | } | ||
| 1250 | YY_BREAK | ||
| 1251 | case 31: | ||
| 1252 | YY_RULE_SETUP | ||
| 1253 | #line 272 "dtc-lexer.l" | ||
| 1254 | ECHO; | ||
| 1255 | YY_BREAK | ||
| 1256 | #line 1257 "dtc-lexer.lex.c" | ||
| 1257 | |||
| 1258 | case YY_END_OF_BUFFER: | ||
| 1259 | { | ||
| 1260 | /* Amount of text matched not including the EOB char. */ | ||
| 1261 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | ||
| 1262 | |||
| 1263 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
| 1264 | *yy_cp = (yy_hold_char); | ||
| 1265 | YY_RESTORE_YY_MORE_OFFSET | ||
| 1266 | |||
| 1267 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | ||
| 1268 | { | ||
| 1269 | /* We're scanning a new file or input source. It's | ||
| 1270 | * possible that this happened because the user | ||
| 1271 | * just pointed yyin at a new source and called | ||
| 1272 | * yylex(). If so, then we have to assure | ||
| 1273 | * consistency between YY_CURRENT_BUFFER and our | ||
| 1274 | * globals. Here is the right place to do so, because | ||
| 1275 | * this is the first action (other than possibly a | ||
| 1276 | * back-up) that will match for the new input source. | ||
| 1277 | */ | ||
| 1278 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
| 1279 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; | ||
| 1280 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | ||
| 1281 | } | ||
| 1282 | |||
| 1283 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
| 1284 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
| 1285 | * already have been incremented past the NUL character | ||
| 1286 | * (since all states make transitions on EOB to the | ||
| 1287 | * end-of-buffer state). Contrast this with the test | ||
| 1288 | * in input(). | ||
| 1289 | */ | ||
| 1290 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
| 1291 | { /* This was really a NUL. */ | ||
| 1292 | yy_state_type yy_next_state; | ||
| 1293 | |||
| 1294 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | ||
| 1295 | |||
| 1296 | yy_current_state = yy_get_previous_state( ); | ||
| 1297 | |||
| 1298 | /* Okay, we're now positioned to make the NUL | ||
| 1299 | * transition. We couldn't have | ||
| 1300 | * yy_get_previous_state() go ahead and do it | ||
| 1301 | * for us because it doesn't know how to deal | ||
| 1302 | * with the possibility of jamming (and we don't | ||
| 1303 | * want to build jamming into it because then it | ||
| 1304 | * will run more slowly). | ||
| 1305 | */ | ||
| 1306 | |||
| 1307 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
| 1308 | |||
| 1309 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1310 | |||
| 1311 | if ( yy_next_state ) | ||
| 1312 | { | ||
| 1313 | /* Consume the NUL. */ | ||
| 1314 | yy_cp = ++(yy_c_buf_p); | ||
| 1315 | yy_current_state = yy_next_state; | ||
| 1316 | goto yy_match; | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | else | ||
| 1320 | { | ||
| 1321 | yy_cp = (yy_last_accepting_cpos); | ||
| 1322 | yy_current_state = (yy_last_accepting_state); | ||
| 1323 | goto yy_find_action; | ||
| 1324 | } | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | else switch ( yy_get_next_buffer( ) ) | ||
| 1328 | { | ||
| 1329 | case EOB_ACT_END_OF_FILE: | ||
| 1330 | { | ||
| 1331 | (yy_did_buffer_switch_on_eof) = 0; | ||
| 1332 | |||
| 1333 | if ( yywrap( ) ) | ||
| 1334 | { | ||
| 1335 | /* Note: because we've taken care in | ||
| 1336 | * yy_get_next_buffer() to have set up | ||
| 1337 | * yytext, we can now set up | ||
| 1338 | * yy_c_buf_p so that if some total | ||
| 1339 | * hoser (like flex itself) wants to | ||
| 1340 | * call the scanner after we return the | ||
| 1341 | * YY_NULL, it'll still work - another | ||
| 1342 | * YY_NULL will get returned. | ||
| 1343 | */ | ||
| 1344 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1345 | |||
| 1346 | yy_act = YY_STATE_EOF(YY_START); | ||
| 1347 | goto do_action; | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | else | ||
| 1351 | { | ||
| 1352 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
| 1353 | YY_NEW_FILE; | ||
| 1354 | } | ||
| 1355 | break; | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | case EOB_ACT_CONTINUE_SCAN: | ||
| 1359 | (yy_c_buf_p) = | ||
| 1360 | (yytext_ptr) + yy_amount_of_matched_text; | ||
| 1361 | |||
| 1362 | yy_current_state = yy_get_previous_state( ); | ||
| 1363 | |||
| 1364 | yy_cp = (yy_c_buf_p); | ||
| 1365 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1366 | goto yy_match; | ||
| 1367 | |||
| 1368 | case EOB_ACT_LAST_MATCH: | ||
| 1369 | (yy_c_buf_p) = | ||
| 1370 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | ||
| 1371 | |||
| 1372 | yy_current_state = yy_get_previous_state( ); | ||
| 1373 | |||
| 1374 | yy_cp = (yy_c_buf_p); | ||
| 1375 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1376 | goto yy_find_action; | ||
| 1377 | } | ||
| 1378 | break; | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | default: | ||
| 1382 | YY_FATAL_ERROR( | ||
| 1383 | "fatal flex scanner internal error--no action found" ); | ||
| 1384 | } /* end of action switch */ | ||
| 1385 | } /* end of scanning one token */ | ||
| 1386 | } /* end of user's declarations */ | ||
| 1387 | } /* end of yylex */ | ||
| 1388 | |||
| 1389 | /* yy_get_next_buffer - try to read in a new buffer | ||
| 1390 | * | ||
| 1391 | * Returns a code representing an action: | ||
| 1392 | * EOB_ACT_LAST_MATCH - | ||
| 1393 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
| 1394 | * EOB_ACT_END_OF_FILE - end of file | ||
| 1395 | */ | ||
| 1396 | static int yy_get_next_buffer (void) | ||
| 1397 | { | ||
| 1398 | char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | ||
| 1399 | char *source = (yytext_ptr); | ||
| 1400 | int number_to_move, i; | ||
| 1401 | int ret_val; | ||
| 1402 | |||
| 1403 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | ||
| 1404 | YY_FATAL_ERROR( | ||
| 1405 | "fatal flex scanner internal error--end of buffer missed" ); | ||
| 1406 | |||
| 1407 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | ||
| 1408 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
| 1409 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | ||
| 1410 | { | ||
| 1411 | /* We matched a single character, the EOB, so | ||
| 1412 | * treat this as a final EOF. | ||
| 1413 | */ | ||
| 1414 | return EOB_ACT_END_OF_FILE; | ||
| 1415 | } | ||
| 1416 | |||
| 1417 | else | ||
| 1418 | { | ||
| 1419 | /* We matched some text prior to the EOB, first | ||
| 1420 | * process it. | ||
| 1421 | */ | ||
| 1422 | return EOB_ACT_LAST_MATCH; | ||
| 1423 | } | ||
| 1424 | } | ||
| 1425 | |||
| 1426 | /* Try to read more data. */ | ||
| 1427 | |||
| 1428 | /* First move last chars to start of buffer. */ | ||
| 1429 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); | ||
| 1430 | |||
| 1431 | for ( i = 0; i < number_to_move; ++i ) | ||
| 1432 | *(dest++) = *(source++); | ||
| 1433 | |||
| 1434 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
| 1435 | /* don't do the read, it's not guaranteed to return an EOF, | ||
| 1436 | * just force an EOF | ||
| 1437 | */ | ||
| 1438 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | ||
| 1439 | |||
| 1440 | else | ||
| 1441 | { | ||
| 1442 | int num_to_read = | ||
| 1443 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | ||
| 1444 | |||
| 1445 | while ( num_to_read <= 0 ) | ||
| 1446 | { /* Not enough room in the buffer - grow it. */ | ||
| 1447 | |||
| 1448 | /* just a shorter name for the current buffer */ | ||
| 1449 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; | ||
| 1450 | |||
| 1451 | int yy_c_buf_p_offset = | ||
| 1452 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | ||
| 1453 | |||
| 1454 | if ( b->yy_is_our_buffer ) | ||
| 1455 | { | ||
| 1456 | int new_size = b->yy_buf_size * 2; | ||
| 1457 | |||
| 1458 | if ( new_size <= 0 ) | ||
| 1459 | b->yy_buf_size += b->yy_buf_size / 8; | ||
| 1460 | else | ||
| 1461 | b->yy_buf_size *= 2; | ||
| 1462 | |||
| 1463 | b->yy_ch_buf = (char *) | ||
| 1464 | /* Include room in for 2 EOB chars. */ | ||
| 1465 | yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | ||
| 1466 | } | ||
| 1467 | else | ||
| 1468 | /* Can't grow it, we don't own it. */ | ||
| 1469 | b->yy_ch_buf = NULL; | ||
| 1470 | |||
| 1471 | if ( ! b->yy_ch_buf ) | ||
| 1472 | YY_FATAL_ERROR( | ||
| 1473 | "fatal error - scanner input buffer overflow" ); | ||
| 1474 | |||
| 1475 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
| 1476 | |||
| 1477 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | ||
| 1478 | number_to_move - 1; | ||
| 1479 | |||
| 1480 | } | ||
| 1481 | |||
| 1482 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
| 1483 | num_to_read = YY_READ_BUF_SIZE; | ||
| 1484 | |||
| 1485 | /* Read in more data. */ | ||
| 1486 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | ||
| 1487 | (yy_n_chars), num_to_read ); | ||
| 1488 | |||
| 1489 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1490 | } | ||
| 1491 | |||
| 1492 | if ( (yy_n_chars) == 0 ) | ||
| 1493 | { | ||
| 1494 | if ( number_to_move == YY_MORE_ADJ ) | ||
| 1495 | { | ||
| 1496 | ret_val = EOB_ACT_END_OF_FILE; | ||
| 1497 | yyrestart(yyin ); | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | else | ||
| 1501 | { | ||
| 1502 | ret_val = EOB_ACT_LAST_MATCH; | ||
| 1503 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | ||
| 1504 | YY_BUFFER_EOF_PENDING; | ||
| 1505 | } | ||
| 1506 | } | ||
| 1507 | |||
| 1508 | else | ||
| 1509 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
| 1510 | |||
| 1511 | if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { | ||
| 1512 | /* Extend the array by 50%, plus the number we really need. */ | ||
| 1513 | int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); | ||
| 1514 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); | ||
| 1515 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
| 1516 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | (yy_n_chars) += number_to_move; | ||
| 1520 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | ||
| 1521 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | ||
| 1522 | |||
| 1523 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | ||
| 1524 | |||
| 1525 | return ret_val; | ||
| 1526 | } | ||
| 1527 | |||
| 1528 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
| 1529 | |||
| 1530 | static yy_state_type yy_get_previous_state (void) | ||
| 1531 | { | ||
| 1532 | yy_state_type yy_current_state; | ||
| 1533 | char *yy_cp; | ||
| 1534 | |||
| 1535 | yy_current_state = (yy_start); | ||
| 1536 | yy_current_state += YY_AT_BOL(); | ||
| 1537 | |||
| 1538 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | ||
| 1539 | { | ||
| 1540 | YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | ||
| 1541 | if ( yy_accept[yy_current_state] ) | ||
| 1542 | { | ||
| 1543 | (yy_last_accepting_state) = yy_current_state; | ||
| 1544 | (yy_last_accepting_cpos) = yy_cp; | ||
| 1545 | } | ||
| 1546 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1547 | { | ||
| 1548 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1549 | if ( yy_current_state >= 166 ) | ||
| 1550 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1551 | } | ||
| 1552 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | return yy_current_state; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
| 1559 | * | ||
| 1560 | * synopsis | ||
| 1561 | * next_state = yy_try_NUL_trans( current_state ); | ||
| 1562 | */ | ||
| 1563 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | ||
| 1564 | { | ||
| 1565 | int yy_is_jam; | ||
| 1566 | char *yy_cp = (yy_c_buf_p); | ||
| 1567 | |||
| 1568 | YY_CHAR yy_c = 1; | ||
| 1569 | if ( yy_accept[yy_current_state] ) | ||
| 1570 | { | ||
| 1571 | (yy_last_accepting_state) = yy_current_state; | ||
| 1572 | (yy_last_accepting_cpos) = yy_cp; | ||
| 1573 | } | ||
| 1574 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1575 | { | ||
| 1576 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1577 | if ( yy_current_state >= 166 ) | ||
| 1578 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1579 | } | ||
| 1580 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; | ||
| 1581 | yy_is_jam = (yy_current_state == 165); | ||
| 1582 | |||
| 1583 | return yy_is_jam ? 0 : yy_current_state; | ||
| 1584 | } | ||
| 1585 | |||
| 1586 | #ifndef YY_NO_UNPUT | ||
| 1587 | |||
| 1588 | #endif | ||
| 1589 | |||
| 1590 | #ifndef YY_NO_INPUT | ||
| 1591 | #ifdef __cplusplus | ||
| 1592 | static int yyinput (void) | ||
| 1593 | #else | ||
| 1594 | static int input (void) | ||
| 1595 | #endif | ||
| 1596 | |||
| 1597 | { | ||
| 1598 | int c; | ||
| 1599 | |||
| 1600 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1601 | |||
| 1602 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | ||
| 1603 | { | ||
| 1604 | /* yy_c_buf_p now points to the character we want to return. | ||
| 1605 | * If this occurs *before* the EOB characters, then it's a | ||
| 1606 | * valid NUL; if not, then we've hit the end of the buffer. | ||
| 1607 | */ | ||
| 1608 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
| 1609 | /* This was really a NUL. */ | ||
| 1610 | *(yy_c_buf_p) = '\0'; | ||
| 1611 | |||
| 1612 | else | ||
| 1613 | { /* need more input */ | ||
| 1614 | int offset = (yy_c_buf_p) - (yytext_ptr); | ||
| 1615 | ++(yy_c_buf_p); | ||
| 1616 | |||
| 1617 | switch ( yy_get_next_buffer( ) ) | ||
| 1618 | { | ||
| 1619 | case EOB_ACT_LAST_MATCH: | ||
| 1620 | /* This happens because yy_g_n_b() | ||
| 1621 | * sees that we've accumulated a | ||
| 1622 | * token and flags that we need to | ||
| 1623 | * try matching the token before | ||
| 1624 | * proceeding. But for input(), | ||
| 1625 | * there's no matching to consider. | ||
| 1626 | * So convert the EOB_ACT_LAST_MATCH | ||
| 1627 | * to EOB_ACT_END_OF_FILE. | ||
| 1628 | */ | ||
| 1629 | |||
| 1630 | /* Reset buffer status. */ | ||
| 1631 | yyrestart(yyin ); | ||
| 1632 | |||
| 1633 | /*FALLTHROUGH*/ | ||
| 1634 | |||
| 1635 | case EOB_ACT_END_OF_FILE: | ||
| 1636 | { | ||
| 1637 | if ( yywrap( ) ) | ||
| 1638 | return 0; | ||
| 1639 | |||
| 1640 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
| 1641 | YY_NEW_FILE; | ||
| 1642 | #ifdef __cplusplus | ||
| 1643 | return yyinput(); | ||
| 1644 | #else | ||
| 1645 | return input(); | ||
| 1646 | #endif | ||
| 1647 | } | ||
| 1648 | |||
| 1649 | case EOB_ACT_CONTINUE_SCAN: | ||
| 1650 | (yy_c_buf_p) = (yytext_ptr) + offset; | ||
| 1651 | break; | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | } | ||
| 1655 | |||
| 1656 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | ||
| 1657 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ | ||
| 1658 | (yy_hold_char) = *++(yy_c_buf_p); | ||
| 1659 | |||
| 1660 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); | ||
| 1661 | |||
| 1662 | return c; | ||
| 1663 | } | ||
| 1664 | #endif /* ifndef YY_NO_INPUT */ | ||
| 1665 | |||
| 1666 | /** Immediately switch to a different input stream. | ||
| 1667 | * @param input_file A readable stream. | ||
| 1668 | * | ||
| 1669 | * @note This function does not reset the start condition to @c INITIAL . | ||
| 1670 | */ | ||
| 1671 | void yyrestart (FILE * input_file ) | ||
| 1672 | { | ||
| 1673 | |||
| 1674 | if ( ! YY_CURRENT_BUFFER ){ | ||
| 1675 | yyensure_buffer_stack (); | ||
| 1676 | YY_CURRENT_BUFFER_LVALUE = | ||
| 1677 | yy_create_buffer(yyin,YY_BUF_SIZE ); | ||
| 1678 | } | ||
| 1679 | |||
| 1680 | yy_init_buffer(YY_CURRENT_BUFFER,input_file ); | ||
| 1681 | yy_load_buffer_state( ); | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | /** Switch to a different input buffer. | ||
| 1685 | * @param new_buffer The new input buffer. | ||
| 1686 | * | ||
| 1687 | */ | ||
| 1688 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) | ||
| 1689 | { | ||
| 1690 | |||
| 1691 | /* TODO. We should be able to replace this entire function body | ||
| 1692 | * with | ||
| 1693 | * yypop_buffer_state(); | ||
| 1694 | * yypush_buffer_state(new_buffer); | ||
| 1695 | */ | ||
| 1696 | yyensure_buffer_stack (); | ||
| 1697 | if ( YY_CURRENT_BUFFER == new_buffer ) | ||
| 1698 | return; | ||
| 1699 | |||
| 1700 | if ( YY_CURRENT_BUFFER ) | ||
| 1701 | { | ||
| 1702 | /* Flush out information for old buffer. */ | ||
| 1703 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1704 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
| 1705 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
| 1709 | yy_load_buffer_state( ); | ||
| 1710 | |||
| 1711 | /* We don't actually know whether we did this switch during | ||
| 1712 | * EOF (yywrap()) processing, but the only time this flag | ||
| 1713 | * is looked at is after yywrap() is called, so it's safe | ||
| 1714 | * to go ahead and always set it. | ||
| 1715 | */ | ||
| 1716 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1717 | } | ||
| 1718 | |||
| 1719 | static void yy_load_buffer_state (void) | ||
| 1720 | { | ||
| 1721 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
| 1722 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | ||
| 1723 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | ||
| 1724 | (yy_hold_char) = *(yy_c_buf_p); | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | /** Allocate and initialize an input buffer state. | ||
| 1728 | * @param file A readable stream. | ||
| 1729 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | ||
| 1730 | * | ||
| 1731 | * @return the allocated buffer state. | ||
| 1732 | */ | ||
| 1733 | YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) | ||
| 1734 | { | ||
| 1735 | YY_BUFFER_STATE b; | ||
| 1736 | |||
| 1737 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); | ||
| 1738 | if ( ! b ) | ||
| 1739 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1740 | |||
| 1741 | b->yy_buf_size = (yy_size_t)size; | ||
| 1742 | |||
| 1743 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
| 1744 | * we need to put in 2 end-of-buffer characters. | ||
| 1745 | */ | ||
| 1746 | b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); | ||
| 1747 | if ( ! b->yy_ch_buf ) | ||
| 1748 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1749 | |||
| 1750 | b->yy_is_our_buffer = 1; | ||
| 1751 | |||
| 1752 | yy_init_buffer(b,file ); | ||
| 1753 | |||
| 1754 | return b; | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | /** Destroy the buffer. | ||
| 1758 | * @param b a buffer created with yy_create_buffer() | ||
| 1759 | * | ||
| 1760 | */ | ||
| 1761 | void yy_delete_buffer (YY_BUFFER_STATE b ) | ||
| 1762 | { | ||
| 1763 | |||
| 1764 | if ( ! b ) | ||
| 1765 | return; | ||
| 1766 | |||
| 1767 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | ||
| 1768 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | ||
| 1769 | |||
| 1770 | if ( b->yy_is_our_buffer ) | ||
| 1771 | yyfree((void *) b->yy_ch_buf ); | ||
| 1772 | |||
| 1773 | yyfree((void *) b ); | ||
| 1774 | } | ||
| 1775 | |||
| 1776 | /* Initializes or reinitializes a buffer. | ||
| 1777 | * This function is sometimes called more than once on the same buffer, | ||
| 1778 | * such as during a yyrestart() or at EOF. | ||
| 1779 | */ | ||
| 1780 | static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) | ||
| 1781 | |||
| 1782 | { | ||
| 1783 | int oerrno = errno; | ||
| 1784 | |||
| 1785 | yy_flush_buffer(b ); | ||
| 1786 | |||
| 1787 | b->yy_input_file = file; | ||
| 1788 | b->yy_fill_buffer = 1; | ||
| 1789 | |||
| 1790 | /* If b is the current buffer, then yy_init_buffer was _probably_ | ||
| 1791 | * called from yyrestart() or through yy_get_next_buffer. | ||
| 1792 | * In that case, we don't want to reset the lineno or column. | ||
| 1793 | */ | ||
| 1794 | if (b != YY_CURRENT_BUFFER){ | ||
| 1795 | b->yy_bs_lineno = 1; | ||
| 1796 | b->yy_bs_column = 0; | ||
| 1797 | } | ||
| 1798 | |||
| 1799 | b->yy_is_interactive = 0; | ||
| 1800 | |||
| 1801 | errno = oerrno; | ||
| 1802 | } | ||
| 1803 | |||
| 1804 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | ||
| 1805 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | ||
| 1806 | * | ||
| 1807 | */ | ||
| 1808 | void yy_flush_buffer (YY_BUFFER_STATE b ) | ||
| 1809 | { | ||
| 1810 | if ( ! b ) | ||
| 1811 | return; | ||
| 1812 | |||
| 1813 | b->yy_n_chars = 0; | ||
| 1814 | |||
| 1815 | /* We always need two end-of-buffer characters. The first causes | ||
| 1816 | * a transition to the end-of-buffer state. The second causes | ||
| 1817 | * a jam in that state. | ||
| 1818 | */ | ||
| 1819 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
| 1820 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
| 1821 | |||
| 1822 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
| 1823 | |||
| 1824 | b->yy_at_bol = 1; | ||
| 1825 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1826 | |||
| 1827 | if ( b == YY_CURRENT_BUFFER ) | ||
| 1828 | yy_load_buffer_state( ); | ||
| 1829 | } | ||
| 1830 | |||
| 1831 | /** Pushes the new state onto the stack. The new state becomes | ||
| 1832 | * the current state. This function will allocate the stack | ||
| 1833 | * if necessary. | ||
| 1834 | * @param new_buffer The new state. | ||
| 1835 | * | ||
| 1836 | */ | ||
| 1837 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) | ||
| 1838 | { | ||
| 1839 | if (new_buffer == NULL) | ||
| 1840 | return; | ||
| 1841 | |||
| 1842 | yyensure_buffer_stack(); | ||
| 1843 | |||
| 1844 | /* This block is copied from yy_switch_to_buffer. */ | ||
| 1845 | if ( YY_CURRENT_BUFFER ) | ||
| 1846 | { | ||
| 1847 | /* Flush out information for old buffer. */ | ||
| 1848 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1849 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
| 1850 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1851 | } | ||
| 1852 | |||
| 1853 | /* Only push if top exists. Otherwise, replace top. */ | ||
| 1854 | if (YY_CURRENT_BUFFER) | ||
| 1855 | (yy_buffer_stack_top)++; | ||
| 1856 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
| 1857 | |||
| 1858 | /* copied from yy_switch_to_buffer. */ | ||
| 1859 | yy_load_buffer_state( ); | ||
| 1860 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1861 | } | ||
| 1862 | |||
| 1863 | /** Removes and deletes the top of the stack, if present. | ||
| 1864 | * The next element becomes the new top. | ||
| 1865 | * | ||
| 1866 | */ | ||
| 1867 | void yypop_buffer_state (void) | ||
| 1868 | { | ||
| 1869 | if (!YY_CURRENT_BUFFER) | ||
| 1870 | return; | ||
| 1871 | |||
| 1872 | yy_delete_buffer(YY_CURRENT_BUFFER ); | ||
| 1873 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
| 1874 | if ((yy_buffer_stack_top) > 0) | ||
| 1875 | --(yy_buffer_stack_top); | ||
| 1876 | |||
| 1877 | if (YY_CURRENT_BUFFER) { | ||
| 1878 | yy_load_buffer_state( ); | ||
| 1879 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1880 | } | ||
| 1881 | } | ||
| 1882 | |||
| 1883 | /* Allocates the stack if it does not exist. | ||
| 1884 | * Guarantees space for at least one push. | ||
| 1885 | */ | ||
| 1886 | static void yyensure_buffer_stack (void) | ||
| 1887 | { | ||
| 1888 | int num_to_alloc; | ||
| 1889 | |||
| 1890 | if (!(yy_buffer_stack)) { | ||
| 1891 | |||
| 1892 | /* First allocation is just for 2 elements, since we don't know if this | ||
| 1893 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | ||
| 1894 | * immediate realloc on the next call. | ||
| 1895 | */ | ||
| 1896 | num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ | ||
| 1897 | (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc | ||
| 1898 | (num_to_alloc * sizeof(struct yy_buffer_state*) | ||
| 1899 | ); | ||
| 1900 | if ( ! (yy_buffer_stack) ) | ||
| 1901 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); | ||
| 1902 | |||
| 1903 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | ||
| 1904 | |||
| 1905 | (yy_buffer_stack_max) = num_to_alloc; | ||
| 1906 | (yy_buffer_stack_top) = 0; | ||
| 1907 | return; | ||
| 1908 | } | ||
| 1909 | |||
| 1910 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | ||
| 1911 | |||
| 1912 | /* Increase the buffer to prepare for a possible push. */ | ||
| 1913 | yy_size_t grow_size = 8 /* arbitrary grow size */; | ||
| 1914 | |||
| 1915 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | ||
| 1916 | (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc | ||
| 1917 | ((yy_buffer_stack), | ||
| 1918 | num_to_alloc * sizeof(struct yy_buffer_state*) | ||
| 1919 | ); | ||
| 1920 | if ( ! (yy_buffer_stack) ) | ||
| 1921 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); | ||
| 1922 | |||
| 1923 | /* zero only the new slots.*/ | ||
| 1924 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | ||
| 1925 | (yy_buffer_stack_max) = num_to_alloc; | ||
| 1926 | } | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | ||
| 1930 | * @param base the character buffer | ||
| 1931 | * @param size the size in bytes of the character buffer | ||
| 1932 | * | ||
| 1933 | * @return the newly allocated buffer state object. | ||
| 1934 | */ | ||
| 1935 | YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) | ||
| 1936 | { | ||
| 1937 | YY_BUFFER_STATE b; | ||
| 1938 | |||
| 1939 | if ( size < 2 || | ||
| 1940 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
| 1941 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
| 1942 | /* They forgot to leave room for the EOB's. */ | ||
| 1943 | return NULL; | ||
| 1944 | |||
| 1945 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); | ||
| 1946 | if ( ! b ) | ||
| 1947 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); | ||
| 1948 | |||
| 1949 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
| 1950 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
| 1951 | b->yy_is_our_buffer = 0; | ||
| 1952 | b->yy_input_file = NULL; | ||
| 1953 | b->yy_n_chars = b->yy_buf_size; | ||
| 1954 | b->yy_is_interactive = 0; | ||
| 1955 | b->yy_at_bol = 1; | ||
| 1956 | b->yy_fill_buffer = 0; | ||
| 1957 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1958 | |||
| 1959 | yy_switch_to_buffer(b ); | ||
| 1960 | |||
| 1961 | return b; | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | /** Setup the input buffer state to scan a string. The next call to yylex() will | ||
| 1965 | * scan from a @e copy of @a str. | ||
| 1966 | * @param yystr a NUL-terminated string to scan | ||
| 1967 | * | ||
| 1968 | * @return the newly allocated buffer state object. | ||
| 1969 | * @note If you want to scan bytes that may contain NUL values, then use | ||
| 1970 | * yy_scan_bytes() instead. | ||
| 1971 | */ | ||
| 1972 | YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) | ||
| 1973 | { | ||
| 1974 | |||
| 1975 | return yy_scan_bytes(yystr,(int) strlen(yystr) ); | ||
| 1976 | } | ||
| 1977 | |||
| 1978 | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will | ||
| 1979 | * scan from a @e copy of @a bytes. | ||
| 1980 | * @param yybytes the byte buffer to scan | ||
| 1981 | * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. | ||
| 1982 | * | ||
| 1983 | * @return the newly allocated buffer state object. | ||
| 1984 | */ | ||
| 1985 | YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) | ||
| 1986 | { | ||
| 1987 | YY_BUFFER_STATE b; | ||
| 1988 | char *buf; | ||
| 1989 | yy_size_t n; | ||
| 1990 | int i; | ||
| 1991 | |||
| 1992 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
| 1993 | n = (yy_size_t) (_yybytes_len + 2); | ||
| 1994 | buf = (char *) yyalloc(n ); | ||
| 1995 | if ( ! buf ) | ||
| 1996 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); | ||
| 1997 | |||
| 1998 | for ( i = 0; i < _yybytes_len; ++i ) | ||
| 1999 | buf[i] = yybytes[i]; | ||
| 2000 | |||
| 2001 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; | ||
| 2002 | |||
| 2003 | b = yy_scan_buffer(buf,n ); | ||
| 2004 | if ( ! b ) | ||
| 2005 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); | ||
| 2006 | |||
| 2007 | /* It's okay to grow etc. this buffer, and we should throw it | ||
| 2008 | * away when we're done. | ||
| 2009 | */ | ||
| 2010 | b->yy_is_our_buffer = 1; | ||
| 2011 | |||
| 2012 | return b; | ||
| 2013 | } | ||
| 2014 | |||
| 2015 | #ifndef YY_EXIT_FAILURE | ||
| 2016 | #define YY_EXIT_FAILURE 2 | ||
| 2017 | #endif | ||
| 2018 | |||
| 2019 | static void yynoreturn yy_fatal_error (yyconst char* msg ) | ||
| 2020 | { | ||
| 2021 | (void) fprintf( stderr, "%s\n", msg ); | ||
| 2022 | exit( YY_EXIT_FAILURE ); | ||
| 2023 | } | ||
| 2024 | |||
| 2025 | /* Redefine yyless() so it works in section 3 code. */ | ||
| 2026 | |||
| 2027 | #undef yyless | ||
| 2028 | #define yyless(n) \ | ||
| 2029 | do \ | ||
| 2030 | { \ | ||
| 2031 | /* Undo effects of setting up yytext. */ \ | ||
| 2032 | int yyless_macro_arg = (n); \ | ||
| 2033 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
| 2034 | yytext[yyleng] = (yy_hold_char); \ | ||
| 2035 | (yy_c_buf_p) = yytext + yyless_macro_arg; \ | ||
| 2036 | (yy_hold_char) = *(yy_c_buf_p); \ | ||
| 2037 | *(yy_c_buf_p) = '\0'; \ | ||
| 2038 | yyleng = yyless_macro_arg; \ | ||
| 2039 | } \ | ||
| 2040 | while ( 0 ) | ||
| 2041 | |||
| 2042 | /* Accessor methods (get/set functions) to struct members. */ | ||
| 2043 | |||
| 2044 | /** Get the current line number. | ||
| 2045 | * | ||
| 2046 | */ | ||
| 2047 | int yyget_lineno (void) | ||
| 2048 | { | ||
| 2049 | |||
| 2050 | return yylineno; | ||
| 2051 | } | ||
| 2052 | |||
| 2053 | /** Get the input stream. | ||
| 2054 | * | ||
| 2055 | */ | ||
| 2056 | FILE *yyget_in (void) | ||
| 2057 | { | ||
| 2058 | return yyin; | ||
| 2059 | } | ||
| 2060 | |||
| 2061 | /** Get the output stream. | ||
| 2062 | * | ||
| 2063 | */ | ||
| 2064 | FILE *yyget_out (void) | ||
| 2065 | { | ||
| 2066 | return yyout; | ||
| 2067 | } | ||
| 2068 | |||
| 2069 | /** Get the length of the current token. | ||
| 2070 | * | ||
| 2071 | */ | ||
| 2072 | int yyget_leng (void) | ||
| 2073 | { | ||
| 2074 | return yyleng; | ||
| 2075 | } | ||
| 2076 | |||
| 2077 | /** Get the current token. | ||
| 2078 | * | ||
| 2079 | */ | ||
| 2080 | |||
| 2081 | char *yyget_text (void) | ||
| 2082 | { | ||
| 2083 | return yytext; | ||
| 2084 | } | ||
| 2085 | |||
| 2086 | /** Set the current line number. | ||
| 2087 | * @param _line_number line number | ||
| 2088 | * | ||
| 2089 | */ | ||
| 2090 | void yyset_lineno (int _line_number ) | ||
| 2091 | { | ||
| 2092 | |||
| 2093 | yylineno = _line_number; | ||
| 2094 | } | ||
| 2095 | |||
| 2096 | /** Set the input stream. This does not discard the current | ||
| 2097 | * input buffer. | ||
| 2098 | * @param _in_str A readable stream. | ||
| 2099 | * | ||
| 2100 | * @see yy_switch_to_buffer | ||
| 2101 | */ | ||
| 2102 | void yyset_in (FILE * _in_str ) | ||
| 2103 | { | ||
| 2104 | yyin = _in_str ; | ||
| 2105 | } | ||
| 2106 | |||
| 2107 | void yyset_out (FILE * _out_str ) | ||
| 2108 | { | ||
| 2109 | yyout = _out_str ; | ||
| 2110 | } | ||
| 2111 | |||
| 2112 | int yyget_debug (void) | ||
| 2113 | { | ||
| 2114 | return yy_flex_debug; | ||
| 2115 | } | ||
| 2116 | |||
| 2117 | void yyset_debug (int _bdebug ) | ||
| 2118 | { | ||
| 2119 | yy_flex_debug = _bdebug ; | ||
| 2120 | } | ||
| 2121 | |||
| 2122 | static int yy_init_globals (void) | ||
| 2123 | { | ||
| 2124 | /* Initialization is the same as for the non-reentrant scanner. | ||
| 2125 | * This function is called from yylex_destroy(), so don't allocate here. | ||
| 2126 | */ | ||
| 2127 | |||
| 2128 | (yy_buffer_stack) = NULL; | ||
| 2129 | (yy_buffer_stack_top) = 0; | ||
| 2130 | (yy_buffer_stack_max) = 0; | ||
| 2131 | (yy_c_buf_p) = NULL; | ||
| 2132 | (yy_init) = 0; | ||
| 2133 | (yy_start) = 0; | ||
| 2134 | |||
| 2135 | /* Defined in main.c */ | ||
| 2136 | #ifdef YY_STDINIT | ||
| 2137 | yyin = stdin; | ||
| 2138 | yyout = stdout; | ||
| 2139 | #else | ||
| 2140 | yyin = NULL; | ||
| 2141 | yyout = NULL; | ||
| 2142 | #endif | ||
| 2143 | |||
| 2144 | /* For future reference: Set errno on error, since we are called by | ||
| 2145 | * yylex_init() | ||
| 2146 | */ | ||
| 2147 | return 0; | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ | ||
| 2151 | int yylex_destroy (void) | ||
| 2152 | { | ||
| 2153 | |||
| 2154 | /* Pop the buffer stack, destroying each element. */ | ||
| 2155 | while(YY_CURRENT_BUFFER){ | ||
| 2156 | yy_delete_buffer(YY_CURRENT_BUFFER ); | ||
| 2157 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
| 2158 | yypop_buffer_state(); | ||
| 2159 | } | ||
| 2160 | |||
| 2161 | /* Destroy the stack itself. */ | ||
| 2162 | yyfree((yy_buffer_stack) ); | ||
| 2163 | (yy_buffer_stack) = NULL; | ||
| 2164 | |||
| 2165 | /* Reset the globals. This is important in a non-reentrant scanner so the next time | ||
| 2166 | * yylex() is called, initialization will occur. */ | ||
| 2167 | yy_init_globals( ); | ||
| 2168 | |||
| 2169 | return 0; | ||
| 2170 | } | ||
| 2171 | |||
| 2172 | /* | ||
| 2173 | * Internal utility routines. | ||
| 2174 | */ | ||
| 2175 | |||
| 2176 | #ifndef yytext_ptr | ||
| 2177 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | ||
| 2178 | { | ||
| 2179 | |||
| 2180 | int i; | ||
| 2181 | for ( i = 0; i < n; ++i ) | ||
| 2182 | s1[i] = s2[i]; | ||
| 2183 | } | ||
| 2184 | #endif | ||
| 2185 | |||
| 2186 | #ifdef YY_NEED_STRLEN | ||
| 2187 | static int yy_flex_strlen (yyconst char * s ) | ||
| 2188 | { | ||
| 2189 | int n; | ||
| 2190 | for ( n = 0; s[n]; ++n ) | ||
| 2191 | ; | ||
| 2192 | |||
| 2193 | return n; | ||
| 2194 | } | ||
| 2195 | #endif | ||
| 2196 | |||
| 2197 | void *yyalloc (yy_size_t size ) | ||
| 2198 | { | ||
| 2199 | return malloc(size); | ||
| 2200 | } | ||
| 2201 | |||
| 2202 | void *yyrealloc (void * ptr, yy_size_t size ) | ||
| 2203 | { | ||
| 2204 | |||
| 2205 | /* The cast to (char *) in the following accommodates both | ||
| 2206 | * implementations that use char* generic pointers, and those | ||
| 2207 | * that use void* generic pointers. It works with the latter | ||
| 2208 | * because both ANSI C and C++ allow castless assignment from | ||
| 2209 | * any pointer type to void*, and deal with argument conversions | ||
| 2210 | * as though doing an assignment. | ||
| 2211 | */ | ||
| 2212 | return realloc(ptr, size); | ||
| 2213 | } | ||
| 2214 | |||
| 2215 | void yyfree (void * ptr ) | ||
| 2216 | { | ||
| 2217 | free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ | ||
| 2218 | } | ||
| 2219 | |||
| 2220 | #define YYTABLES_NAME "yytables" | ||
| 2221 | |||
| 2222 | #line 272 "dtc-lexer.l" | ||
| 2223 | |||
| 2224 | |||
| 2225 | |||
| 2226 | static void push_input_file(const char *filename) | ||
| 2227 | { | ||
| 2228 | assert(filename); | ||
| 2229 | |||
| 2230 | srcfile_push(filename); | ||
| 2231 | |||
| 2232 | yyin = current_srcfile->f; | ||
| 2233 | |||
| 2234 | yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); | ||
| 2235 | } | ||
| 2236 | |||
| 2237 | |||
| 2238 | static bool pop_input_file(void) | ||
| 2239 | { | ||
| 2240 | if (srcfile_pop() == 0) | ||
| 2241 | return false; | ||
| 2242 | |||
| 2243 | yypop_buffer_state(); | ||
| 2244 | yyin = current_srcfile->f; | ||
| 2245 | |||
| 2246 | return true; | ||
| 2247 | } | ||
| 2248 | |||
| 2249 | static void lexical_error(const char *fmt, ...) | ||
| 2250 | { | ||
| 2251 | va_list ap; | ||
| 2252 | |||
| 2253 | va_start(ap, fmt); | ||
| 2254 | srcpos_verror(&yylloc, "Lexical error", fmt, ap); | ||
| 2255 | va_end(ap); | ||
| 2256 | |||
| 2257 | treesource_error = true; | ||
| 2258 | } | ||
| 2259 | |||
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped deleted file mode 100644 index aea514fa6928..000000000000 --- a/scripts/dtc/dtc-parser.tab.c_shipped +++ /dev/null | |||
| @@ -1,2321 +0,0 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 3.0.4. */ | ||
| 2 | |||
| 3 | /* Bison implementation for Yacc-like parsers in C | ||
| 4 | |||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (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 | ||
| 15 | GNU 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, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* As a special exception, you may create a larger work that contains | ||
| 21 | part or all of the Bison parser skeleton and distribute that work | ||
| 22 | under terms of your choice, so long as that work isn't itself a | ||
| 23 | parser generator using the skeleton or a modified version thereof | ||
| 24 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
| 25 | the parser skeleton itself, you may (at your option) remove this | ||
| 26 | special exception, which will cause the skeleton and the resulting | ||
| 27 | Bison output files to be licensed under the GNU General Public | ||
| 28 | License without this special exception. | ||
| 29 | |||
| 30 | This special exception was added by the Free Software Foundation in | ||
| 31 | version 2.2 of Bison. */ | ||
| 32 | |||
| 33 | /* C LALR(1) parser skeleton written by Richard Stallman, by | ||
| 34 | simplifying the original so-called "semantic" parser. */ | ||
| 35 | |||
| 36 | /* All symbols defined below should begin with yy or YY, to avoid | ||
| 37 | infringing on user name space. This should be done even for local | ||
| 38 | variables, as they might otherwise be expanded by user macros. | ||
| 39 | There are some unavoidable exceptions within include files to | ||
| 40 | define necessary library symbols; they are noted "INFRINGES ON | ||
| 41 | USER NAME SPACE" below. */ | ||
| 42 | |||
| 43 | /* Identify Bison output. */ | ||
| 44 | #define YYBISON 1 | ||
| 45 | |||
| 46 | /* Bison version. */ | ||
| 47 | #define YYBISON_VERSION "3.0.4" | ||
| 48 | |||
| 49 | /* Skeleton name. */ | ||
| 50 | #define YYSKELETON_NAME "yacc.c" | ||
| 51 | |||
| 52 | /* Pure parsers. */ | ||
| 53 | #define YYPURE 0 | ||
| 54 | |||
| 55 | /* Push parsers. */ | ||
| 56 | #define YYPUSH 0 | ||
| 57 | |||
| 58 | /* Pull parsers. */ | ||
| 59 | #define YYPULL 1 | ||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | /* Copy the first part of user declarations. */ | ||
| 65 | #line 20 "dtc-parser.y" /* yacc.c:339 */ | ||
| 66 | |||
| 67 | #include <stdio.h> | ||
| 68 | #include <inttypes.h> | ||
| 69 | |||
| 70 | #include "dtc.h" | ||
| 71 | #include "srcpos.h" | ||
| 72 | |||
| 73 | extern int yylex(void); | ||
| 74 | extern void yyerror(char const *s); | ||
| 75 | #define ERROR(loc, ...) \ | ||
| 76 | do { \ | ||
| 77 | srcpos_error((loc), "Error", __VA_ARGS__); \ | ||
| 78 | treesource_error = true; \ | ||
| 79 | } while (0) | ||
| 80 | |||
| 81 | extern struct dt_info *parser_output; | ||
| 82 | extern bool treesource_error; | ||
| 83 | |||
| 84 | #line 85 "dtc-parser.tab.c" /* yacc.c:339 */ | ||
| 85 | |||
| 86 | # ifndef YY_NULLPTR | ||
| 87 | # if defined __cplusplus && 201103L <= __cplusplus | ||
| 88 | # define YY_NULLPTR nullptr | ||
| 89 | # else | ||
| 90 | # define YY_NULLPTR 0 | ||
| 91 | # endif | ||
| 92 | # endif | ||
| 93 | |||
| 94 | /* Enabling verbose error messages. */ | ||
| 95 | #ifdef YYERROR_VERBOSE | ||
| 96 | # undef YYERROR_VERBOSE | ||
| 97 | # define YYERROR_VERBOSE 1 | ||
| 98 | #else | ||
| 99 | # define YYERROR_VERBOSE 0 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | /* In a future release of Bison, this section will be replaced | ||
| 103 | by #include "dtc-parser.tab.h". */ | ||
| 104 | #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 105 | # define YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 106 | /* Debug traces. */ | ||
| 107 | #ifndef YYDEBUG | ||
| 108 | # define YYDEBUG 0 | ||
| 109 | #endif | ||
| 110 | #if YYDEBUG | ||
| 111 | extern int yydebug; | ||
| 112 | #endif | ||
| 113 | |||
| 114 | /* Token type. */ | ||
| 115 | #ifndef YYTOKENTYPE | ||
| 116 | # define YYTOKENTYPE | ||
| 117 | enum yytokentype | ||
| 118 | { | ||
| 119 | DT_V1 = 258, | ||
| 120 | DT_PLUGIN = 259, | ||
| 121 | DT_MEMRESERVE = 260, | ||
| 122 | DT_LSHIFT = 261, | ||
| 123 | DT_RSHIFT = 262, | ||
| 124 | DT_LE = 263, | ||
| 125 | DT_GE = 264, | ||
| 126 | DT_EQ = 265, | ||
| 127 | DT_NE = 266, | ||
| 128 | DT_AND = 267, | ||
| 129 | DT_OR = 268, | ||
| 130 | DT_BITS = 269, | ||
| 131 | DT_DEL_PROP = 270, | ||
| 132 | DT_DEL_NODE = 271, | ||
| 133 | DT_PROPNODENAME = 272, | ||
| 134 | DT_LITERAL = 273, | ||
| 135 | DT_CHAR_LITERAL = 274, | ||
| 136 | DT_BYTE = 275, | ||
| 137 | DT_STRING = 276, | ||
| 138 | DT_LABEL = 277, | ||
| 139 | DT_REF = 278, | ||
| 140 | DT_INCBIN = 279 | ||
| 141 | }; | ||
| 142 | #endif | ||
| 143 | |||
| 144 | /* Value type. */ | ||
| 145 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
| 146 | |||
| 147 | union YYSTYPE | ||
| 148 | { | ||
| 149 | #line 39 "dtc-parser.y" /* yacc.c:355 */ | ||
| 150 | |||
| 151 | char *propnodename; | ||
| 152 | char *labelref; | ||
| 153 | uint8_t byte; | ||
| 154 | struct data data; | ||
| 155 | |||
| 156 | struct { | ||
| 157 | struct data data; | ||
| 158 | int bits; | ||
| 159 | } array; | ||
| 160 | |||
| 161 | struct property *prop; | ||
| 162 | struct property *proplist; | ||
| 163 | struct node *node; | ||
| 164 | struct node *nodelist; | ||
| 165 | struct reserve_info *re; | ||
| 166 | uint64_t integer; | ||
| 167 | unsigned int flags; | ||
| 168 | |||
| 169 | #line 170 "dtc-parser.tab.c" /* yacc.c:355 */ | ||
| 170 | }; | ||
| 171 | |||
| 172 | typedef union YYSTYPE YYSTYPE; | ||
| 173 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 174 | # define YYSTYPE_IS_DECLARED 1 | ||
| 175 | #endif | ||
| 176 | |||
| 177 | /* Location type. */ | ||
| 178 | #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED | ||
| 179 | typedef struct YYLTYPE YYLTYPE; | ||
| 180 | struct YYLTYPE | ||
| 181 | { | ||
| 182 | int first_line; | ||
| 183 | int first_column; | ||
| 184 | int last_line; | ||
| 185 | int last_column; | ||
| 186 | }; | ||
| 187 | # define YYLTYPE_IS_DECLARED 1 | ||
| 188 | # define YYLTYPE_IS_TRIVIAL 1 | ||
| 189 | #endif | ||
| 190 | |||
| 191 | |||
| 192 | extern YYSTYPE yylval; | ||
| 193 | extern YYLTYPE yylloc; | ||
| 194 | int yyparse (void); | ||
| 195 | |||
| 196 | #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ | ||
| 197 | |||
| 198 | /* Copy the second part of user declarations. */ | ||
| 199 | |||
| 200 | #line 201 "dtc-parser.tab.c" /* yacc.c:358 */ | ||
| 201 | |||
| 202 | #ifdef short | ||
| 203 | # undef short | ||
| 204 | #endif | ||
| 205 | |||
| 206 | #ifdef YYTYPE_UINT8 | ||
| 207 | typedef YYTYPE_UINT8 yytype_uint8; | ||
| 208 | #else | ||
| 209 | typedef unsigned char yytype_uint8; | ||
| 210 | #endif | ||
| 211 | |||
| 212 | #ifdef YYTYPE_INT8 | ||
| 213 | typedef YYTYPE_INT8 yytype_int8; | ||
| 214 | #else | ||
| 215 | typedef signed char yytype_int8; | ||
| 216 | #endif | ||
| 217 | |||
| 218 | #ifdef YYTYPE_UINT16 | ||
| 219 | typedef YYTYPE_UINT16 yytype_uint16; | ||
| 220 | #else | ||
| 221 | typedef unsigned short int yytype_uint16; | ||
| 222 | #endif | ||
| 223 | |||
| 224 | #ifdef YYTYPE_INT16 | ||
| 225 | typedef YYTYPE_INT16 yytype_int16; | ||
| 226 | #else | ||
| 227 | typedef short int yytype_int16; | ||
| 228 | #endif | ||
| 229 | |||
| 230 | #ifndef YYSIZE_T | ||
| 231 | # ifdef __SIZE_TYPE__ | ||
| 232 | # define YYSIZE_T __SIZE_TYPE__ | ||
| 233 | # elif defined size_t | ||
| 234 | # define YYSIZE_T size_t | ||
| 235 | # elif ! defined YYSIZE_T | ||
| 236 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 237 | # define YYSIZE_T size_t | ||
| 238 | # else | ||
| 239 | # define YYSIZE_T unsigned int | ||
| 240 | # endif | ||
| 241 | #endif | ||
| 242 | |||
| 243 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | ||
| 244 | |||
| 245 | #ifndef YY_ | ||
| 246 | # if defined YYENABLE_NLS && YYENABLE_NLS | ||
| 247 | # if ENABLE_NLS | ||
| 248 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 249 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) | ||
| 250 | # endif | ||
| 251 | # endif | ||
| 252 | # ifndef YY_ | ||
| 253 | # define YY_(Msgid) Msgid | ||
| 254 | # endif | ||
| 255 | #endif | ||
| 256 | |||
| 257 | #ifndef YY_ATTRIBUTE | ||
| 258 | # if (defined __GNUC__ \ | ||
| 259 | && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ | ||
| 260 | || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C | ||
| 261 | # define YY_ATTRIBUTE(Spec) __attribute__(Spec) | ||
| 262 | # else | ||
| 263 | # define YY_ATTRIBUTE(Spec) /* empty */ | ||
| 264 | # endif | ||
| 265 | #endif | ||
| 266 | |||
| 267 | #ifndef YY_ATTRIBUTE_PURE | ||
| 268 | # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) | ||
| 269 | #endif | ||
| 270 | |||
| 271 | #ifndef YY_ATTRIBUTE_UNUSED | ||
| 272 | # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) | ||
| 273 | #endif | ||
| 274 | |||
| 275 | #if !defined _Noreturn \ | ||
| 276 | && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) | ||
| 277 | # if defined _MSC_VER && 1200 <= _MSC_VER | ||
| 278 | # define _Noreturn __declspec (noreturn) | ||
| 279 | # else | ||
| 280 | # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) | ||
| 281 | # endif | ||
| 282 | #endif | ||
| 283 | |||
| 284 | /* Suppress unused-variable warnings by "using" E. */ | ||
| 285 | #if ! defined lint || defined __GNUC__ | ||
| 286 | # define YYUSE(E) ((void) (E)) | ||
| 287 | #else | ||
| 288 | # define YYUSE(E) /* empty */ | ||
| 289 | #endif | ||
| 290 | |||
| 291 | #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ | ||
| 292 | /* Suppress an incorrect diagnostic about yylval being uninitialized. */ | ||
| 293 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ | ||
| 294 | _Pragma ("GCC diagnostic push") \ | ||
| 295 | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ | ||
| 296 | _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") | ||
| 297 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ | ||
| 298 | _Pragma ("GCC diagnostic pop") | ||
| 299 | #else | ||
| 300 | # define YY_INITIAL_VALUE(Value) Value | ||
| 301 | #endif | ||
| 302 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 303 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 304 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 305 | #endif | ||
| 306 | #ifndef YY_INITIAL_VALUE | ||
| 307 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ | ||
| 308 | #endif | ||
| 309 | |||
| 310 | |||
| 311 | #if ! defined yyoverflow || YYERROR_VERBOSE | ||
| 312 | |||
| 313 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
| 314 | |||
| 315 | # ifdef YYSTACK_USE_ALLOCA | ||
| 316 | # if YYSTACK_USE_ALLOCA | ||
| 317 | # ifdef __GNUC__ | ||
| 318 | # define YYSTACK_ALLOC __builtin_alloca | ||
| 319 | # elif defined __BUILTIN_VA_ARG_INCR | ||
| 320 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 321 | # elif defined _AIX | ||
| 322 | # define YYSTACK_ALLOC __alloca | ||
| 323 | # elif defined _MSC_VER | ||
| 324 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 325 | # define alloca _alloca | ||
| 326 | # else | ||
| 327 | # define YYSTACK_ALLOC alloca | ||
| 328 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS | ||
| 329 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 330 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ | ||
| 331 | # ifndef EXIT_SUCCESS | ||
| 332 | # define EXIT_SUCCESS 0 | ||
| 333 | # endif | ||
| 334 | # endif | ||
| 335 | # endif | ||
| 336 | # endif | ||
| 337 | # endif | ||
| 338 | |||
| 339 | # ifdef YYSTACK_ALLOC | ||
| 340 | /* Pacify GCC's 'empty if-body' warning. */ | ||
| 341 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | ||
| 342 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
| 343 | /* The OS might guarantee only one guard page at the bottom of the stack, | ||
| 344 | and a page size can be as small as 4096 bytes. So we cannot safely | ||
| 345 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | ||
| 346 | to allow for a few compiler-allocated temporary stack slots. */ | ||
| 347 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | ||
| 348 | # endif | ||
| 349 | # else | ||
| 350 | # define YYSTACK_ALLOC YYMALLOC | ||
| 351 | # define YYSTACK_FREE YYFREE | ||
| 352 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
| 353 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | ||
| 354 | # endif | ||
| 355 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ | ||
| 356 | && ! ((defined YYMALLOC || defined malloc) \ | ||
| 357 | && (defined YYFREE || defined free))) | ||
| 358 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 359 | # ifndef EXIT_SUCCESS | ||
| 360 | # define EXIT_SUCCESS 0 | ||
| 361 | # endif | ||
| 362 | # endif | ||
| 363 | # ifndef YYMALLOC | ||
| 364 | # define YYMALLOC malloc | ||
| 365 | # if ! defined malloc && ! defined EXIT_SUCCESS | ||
| 366 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | ||
| 367 | # endif | ||
| 368 | # endif | ||
| 369 | # ifndef YYFREE | ||
| 370 | # define YYFREE free | ||
| 371 | # if ! defined free && ! defined EXIT_SUCCESS | ||
| 372 | void free (void *); /* INFRINGES ON USER NAME SPACE */ | ||
| 373 | # endif | ||
| 374 | # endif | ||
| 375 | # endif | ||
| 376 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ | ||
| 377 | |||
| 378 | |||
| 379 | #if (! defined yyoverflow \ | ||
| 380 | && (! defined __cplusplus \ | ||
| 381 | || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ | ||
| 382 | && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
| 383 | |||
| 384 | /* A type that is properly aligned for any stack member. */ | ||
| 385 | union yyalloc | ||
| 386 | { | ||
| 387 | yytype_int16 yyss_alloc; | ||
| 388 | YYSTYPE yyvs_alloc; | ||
| 389 | YYLTYPE yyls_alloc; | ||
| 390 | }; | ||
| 391 | |||
| 392 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
| 393 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | ||
| 394 | |||
| 395 | /* The size of an array large to enough to hold all stacks, each with | ||
| 396 | N elements. */ | ||
| 397 | # define YYSTACK_BYTES(N) \ | ||
| 398 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ | ||
| 399 | + 2 * YYSTACK_GAP_MAXIMUM) | ||
| 400 | |||
| 401 | # define YYCOPY_NEEDED 1 | ||
| 402 | |||
| 403 | /* Relocate STACK from its old location to the new one. The | ||
| 404 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
| 405 | elements in the stack, and YYPTR gives the new location of the | ||
| 406 | stack. Advance YYPTR to a properly aligned location for the next | ||
| 407 | stack. */ | ||
| 408 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | ||
| 409 | do \ | ||
| 410 | { \ | ||
| 411 | YYSIZE_T yynewbytes; \ | ||
| 412 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | ||
| 413 | Stack = &yyptr->Stack_alloc; \ | ||
| 414 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | ||
| 415 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
| 416 | } \ | ||
| 417 | while (0) | ||
| 418 | |||
| 419 | #endif | ||
| 420 | |||
| 421 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED | ||
| 422 | /* Copy COUNT objects from SRC to DST. The source and destination do | ||
| 423 | not overlap. */ | ||
| 424 | # ifndef YYCOPY | ||
| 425 | # if defined __GNUC__ && 1 < __GNUC__ | ||
| 426 | # define YYCOPY(Dst, Src, Count) \ | ||
| 427 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) | ||
| 428 | # else | ||
| 429 | # define YYCOPY(Dst, Src, Count) \ | ||
| 430 | do \ | ||
| 431 | { \ | ||
| 432 | YYSIZE_T yyi; \ | ||
| 433 | for (yyi = 0; yyi < (Count); yyi++) \ | ||
| 434 | (Dst)[yyi] = (Src)[yyi]; \ | ||
| 435 | } \ | ||
| 436 | while (0) | ||
| 437 | # endif | ||
| 438 | # endif | ||
| 439 | #endif /* !YYCOPY_NEEDED */ | ||
| 440 | |||
| 441 | /* YYFINAL -- State number of the termination state. */ | ||
| 442 | #define YYFINAL 6 | ||
| 443 | /* YYLAST -- Last index in YYTABLE. */ | ||
| 444 | #define YYLAST 138 | ||
| 445 | |||
| 446 | /* YYNTOKENS -- Number of terminals. */ | ||
| 447 | #define YYNTOKENS 48 | ||
| 448 | /* YYNNTS -- Number of nonterminals. */ | ||
| 449 | #define YYNNTS 30 | ||
| 450 | /* YYNRULES -- Number of rules. */ | ||
| 451 | #define YYNRULES 85 | ||
| 452 | /* YYNSTATES -- Number of states. */ | ||
| 453 | #define YYNSTATES 149 | ||
| 454 | |||
| 455 | /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned | ||
| 456 | by yylex, with out-of-bounds checking. */ | ||
| 457 | #define YYUNDEFTOK 2 | ||
| 458 | #define YYMAXUTOK 279 | ||
| 459 | |||
| 460 | #define YYTRANSLATE(YYX) \ | ||
| 461 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | ||
| 462 | |||
| 463 | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM | ||
| 464 | as returned by yylex, without out-of-bounds checking. */ | ||
| 465 | static const yytype_uint8 yytranslate[] = | ||
| 466 | { | ||
| 467 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 468 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 469 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 470 | 2, 2, 2, 47, 2, 2, 2, 45, 41, 2, | ||
| 471 | 33, 35, 44, 42, 34, 43, 2, 26, 2, 2, | ||
| 472 | 2, 2, 2, 2, 2, 2, 2, 2, 38, 25, | ||
| 473 | 36, 29, 30, 37, 2, 2, 2, 2, 2, 2, | ||
| 474 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 475 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 476 | 2, 31, 2, 32, 40, 2, 2, 2, 2, 2, | ||
| 477 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 478 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 479 | 2, 2, 2, 27, 39, 28, 46, 2, 2, 2, | ||
| 480 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 481 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 482 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 483 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 484 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 485 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 486 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 487 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 488 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 489 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 490 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 491 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 492 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | ||
| 493 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | ||
| 494 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 | ||
| 495 | }; | ||
| 496 | |||
| 497 | #if YYDEBUG | ||
| 498 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ | ||
| 499 | static const yytype_uint16 yyrline[] = | ||
| 500 | { | ||
| 501 | 0, 109, 109, 117, 121, 128, 129, 139, 142, 149, | ||
| 502 | 153, 161, 165, 170, 181, 200, 213, 220, 228, 231, | ||
| 503 | 238, 242, 246, 250, 258, 262, 266, 270, 274, 290, | ||
| 504 | 300, 308, 311, 315, 322, 338, 343, 362, 376, 383, | ||
| 505 | 384, 385, 392, 396, 397, 401, 402, 406, 407, 411, | ||
| 506 | 412, 416, 417, 421, 422, 426, 427, 428, 432, 433, | ||
| 507 | 434, 435, 436, 440, 441, 442, 446, 447, 448, 452, | ||
| 508 | 453, 462, 471, 475, 476, 477, 478, 483, 486, 490, | ||
| 509 | 498, 501, 505, 513, 517, 521 | ||
| 510 | }; | ||
| 511 | #endif | ||
| 512 | |||
| 513 | #if YYDEBUG || YYERROR_VERBOSE || 0 | ||
| 514 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
| 515 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
| 516 | static const char *const yytname[] = | ||
| 517 | { | ||
| 518 | "$end", "error", "$undefined", "DT_V1", "DT_PLUGIN", "DT_MEMRESERVE", | ||
| 519 | "DT_LSHIFT", "DT_RSHIFT", "DT_LE", "DT_GE", "DT_EQ", "DT_NE", "DT_AND", | ||
| 520 | "DT_OR", "DT_BITS", "DT_DEL_PROP", "DT_DEL_NODE", "DT_PROPNODENAME", | ||
| 521 | "DT_LITERAL", "DT_CHAR_LITERAL", "DT_BYTE", "DT_STRING", "DT_LABEL", | ||
| 522 | "DT_REF", "DT_INCBIN", "';'", "'/'", "'{'", "'}'", "'='", "'>'", "'['", | ||
| 523 | "']'", "'('", "','", "')'", "'<'", "'?'", "':'", "'|'", "'^'", "'&'", | ||
| 524 | "'+'", "'-'", "'*'", "'%'", "'~'", "'!'", "$accept", "sourcefile", | ||
| 525 | "header", "headers", "memreserves", "memreserve", "devicetree", | ||
| 526 | "nodedef", "proplist", "propdef", "propdata", "propdataprefix", | ||
| 527 | "arrayprefix", "integer_prim", "integer_expr", "integer_trinary", | ||
| 528 | "integer_or", "integer_and", "integer_bitor", "integer_bitxor", | ||
| 529 | "integer_bitand", "integer_eq", "integer_rela", "integer_shift", | ||
| 530 | "integer_add", "integer_mul", "integer_unary", "bytestring", "subnodes", | ||
| 531 | "subnode", YY_NULLPTR | ||
| 532 | }; | ||
| 533 | #endif | ||
| 534 | |||
| 535 | # ifdef YYPRINT | ||
| 536 | /* YYTOKNUM[NUM] -- (External) token number corresponding to the | ||
| 537 | (internal) symbol number NUM (which must be that of a token). */ | ||
| 538 | static const yytype_uint16 yytoknum[] = | ||
| 539 | { | ||
| 540 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||
| 541 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | ||
| 542 | 275, 276, 277, 278, 279, 59, 47, 123, 125, 61, | ||
| 543 | 62, 91, 93, 40, 44, 41, 60, 63, 58, 124, | ||
| 544 | 94, 38, 43, 45, 42, 37, 126, 33 | ||
| 545 | }; | ||
| 546 | # endif | ||
| 547 | |||
| 548 | #define YYPACT_NINF -44 | ||
| 549 | |||
| 550 | #define yypact_value_is_default(Yystate) \ | ||
| 551 | (!!((Yystate) == (-44))) | ||
| 552 | |||
| 553 | #define YYTABLE_NINF -1 | ||
| 554 | |||
| 555 | #define yytable_value_is_error(Yytable_value) \ | ||
| 556 | 0 | ||
| 557 | |||
| 558 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
| 559 | STATE-NUM. */ | ||
| 560 | static const yytype_int8 yypact[] = | ||
| 561 | { | ||
| 562 | 14, 27, 61, 14, 8, 18, -44, -44, 37, 8, | ||
| 563 | 40, 8, 64, -44, -44, -12, 37, -44, 50, 52, | ||
| 564 | -44, -44, -12, -12, -12, -44, 51, -44, -4, 78, | ||
| 565 | 53, 54, 55, 17, 2, 30, 38, -3, -44, 66, | ||
| 566 | -44, -44, 70, 72, 50, 50, -44, -44, -44, -44, | ||
| 567 | -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, | ||
| 568 | -12, -12, -12, -12, -12, -12, -12, -12, -12, -44, | ||
| 569 | 3, 73, 50, -44, -44, 78, 59, 53, 54, 55, | ||
| 570 | 17, 2, 2, 30, 30, 30, 30, 38, 38, -3, | ||
| 571 | -3, -44, -44, -44, 82, 83, 44, 3, -44, 74, | ||
| 572 | 3, -44, -44, -12, 76, 79, -44, -44, -44, -44, | ||
| 573 | -44, 80, -44, -44, -44, -44, -44, -10, 36, -44, | ||
| 574 | -44, -44, -44, 85, -44, -44, -44, 75, -44, -44, | ||
| 575 | 21, 71, 88, -6, -44, -44, -44, -44, -44, 11, | ||
| 576 | -44, -44, -44, 37, -44, 77, 37, 81, -44 | ||
| 577 | }; | ||
| 578 | |||
| 579 | /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. | ||
| 580 | Performed when YYTABLE does not specify something else to do. Zero | ||
| 581 | means the default is an error. */ | ||
| 582 | static const yytype_uint8 yydefact[] = | ||
| 583 | { | ||
| 584 | 0, 0, 0, 5, 7, 3, 1, 6, 0, 0, | ||
| 585 | 16, 7, 0, 39, 40, 0, 0, 10, 0, 2, | ||
| 586 | 8, 4, 0, 0, 0, 73, 0, 42, 43, 45, | ||
| 587 | 47, 49, 51, 53, 55, 58, 65, 68, 72, 0, | ||
| 588 | 18, 11, 0, 0, 0, 0, 74, 75, 76, 41, | ||
| 589 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 590 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, | ||
| 591 | 80, 0, 0, 14, 12, 46, 0, 48, 50, 52, | ||
| 592 | 54, 56, 57, 61, 62, 60, 59, 63, 64, 66, | ||
| 593 | 67, 70, 69, 71, 0, 0, 0, 0, 19, 0, | ||
| 594 | 80, 15, 13, 0, 0, 0, 21, 31, 83, 23, | ||
| 595 | 85, 0, 82, 81, 44, 22, 84, 0, 0, 17, | ||
| 596 | 30, 20, 32, 0, 24, 33, 27, 0, 77, 35, | ||
| 597 | 0, 0, 0, 0, 38, 37, 25, 36, 34, 0, | ||
| 598 | 78, 79, 26, 0, 29, 0, 0, 0, 28 | ||
| 599 | }; | ||
| 600 | |||
| 601 | /* YYPGOTO[NTERM-NUM]. */ | ||
| 602 | static const yytype_int8 yypgoto[] = | ||
| 603 | { | ||
| 604 | -44, -44, -44, 103, 99, 104, -44, -43, -44, -21, | ||
| 605 | -44, -44, -44, -8, 63, 9, -44, 65, 67, 68, | ||
| 606 | 69, 62, 26, 4, 22, 23, -19, -44, 20, 28 | ||
| 607 | }; | ||
| 608 | |||
| 609 | /* YYDEFGOTO[NTERM-NUM]. */ | ||
| 610 | static const yytype_int16 yydefgoto[] = | ||
| 611 | { | ||
| 612 | -1, 2, 3, 4, 10, 11, 19, 41, 70, 98, | ||
| 613 | 117, 118, 130, 25, 26, 27, 28, 29, 30, 31, | ||
| 614 | 32, 33, 34, 35, 36, 37, 38, 133, 99, 100 | ||
| 615 | }; | ||
| 616 | |||
| 617 | /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If | ||
| 618 | positive, shift that token. If negative, reduce the rule whose | ||
| 619 | number is the opposite. If YYTABLE_NINF, syntax error. */ | ||
| 620 | static const yytype_uint8 yytable[] = | ||
| 621 | { | ||
| 622 | 16, 73, 74, 46, 47, 48, 13, 14, 39, 50, | ||
| 623 | 58, 59, 120, 8, 140, 121, 141, 1, 94, 95, | ||
| 624 | 96, 15, 12, 66, 122, 97, 142, 56, 57, 102, | ||
| 625 | 9, 22, 60, 51, 23, 24, 62, 63, 61, 13, | ||
| 626 | 14, 67, 68, 134, 135, 143, 144, 91, 92, 93, | ||
| 627 | 123, 136, 5, 108, 15, 13, 14, 124, 125, 126, | ||
| 628 | 127, 6, 83, 84, 85, 86, 18, 128, 42, 106, | ||
| 629 | 15, 40, 129, 107, 43, 44, 109, 40, 45, 112, | ||
| 630 | 64, 65, 81, 82, 87, 88, 49, 89, 90, 21, | ||
| 631 | 52, 69, 53, 71, 54, 72, 55, 103, 101, 104, | ||
| 632 | 105, 115, 111, 131, 116, 119, 7, 138, 132, 139, | ||
| 633 | 20, 146, 114, 17, 76, 75, 148, 80, 0, 77, | ||
| 634 | 113, 78, 137, 79, 0, 110, 0, 0, 0, 0, | ||
| 635 | 0, 0, 0, 0, 0, 145, 0, 0, 147 | ||
| 636 | }; | ||
| 637 | |||
| 638 | static const yytype_int16 yycheck[] = | ||
| 639 | { | ||
| 640 | 8, 44, 45, 22, 23, 24, 18, 19, 16, 13, | ||
| 641 | 8, 9, 22, 5, 20, 25, 22, 3, 15, 16, | ||
| 642 | 17, 33, 4, 26, 34, 22, 32, 10, 11, 72, | ||
| 643 | 22, 43, 30, 37, 46, 47, 6, 7, 36, 18, | ||
| 644 | 19, 44, 45, 22, 23, 34, 35, 66, 67, 68, | ||
| 645 | 14, 30, 25, 96, 33, 18, 19, 21, 22, 23, | ||
| 646 | 24, 0, 58, 59, 60, 61, 26, 31, 16, 25, | ||
| 647 | 33, 27, 36, 29, 22, 23, 97, 27, 26, 100, | ||
| 648 | 42, 43, 56, 57, 62, 63, 35, 64, 65, 25, | ||
| 649 | 12, 25, 39, 23, 40, 23, 41, 38, 25, 17, | ||
| 650 | 17, 25, 28, 18, 25, 25, 3, 36, 33, 21, | ||
| 651 | 11, 34, 103, 9, 51, 50, 35, 55, -1, 52, | ||
| 652 | 100, 53, 130, 54, -1, 97, -1, -1, -1, -1, | ||
| 653 | -1, -1, -1, -1, -1, 143, -1, -1, 146 | ||
| 654 | }; | ||
| 655 | |||
| 656 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
| 657 | symbol of state STATE-NUM. */ | ||
| 658 | static const yytype_uint8 yystos[] = | ||
| 659 | { | ||
| 660 | 0, 3, 49, 50, 51, 25, 0, 51, 5, 22, | ||
| 661 | 52, 53, 4, 18, 19, 33, 61, 53, 26, 54, | ||
| 662 | 52, 25, 43, 46, 47, 61, 62, 63, 64, 65, | ||
| 663 | 66, 67, 68, 69, 70, 71, 72, 73, 74, 61, | ||
| 664 | 27, 55, 16, 22, 23, 26, 74, 74, 74, 35, | ||
| 665 | 13, 37, 12, 39, 40, 41, 10, 11, 8, 9, | ||
| 666 | 30, 36, 6, 7, 42, 43, 26, 44, 45, 25, | ||
| 667 | 56, 23, 23, 55, 55, 65, 62, 66, 67, 68, | ||
| 668 | 69, 70, 70, 71, 71, 71, 71, 72, 72, 73, | ||
| 669 | 73, 74, 74, 74, 15, 16, 17, 22, 57, 76, | ||
| 670 | 77, 25, 55, 38, 17, 17, 25, 29, 55, 57, | ||
| 671 | 77, 28, 57, 76, 63, 25, 25, 58, 59, 25, | ||
| 672 | 22, 25, 34, 14, 21, 22, 23, 24, 31, 36, | ||
| 673 | 60, 18, 33, 75, 22, 23, 30, 61, 36, 21, | ||
| 674 | 20, 22, 32, 34, 35, 61, 34, 61, 35 | ||
| 675 | }; | ||
| 676 | |||
| 677 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
| 678 | static const yytype_uint8 yyr1[] = | ||
| 679 | { | ||
| 680 | 0, 48, 49, 50, 50, 51, 51, 52, 52, 53, | ||
| 681 | 53, 54, 54, 54, 54, 54, 54, 55, 56, 56, | ||
| 682 | 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, | ||
| 683 | 58, 59, 59, 59, 60, 60, 60, 60, 60, 61, | ||
| 684 | 61, 61, 62, 63, 63, 64, 64, 65, 65, 66, | ||
| 685 | 66, 67, 67, 68, 68, 69, 69, 69, 70, 70, | ||
| 686 | 70, 70, 70, 71, 71, 71, 72, 72, 72, 73, | ||
| 687 | 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, | ||
| 688 | 76, 76, 76, 77, 77, 77 | ||
| 689 | }; | ||
| 690 | |||
| 691 | /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ | ||
| 692 | static const yytype_uint8 yyr2[] = | ||
| 693 | { | ||
| 694 | 0, 2, 3, 2, 4, 1, 2, 0, 2, 4, | ||
| 695 | 2, 2, 3, 4, 3, 4, 0, 5, 0, 2, | ||
| 696 | 4, 2, 3, 2, 2, 3, 4, 2, 9, 5, | ||
| 697 | 2, 0, 2, 2, 3, 1, 2, 2, 2, 1, | ||
| 698 | 1, 3, 1, 1, 5, 1, 3, 1, 3, 1, | ||
| 699 | 3, 1, 3, 1, 3, 1, 3, 3, 1, 3, | ||
| 700 | 3, 3, 3, 3, 3, 1, 3, 3, 1, 3, | ||
| 701 | 3, 3, 1, 1, 2, 2, 2, 0, 2, 2, | ||
| 702 | 0, 2, 2, 2, 3, 2 | ||
| 703 | }; | ||
| 704 | |||
| 705 | |||
| 706 | #define yyerrok (yyerrstatus = 0) | ||
| 707 | #define yyclearin (yychar = YYEMPTY) | ||
| 708 | #define YYEMPTY (-2) | ||
| 709 | #define YYEOF 0 | ||
| 710 | |||
| 711 | #define YYACCEPT goto yyacceptlab | ||
| 712 | #define YYABORT goto yyabortlab | ||
| 713 | #define YYERROR goto yyerrorlab | ||
| 714 | |||
| 715 | |||
| 716 | #define YYRECOVERING() (!!yyerrstatus) | ||
| 717 | |||
| 718 | #define YYBACKUP(Token, Value) \ | ||
| 719 | do \ | ||
| 720 | if (yychar == YYEMPTY) \ | ||
| 721 | { \ | ||
| 722 | yychar = (Token); \ | ||
| 723 | yylval = (Value); \ | ||
| 724 | YYPOPSTACK (yylen); \ | ||
| 725 | yystate = *yyssp; \ | ||
| 726 | goto yybackup; \ | ||
| 727 | } \ | ||
| 728 | else \ | ||
| 729 | { \ | ||
| 730 | yyerror (YY_("syntax error: cannot back up")); \ | ||
| 731 | YYERROR; \ | ||
| 732 | } \ | ||
| 733 | while (0) | ||
| 734 | |||
| 735 | /* Error token number */ | ||
| 736 | #define YYTERROR 1 | ||
| 737 | #define YYERRCODE 256 | ||
| 738 | |||
| 739 | |||
| 740 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | ||
| 741 | If N is 0, then set CURRENT to the empty location which ends | ||
| 742 | the previous symbol: RHS[0] (always defined). */ | ||
| 743 | |||
| 744 | #ifndef YYLLOC_DEFAULT | ||
| 745 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
| 746 | do \ | ||
| 747 | if (N) \ | ||
| 748 | { \ | ||
| 749 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ | ||
| 750 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ | ||
| 751 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ | ||
| 752 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ | ||
| 753 | } \ | ||
| 754 | else \ | ||
| 755 | { \ | ||
| 756 | (Current).first_line = (Current).last_line = \ | ||
| 757 | YYRHSLOC (Rhs, 0).last_line; \ | ||
| 758 | (Current).first_column = (Current).last_column = \ | ||
| 759 | YYRHSLOC (Rhs, 0).last_column; \ | ||
| 760 | } \ | ||
| 761 | while (0) | ||
| 762 | #endif | ||
| 763 | |||
| 764 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) | ||
| 765 | |||
| 766 | |||
| 767 | /* Enable debugging if requested. */ | ||
| 768 | #if YYDEBUG | ||
| 769 | |||
| 770 | # ifndef YYFPRINTF | ||
| 771 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 772 | # define YYFPRINTF fprintf | ||
| 773 | # endif | ||
| 774 | |||
| 775 | # define YYDPRINTF(Args) \ | ||
| 776 | do { \ | ||
| 777 | if (yydebug) \ | ||
| 778 | YYFPRINTF Args; \ | ||
| 779 | } while (0) | ||
| 780 | |||
| 781 | |||
| 782 | /* YY_LOCATION_PRINT -- Print the location on the stream. | ||
| 783 | This macro was not mandated originally: define only if we know | ||
| 784 | we won't break user code: when these are the locations we know. */ | ||
| 785 | |||
| 786 | #ifndef YY_LOCATION_PRINT | ||
| 787 | # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL | ||
| 788 | |||
| 789 | /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ | ||
| 790 | |||
| 791 | YY_ATTRIBUTE_UNUSED | ||
| 792 | static unsigned | ||
| 793 | yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) | ||
| 794 | { | ||
| 795 | unsigned res = 0; | ||
| 796 | int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; | ||
| 797 | if (0 <= yylocp->first_line) | ||
| 798 | { | ||
| 799 | res += YYFPRINTF (yyo, "%d", yylocp->first_line); | ||
| 800 | if (0 <= yylocp->first_column) | ||
| 801 | res += YYFPRINTF (yyo, ".%d", yylocp->first_column); | ||
| 802 | } | ||
| 803 | if (0 <= yylocp->last_line) | ||
| 804 | { | ||
| 805 | if (yylocp->first_line < yylocp->last_line) | ||
| 806 | { | ||
| 807 | res += YYFPRINTF (yyo, "-%d", yylocp->last_line); | ||
| 808 | if (0 <= end_col) | ||
| 809 | res += YYFPRINTF (yyo, ".%d", end_col); | ||
| 810 | } | ||
| 811 | else if (0 <= end_col && yylocp->first_column < end_col) | ||
| 812 | res += YYFPRINTF (yyo, "-%d", end_col); | ||
| 813 | } | ||
| 814 | return res; | ||
| 815 | } | ||
| 816 | |||
| 817 | # define YY_LOCATION_PRINT(File, Loc) \ | ||
| 818 | yy_location_print_ (File, &(Loc)) | ||
| 819 | |||
| 820 | # else | ||
| 821 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | ||
| 822 | # endif | ||
| 823 | #endif | ||
| 824 | |||
| 825 | |||
| 826 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | ||
| 827 | do { \ | ||
| 828 | if (yydebug) \ | ||
| 829 | { \ | ||
| 830 | YYFPRINTF (stderr, "%s ", Title); \ | ||
| 831 | yy_symbol_print (stderr, \ | ||
| 832 | Type, Value, Location); \ | ||
| 833 | YYFPRINTF (stderr, "\n"); \ | ||
| 834 | } \ | ||
| 835 | } while (0) | ||
| 836 | |||
| 837 | |||
| 838 | /*----------------------------------------. | ||
| 839 | | Print this symbol's value on YYOUTPUT. | | ||
| 840 | `----------------------------------------*/ | ||
| 841 | |||
| 842 | static void | ||
| 843 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) | ||
| 844 | { | ||
| 845 | FILE *yyo = yyoutput; | ||
| 846 | YYUSE (yyo); | ||
| 847 | YYUSE (yylocationp); | ||
| 848 | if (!yyvaluep) | ||
| 849 | return; | ||
| 850 | # ifdef YYPRINT | ||
| 851 | if (yytype < YYNTOKENS) | ||
| 852 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
| 853 | # endif | ||
| 854 | YYUSE (yytype); | ||
| 855 | } | ||
| 856 | |||
| 857 | |||
| 858 | /*--------------------------------. | ||
| 859 | | Print this symbol on YYOUTPUT. | | ||
| 860 | `--------------------------------*/ | ||
| 861 | |||
| 862 | static void | ||
| 863 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) | ||
| 864 | { | ||
| 865 | YYFPRINTF (yyoutput, "%s %s (", | ||
| 866 | yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); | ||
| 867 | |||
| 868 | YY_LOCATION_PRINT (yyoutput, *yylocationp); | ||
| 869 | YYFPRINTF (yyoutput, ": "); | ||
| 870 | yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); | ||
| 871 | YYFPRINTF (yyoutput, ")"); | ||
| 872 | } | ||
| 873 | |||
| 874 | /*------------------------------------------------------------------. | ||
| 875 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | ||
| 876 | | TOP (included). | | ||
| 877 | `------------------------------------------------------------------*/ | ||
| 878 | |||
| 879 | static void | ||
| 880 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | ||
| 881 | { | ||
| 882 | YYFPRINTF (stderr, "Stack now"); | ||
| 883 | for (; yybottom <= yytop; yybottom++) | ||
| 884 | { | ||
| 885 | int yybot = *yybottom; | ||
| 886 | YYFPRINTF (stderr, " %d", yybot); | ||
| 887 | } | ||
| 888 | YYFPRINTF (stderr, "\n"); | ||
| 889 | } | ||
| 890 | |||
| 891 | # define YY_STACK_PRINT(Bottom, Top) \ | ||
| 892 | do { \ | ||
| 893 | if (yydebug) \ | ||
| 894 | yy_stack_print ((Bottom), (Top)); \ | ||
| 895 | } while (0) | ||
| 896 | |||
| 897 | |||
| 898 | /*------------------------------------------------. | ||
| 899 | | Report that the YYRULE is going to be reduced. | | ||
| 900 | `------------------------------------------------*/ | ||
| 901 | |||
| 902 | static void | ||
| 903 | yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) | ||
| 904 | { | ||
| 905 | unsigned long int yylno = yyrline[yyrule]; | ||
| 906 | int yynrhs = yyr2[yyrule]; | ||
| 907 | int yyi; | ||
| 908 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | ||
| 909 | yyrule - 1, yylno); | ||
| 910 | /* The symbols being reduced. */ | ||
| 911 | for (yyi = 0; yyi < yynrhs; yyi++) | ||
| 912 | { | ||
| 913 | YYFPRINTF (stderr, " $%d = ", yyi + 1); | ||
| 914 | yy_symbol_print (stderr, | ||
| 915 | yystos[yyssp[yyi + 1 - yynrhs]], | ||
| 916 | &(yyvsp[(yyi + 1) - (yynrhs)]) | ||
| 917 | , &(yylsp[(yyi + 1) - (yynrhs)]) ); | ||
| 918 | YYFPRINTF (stderr, "\n"); | ||
| 919 | } | ||
| 920 | } | ||
| 921 | |||
| 922 | # define YY_REDUCE_PRINT(Rule) \ | ||
| 923 | do { \ | ||
| 924 | if (yydebug) \ | ||
| 925 | yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \ | ||
| 926 | } while (0) | ||
| 927 | |||
| 928 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
| 929 | multiple parsers can coexist. */ | ||
| 930 | int yydebug; | ||
| 931 | #else /* !YYDEBUG */ | ||
| 932 | # define YYDPRINTF(Args) | ||
| 933 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) | ||
| 934 | # define YY_STACK_PRINT(Bottom, Top) | ||
| 935 | # define YY_REDUCE_PRINT(Rule) | ||
| 936 | #endif /* !YYDEBUG */ | ||
| 937 | |||
| 938 | |||
| 939 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
| 940 | #ifndef YYINITDEPTH | ||
| 941 | # define YYINITDEPTH 200 | ||
| 942 | #endif | ||
| 943 | |||
| 944 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
| 945 | if the built-in stack extension method is used). | ||
| 946 | |||
| 947 | Do not make this value too large; the results are undefined if | ||
| 948 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | ||
| 949 | evaluated with infinite-precision integer arithmetic. */ | ||
| 950 | |||
| 951 | #ifndef YYMAXDEPTH | ||
| 952 | # define YYMAXDEPTH 10000 | ||
| 953 | #endif | ||
| 954 | |||
| 955 | |||
| 956 | #if YYERROR_VERBOSE | ||
| 957 | |||
| 958 | # ifndef yystrlen | ||
| 959 | # if defined __GLIBC__ && defined _STRING_H | ||
| 960 | # define yystrlen strlen | ||
| 961 | # else | ||
| 962 | /* Return the length of YYSTR. */ | ||
| 963 | static YYSIZE_T | ||
| 964 | yystrlen (const char *yystr) | ||
| 965 | { | ||
| 966 | YYSIZE_T yylen; | ||
| 967 | for (yylen = 0; yystr[yylen]; yylen++) | ||
| 968 | continue; | ||
| 969 | return yylen; | ||
| 970 | } | ||
| 971 | # endif | ||
| 972 | # endif | ||
| 973 | |||
| 974 | # ifndef yystpcpy | ||
| 975 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | ||
| 976 | # define yystpcpy stpcpy | ||
| 977 | # else | ||
| 978 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
| 979 | YYDEST. */ | ||
| 980 | static char * | ||
| 981 | yystpcpy (char *yydest, const char *yysrc) | ||
| 982 | { | ||
| 983 | char *yyd = yydest; | ||
| 984 | const char *yys = yysrc; | ||
| 985 | |||
| 986 | while ((*yyd++ = *yys++) != '\0') | ||
| 987 | continue; | ||
| 988 | |||
| 989 | return yyd - 1; | ||
| 990 | } | ||
| 991 | # endif | ||
| 992 | # endif | ||
| 993 | |||
| 994 | # ifndef yytnamerr | ||
| 995 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | ||
| 996 | quotes and backslashes, so that it's suitable for yyerror. The | ||
| 997 | heuristic is that double-quoting is unnecessary unless the string | ||
| 998 | contains an apostrophe, a comma, or backslash (other than | ||
| 999 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | ||
| 1000 | null, do not copy; instead, return the length of what the result | ||
| 1001 | would have been. */ | ||
| 1002 | static YYSIZE_T | ||
| 1003 | yytnamerr (char *yyres, const char *yystr) | ||
| 1004 | { | ||
| 1005 | if (*yystr == '"') | ||
| 1006 | { | ||
| 1007 | YYSIZE_T yyn = 0; | ||
| 1008 | char const *yyp = yystr; | ||
| 1009 | |||
| 1010 | for (;;) | ||
| 1011 | switch (*++yyp) | ||
| 1012 | { | ||
| 1013 | case '\'': | ||
| 1014 | case ',': | ||
| 1015 | goto do_not_strip_quotes; | ||
| 1016 | |||
| 1017 | case '\\': | ||
| 1018 | if (*++yyp != '\\') | ||
| 1019 | goto do_not_strip_quotes; | ||
| 1020 | /* Fall through. */ | ||
| 1021 | default: | ||
| 1022 | if (yyres) | ||
| 1023 | yyres[yyn] = *yyp; | ||
| 1024 | yyn++; | ||
| 1025 | break; | ||
| 1026 | |||
| 1027 | case '"': | ||
| 1028 | if (yyres) | ||
| 1029 | yyres[yyn] = '\0'; | ||
| 1030 | return yyn; | ||
| 1031 | } | ||
| 1032 | do_not_strip_quotes: ; | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | if (! yyres) | ||
| 1036 | return yystrlen (yystr); | ||
| 1037 | |||
| 1038 | return yystpcpy (yyres, yystr) - yyres; | ||
| 1039 | } | ||
| 1040 | # endif | ||
| 1041 | |||
| 1042 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message | ||
| 1043 | about the unexpected token YYTOKEN for the state stack whose top is | ||
| 1044 | YYSSP. | ||
| 1045 | |||
| 1046 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is | ||
| 1047 | not large enough to hold the message. In that case, also set | ||
| 1048 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the | ||
| 1049 | required number of bytes is too large to store. */ | ||
| 1050 | static int | ||
| 1051 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | ||
| 1052 | yytype_int16 *yyssp, int yytoken) | ||
| 1053 | { | ||
| 1054 | YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); | ||
| 1055 | YYSIZE_T yysize = yysize0; | ||
| 1056 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | ||
| 1057 | /* Internationalized format string. */ | ||
| 1058 | const char *yyformat = YY_NULLPTR; | ||
| 1059 | /* Arguments of yyformat. */ | ||
| 1060 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | ||
| 1061 | /* Number of reported tokens (one for the "unexpected", one per | ||
| 1062 | "expected"). */ | ||
| 1063 | int yycount = 0; | ||
| 1064 | |||
| 1065 | /* There are many possibilities here to consider: | ||
| 1066 | - If this state is a consistent state with a default action, then | ||
| 1067 | the only way this function was invoked is if the default action | ||
| 1068 | is an error action. In that case, don't check for expected | ||
| 1069 | tokens because there are none. | ||
| 1070 | - The only way there can be no lookahead present (in yychar) is if | ||
| 1071 | this state is a consistent state with a default action. Thus, | ||
| 1072 | detecting the absence of a lookahead is sufficient to determine | ||
| 1073 | that there is no unexpected or expected token to report. In that | ||
| 1074 | case, just report a simple "syntax error". | ||
| 1075 | - Don't assume there isn't a lookahead just because this state is a | ||
| 1076 | consistent state with a default action. There might have been a | ||
| 1077 | previous inconsistent state, consistent state with a non-default | ||
| 1078 | action, or user semantic action that manipulated yychar. | ||
| 1079 | - Of course, the expected token list depends on states to have | ||
| 1080 | correct lookahead information, and it depends on the parser not | ||
| 1081 | to perform extra reductions after fetching a lookahead from the | ||
| 1082 | scanner and before detecting a syntax error. Thus, state merging | ||
| 1083 | (from LALR or IELR) and default reductions corrupt the expected | ||
| 1084 | token list. However, the list is correct for canonical LR with | ||
| 1085 | one exception: it will still contain any token that will not be | ||
| 1086 | accepted due to an error action in a later state. | ||
| 1087 | */ | ||
| 1088 | if (yytoken != YYEMPTY) | ||
| 1089 | { | ||
| 1090 | int yyn = yypact[*yyssp]; | ||
| 1091 | yyarg[yycount++] = yytname[yytoken]; | ||
| 1092 | if (!yypact_value_is_default (yyn)) | ||
| 1093 | { | ||
| 1094 | /* Start YYX at -YYN if negative to avoid negative indexes in | ||
| 1095 | YYCHECK. In other words, skip the first -YYN actions for | ||
| 1096 | this state because they are default actions. */ | ||
| 1097 | int yyxbegin = yyn < 0 ? -yyn : 0; | ||
| 1098 | /* Stay within bounds of both yycheck and yytname. */ | ||
| 1099 | int yychecklim = YYLAST - yyn + 1; | ||
| 1100 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | ||
| 1101 | int yyx; | ||
| 1102 | |||
| 1103 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | ||
| 1104 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR | ||
| 1105 | && !yytable_value_is_error (yytable[yyx + yyn])) | ||
| 1106 | { | ||
| 1107 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | ||
| 1108 | { | ||
| 1109 | yycount = 1; | ||
| 1110 | yysize = yysize0; | ||
| 1111 | break; | ||
| 1112 | } | ||
| 1113 | yyarg[yycount++] = yytname[yyx]; | ||
| 1114 | { | ||
| 1115 | YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); | ||
| 1116 | if (! (yysize <= yysize1 | ||
| 1117 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1118 | return 2; | ||
| 1119 | yysize = yysize1; | ||
| 1120 | } | ||
| 1121 | } | ||
| 1122 | } | ||
| 1123 | } | ||
| 1124 | |||
| 1125 | switch (yycount) | ||
| 1126 | { | ||
| 1127 | # define YYCASE_(N, S) \ | ||
| 1128 | case N: \ | ||
| 1129 | yyformat = S; \ | ||
| 1130 | break | ||
| 1131 | YYCASE_(0, YY_("syntax error")); | ||
| 1132 | YYCASE_(1, YY_("syntax error, unexpected %s")); | ||
| 1133 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | ||
| 1134 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | ||
| 1135 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | ||
| 1136 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | ||
| 1137 | # undef YYCASE_ | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | { | ||
| 1141 | YYSIZE_T yysize1 = yysize + yystrlen (yyformat); | ||
| 1142 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1143 | return 2; | ||
| 1144 | yysize = yysize1; | ||
| 1145 | } | ||
| 1146 | |||
| 1147 | if (*yymsg_alloc < yysize) | ||
| 1148 | { | ||
| 1149 | *yymsg_alloc = 2 * yysize; | ||
| 1150 | if (! (yysize <= *yymsg_alloc | ||
| 1151 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1152 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; | ||
| 1153 | return 1; | ||
| 1154 | } | ||
| 1155 | |||
| 1156 | /* Avoid sprintf, as that infringes on the user's name space. | ||
| 1157 | Don't have undefined behavior even if the translation | ||
| 1158 | produced a string with the wrong number of "%s"s. */ | ||
| 1159 | { | ||
| 1160 | char *yyp = *yymsg; | ||
| 1161 | int yyi = 0; | ||
| 1162 | while ((*yyp = *yyformat) != '\0') | ||
| 1163 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) | ||
| 1164 | { | ||
| 1165 | yyp += yytnamerr (yyp, yyarg[yyi++]); | ||
| 1166 | yyformat += 2; | ||
| 1167 | } | ||
| 1168 | else | ||
| 1169 | { | ||
| 1170 | yyp++; | ||
| 1171 | yyformat++; | ||
| 1172 | } | ||
| 1173 | } | ||
| 1174 | return 0; | ||
| 1175 | } | ||
| 1176 | #endif /* YYERROR_VERBOSE */ | ||
| 1177 | |||
| 1178 | /*-----------------------------------------------. | ||
| 1179 | | Release the memory associated to this symbol. | | ||
| 1180 | `-----------------------------------------------*/ | ||
| 1181 | |||
| 1182 | static void | ||
| 1183 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) | ||
| 1184 | { | ||
| 1185 | YYUSE (yyvaluep); | ||
| 1186 | YYUSE (yylocationp); | ||
| 1187 | if (!yymsg) | ||
| 1188 | yymsg = "Deleting"; | ||
| 1189 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | ||
| 1190 | |||
| 1191 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1192 | YYUSE (yytype); | ||
| 1193 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | |||
| 1197 | |||
| 1198 | |||
| 1199 | /* The lookahead symbol. */ | ||
| 1200 | int yychar; | ||
| 1201 | |||
| 1202 | /* The semantic value of the lookahead symbol. */ | ||
| 1203 | YYSTYPE yylval; | ||
| 1204 | /* Location data for the lookahead symbol. */ | ||
| 1205 | YYLTYPE yylloc | ||
| 1206 | # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL | ||
| 1207 | = { 1, 1, 1, 1 } | ||
| 1208 | # endif | ||
| 1209 | ; | ||
| 1210 | /* Number of syntax errors so far. */ | ||
| 1211 | int yynerrs; | ||
| 1212 | |||
| 1213 | |||
| 1214 | /*----------. | ||
| 1215 | | yyparse. | | ||
| 1216 | `----------*/ | ||
| 1217 | |||
| 1218 | int | ||
| 1219 | yyparse (void) | ||
| 1220 | { | ||
| 1221 | int yystate; | ||
| 1222 | /* Number of tokens to shift before error messages enabled. */ | ||
| 1223 | int yyerrstatus; | ||
| 1224 | |||
| 1225 | /* The stacks and their tools: | ||
| 1226 | 'yyss': related to states. | ||
| 1227 | 'yyvs': related to semantic values. | ||
| 1228 | 'yyls': related to locations. | ||
| 1229 | |||
| 1230 | Refer to the stacks through separate pointers, to allow yyoverflow | ||
| 1231 | to reallocate them elsewhere. */ | ||
| 1232 | |||
| 1233 | /* The state stack. */ | ||
| 1234 | yytype_int16 yyssa[YYINITDEPTH]; | ||
| 1235 | yytype_int16 *yyss; | ||
| 1236 | yytype_int16 *yyssp; | ||
| 1237 | |||
| 1238 | /* The semantic value stack. */ | ||
| 1239 | YYSTYPE yyvsa[YYINITDEPTH]; | ||
| 1240 | YYSTYPE *yyvs; | ||
| 1241 | YYSTYPE *yyvsp; | ||
| 1242 | |||
| 1243 | /* The location stack. */ | ||
| 1244 | YYLTYPE yylsa[YYINITDEPTH]; | ||
| 1245 | YYLTYPE *yyls; | ||
| 1246 | YYLTYPE *yylsp; | ||
| 1247 | |||
| 1248 | /* The locations where the error started and ended. */ | ||
| 1249 | YYLTYPE yyerror_range[3]; | ||
| 1250 | |||
| 1251 | YYSIZE_T yystacksize; | ||
| 1252 | |||
| 1253 | int yyn; | ||
| 1254 | int yyresult; | ||
| 1255 | /* Lookahead token as an internal (translated) token number. */ | ||
| 1256 | int yytoken = 0; | ||
| 1257 | /* The variables used to return semantic value and location from the | ||
| 1258 | action routines. */ | ||
| 1259 | YYSTYPE yyval; | ||
| 1260 | YYLTYPE yyloc; | ||
| 1261 | |||
| 1262 | #if YYERROR_VERBOSE | ||
| 1263 | /* Buffer for error messages, and its allocated size. */ | ||
| 1264 | char yymsgbuf[128]; | ||
| 1265 | char *yymsg = yymsgbuf; | ||
| 1266 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | ||
| 1267 | #endif | ||
| 1268 | |||
| 1269 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) | ||
| 1270 | |||
| 1271 | /* The number of symbols on the RHS of the reduced rule. | ||
| 1272 | Keep to zero when no symbol should be popped. */ | ||
| 1273 | int yylen = 0; | ||
| 1274 | |||
| 1275 | yyssp = yyss = yyssa; | ||
| 1276 | yyvsp = yyvs = yyvsa; | ||
| 1277 | yylsp = yyls = yylsa; | ||
| 1278 | yystacksize = YYINITDEPTH; | ||
| 1279 | |||
| 1280 | YYDPRINTF ((stderr, "Starting parse\n")); | ||
| 1281 | |||
| 1282 | yystate = 0; | ||
| 1283 | yyerrstatus = 0; | ||
| 1284 | yynerrs = 0; | ||
| 1285 | yychar = YYEMPTY; /* Cause a token to be read. */ | ||
| 1286 | yylsp[0] = yylloc; | ||
| 1287 | goto yysetstate; | ||
| 1288 | |||
| 1289 | /*------------------------------------------------------------. | ||
| 1290 | | yynewstate -- Push a new state, which is found in yystate. | | ||
| 1291 | `------------------------------------------------------------*/ | ||
| 1292 | yynewstate: | ||
| 1293 | /* In all cases, when you get here, the value and location stacks | ||
| 1294 | have just been pushed. So pushing a state here evens the stacks. */ | ||
| 1295 | yyssp++; | ||
| 1296 | |||
| 1297 | yysetstate: | ||
| 1298 | *yyssp = yystate; | ||
| 1299 | |||
| 1300 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 1301 | { | ||
| 1302 | /* Get the current used size of the three stacks, in elements. */ | ||
| 1303 | YYSIZE_T yysize = yyssp - yyss + 1; | ||
| 1304 | |||
| 1305 | #ifdef yyoverflow | ||
| 1306 | { | ||
| 1307 | /* Give user a chance to reallocate the stack. Use copies of | ||
| 1308 | these so that the &'s don't force the real ones into | ||
| 1309 | memory. */ | ||
| 1310 | YYSTYPE *yyvs1 = yyvs; | ||
| 1311 | yytype_int16 *yyss1 = yyss; | ||
| 1312 | YYLTYPE *yyls1 = yyls; | ||
| 1313 | |||
| 1314 | /* Each stack pointer address is followed by the size of the | ||
| 1315 | data in use in that stack, in bytes. This used to be a | ||
| 1316 | conditional around just the two extra args, but that might | ||
| 1317 | be undefined if yyoverflow is a macro. */ | ||
| 1318 | yyoverflow (YY_("memory exhausted"), | ||
| 1319 | &yyss1, yysize * sizeof (*yyssp), | ||
| 1320 | &yyvs1, yysize * sizeof (*yyvsp), | ||
| 1321 | &yyls1, yysize * sizeof (*yylsp), | ||
| 1322 | &yystacksize); | ||
| 1323 | |||
| 1324 | yyls = yyls1; | ||
| 1325 | yyss = yyss1; | ||
| 1326 | yyvs = yyvs1; | ||
| 1327 | } | ||
| 1328 | #else /* no yyoverflow */ | ||
| 1329 | # ifndef YYSTACK_RELOCATE | ||
| 1330 | goto yyexhaustedlab; | ||
| 1331 | # else | ||
| 1332 | /* Extend the stack our own way. */ | ||
| 1333 | if (YYMAXDEPTH <= yystacksize) | ||
| 1334 | goto yyexhaustedlab; | ||
| 1335 | yystacksize *= 2; | ||
| 1336 | if (YYMAXDEPTH < yystacksize) | ||
| 1337 | yystacksize = YYMAXDEPTH; | ||
| 1338 | |||
| 1339 | { | ||
| 1340 | yytype_int16 *yyss1 = yyss; | ||
| 1341 | union yyalloc *yyptr = | ||
| 1342 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
| 1343 | if (! yyptr) | ||
| 1344 | goto yyexhaustedlab; | ||
| 1345 | YYSTACK_RELOCATE (yyss_alloc, yyss); | ||
| 1346 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); | ||
| 1347 | YYSTACK_RELOCATE (yyls_alloc, yyls); | ||
| 1348 | # undef YYSTACK_RELOCATE | ||
| 1349 | if (yyss1 != yyssa) | ||
| 1350 | YYSTACK_FREE (yyss1); | ||
| 1351 | } | ||
| 1352 | # endif | ||
| 1353 | #endif /* no yyoverflow */ | ||
| 1354 | |||
| 1355 | yyssp = yyss + yysize - 1; | ||
| 1356 | yyvsp = yyvs + yysize - 1; | ||
| 1357 | yylsp = yyls + yysize - 1; | ||
| 1358 | |||
| 1359 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
| 1360 | (unsigned long int) yystacksize)); | ||
| 1361 | |||
| 1362 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 1363 | YYABORT; | ||
| 1364 | } | ||
| 1365 | |||
| 1366 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
| 1367 | |||
| 1368 | if (yystate == YYFINAL) | ||
| 1369 | YYACCEPT; | ||
| 1370 | |||
| 1371 | goto yybackup; | ||
| 1372 | |||
| 1373 | /*-----------. | ||
| 1374 | | yybackup. | | ||
| 1375 | `-----------*/ | ||
| 1376 | yybackup: | ||
| 1377 | |||
| 1378 | /* Do appropriate processing given the current state. Read a | ||
| 1379 | lookahead token if we need one and don't already have one. */ | ||
| 1380 | |||
| 1381 | /* First try to decide what to do without reference to lookahead token. */ | ||
| 1382 | yyn = yypact[yystate]; | ||
| 1383 | if (yypact_value_is_default (yyn)) | ||
| 1384 | goto yydefault; | ||
| 1385 | |||
| 1386 | /* Not known => get a lookahead token if don't already have one. */ | ||
| 1387 | |||
| 1388 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | ||
| 1389 | if (yychar == YYEMPTY) | ||
| 1390 | { | ||
| 1391 | YYDPRINTF ((stderr, "Reading a token: ")); | ||
| 1392 | yychar = yylex (); | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | if (yychar <= YYEOF) | ||
| 1396 | { | ||
| 1397 | yychar = yytoken = YYEOF; | ||
| 1398 | YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
| 1399 | } | ||
| 1400 | else | ||
| 1401 | { | ||
| 1402 | yytoken = YYTRANSLATE (yychar); | ||
| 1403 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | ||
| 1404 | } | ||
| 1405 | |||
| 1406 | /* If the proper action on seeing token YYTOKEN is to reduce or to | ||
| 1407 | detect an error, take that action. */ | ||
| 1408 | yyn += yytoken; | ||
| 1409 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | ||
| 1410 | goto yydefault; | ||
| 1411 | yyn = yytable[yyn]; | ||
| 1412 | if (yyn <= 0) | ||
| 1413 | { | ||
| 1414 | if (yytable_value_is_error (yyn)) | ||
| 1415 | goto yyerrlab; | ||
| 1416 | yyn = -yyn; | ||
| 1417 | goto yyreduce; | ||
| 1418 | } | ||
| 1419 | |||
| 1420 | /* Count tokens shifted since error; after three, turn off error | ||
| 1421 | status. */ | ||
| 1422 | if (yyerrstatus) | ||
| 1423 | yyerrstatus--; | ||
| 1424 | |||
| 1425 | /* Shift the lookahead token. */ | ||
| 1426 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | ||
| 1427 | |||
| 1428 | /* Discard the shifted token. */ | ||
| 1429 | yychar = YYEMPTY; | ||
| 1430 | |||
| 1431 | yystate = yyn; | ||
| 1432 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1433 | *++yyvsp = yylval; | ||
| 1434 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1435 | *++yylsp = yylloc; | ||
| 1436 | goto yynewstate; | ||
| 1437 | |||
| 1438 | |||
| 1439 | /*-----------------------------------------------------------. | ||
| 1440 | | yydefault -- do the default action for the current state. | | ||
| 1441 | `-----------------------------------------------------------*/ | ||
| 1442 | yydefault: | ||
| 1443 | yyn = yydefact[yystate]; | ||
| 1444 | if (yyn == 0) | ||
| 1445 | goto yyerrlab; | ||
| 1446 | goto yyreduce; | ||
| 1447 | |||
| 1448 | |||
| 1449 | /*-----------------------------. | ||
| 1450 | | yyreduce -- Do a reduction. | | ||
| 1451 | `-----------------------------*/ | ||
| 1452 | yyreduce: | ||
| 1453 | /* yyn is the number of a rule to reduce with. */ | ||
| 1454 | yylen = yyr2[yyn]; | ||
| 1455 | |||
| 1456 | /* If YYLEN is nonzero, implement the default value of the action: | ||
| 1457 | '$$ = $1'. | ||
| 1458 | |||
| 1459 | Otherwise, the following line sets YYVAL to garbage. | ||
| 1460 | This behavior is undocumented and Bison | ||
| 1461 | users should not rely upon it. Assigning to YYVAL | ||
| 1462 | unconditionally makes the parser a bit smaller, and it avoids a | ||
| 1463 | GCC warning that YYVAL may be used uninitialized. */ | ||
| 1464 | yyval = yyvsp[1-yylen]; | ||
| 1465 | |||
| 1466 | /* Default location. */ | ||
| 1467 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); | ||
| 1468 | YY_REDUCE_PRINT (yyn); | ||
| 1469 | switch (yyn) | ||
| 1470 | { | ||
| 1471 | case 2: | ||
| 1472 | #line 110 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1473 | { | ||
| 1474 | parser_output = build_dt_info((yyvsp[-2].flags), (yyvsp[-1].re), (yyvsp[0].node), | ||
| 1475 | guess_boot_cpuid((yyvsp[0].node))); | ||
| 1476 | } | ||
| 1477 | #line 1478 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1478 | break; | ||
| 1479 | |||
| 1480 | case 3: | ||
| 1481 | #line 118 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1482 | { | ||
| 1483 | (yyval.flags) = DTSF_V1; | ||
| 1484 | } | ||
| 1485 | #line 1486 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1486 | break; | ||
| 1487 | |||
| 1488 | case 4: | ||
| 1489 | #line 122 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1490 | { | ||
| 1491 | (yyval.flags) = DTSF_V1 | DTSF_PLUGIN; | ||
| 1492 | } | ||
| 1493 | #line 1494 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1494 | break; | ||
| 1495 | |||
| 1496 | case 6: | ||
| 1497 | #line 130 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1498 | { | ||
| 1499 | if ((yyvsp[0].flags) != (yyvsp[-1].flags)) | ||
| 1500 | ERROR(&(yylsp[0]), "Header flags don't match earlier ones"); | ||
| 1501 | (yyval.flags) = (yyvsp[-1].flags); | ||
| 1502 | } | ||
| 1503 | #line 1504 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1504 | break; | ||
| 1505 | |||
| 1506 | case 7: | ||
| 1507 | #line 139 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1508 | { | ||
| 1509 | (yyval.re) = NULL; | ||
| 1510 | } | ||
| 1511 | #line 1512 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1512 | break; | ||
| 1513 | |||
| 1514 | case 8: | ||
| 1515 | #line 143 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1516 | { | ||
| 1517 | (yyval.re) = chain_reserve_entry((yyvsp[-1].re), (yyvsp[0].re)); | ||
| 1518 | } | ||
| 1519 | #line 1520 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1520 | break; | ||
| 1521 | |||
| 1522 | case 9: | ||
| 1523 | #line 150 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1524 | { | ||
| 1525 | (yyval.re) = build_reserve_entry((yyvsp[-2].integer), (yyvsp[-1].integer)); | ||
| 1526 | } | ||
| 1527 | #line 1528 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1528 | break; | ||
| 1529 | |||
| 1530 | case 10: | ||
| 1531 | #line 154 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1532 | { | ||
| 1533 | add_label(&(yyvsp[0].re)->labels, (yyvsp[-1].labelref)); | ||
| 1534 | (yyval.re) = (yyvsp[0].re); | ||
| 1535 | } | ||
| 1536 | #line 1537 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1537 | break; | ||
| 1538 | |||
| 1539 | case 11: | ||
| 1540 | #line 162 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1541 | { | ||
| 1542 | (yyval.node) = name_node((yyvsp[0].node), ""); | ||
| 1543 | } | ||
| 1544 | #line 1545 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1545 | break; | ||
| 1546 | |||
| 1547 | case 12: | ||
| 1548 | #line 166 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1549 | { | ||
| 1550 | (yyval.node) = merge_nodes((yyvsp[-2].node), (yyvsp[0].node)); | ||
| 1551 | } | ||
| 1552 | #line 1553 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1553 | break; | ||
| 1554 | |||
| 1555 | case 13: | ||
| 1556 | #line 171 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1557 | { | ||
| 1558 | struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); | ||
| 1559 | |||
| 1560 | if (target) { | ||
| 1561 | add_label(&target->labels, (yyvsp[-2].labelref)); | ||
| 1562 | merge_nodes(target, (yyvsp[0].node)); | ||
| 1563 | } else | ||
| 1564 | ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); | ||
| 1565 | (yyval.node) = (yyvsp[-3].node); | ||
| 1566 | } | ||
| 1567 | #line 1568 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1568 | break; | ||
| 1569 | |||
| 1570 | case 14: | ||
| 1571 | #line 182 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1572 | { | ||
| 1573 | struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref)); | ||
| 1574 | |||
| 1575 | if (target) { | ||
| 1576 | merge_nodes(target, (yyvsp[0].node)); | ||
| 1577 | } else { | ||
| 1578 | /* | ||
| 1579 | * We rely on the rule being always: | ||
| 1580 | * versioninfo plugindecl memreserves devicetree | ||
| 1581 | * so $-1 is what we want (plugindecl) | ||
| 1582 | */ | ||
| 1583 | if ((yyvsp[(-1) - (3)].flags) & DTSF_PLUGIN) | ||
| 1584 | add_orphan_node((yyvsp[-2].node), (yyvsp[0].node), (yyvsp[-1].labelref)); | ||
| 1585 | else | ||
| 1586 | ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); | ||
| 1587 | } | ||
| 1588 | (yyval.node) = (yyvsp[-2].node); | ||
| 1589 | } | ||
| 1590 | #line 1591 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1591 | break; | ||
| 1592 | |||
| 1593 | case 15: | ||
| 1594 | #line 201 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1595 | { | ||
| 1596 | struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); | ||
| 1597 | |||
| 1598 | if (target) | ||
| 1599 | delete_node(target); | ||
| 1600 | else | ||
| 1601 | ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); | ||
| 1602 | |||
| 1603 | |||
| 1604 | (yyval.node) = (yyvsp[-3].node); | ||
| 1605 | } | ||
| 1606 | #line 1607 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1607 | break; | ||
| 1608 | |||
| 1609 | case 16: | ||
| 1610 | #line 213 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1611 | { | ||
| 1612 | /* build empty node */ | ||
| 1613 | (yyval.node) = name_node(build_node(NULL, NULL), ""); | ||
| 1614 | } | ||
| 1615 | #line 1616 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1616 | break; | ||
| 1617 | |||
| 1618 | case 17: | ||
| 1619 | #line 221 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1620 | { | ||
| 1621 | (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist)); | ||
| 1622 | } | ||
| 1623 | #line 1624 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1624 | break; | ||
| 1625 | |||
| 1626 | case 18: | ||
| 1627 | #line 228 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1628 | { | ||
| 1629 | (yyval.proplist) = NULL; | ||
| 1630 | } | ||
| 1631 | #line 1632 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1632 | break; | ||
| 1633 | |||
| 1634 | case 19: | ||
| 1635 | #line 232 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1636 | { | ||
| 1637 | (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist)); | ||
| 1638 | } | ||
| 1639 | #line 1640 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1640 | break; | ||
| 1641 | |||
| 1642 | case 20: | ||
| 1643 | #line 239 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1644 | { | ||
| 1645 | (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data)); | ||
| 1646 | } | ||
| 1647 | #line 1648 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1648 | break; | ||
| 1649 | |||
| 1650 | case 21: | ||
| 1651 | #line 243 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1652 | { | ||
| 1653 | (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data); | ||
| 1654 | } | ||
| 1655 | #line 1656 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1656 | break; | ||
| 1657 | |||
| 1658 | case 22: | ||
| 1659 | #line 247 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1660 | { | ||
| 1661 | (yyval.prop) = build_property_delete((yyvsp[-1].propnodename)); | ||
| 1662 | } | ||
| 1663 | #line 1664 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1664 | break; | ||
| 1665 | |||
| 1666 | case 23: | ||
| 1667 | #line 251 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1668 | { | ||
| 1669 | add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref)); | ||
| 1670 | (yyval.prop) = (yyvsp[0].prop); | ||
| 1671 | } | ||
| 1672 | #line 1673 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1673 | break; | ||
| 1674 | |||
| 1675 | case 24: | ||
| 1676 | #line 259 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1677 | { | ||
| 1678 | (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data)); | ||
| 1679 | } | ||
| 1680 | #line 1681 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1681 | break; | ||
| 1682 | |||
| 1683 | case 25: | ||
| 1684 | #line 263 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1685 | { | ||
| 1686 | (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data); | ||
| 1687 | } | ||
| 1688 | #line 1689 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1689 | break; | ||
| 1690 | |||
| 1691 | case 26: | ||
| 1692 | #line 267 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1693 | { | ||
| 1694 | (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data)); | ||
| 1695 | } | ||
| 1696 | #line 1697 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1697 | break; | ||
| 1698 | |||
| 1699 | case 27: | ||
| 1700 | #line 271 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1701 | { | ||
| 1702 | (yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref)); | ||
| 1703 | } | ||
| 1704 | #line 1705 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1705 | break; | ||
| 1706 | |||
| 1707 | case 28: | ||
| 1708 | #line 275 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1709 | { | ||
| 1710 | FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL); | ||
| 1711 | struct data d; | ||
| 1712 | |||
| 1713 | if ((yyvsp[-3].integer) != 0) | ||
| 1714 | if (fseek(f, (yyvsp[-3].integer), SEEK_SET) != 0) | ||
| 1715 | die("Couldn't seek to offset %llu in \"%s\": %s", | ||
| 1716 | (unsigned long long)(yyvsp[-3].integer), (yyvsp[-5].data).val, | ||
| 1717 | strerror(errno)); | ||
| 1718 | |||
| 1719 | d = data_copy_file(f, (yyvsp[-1].integer)); | ||
| 1720 | |||
| 1721 | (yyval.data) = data_merge((yyvsp[-8].data), d); | ||
| 1722 | fclose(f); | ||
| 1723 | } | ||
| 1724 | #line 1725 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1725 | break; | ||
| 1726 | |||
| 1727 | case 29: | ||
| 1728 | #line 291 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1729 | { | ||
| 1730 | FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL); | ||
| 1731 | struct data d = empty_data; | ||
| 1732 | |||
| 1733 | d = data_copy_file(f, -1); | ||
| 1734 | |||
| 1735 | (yyval.data) = data_merge((yyvsp[-4].data), d); | ||
| 1736 | fclose(f); | ||
| 1737 | } | ||
| 1738 | #line 1739 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1739 | break; | ||
| 1740 | |||
| 1741 | case 30: | ||
| 1742 | #line 301 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1743 | { | ||
| 1744 | (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); | ||
| 1745 | } | ||
| 1746 | #line 1747 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1747 | break; | ||
| 1748 | |||
| 1749 | case 31: | ||
| 1750 | #line 308 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1751 | { | ||
| 1752 | (yyval.data) = empty_data; | ||
| 1753 | } | ||
| 1754 | #line 1755 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1755 | break; | ||
| 1756 | |||
| 1757 | case 32: | ||
| 1758 | #line 312 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1759 | { | ||
| 1760 | (yyval.data) = (yyvsp[-1].data); | ||
| 1761 | } | ||
| 1762 | #line 1763 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1763 | break; | ||
| 1764 | |||
| 1765 | case 33: | ||
| 1766 | #line 316 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1767 | { | ||
| 1768 | (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); | ||
| 1769 | } | ||
| 1770 | #line 1771 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1771 | break; | ||
| 1772 | |||
| 1773 | case 34: | ||
| 1774 | #line 323 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1775 | { | ||
| 1776 | unsigned long long bits; | ||
| 1777 | |||
| 1778 | bits = (yyvsp[-1].integer); | ||
| 1779 | |||
| 1780 | if ((bits != 8) && (bits != 16) && | ||
| 1781 | (bits != 32) && (bits != 64)) { | ||
| 1782 | ERROR(&(yylsp[-1]), "Array elements must be" | ||
| 1783 | " 8, 16, 32 or 64-bits"); | ||
| 1784 | bits = 32; | ||
| 1785 | } | ||
| 1786 | |||
| 1787 | (yyval.array).data = empty_data; | ||
| 1788 | (yyval.array).bits = bits; | ||
| 1789 | } | ||
| 1790 | #line 1791 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1791 | break; | ||
| 1792 | |||
| 1793 | case 35: | ||
| 1794 | #line 339 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1795 | { | ||
| 1796 | (yyval.array).data = empty_data; | ||
| 1797 | (yyval.array).bits = 32; | ||
| 1798 | } | ||
| 1799 | #line 1800 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1800 | break; | ||
| 1801 | |||
| 1802 | case 36: | ||
| 1803 | #line 344 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1804 | { | ||
| 1805 | if ((yyvsp[-1].array).bits < 64) { | ||
| 1806 | uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1; | ||
| 1807 | /* | ||
| 1808 | * Bits above mask must either be all zero | ||
| 1809 | * (positive within range of mask) or all one | ||
| 1810 | * (negative and sign-extended). The second | ||
| 1811 | * condition is true if when we set all bits | ||
| 1812 | * within the mask to one (i.e. | in the | ||
| 1813 | * mask), all bits are one. | ||
| 1814 | */ | ||
| 1815 | if (((yyvsp[0].integer) > mask) && (((yyvsp[0].integer) | mask) != -1ULL)) | ||
| 1816 | ERROR(&(yylsp[0]), "Value out of range for" | ||
| 1817 | " %d-bit array element", (yyvsp[-1].array).bits); | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits); | ||
| 1821 | } | ||
| 1822 | #line 1823 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1823 | break; | ||
| 1824 | |||
| 1825 | case 37: | ||
| 1826 | #line 363 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1827 | { | ||
| 1828 | uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits); | ||
| 1829 | |||
| 1830 | if ((yyvsp[-1].array).bits == 32) | ||
| 1831 | (yyvsp[-1].array).data = data_add_marker((yyvsp[-1].array).data, | ||
| 1832 | REF_PHANDLE, | ||
| 1833 | (yyvsp[0].labelref)); | ||
| 1834 | else | ||
| 1835 | ERROR(&(yylsp[0]), "References are only allowed in " | ||
| 1836 | "arrays with 32-bit elements."); | ||
| 1837 | |||
| 1838 | (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits); | ||
| 1839 | } | ||
| 1840 | #line 1841 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1841 | break; | ||
| 1842 | |||
| 1843 | case 38: | ||
| 1844 | #line 377 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1845 | { | ||
| 1846 | (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref)); | ||
| 1847 | } | ||
| 1848 | #line 1849 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1849 | break; | ||
| 1850 | |||
| 1851 | case 41: | ||
| 1852 | #line 386 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1853 | { | ||
| 1854 | (yyval.integer) = (yyvsp[-1].integer); | ||
| 1855 | } | ||
| 1856 | #line 1857 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1857 | break; | ||
| 1858 | |||
| 1859 | case 44: | ||
| 1860 | #line 397 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1861 | { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); } | ||
| 1862 | #line 1863 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1863 | break; | ||
| 1864 | |||
| 1865 | case 46: | ||
| 1866 | #line 402 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1867 | { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); } | ||
| 1868 | #line 1869 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1869 | break; | ||
| 1870 | |||
| 1871 | case 48: | ||
| 1872 | #line 407 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1873 | { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); } | ||
| 1874 | #line 1875 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1875 | break; | ||
| 1876 | |||
| 1877 | case 50: | ||
| 1878 | #line 412 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1879 | { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); } | ||
| 1880 | #line 1881 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1881 | break; | ||
| 1882 | |||
| 1883 | case 52: | ||
| 1884 | #line 417 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1885 | { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); } | ||
| 1886 | #line 1887 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1887 | break; | ||
| 1888 | |||
| 1889 | case 54: | ||
| 1890 | #line 422 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1891 | { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); } | ||
| 1892 | #line 1893 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1893 | break; | ||
| 1894 | |||
| 1895 | case 56: | ||
| 1896 | #line 427 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1897 | { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); } | ||
| 1898 | #line 1899 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1899 | break; | ||
| 1900 | |||
| 1901 | case 57: | ||
| 1902 | #line 428 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1903 | { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); } | ||
| 1904 | #line 1905 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1905 | break; | ||
| 1906 | |||
| 1907 | case 59: | ||
| 1908 | #line 433 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1909 | { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); } | ||
| 1910 | #line 1911 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1911 | break; | ||
| 1912 | |||
| 1913 | case 60: | ||
| 1914 | #line 434 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1915 | { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); } | ||
| 1916 | #line 1917 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1917 | break; | ||
| 1918 | |||
| 1919 | case 61: | ||
| 1920 | #line 435 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1921 | { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); } | ||
| 1922 | #line 1923 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1923 | break; | ||
| 1924 | |||
| 1925 | case 62: | ||
| 1926 | #line 436 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1927 | { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); } | ||
| 1928 | #line 1929 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1929 | break; | ||
| 1930 | |||
| 1931 | case 63: | ||
| 1932 | #line 440 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1933 | { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); } | ||
| 1934 | #line 1935 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1935 | break; | ||
| 1936 | |||
| 1937 | case 64: | ||
| 1938 | #line 441 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1939 | { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); } | ||
| 1940 | #line 1941 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1941 | break; | ||
| 1942 | |||
| 1943 | case 66: | ||
| 1944 | #line 446 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1945 | { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); } | ||
| 1946 | #line 1947 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1947 | break; | ||
| 1948 | |||
| 1949 | case 67: | ||
| 1950 | #line 447 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1951 | { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); } | ||
| 1952 | #line 1953 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1953 | break; | ||
| 1954 | |||
| 1955 | case 69: | ||
| 1956 | #line 452 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1957 | { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); } | ||
| 1958 | #line 1959 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1959 | break; | ||
| 1960 | |||
| 1961 | case 70: | ||
| 1962 | #line 454 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1963 | { | ||
| 1964 | if ((yyvsp[0].integer) != 0) { | ||
| 1965 | (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer); | ||
| 1966 | } else { | ||
| 1967 | ERROR(&(yyloc), "Division by zero"); | ||
| 1968 | (yyval.integer) = 0; | ||
| 1969 | } | ||
| 1970 | } | ||
| 1971 | #line 1972 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1972 | break; | ||
| 1973 | |||
| 1974 | case 71: | ||
| 1975 | #line 463 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1976 | { | ||
| 1977 | if ((yyvsp[0].integer) != 0) { | ||
| 1978 | (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer); | ||
| 1979 | } else { | ||
| 1980 | ERROR(&(yyloc), "Division by zero"); | ||
| 1981 | (yyval.integer) = 0; | ||
| 1982 | } | ||
| 1983 | } | ||
| 1984 | #line 1985 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1985 | break; | ||
| 1986 | |||
| 1987 | case 74: | ||
| 1988 | #line 476 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1989 | { (yyval.integer) = -(yyvsp[0].integer); } | ||
| 1990 | #line 1991 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1991 | break; | ||
| 1992 | |||
| 1993 | case 75: | ||
| 1994 | #line 477 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 1995 | { (yyval.integer) = ~(yyvsp[0].integer); } | ||
| 1996 | #line 1997 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 1997 | break; | ||
| 1998 | |||
| 1999 | case 76: | ||
| 2000 | #line 478 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2001 | { (yyval.integer) = !(yyvsp[0].integer); } | ||
| 2002 | #line 2003 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2003 | break; | ||
| 2004 | |||
| 2005 | case 77: | ||
| 2006 | #line 483 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2007 | { | ||
| 2008 | (yyval.data) = empty_data; | ||
| 2009 | } | ||
| 2010 | #line 2011 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2011 | break; | ||
| 2012 | |||
| 2013 | case 78: | ||
| 2014 | #line 487 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2015 | { | ||
| 2016 | (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte)); | ||
| 2017 | } | ||
| 2018 | #line 2019 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2019 | break; | ||
| 2020 | |||
| 2021 | case 79: | ||
| 2022 | #line 491 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2023 | { | ||
| 2024 | (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); | ||
| 2025 | } | ||
| 2026 | #line 2027 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2027 | break; | ||
| 2028 | |||
| 2029 | case 80: | ||
| 2030 | #line 498 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2031 | { | ||
| 2032 | (yyval.nodelist) = NULL; | ||
| 2033 | } | ||
| 2034 | #line 2035 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2035 | break; | ||
| 2036 | |||
| 2037 | case 81: | ||
| 2038 | #line 502 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2039 | { | ||
| 2040 | (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist)); | ||
| 2041 | } | ||
| 2042 | #line 2043 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2043 | break; | ||
| 2044 | |||
| 2045 | case 82: | ||
| 2046 | #line 506 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2047 | { | ||
| 2048 | ERROR(&(yylsp[0]), "Properties must precede subnodes"); | ||
| 2049 | YYERROR; | ||
| 2050 | } | ||
| 2051 | #line 2052 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2052 | break; | ||
| 2053 | |||
| 2054 | case 83: | ||
| 2055 | #line 514 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2056 | { | ||
| 2057 | (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename)); | ||
| 2058 | } | ||
| 2059 | #line 2060 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2060 | break; | ||
| 2061 | |||
| 2062 | case 84: | ||
| 2063 | #line 518 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2064 | { | ||
| 2065 | (yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename)); | ||
| 2066 | } | ||
| 2067 | #line 2068 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2068 | break; | ||
| 2069 | |||
| 2070 | case 85: | ||
| 2071 | #line 522 "dtc-parser.y" /* yacc.c:1646 */ | ||
| 2072 | { | ||
| 2073 | add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref)); | ||
| 2074 | (yyval.node) = (yyvsp[0].node); | ||
| 2075 | } | ||
| 2076 | #line 2077 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2077 | break; | ||
| 2078 | |||
| 2079 | |||
| 2080 | #line 2081 "dtc-parser.tab.c" /* yacc.c:1646 */ | ||
| 2081 | default: break; | ||
| 2082 | } | ||
| 2083 | /* User semantic actions sometimes alter yychar, and that requires | ||
| 2084 | that yytoken be updated with the new translation. We take the | ||
| 2085 | approach of translating immediately before every use of yytoken. | ||
| 2086 | One alternative is translating here after every semantic action, | ||
| 2087 | but that translation would be missed if the semantic action invokes | ||
| 2088 | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or | ||
| 2089 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an | ||
| 2090 | incorrect destructor might then be invoked immediately. In the | ||
| 2091 | case of YYERROR or YYBACKUP, subsequent parser actions might lead | ||
| 2092 | to an incorrect destructor call or verbose syntax error message | ||
| 2093 | before the lookahead is translated. */ | ||
| 2094 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | ||
| 2095 | |||
| 2096 | YYPOPSTACK (yylen); | ||
| 2097 | yylen = 0; | ||
| 2098 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2099 | |||
| 2100 | *++yyvsp = yyval; | ||
| 2101 | *++yylsp = yyloc; | ||
| 2102 | |||
| 2103 | /* Now 'shift' the result of the reduction. Determine what state | ||
| 2104 | that goes to, based on the state we popped back to and the rule | ||
| 2105 | number reduced by. */ | ||
| 2106 | |||
| 2107 | yyn = yyr1[yyn]; | ||
| 2108 | |||
| 2109 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
| 2110 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
| 2111 | yystate = yytable[yystate]; | ||
| 2112 | else | ||
| 2113 | yystate = yydefgoto[yyn - YYNTOKENS]; | ||
| 2114 | |||
| 2115 | goto yynewstate; | ||
| 2116 | |||
| 2117 | |||
| 2118 | /*--------------------------------------. | ||
| 2119 | | yyerrlab -- here on detecting error. | | ||
| 2120 | `--------------------------------------*/ | ||
| 2121 | yyerrlab: | ||
| 2122 | /* Make sure we have latest lookahead translation. See comments at | ||
| 2123 | user semantic actions for why this is necessary. */ | ||
| 2124 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); | ||
| 2125 | |||
| 2126 | /* If not already recovering from an error, report this error. */ | ||
| 2127 | if (!yyerrstatus) | ||
| 2128 | { | ||
| 2129 | ++yynerrs; | ||
| 2130 | #if ! YYERROR_VERBOSE | ||
| 2131 | yyerror (YY_("syntax error")); | ||
| 2132 | #else | ||
| 2133 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ | ||
| 2134 | yyssp, yytoken) | ||
| 2135 | { | ||
| 2136 | char const *yymsgp = YY_("syntax error"); | ||
| 2137 | int yysyntax_error_status; | ||
| 2138 | yysyntax_error_status = YYSYNTAX_ERROR; | ||
| 2139 | if (yysyntax_error_status == 0) | ||
| 2140 | yymsgp = yymsg; | ||
| 2141 | else if (yysyntax_error_status == 1) | ||
| 2142 | { | ||
| 2143 | if (yymsg != yymsgbuf) | ||
| 2144 | YYSTACK_FREE (yymsg); | ||
| 2145 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); | ||
| 2146 | if (!yymsg) | ||
| 2147 | { | ||
| 2148 | yymsg = yymsgbuf; | ||
| 2149 | yymsg_alloc = sizeof yymsgbuf; | ||
| 2150 | yysyntax_error_status = 2; | ||
| 2151 | } | ||
| 2152 | else | ||
| 2153 | { | ||
| 2154 | yysyntax_error_status = YYSYNTAX_ERROR; | ||
| 2155 | yymsgp = yymsg; | ||
| 2156 | } | ||
| 2157 | } | ||
| 2158 | yyerror (yymsgp); | ||
| 2159 | if (yysyntax_error_status == 2) | ||
| 2160 | goto yyexhaustedlab; | ||
| 2161 | } | ||
| 2162 | # undef YYSYNTAX_ERROR | ||
| 2163 | #endif | ||
| 2164 | } | ||
| 2165 | |||
| 2166 | yyerror_range[1] = yylloc; | ||
| 2167 | |||
| 2168 | if (yyerrstatus == 3) | ||
| 2169 | { | ||
| 2170 | /* If just tried and failed to reuse lookahead token after an | ||
| 2171 | error, discard it. */ | ||
| 2172 | |||
| 2173 | if (yychar <= YYEOF) | ||
| 2174 | { | ||
| 2175 | /* Return failure if at end of input. */ | ||
| 2176 | if (yychar == YYEOF) | ||
| 2177 | YYABORT; | ||
| 2178 | } | ||
| 2179 | else | ||
| 2180 | { | ||
| 2181 | yydestruct ("Error: discarding", | ||
| 2182 | yytoken, &yylval, &yylloc); | ||
| 2183 | yychar = YYEMPTY; | ||
| 2184 | } | ||
| 2185 | } | ||
| 2186 | |||
| 2187 | /* Else will try to reuse lookahead token after shifting the error | ||
| 2188 | token. */ | ||
| 2189 | goto yyerrlab1; | ||
| 2190 | |||
| 2191 | |||
| 2192 | /*---------------------------------------------------. | ||
| 2193 | | yyerrorlab -- error raised explicitly by YYERROR. | | ||
| 2194 | `---------------------------------------------------*/ | ||
| 2195 | yyerrorlab: | ||
| 2196 | |||
| 2197 | /* Pacify compilers like GCC when the user code never invokes | ||
| 2198 | YYERROR and the label yyerrorlab therefore never appears in user | ||
| 2199 | code. */ | ||
| 2200 | if (/*CONSTCOND*/ 0) | ||
| 2201 | goto yyerrorlab; | ||
| 2202 | |||
| 2203 | yyerror_range[1] = yylsp[1-yylen]; | ||
| 2204 | /* Do not reclaim the symbols of the rule whose action triggered | ||
| 2205 | this YYERROR. */ | ||
| 2206 | YYPOPSTACK (yylen); | ||
| 2207 | yylen = 0; | ||
| 2208 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2209 | yystate = *yyssp; | ||
| 2210 | goto yyerrlab1; | ||
| 2211 | |||
| 2212 | |||
| 2213 | /*-------------------------------------------------------------. | ||
| 2214 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | ||
| 2215 | `-------------------------------------------------------------*/ | ||
| 2216 | yyerrlab1: | ||
| 2217 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
| 2218 | |||
| 2219 | for (;;) | ||
| 2220 | { | ||
| 2221 | yyn = yypact[yystate]; | ||
| 2222 | if (!yypact_value_is_default (yyn)) | ||
| 2223 | { | ||
| 2224 | yyn += YYTERROR; | ||
| 2225 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
| 2226 | { | ||
| 2227 | yyn = yytable[yyn]; | ||
| 2228 | if (0 < yyn) | ||
| 2229 | break; | ||
| 2230 | } | ||
| 2231 | } | ||
| 2232 | |||
| 2233 | /* Pop the current state because it cannot handle the error token. */ | ||
| 2234 | if (yyssp == yyss) | ||
| 2235 | YYABORT; | ||
| 2236 | |||
| 2237 | yyerror_range[1] = *yylsp; | ||
| 2238 | yydestruct ("Error: popping", | ||
| 2239 | yystos[yystate], yyvsp, yylsp); | ||
| 2240 | YYPOPSTACK (1); | ||
| 2241 | yystate = *yyssp; | ||
| 2242 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2243 | } | ||
| 2244 | |||
| 2245 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 2246 | *++yyvsp = yylval; | ||
| 2247 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 2248 | |||
| 2249 | yyerror_range[2] = yylloc; | ||
| 2250 | /* Using YYLLOC is tempting, but would change the location of | ||
| 2251 | the lookahead. YYLOC is available though. */ | ||
| 2252 | YYLLOC_DEFAULT (yyloc, yyerror_range, 2); | ||
| 2253 | *++yylsp = yyloc; | ||
| 2254 | |||
| 2255 | /* Shift the error token. */ | ||
| 2256 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | ||
| 2257 | |||
| 2258 | yystate = yyn; | ||
| 2259 | goto yynewstate; | ||
| 2260 | |||
| 2261 | |||
| 2262 | /*-------------------------------------. | ||
| 2263 | | yyacceptlab -- YYACCEPT comes here. | | ||
| 2264 | `-------------------------------------*/ | ||
| 2265 | yyacceptlab: | ||
| 2266 | yyresult = 0; | ||
| 2267 | goto yyreturn; | ||
| 2268 | |||
| 2269 | /*-----------------------------------. | ||
| 2270 | | yyabortlab -- YYABORT comes here. | | ||
| 2271 | `-----------------------------------*/ | ||
| 2272 | yyabortlab: | ||
| 2273 | yyresult = 1; | ||
| 2274 | goto yyreturn; | ||
| 2275 | |||
| 2276 | #if !defined yyoverflow || YYERROR_VERBOSE | ||
| 2277 | /*-------------------------------------------------. | ||
| 2278 | | yyexhaustedlab -- memory exhaustion comes here. | | ||
| 2279 | `-------------------------------------------------*/ | ||
| 2280 | yyexhaustedlab: | ||
| 2281 | yyerror (YY_("memory exhausted")); | ||
| 2282 | yyresult = 2; | ||
| 2283 | /* Fall through. */ | ||
| 2284 | #endif | ||
| 2285 | |||
| 2286 | yyreturn: | ||
| 2287 | if (yychar != YYEMPTY) | ||
| 2288 | { | ||
| 2289 | /* Make sure we have latest lookahead translation. See comments at | ||
| 2290 | user semantic actions for why this is necessary. */ | ||
| 2291 | yytoken = YYTRANSLATE (yychar); | ||
| 2292 | yydestruct ("Cleanup: discarding lookahead", | ||
| 2293 | yytoken, &yylval, &yylloc); | ||
| 2294 | } | ||
| 2295 | /* Do not reclaim the symbols of the rule whose action triggered | ||
| 2296 | this YYABORT or YYACCEPT. */ | ||
| 2297 | YYPOPSTACK (yylen); | ||
| 2298 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2299 | while (yyssp != yyss) | ||
| 2300 | { | ||
| 2301 | yydestruct ("Cleanup: popping", | ||
| 2302 | yystos[*yyssp], yyvsp, yylsp); | ||
| 2303 | YYPOPSTACK (1); | ||
| 2304 | } | ||
| 2305 | #ifndef yyoverflow | ||
| 2306 | if (yyss != yyssa) | ||
| 2307 | YYSTACK_FREE (yyss); | ||
| 2308 | #endif | ||
| 2309 | #if YYERROR_VERBOSE | ||
| 2310 | if (yymsg != yymsgbuf) | ||
| 2311 | YYSTACK_FREE (yymsg); | ||
| 2312 | #endif | ||
| 2313 | return yyresult; | ||
| 2314 | } | ||
| 2315 | #line 528 "dtc-parser.y" /* yacc.c:1906 */ | ||
| 2316 | |||
| 2317 | |||
| 2318 | void yyerror(char const *s) | ||
| 2319 | { | ||
| 2320 | ERROR(&yylloc, "%s", s); | ||
| 2321 | } | ||
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped deleted file mode 100644 index 6aa512c1b337..000000000000 --- a/scripts/dtc/dtc-parser.tab.h_shipped +++ /dev/null | |||
| @@ -1,125 +0,0 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 3.0.4. */ | ||
| 2 | |||
| 3 | /* Bison interface for Yacc-like parsers in C | ||
| 4 | |||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (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 | ||
| 15 | GNU 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, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* As a special exception, you may create a larger work that contains | ||
| 21 | part or all of the Bison parser skeleton and distribute that work | ||
| 22 | under terms of your choice, so long as that work isn't itself a | ||
| 23 | parser generator using the skeleton or a modified version thereof | ||
| 24 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
| 25 | the parser skeleton itself, you may (at your option) remove this | ||
| 26 | special exception, which will cause the skeleton and the resulting | ||
| 27 | Bison output files to be licensed under the GNU General Public | ||
| 28 | License without this special exception. | ||
| 29 | |||
| 30 | This special exception was added by the Free Software Foundation in | ||
| 31 | version 2.2 of Bison. */ | ||
| 32 | |||
| 33 | #ifndef YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 34 | # define YY_YY_DTC_PARSER_TAB_H_INCLUDED | ||
| 35 | /* Debug traces. */ | ||
| 36 | #ifndef YYDEBUG | ||
| 37 | # define YYDEBUG 0 | ||
| 38 | #endif | ||
| 39 | #if YYDEBUG | ||
| 40 | extern int yydebug; | ||
| 41 | #endif | ||
| 42 | |||
| 43 | /* Token type. */ | ||
| 44 | #ifndef YYTOKENTYPE | ||
| 45 | # define YYTOKENTYPE | ||
| 46 | enum yytokentype | ||
| 47 | { | ||
| 48 | DT_V1 = 258, | ||
| 49 | DT_PLUGIN = 259, | ||
| 50 | DT_MEMRESERVE = 260, | ||
| 51 | DT_LSHIFT = 261, | ||
| 52 | DT_RSHIFT = 262, | ||
| 53 | DT_LE = 263, | ||
| 54 | DT_GE = 264, | ||
| 55 | DT_EQ = 265, | ||
| 56 | DT_NE = 266, | ||
| 57 | DT_AND = 267, | ||
| 58 | DT_OR = 268, | ||
| 59 | DT_BITS = 269, | ||
| 60 | DT_DEL_PROP = 270, | ||
| 61 | DT_DEL_NODE = 271, | ||
| 62 | DT_PROPNODENAME = 272, | ||
| 63 | DT_LITERAL = 273, | ||
| 64 | DT_CHAR_LITERAL = 274, | ||
| 65 | DT_BYTE = 275, | ||
| 66 | DT_STRING = 276, | ||
| 67 | DT_LABEL = 277, | ||
| 68 | DT_REF = 278, | ||
| 69 | DT_INCBIN = 279 | ||
| 70 | }; | ||
| 71 | #endif | ||
| 72 | |||
| 73 | /* Value type. */ | ||
| 74 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
| 75 | |||
| 76 | union YYSTYPE | ||
| 77 | { | ||
| 78 | #line 39 "dtc-parser.y" /* yacc.c:1909 */ | ||
| 79 | |||
| 80 | char *propnodename; | ||
| 81 | char *labelref; | ||
| 82 | uint8_t byte; | ||
| 83 | struct data data; | ||
| 84 | |||
| 85 | struct { | ||
| 86 | struct data data; | ||
| 87 | int bits; | ||
| 88 | } array; | ||
| 89 | |||
| 90 | struct property *prop; | ||
| 91 | struct property *proplist; | ||
| 92 | struct node *node; | ||
| 93 | struct node *nodelist; | ||
| 94 | struct reserve_info *re; | ||
| 95 | uint64_t integer; | ||
| 96 | unsigned int flags; | ||
| 97 | |||
| 98 | #line 99 "dtc-parser.tab.h" /* yacc.c:1909 */ | ||
| 99 | }; | ||
| 100 | |||
| 101 | typedef union YYSTYPE YYSTYPE; | ||
| 102 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 103 | # define YYSTYPE_IS_DECLARED 1 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | /* Location type. */ | ||
| 107 | #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED | ||
| 108 | typedef struct YYLTYPE YYLTYPE; | ||
| 109 | struct YYLTYPE | ||
| 110 | { | ||
| 111 | int first_line; | ||
| 112 | int first_column; | ||
| 113 | int last_line; | ||
| 114 | int last_column; | ||
| 115 | }; | ||
| 116 | # define YYLTYPE_IS_DECLARED 1 | ||
| 117 | # define YYLTYPE_IS_TRIVIAL 1 | ||
| 118 | #endif | ||
| 119 | |||
| 120 | |||
| 121 | extern YYSTYPE yylval; | ||
| 122 | extern YYLTYPE yylloc; | ||
| 123 | int yyparse (void); | ||
| 124 | |||
| 125 | #endif /* !YY_YY_DTC_PARSER_TAB_H_INCLUDED */ | ||
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index affc81a8f9ab..44af170abfea 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y | |||
| @@ -166,7 +166,17 @@ devicetree: | |||
| 166 | { | 166 | { |
| 167 | $$ = merge_nodes($1, $3); | 167 | $$ = merge_nodes($1, $3); |
| 168 | } | 168 | } |
| 169 | 169 | | DT_REF nodedef | |
| 170 | { | ||
| 171 | /* | ||
| 172 | * We rely on the rule being always: | ||
| 173 | * versioninfo plugindecl memreserves devicetree | ||
| 174 | * so $-1 is what we want (plugindecl) | ||
| 175 | */ | ||
| 176 | if (!($<flags>-1 & DTSF_PLUGIN)) | ||
| 177 | ERROR(&@2, "Label or path %s not found", $1); | ||
| 178 | $$ = add_orphan_node(name_node(build_node(NULL, NULL), ""), $2, $1); | ||
| 179 | } | ||
| 170 | | devicetree DT_LABEL DT_REF nodedef | 180 | | devicetree DT_LABEL DT_REF nodedef |
| 171 | { | 181 | { |
| 172 | struct node *target = get_node_by_ref($1, $3); | 182 | struct node *target = get_node_by_ref($1, $3); |
| @@ -209,11 +219,6 @@ devicetree: | |||
| 209 | 219 | ||
| 210 | $$ = $1; | 220 | $$ = $1; |
| 211 | } | 221 | } |
| 212 | | /* empty */ | ||
| 213 | { | ||
| 214 | /* build empty node */ | ||
| 215 | $$ = name_node(build_node(NULL, NULL), ""); | ||
| 216 | } | ||
| 217 | ; | 222 | ; |
| 218 | 223 | ||
| 219 | nodedef: | 224 | nodedef: |
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c index 5ed873c72ad1..c36994e6eac5 100644 --- a/scripts/dtc/dtc.c +++ b/scripts/dtc/dtc.c | |||
| @@ -59,8 +59,6 @@ static void fill_fullpaths(struct node *tree, const char *prefix) | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | /* Usage related data. */ | 61 | /* Usage related data. */ |
| 62 | #define FDT_VERSION(version) _FDT_VERSION(version) | ||
| 63 | #define _FDT_VERSION(version) #version | ||
| 64 | static const char usage_synopsis[] = "dtc [options] <input file>"; | 62 | static const char usage_synopsis[] = "dtc [options] <input file>"; |
| 65 | static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv"; | 63 | static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv"; |
| 66 | static struct option const usage_long_opts[] = { | 64 | static struct option const usage_long_opts[] = { |
| @@ -98,7 +96,7 @@ static const char * const usage_opts_help[] = { | |||
| 98 | "\t\tdts - device tree source text\n" | 96 | "\t\tdts - device tree source text\n" |
| 99 | "\t\tdtb - device tree blob\n" | 97 | "\t\tdtb - device tree blob\n" |
| 100 | "\t\tasm - assembler source", | 98 | "\t\tasm - assembler source", |
| 101 | "\n\tBlob version to produce, defaults to "FDT_VERSION(DEFAULT_FDT_VERSION)" (for dtb and asm output)", | 99 | "\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)", |
| 102 | "\n\tOutput dependency file", | 100 | "\n\tOutput dependency file", |
| 103 | "\n\tMake space for <number> reserve map entries (for dtb and asm output)", | 101 | "\n\tMake space for <number> reserve map entries (for dtb and asm output)", |
| 104 | "\n\tMake the blob at least <bytes> long (extra space)", | 102 | "\n\tMake the blob at least <bytes> long (extra space)", |
| @@ -319,13 +317,14 @@ int main(int argc, char *argv[]) | |||
| 319 | dti->boot_cpuid_phys = cmdline_boot_cpuid; | 317 | dti->boot_cpuid_phys = cmdline_boot_cpuid; |
| 320 | 318 | ||
| 321 | fill_fullpaths(dti->dt, ""); | 319 | fill_fullpaths(dti->dt, ""); |
| 322 | process_checks(force, dti); | ||
| 323 | 320 | ||
| 324 | /* on a plugin, generate by default */ | 321 | /* on a plugin, generate by default */ |
| 325 | if (dti->dtsflags & DTSF_PLUGIN) { | 322 | if (dti->dtsflags & DTSF_PLUGIN) { |
| 326 | generate_fixups = 1; | 323 | generate_fixups = 1; |
| 327 | } | 324 | } |
| 328 | 325 | ||
| 326 | process_checks(force, dti); | ||
| 327 | |||
| 329 | if (auto_label_aliases) | 328 | if (auto_label_aliases) |
| 330 | generate_label_tree(dti, "aliases", false); | 329 | generate_label_tree(dti, "aliases", false); |
| 331 | 330 | ||
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index 35cf926cc14a..3b18a42b866e 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _DTC_H | 1 | #ifndef DTC_H |
| 2 | #define _DTC_H | 2 | #define DTC_H |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| 5 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. | 5 | * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. |
| @@ -67,7 +67,8 @@ typedef uint32_t cell_t; | |||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | #define streq(a, b) (strcmp((a), (b)) == 0) | 69 | #define streq(a, b) (strcmp((a), (b)) == 0) |
| 70 | #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) | 70 | #define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0) |
| 71 | #define strprefixeq(a, n, b) (strlen(b) == (n) && (memcmp(a, b, n) == 0)) | ||
| 71 | 72 | ||
| 72 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) | 73 | #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) |
| 73 | 74 | ||
| @@ -203,7 +204,7 @@ struct node *build_node_delete(void); | |||
| 203 | struct node *name_node(struct node *node, char *name); | 204 | struct node *name_node(struct node *node, char *name); |
| 204 | struct node *chain_node(struct node *first, struct node *list); | 205 | struct node *chain_node(struct node *first, struct node *list); |
| 205 | struct node *merge_nodes(struct node *old_node, struct node *new_node); | 206 | struct node *merge_nodes(struct node *old_node, struct node *new_node); |
| 206 | void add_orphan_node(struct node *old_node, struct node *new_node, char *ref); | 207 | struct node *add_orphan_node(struct node *old_node, struct node *new_node, char *ref); |
| 207 | 208 | ||
| 208 | void add_property(struct node *node, struct property *prop); | 209 | void add_property(struct node *node, struct property *prop); |
| 209 | void delete_property_by_name(struct node *node, char *name); | 210 | void delete_property_by_name(struct node *node, char *name); |
| @@ -289,4 +290,4 @@ struct dt_info *dt_from_source(const char *f); | |||
| 289 | 290 | ||
| 290 | struct dt_info *dt_from_fs(const char *dirname); | 291 | struct dt_info *dt_from_fs(const char *dirname); |
| 291 | 292 | ||
| 292 | #endif /* _DTC_H */ | 293 | #endif /* DTC_H */ |
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index fcf71541d8a7..8d268fb785db 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c | |||
| @@ -731,7 +731,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath) | |||
| 731 | 731 | ||
| 732 | plen = strlen(ppath); | 732 | plen = strlen(ppath); |
| 733 | 733 | ||
| 734 | if (!strneq(ppath, cpath, plen)) | 734 | if (!strstarts(cpath, ppath)) |
| 735 | die("Path \"%s\" is not valid as a child of \"%s\"\n", | 735 | die("Path \"%s\" is not valid as a child of \"%s\"\n", |
| 736 | cpath, ppath); | 736 | cpath, ppath); |
| 737 | 737 | ||
diff --git a/scripts/dtc/include-prefixes/cris b/scripts/dtc/include-prefixes/cris deleted file mode 120000 index 736d998ba506..000000000000 --- a/scripts/dtc/include-prefixes/cris +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | ../../../arch/cris/boot/dts \ No newline at end of file | ||
diff --git a/scripts/dtc/include-prefixes/metag b/scripts/dtc/include-prefixes/metag deleted file mode 120000 index 87a3c847db8f..000000000000 --- a/scripts/dtc/include-prefixes/metag +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | ../../../arch/metag/boot/dts \ No newline at end of file | ||
diff --git a/scripts/dtc/libfdt/fdt.c b/scripts/dtc/libfdt/fdt.c index 22286a1aaeaf..7855a1787763 100644 --- a/scripts/dtc/libfdt/fdt.c +++ b/scripts/dtc/libfdt/fdt.c | |||
| @@ -88,7 +88,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) | |||
| 88 | || ((offset + len) > fdt_size_dt_struct(fdt))) | 88 | || ((offset + len) > fdt_size_dt_struct(fdt))) |
| 89 | return NULL; | 89 | return NULL; |
| 90 | 90 | ||
| 91 | return _fdt_offset_ptr(fdt, offset); | 91 | return fdt_offset_ptr_(fdt, offset); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) | 94 | uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) |
| @@ -123,6 +123,9 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) | |||
| 123 | /* skip-name offset, length and value */ | 123 | /* skip-name offset, length and value */ |
| 124 | offset += sizeof(struct fdt_property) - FDT_TAGSIZE | 124 | offset += sizeof(struct fdt_property) - FDT_TAGSIZE |
| 125 | + fdt32_to_cpu(*lenp); | 125 | + fdt32_to_cpu(*lenp); |
| 126 | if (fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >= 8 && | ||
| 127 | ((offset - fdt32_to_cpu(*lenp)) % 8) != 0) | ||
| 128 | offset += 4; | ||
| 126 | break; | 129 | break; |
| 127 | 130 | ||
| 128 | case FDT_END: | 131 | case FDT_END: |
| @@ -141,7 +144,7 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) | |||
| 141 | return tag; | 144 | return tag; |
| 142 | } | 145 | } |
| 143 | 146 | ||
| 144 | int _fdt_check_node_offset(const void *fdt, int offset) | 147 | int fdt_check_node_offset_(const void *fdt, int offset) |
| 145 | { | 148 | { |
| 146 | if ((offset < 0) || (offset % FDT_TAGSIZE) | 149 | if ((offset < 0) || (offset % FDT_TAGSIZE) |
| 147 | || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) | 150 | || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) |
| @@ -150,7 +153,7 @@ int _fdt_check_node_offset(const void *fdt, int offset) | |||
| 150 | return offset; | 153 | return offset; |
| 151 | } | 154 | } |
| 152 | 155 | ||
| 153 | int _fdt_check_prop_offset(const void *fdt, int offset) | 156 | int fdt_check_prop_offset_(const void *fdt, int offset) |
| 154 | { | 157 | { |
| 155 | if ((offset < 0) || (offset % FDT_TAGSIZE) | 158 | if ((offset < 0) || (offset % FDT_TAGSIZE) |
| 156 | || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) | 159 | || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) |
| @@ -165,7 +168,7 @@ int fdt_next_node(const void *fdt, int offset, int *depth) | |||
| 165 | uint32_t tag; | 168 | uint32_t tag; |
| 166 | 169 | ||
| 167 | if (offset >= 0) | 170 | if (offset >= 0) |
| 168 | if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0) | 171 | if ((nextoffset = fdt_check_node_offset_(fdt, offset)) < 0) |
| 169 | return nextoffset; | 172 | return nextoffset; |
| 170 | 173 | ||
| 171 | do { | 174 | do { |
| @@ -227,7 +230,7 @@ int fdt_next_subnode(const void *fdt, int offset) | |||
| 227 | return offset; | 230 | return offset; |
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s) | 233 | const char *fdt_find_string_(const char *strtab, int tabsize, const char *s) |
| 231 | { | 234 | { |
| 232 | int len = strlen(s) + 1; | 235 | int len = strlen(s) + 1; |
| 233 | const char *last = strtab + tabsize - len; | 236 | const char *last = strtab + tabsize - len; |
diff --git a/scripts/dtc/libfdt/fdt.h b/scripts/dtc/libfdt/fdt.h index 526aedb51556..74961f9026d1 100644 --- a/scripts/dtc/libfdt/fdt.h +++ b/scripts/dtc/libfdt/fdt.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _FDT_H | 1 | #ifndef FDT_H |
| 2 | #define _FDT_H | 2 | #define FDT_H |
| 3 | /* | 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation | 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. | 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| @@ -108,4 +108,4 @@ struct fdt_property { | |||
| 108 | #define FDT_V16_SIZE FDT_V3_SIZE | 108 | #define FDT_V16_SIZE FDT_V3_SIZE |
| 109 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) | 109 | #define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) |
| 110 | 110 | ||
| 111 | #endif /* _FDT_H */ | 111 | #endif /* FDT_H */ |
diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c index bd81241e6658..bf75388ec9a2 100644 --- a/scripts/dtc/libfdt/fdt_overlay.c +++ b/scripts/dtc/libfdt/fdt_overlay.c | |||
| @@ -1,3 +1,54 @@ | |||
| 1 | /* | ||
| 2 | * libfdt - Flat Device Tree manipulation | ||
| 3 | * Copyright (C) 2016 Free Electrons | ||
| 4 | * Copyright (C) 2016 NextThing Co. | ||
| 5 | * | ||
| 6 | * libfdt is dual licensed: you can use it either under the terms of | ||
| 7 | * the GPL, or the BSD license, at your option. | ||
| 8 | * | ||
| 9 | * a) This library is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU General Public License as | ||
| 11 | * published by the Free Software Foundation; either version 2 of the | ||
| 12 | * License, or (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This library is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public | ||
| 20 | * License along with this library; if not, write to the Free | ||
| 21 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | ||
| 22 | * MA 02110-1301 USA | ||
| 23 | * | ||
| 24 | * Alternatively, | ||
| 25 | * | ||
| 26 | * b) Redistribution and use in source and binary forms, with or | ||
| 27 | * without modification, are permitted provided that the following | ||
| 28 | * conditions are met: | ||
| 29 | * | ||
| 30 | * 1. Redistributions of source code must retain the above | ||
| 31 | * copyright notice, this list of conditions and the following | ||
| 32 | * disclaimer. | ||
| 33 | * 2. Redistributions in binary form must reproduce the above | ||
| 34 | * copyright notice, this list of conditions and the following | ||
| 35 | * disclaimer in the documentation and/or other materials | ||
| 36 | * provided with the distribution. | ||
| 37 | * | ||
| 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
| 39 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
| 40 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 41 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 42 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
| 43 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 48 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
| 49 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| 50 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | */ | ||
| 1 | #include "libfdt_env.h" | 52 | #include "libfdt_env.h" |
| 2 | 53 | ||
| 3 | #include <fdt.h> | 54 | #include <fdt.h> |
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c index 08de2cce674d..dfb3236da388 100644 --- a/scripts/dtc/libfdt/fdt_ro.c +++ b/scripts/dtc/libfdt/fdt_ro.c | |||
| @@ -55,12 +55,13 @@ | |||
| 55 | 55 | ||
| 56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
| 57 | 57 | ||
| 58 | static int _fdt_nodename_eq(const void *fdt, int offset, | 58 | static int fdt_nodename_eq_(const void *fdt, int offset, |
| 59 | const char *s, int len) | 59 | const char *s, int len) |
| 60 | { | 60 | { |
| 61 | const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1); | 61 | int olen; |
| 62 | const char *p = fdt_get_name(fdt, offset, &olen); | ||
| 62 | 63 | ||
| 63 | if (!p) | 64 | if (!p || olen < len) |
| 64 | /* short match */ | 65 | /* short match */ |
| 65 | return 0; | 66 | return 0; |
| 66 | 67 | ||
| @@ -80,7 +81,7 @@ const char *fdt_string(const void *fdt, int stroffset) | |||
| 80 | return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; | 81 | return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | static int _fdt_string_eq(const void *fdt, int stroffset, | 84 | static int fdt_string_eq_(const void *fdt, int stroffset, |
| 84 | const char *s, int len) | 85 | const char *s, int len) |
| 85 | { | 86 | { |
| 86 | const char *p = fdt_string(fdt, stroffset); | 87 | const char *p = fdt_string(fdt, stroffset); |
| @@ -117,8 +118,8 @@ uint32_t fdt_get_max_phandle(const void *fdt) | |||
| 117 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) | 118 | int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size) |
| 118 | { | 119 | { |
| 119 | FDT_CHECK_HEADER(fdt); | 120 | FDT_CHECK_HEADER(fdt); |
| 120 | *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address); | 121 | *address = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->address); |
| 121 | *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size); | 122 | *size = fdt64_to_cpu(fdt_mem_rsv_(fdt, n)->size); |
| 122 | return 0; | 123 | return 0; |
| 123 | } | 124 | } |
| 124 | 125 | ||
| @@ -126,12 +127,12 @@ int fdt_num_mem_rsv(const void *fdt) | |||
| 126 | { | 127 | { |
| 127 | int i = 0; | 128 | int i = 0; |
| 128 | 129 | ||
| 129 | while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0) | 130 | while (fdt64_to_cpu(fdt_mem_rsv_(fdt, i)->size) != 0) |
| 130 | i++; | 131 | i++; |
| 131 | return i; | 132 | return i; |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | static int _nextprop(const void *fdt, int offset) | 135 | static int nextprop_(const void *fdt, int offset) |
| 135 | { | 136 | { |
| 136 | uint32_t tag; | 137 | uint32_t tag; |
| 137 | int nextoffset; | 138 | int nextoffset; |
| @@ -166,7 +167,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset, | |||
| 166 | (offset >= 0) && (depth >= 0); | 167 | (offset >= 0) && (depth >= 0); |
| 167 | offset = fdt_next_node(fdt, offset, &depth)) | 168 | offset = fdt_next_node(fdt, offset, &depth)) |
| 168 | if ((depth == 1) | 169 | if ((depth == 1) |
| 169 | && _fdt_nodename_eq(fdt, offset, name, namelen)) | 170 | && fdt_nodename_eq_(fdt, offset, name, namelen)) |
| 170 | return offset; | 171 | return offset; |
| 171 | 172 | ||
| 172 | if (depth < 0) | 173 | if (depth < 0) |
| @@ -232,17 +233,35 @@ int fdt_path_offset(const void *fdt, const char *path) | |||
| 232 | 233 | ||
| 233 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) | 234 | const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) |
| 234 | { | 235 | { |
| 235 | const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset); | 236 | const struct fdt_node_header *nh = fdt_offset_ptr_(fdt, nodeoffset); |
| 237 | const char *nameptr; | ||
| 236 | int err; | 238 | int err; |
| 237 | 239 | ||
| 238 | if (((err = fdt_check_header(fdt)) != 0) | 240 | if (((err = fdt_check_header(fdt)) != 0) |
| 239 | || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0)) | 241 | || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) |
| 240 | goto fail; | 242 | goto fail; |
| 241 | 243 | ||
| 244 | nameptr = nh->name; | ||
| 245 | |||
| 246 | if (fdt_version(fdt) < 0x10) { | ||
| 247 | /* | ||
| 248 | * For old FDT versions, match the naming conventions of V16: | ||
| 249 | * give only the leaf name (after all /). The actual tree | ||
| 250 | * contents are loosely checked. | ||
| 251 | */ | ||
| 252 | const char *leaf; | ||
| 253 | leaf = strrchr(nameptr, '/'); | ||
| 254 | if (leaf == NULL) { | ||
| 255 | err = -FDT_ERR_BADSTRUCTURE; | ||
| 256 | goto fail; | ||
| 257 | } | ||
| 258 | nameptr = leaf+1; | ||
| 259 | } | ||
| 260 | |||
| 242 | if (len) | 261 | if (len) |
| 243 | *len = strlen(nh->name); | 262 | *len = strlen(nameptr); |
| 244 | 263 | ||
| 245 | return nh->name; | 264 | return nameptr; |
| 246 | 265 | ||
| 247 | fail: | 266 | fail: |
| 248 | if (len) | 267 | if (len) |
| @@ -254,34 +273,34 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset) | |||
| 254 | { | 273 | { |
| 255 | int offset; | 274 | int offset; |
| 256 | 275 | ||
| 257 | if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0) | 276 | if ((offset = fdt_check_node_offset_(fdt, nodeoffset)) < 0) |
| 258 | return offset; | 277 | return offset; |
| 259 | 278 | ||
| 260 | return _nextprop(fdt, offset); | 279 | return nextprop_(fdt, offset); |
| 261 | } | 280 | } |
| 262 | 281 | ||
| 263 | int fdt_next_property_offset(const void *fdt, int offset) | 282 | int fdt_next_property_offset(const void *fdt, int offset) |
| 264 | { | 283 | { |
| 265 | if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0) | 284 | if ((offset = fdt_check_prop_offset_(fdt, offset)) < 0) |
| 266 | return offset; | 285 | return offset; |
| 267 | 286 | ||
| 268 | return _nextprop(fdt, offset); | 287 | return nextprop_(fdt, offset); |
| 269 | } | 288 | } |
| 270 | 289 | ||
| 271 | const struct fdt_property *fdt_get_property_by_offset(const void *fdt, | 290 | static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt, |
| 272 | int offset, | 291 | int offset, |
| 273 | int *lenp) | 292 | int *lenp) |
| 274 | { | 293 | { |
| 275 | int err; | 294 | int err; |
| 276 | const struct fdt_property *prop; | 295 | const struct fdt_property *prop; |
| 277 | 296 | ||
| 278 | if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) { | 297 | if ((err = fdt_check_prop_offset_(fdt, offset)) < 0) { |
| 279 | if (lenp) | 298 | if (lenp) |
| 280 | *lenp = err; | 299 | *lenp = err; |
| 281 | return NULL; | 300 | return NULL; |
| 282 | } | 301 | } |
| 283 | 302 | ||
| 284 | prop = _fdt_offset_ptr(fdt, offset); | 303 | prop = fdt_offset_ptr_(fdt, offset); |
| 285 | 304 | ||
| 286 | if (lenp) | 305 | if (lenp) |
| 287 | *lenp = fdt32_to_cpu(prop->len); | 306 | *lenp = fdt32_to_cpu(prop->len); |
| @@ -289,23 +308,44 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt, | |||
| 289 | return prop; | 308 | return prop; |
| 290 | } | 309 | } |
| 291 | 310 | ||
| 292 | const struct fdt_property *fdt_get_property_namelen(const void *fdt, | 311 | const struct fdt_property *fdt_get_property_by_offset(const void *fdt, |
| 293 | int offset, | 312 | int offset, |
| 294 | const char *name, | 313 | int *lenp) |
| 295 | int namelen, int *lenp) | 314 | { |
| 315 | /* Prior to version 16, properties may need realignment | ||
| 316 | * and this API does not work. fdt_getprop_*() will, however. */ | ||
| 317 | |||
| 318 | if (fdt_version(fdt) < 0x10) { | ||
| 319 | if (lenp) | ||
| 320 | *lenp = -FDT_ERR_BADVERSION; | ||
| 321 | return NULL; | ||
| 322 | } | ||
| 323 | |||
| 324 | return fdt_get_property_by_offset_(fdt, offset, lenp); | ||
| 325 | } | ||
| 326 | |||
| 327 | static const struct fdt_property *fdt_get_property_namelen_(const void *fdt, | ||
| 328 | int offset, | ||
| 329 | const char *name, | ||
| 330 | int namelen, | ||
| 331 | int *lenp, | ||
| 332 | int *poffset) | ||
| 296 | { | 333 | { |
| 297 | for (offset = fdt_first_property_offset(fdt, offset); | 334 | for (offset = fdt_first_property_offset(fdt, offset); |
| 298 | (offset >= 0); | 335 | (offset >= 0); |
| 299 | (offset = fdt_next_property_offset(fdt, offset))) { | 336 | (offset = fdt_next_property_offset(fdt, offset))) { |
| 300 | const struct fdt_property *prop; | 337 | const struct fdt_property *prop; |
| 301 | 338 | ||
| 302 | if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) { | 339 | if (!(prop = fdt_get_property_by_offset_(fdt, offset, lenp))) { |
| 303 | offset = -FDT_ERR_INTERNAL; | 340 | offset = -FDT_ERR_INTERNAL; |
| 304 | break; | 341 | break; |
| 305 | } | 342 | } |
| 306 | if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff), | 343 | if (fdt_string_eq_(fdt, fdt32_to_cpu(prop->nameoff), |
| 307 | name, namelen)) | 344 | name, namelen)) { |
| 345 | if (poffset) | ||
| 346 | *poffset = offset; | ||
| 308 | return prop; | 347 | return prop; |
| 348 | } | ||
| 309 | } | 349 | } |
| 310 | 350 | ||
| 311 | if (lenp) | 351 | if (lenp) |
| @@ -313,6 +353,25 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt, | |||
| 313 | return NULL; | 353 | return NULL; |
| 314 | } | 354 | } |
| 315 | 355 | ||
| 356 | |||
| 357 | const struct fdt_property *fdt_get_property_namelen(const void *fdt, | ||
| 358 | int offset, | ||
| 359 | const char *name, | ||
| 360 | int namelen, int *lenp) | ||
| 361 | { | ||
| 362 | /* Prior to version 16, properties may need realignment | ||
| 363 | * and this API does not work. fdt_getprop_*() will, however. */ | ||
| 364 | if (fdt_version(fdt) < 0x10) { | ||
| 365 | if (lenp) | ||
| 366 | *lenp = -FDT_ERR_BADVERSION; | ||
| 367 | return NULL; | ||
| 368 | } | ||
| 369 | |||
| 370 | return fdt_get_property_namelen_(fdt, offset, name, namelen, lenp, | ||
| 371 | NULL); | ||
| 372 | } | ||
| 373 | |||
| 374 | |||
| 316 | const struct fdt_property *fdt_get_property(const void *fdt, | 375 | const struct fdt_property *fdt_get_property(const void *fdt, |
| 317 | int nodeoffset, | 376 | int nodeoffset, |
| 318 | const char *name, int *lenp) | 377 | const char *name, int *lenp) |
| @@ -324,12 +383,18 @@ const struct fdt_property *fdt_get_property(const void *fdt, | |||
| 324 | const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, | 383 | const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, |
| 325 | const char *name, int namelen, int *lenp) | 384 | const char *name, int namelen, int *lenp) |
| 326 | { | 385 | { |
| 386 | int poffset; | ||
| 327 | const struct fdt_property *prop; | 387 | const struct fdt_property *prop; |
| 328 | 388 | ||
| 329 | prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp); | 389 | prop = fdt_get_property_namelen_(fdt, nodeoffset, name, namelen, lenp, |
| 390 | &poffset); | ||
| 330 | if (!prop) | 391 | if (!prop) |
| 331 | return NULL; | 392 | return NULL; |
| 332 | 393 | ||
| 394 | /* Handle realignment */ | ||
| 395 | if (fdt_version(fdt) < 0x10 && (poffset + sizeof(*prop)) % 8 && | ||
| 396 | fdt32_to_cpu(prop->len) >= 8) | ||
| 397 | return prop->data + 4; | ||
| 333 | return prop->data; | 398 | return prop->data; |
| 334 | } | 399 | } |
| 335 | 400 | ||
| @@ -338,11 +403,16 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, | |||
| 338 | { | 403 | { |
| 339 | const struct fdt_property *prop; | 404 | const struct fdt_property *prop; |
| 340 | 405 | ||
| 341 | prop = fdt_get_property_by_offset(fdt, offset, lenp); | 406 | prop = fdt_get_property_by_offset_(fdt, offset, lenp); |
| 342 | if (!prop) | 407 | if (!prop) |
| 343 | return NULL; | 408 | return NULL; |
| 344 | if (namep) | 409 | if (namep) |
| 345 | *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); | 410 | *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); |
| 411 | |||
| 412 | /* Handle realignment */ | ||
| 413 | if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 && | ||
| 414 | fdt32_to_cpu(prop->len) >= 8) | ||
| 415 | return prop->data + 4; | ||
| 346 | return prop->data; | 416 | return prop->data; |
| 347 | } | 417 | } |
| 348 | 418 | ||
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c index 5c3a2bb0bc6b..9b829051e444 100644 --- a/scripts/dtc/libfdt/fdt_rw.c +++ b/scripts/dtc/libfdt/fdt_rw.c | |||
| @@ -55,8 +55,8 @@ | |||
| 55 | 55 | ||
| 56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
| 57 | 57 | ||
| 58 | static int _fdt_blocks_misordered(const void *fdt, | 58 | static int fdt_blocks_misordered_(const void *fdt, |
| 59 | int mem_rsv_size, int struct_size) | 59 | int mem_rsv_size, int struct_size) |
| 60 | { | 60 | { |
| 61 | return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8)) | 61 | return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8)) |
| 62 | || (fdt_off_dt_struct(fdt) < | 62 | || (fdt_off_dt_struct(fdt) < |
| @@ -67,13 +67,13 @@ static int _fdt_blocks_misordered(const void *fdt, | |||
| 67 | (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt))); | 67 | (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt))); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int _fdt_rw_check_header(void *fdt) | 70 | static int fdt_rw_check_header_(void *fdt) |
| 71 | { | 71 | { |
| 72 | FDT_CHECK_HEADER(fdt); | 72 | FDT_CHECK_HEADER(fdt); |
| 73 | 73 | ||
| 74 | if (fdt_version(fdt) < 17) | 74 | if (fdt_version(fdt) < 17) |
| 75 | return -FDT_ERR_BADVERSION; | 75 | return -FDT_ERR_BADVERSION; |
| 76 | if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry), | 76 | if (fdt_blocks_misordered_(fdt, sizeof(struct fdt_reserve_entry), |
| 77 | fdt_size_dt_struct(fdt))) | 77 | fdt_size_dt_struct(fdt))) |
| 78 | return -FDT_ERR_BADLAYOUT; | 78 | return -FDT_ERR_BADLAYOUT; |
| 79 | if (fdt_version(fdt) > 17) | 79 | if (fdt_version(fdt) > 17) |
| @@ -84,20 +84,20 @@ static int _fdt_rw_check_header(void *fdt) | |||
| 84 | 84 | ||
| 85 | #define FDT_RW_CHECK_HEADER(fdt) \ | 85 | #define FDT_RW_CHECK_HEADER(fdt) \ |
| 86 | { \ | 86 | { \ |
| 87 | int __err; \ | 87 | int err_; \ |
| 88 | if ((__err = _fdt_rw_check_header(fdt)) != 0) \ | 88 | if ((err_ = fdt_rw_check_header_(fdt)) != 0) \ |
| 89 | return __err; \ | 89 | return err_; \ |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | static inline int _fdt_data_size(void *fdt) | 92 | static inline int fdt_data_size_(void *fdt) |
| 93 | { | 93 | { |
| 94 | return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); | 94 | return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen) | 97 | static int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen) |
| 98 | { | 98 | { |
| 99 | char *p = splicepoint; | 99 | char *p = splicepoint; |
| 100 | char *end = (char *)fdt + _fdt_data_size(fdt); | 100 | char *end = (char *)fdt + fdt_data_size_(fdt); |
| 101 | 101 | ||
| 102 | if (((p + oldlen) < p) || ((p + oldlen) > end)) | 102 | if (((p + oldlen) < p) || ((p + oldlen) > end)) |
| 103 | return -FDT_ERR_BADOFFSET; | 103 | return -FDT_ERR_BADOFFSET; |
| @@ -109,12 +109,12 @@ static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen) | |||
| 109 | return 0; | 109 | return 0; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p, | 112 | static int fdt_splice_mem_rsv_(void *fdt, struct fdt_reserve_entry *p, |
| 113 | int oldn, int newn) | 113 | int oldn, int newn) |
| 114 | { | 114 | { |
| 115 | int delta = (newn - oldn) * sizeof(*p); | 115 | int delta = (newn - oldn) * sizeof(*p); |
| 116 | int err; | 116 | int err; |
| 117 | err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p)); | 117 | err = fdt_splice_(fdt, p, oldn * sizeof(*p), newn * sizeof(*p)); |
| 118 | if (err) | 118 | if (err) |
| 119 | return err; | 119 | return err; |
| 120 | fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta); | 120 | fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta); |
| @@ -122,13 +122,13 @@ static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p, | |||
| 122 | return 0; | 122 | return 0; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | static int _fdt_splice_struct(void *fdt, void *p, | 125 | static int fdt_splice_struct_(void *fdt, void *p, |
| 126 | int oldlen, int newlen) | 126 | int oldlen, int newlen) |
| 127 | { | 127 | { |
| 128 | int delta = newlen - oldlen; | 128 | int delta = newlen - oldlen; |
| 129 | int err; | 129 | int err; |
| 130 | 130 | ||
| 131 | if ((err = _fdt_splice(fdt, p, oldlen, newlen))) | 131 | if ((err = fdt_splice_(fdt, p, oldlen, newlen))) |
| 132 | return err; | 132 | return err; |
| 133 | 133 | ||
| 134 | fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta); | 134 | fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta); |
| @@ -136,20 +136,20 @@ static int _fdt_splice_struct(void *fdt, void *p, | |||
| 136 | return 0; | 136 | return 0; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | static int _fdt_splice_string(void *fdt, int newlen) | 139 | static int fdt_splice_string_(void *fdt, int newlen) |
| 140 | { | 140 | { |
| 141 | void *p = (char *)fdt | 141 | void *p = (char *)fdt |
| 142 | + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); | 142 | + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); |
| 143 | int err; | 143 | int err; |
| 144 | 144 | ||
| 145 | if ((err = _fdt_splice(fdt, p, 0, newlen))) | 145 | if ((err = fdt_splice_(fdt, p, 0, newlen))) |
| 146 | return err; | 146 | return err; |
| 147 | 147 | ||
| 148 | fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen); | 148 | fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen); |
| 149 | return 0; | 149 | return 0; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static int _fdt_find_add_string(void *fdt, const char *s) | 152 | static int fdt_find_add_string_(void *fdt, const char *s) |
| 153 | { | 153 | { |
| 154 | char *strtab = (char *)fdt + fdt_off_dt_strings(fdt); | 154 | char *strtab = (char *)fdt + fdt_off_dt_strings(fdt); |
| 155 | const char *p; | 155 | const char *p; |
| @@ -157,13 +157,13 @@ static int _fdt_find_add_string(void *fdt, const char *s) | |||
| 157 | int len = strlen(s) + 1; | 157 | int len = strlen(s) + 1; |
| 158 | int err; | 158 | int err; |
| 159 | 159 | ||
| 160 | p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s); | 160 | p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s); |
| 161 | if (p) | 161 | if (p) |
| 162 | /* found it */ | 162 | /* found it */ |
| 163 | return (p - strtab); | 163 | return (p - strtab); |
| 164 | 164 | ||
| 165 | new = strtab + fdt_size_dt_strings(fdt); | 165 | new = strtab + fdt_size_dt_strings(fdt); |
| 166 | err = _fdt_splice_string(fdt, len); | 166 | err = fdt_splice_string_(fdt, len); |
| 167 | if (err) | 167 | if (err) |
| 168 | return err; | 168 | return err; |
| 169 | 169 | ||
| @@ -178,8 +178,8 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) | |||
| 178 | 178 | ||
| 179 | FDT_RW_CHECK_HEADER(fdt); | 179 | FDT_RW_CHECK_HEADER(fdt); |
| 180 | 180 | ||
| 181 | re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt)); | 181 | re = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt)); |
| 182 | err = _fdt_splice_mem_rsv(fdt, re, 0, 1); | 182 | err = fdt_splice_mem_rsv_(fdt, re, 0, 1); |
| 183 | if (err) | 183 | if (err) |
| 184 | return err; | 184 | return err; |
| 185 | 185 | ||
| @@ -190,17 +190,17 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size) | |||
| 190 | 190 | ||
| 191 | int fdt_del_mem_rsv(void *fdt, int n) | 191 | int fdt_del_mem_rsv(void *fdt, int n) |
| 192 | { | 192 | { |
| 193 | struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n); | 193 | struct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n); |
| 194 | 194 | ||
| 195 | FDT_RW_CHECK_HEADER(fdt); | 195 | FDT_RW_CHECK_HEADER(fdt); |
| 196 | 196 | ||
| 197 | if (n >= fdt_num_mem_rsv(fdt)) | 197 | if (n >= fdt_num_mem_rsv(fdt)) |
| 198 | return -FDT_ERR_NOTFOUND; | 198 | return -FDT_ERR_NOTFOUND; |
| 199 | 199 | ||
| 200 | return _fdt_splice_mem_rsv(fdt, re, 1, 0); | 200 | return fdt_splice_mem_rsv_(fdt, re, 1, 0); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, | 203 | static int fdt_resize_property_(void *fdt, int nodeoffset, const char *name, |
| 204 | int len, struct fdt_property **prop) | 204 | int len, struct fdt_property **prop) |
| 205 | { | 205 | { |
| 206 | int oldlen; | 206 | int oldlen; |
| @@ -210,7 +210,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, | |||
| 210 | if (!*prop) | 210 | if (!*prop) |
| 211 | return oldlen; | 211 | return oldlen; |
| 212 | 212 | ||
| 213 | if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), | 213 | if ((err = fdt_splice_struct_(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), |
| 214 | FDT_TAGALIGN(len)))) | 214 | FDT_TAGALIGN(len)))) |
| 215 | return err; | 215 | return err; |
| 216 | 216 | ||
| @@ -218,7 +218,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, | |||
| 218 | return 0; | 218 | return 0; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | static int _fdt_add_property(void *fdt, int nodeoffset, const char *name, | 221 | static int fdt_add_property_(void *fdt, int nodeoffset, const char *name, |
| 222 | int len, struct fdt_property **prop) | 222 | int len, struct fdt_property **prop) |
| 223 | { | 223 | { |
| 224 | int proplen; | 224 | int proplen; |
| @@ -226,17 +226,17 @@ static int _fdt_add_property(void *fdt, int nodeoffset, const char *name, | |||
| 226 | int namestroff; | 226 | int namestroff; |
| 227 | int err; | 227 | int err; |
| 228 | 228 | ||
| 229 | if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0) | 229 | if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0) |
| 230 | return nextoffset; | 230 | return nextoffset; |
| 231 | 231 | ||
| 232 | namestroff = _fdt_find_add_string(fdt, name); | 232 | namestroff = fdt_find_add_string_(fdt, name); |
| 233 | if (namestroff < 0) | 233 | if (namestroff < 0) |
| 234 | return namestroff; | 234 | return namestroff; |
| 235 | 235 | ||
| 236 | *prop = _fdt_offset_ptr_w(fdt, nextoffset); | 236 | *prop = fdt_offset_ptr_w_(fdt, nextoffset); |
| 237 | proplen = sizeof(**prop) + FDT_TAGALIGN(len); | 237 | proplen = sizeof(**prop) + FDT_TAGALIGN(len); |
| 238 | 238 | ||
| 239 | err = _fdt_splice_struct(fdt, *prop, 0, proplen); | 239 | err = fdt_splice_struct_(fdt, *prop, 0, proplen); |
| 240 | if (err) | 240 | if (err) |
| 241 | return err; | 241 | return err; |
| 242 | 242 | ||
| @@ -260,7 +260,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name) | |||
| 260 | 260 | ||
| 261 | newlen = strlen(name); | 261 | newlen = strlen(name); |
| 262 | 262 | ||
| 263 | err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1), | 263 | err = fdt_splice_struct_(fdt, namep, FDT_TAGALIGN(oldlen+1), |
| 264 | FDT_TAGALIGN(newlen+1)); | 264 | FDT_TAGALIGN(newlen+1)); |
| 265 | if (err) | 265 | if (err) |
| 266 | return err; | 266 | return err; |
| @@ -277,9 +277,9 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, | |||
| 277 | 277 | ||
| 278 | FDT_RW_CHECK_HEADER(fdt); | 278 | FDT_RW_CHECK_HEADER(fdt); |
| 279 | 279 | ||
| 280 | err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop); | 280 | err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop); |
| 281 | if (err == -FDT_ERR_NOTFOUND) | 281 | if (err == -FDT_ERR_NOTFOUND) |
| 282 | err = _fdt_add_property(fdt, nodeoffset, name, len, &prop); | 282 | err = fdt_add_property_(fdt, nodeoffset, name, len, &prop); |
| 283 | if (err) | 283 | if (err) |
| 284 | return err; | 284 | return err; |
| 285 | 285 | ||
| @@ -313,7 +313,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | |||
| 313 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); | 313 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); |
| 314 | if (prop) { | 314 | if (prop) { |
| 315 | newlen = len + oldlen; | 315 | newlen = len + oldlen; |
| 316 | err = _fdt_splice_struct(fdt, prop->data, | 316 | err = fdt_splice_struct_(fdt, prop->data, |
| 317 | FDT_TAGALIGN(oldlen), | 317 | FDT_TAGALIGN(oldlen), |
| 318 | FDT_TAGALIGN(newlen)); | 318 | FDT_TAGALIGN(newlen)); |
| 319 | if (err) | 319 | if (err) |
| @@ -321,7 +321,7 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | |||
| 321 | prop->len = cpu_to_fdt32(newlen); | 321 | prop->len = cpu_to_fdt32(newlen); |
| 322 | memcpy(prop->data + oldlen, val, len); | 322 | memcpy(prop->data + oldlen, val, len); |
| 323 | } else { | 323 | } else { |
| 324 | err = _fdt_add_property(fdt, nodeoffset, name, len, &prop); | 324 | err = fdt_add_property_(fdt, nodeoffset, name, len, &prop); |
| 325 | if (err) | 325 | if (err) |
| 326 | return err; | 326 | return err; |
| 327 | memcpy(prop->data, val, len); | 327 | memcpy(prop->data, val, len); |
| @@ -341,7 +341,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name) | |||
| 341 | return len; | 341 | return len; |
| 342 | 342 | ||
| 343 | proplen = sizeof(*prop) + FDT_TAGALIGN(len); | 343 | proplen = sizeof(*prop) + FDT_TAGALIGN(len); |
| 344 | return _fdt_splice_struct(fdt, prop, proplen, 0); | 344 | return fdt_splice_struct_(fdt, prop, proplen, 0); |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | int fdt_add_subnode_namelen(void *fdt, int parentoffset, | 347 | int fdt_add_subnode_namelen(void *fdt, int parentoffset, |
| @@ -369,10 +369,10 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, | |||
| 369 | tag = fdt_next_tag(fdt, offset, &nextoffset); | 369 | tag = fdt_next_tag(fdt, offset, &nextoffset); |
| 370 | } while ((tag == FDT_PROP) || (tag == FDT_NOP)); | 370 | } while ((tag == FDT_PROP) || (tag == FDT_NOP)); |
| 371 | 371 | ||
| 372 | nh = _fdt_offset_ptr_w(fdt, offset); | 372 | nh = fdt_offset_ptr_w_(fdt, offset); |
| 373 | nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE; | 373 | nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE; |
| 374 | 374 | ||
| 375 | err = _fdt_splice_struct(fdt, nh, 0, nodelen); | 375 | err = fdt_splice_struct_(fdt, nh, 0, nodelen); |
| 376 | if (err) | 376 | if (err) |
| 377 | return err; | 377 | return err; |
| 378 | 378 | ||
| @@ -396,15 +396,15 @@ int fdt_del_node(void *fdt, int nodeoffset) | |||
| 396 | 396 | ||
| 397 | FDT_RW_CHECK_HEADER(fdt); | 397 | FDT_RW_CHECK_HEADER(fdt); |
| 398 | 398 | ||
| 399 | endoffset = _fdt_node_end_offset(fdt, nodeoffset); | 399 | endoffset = fdt_node_end_offset_(fdt, nodeoffset); |
| 400 | if (endoffset < 0) | 400 | if (endoffset < 0) |
| 401 | return endoffset; | 401 | return endoffset; |
| 402 | 402 | ||
| 403 | return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset), | 403 | return fdt_splice_struct_(fdt, fdt_offset_ptr_w_(fdt, nodeoffset), |
| 404 | endoffset - nodeoffset, 0); | 404 | endoffset - nodeoffset, 0); |
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | static void _fdt_packblocks(const char *old, char *new, | 407 | static void fdt_packblocks_(const char *old, char *new, |
| 408 | int mem_rsv_size, int struct_size) | 408 | int mem_rsv_size, int struct_size) |
| 409 | { | 409 | { |
| 410 | int mem_rsv_off, struct_off, strings_off; | 410 | int mem_rsv_off, struct_off, strings_off; |
| @@ -450,7 +450,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) | |||
| 450 | return struct_size; | 450 | return struct_size; |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) { | 453 | if (!fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) { |
| 454 | /* no further work necessary */ | 454 | /* no further work necessary */ |
| 455 | err = fdt_move(fdt, buf, bufsize); | 455 | err = fdt_move(fdt, buf, bufsize); |
| 456 | if (err) | 456 | if (err) |
| @@ -478,7 +478,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) | |||
| 478 | return -FDT_ERR_NOSPACE; | 478 | return -FDT_ERR_NOSPACE; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | _fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size); | 481 | fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size); |
| 482 | memmove(buf, tmp, newsize); | 482 | memmove(buf, tmp, newsize); |
| 483 | 483 | ||
| 484 | fdt_set_magic(buf, FDT_MAGIC); | 484 | fdt_set_magic(buf, FDT_MAGIC); |
| @@ -498,8 +498,8 @@ int fdt_pack(void *fdt) | |||
| 498 | 498 | ||
| 499 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) | 499 | mem_rsv_size = (fdt_num_mem_rsv(fdt)+1) |
| 500 | * sizeof(struct fdt_reserve_entry); | 500 | * sizeof(struct fdt_reserve_entry); |
| 501 | _fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt)); | 501 | fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt)); |
| 502 | fdt_set_totalsize(fdt, _fdt_data_size(fdt)); | 502 | fdt_set_totalsize(fdt, fdt_data_size_(fdt)); |
| 503 | 503 | ||
| 504 | return 0; | 504 | return 0; |
| 505 | } | 505 | } |
diff --git a/scripts/dtc/libfdt/fdt_sw.c b/scripts/dtc/libfdt/fdt_sw.c index 2bd15e7aef87..6d33cc29d022 100644 --- a/scripts/dtc/libfdt/fdt_sw.c +++ b/scripts/dtc/libfdt/fdt_sw.c | |||
| @@ -55,7 +55,7 @@ | |||
| 55 | 55 | ||
| 56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
| 57 | 57 | ||
| 58 | static int _fdt_sw_check_header(void *fdt) | 58 | static int fdt_sw_check_header_(void *fdt) |
| 59 | { | 59 | { |
| 60 | if (fdt_magic(fdt) != FDT_SW_MAGIC) | 60 | if (fdt_magic(fdt) != FDT_SW_MAGIC) |
| 61 | return -FDT_ERR_BADMAGIC; | 61 | return -FDT_ERR_BADMAGIC; |
| @@ -66,11 +66,11 @@ static int _fdt_sw_check_header(void *fdt) | |||
| 66 | #define FDT_SW_CHECK_HEADER(fdt) \ | 66 | #define FDT_SW_CHECK_HEADER(fdt) \ |
| 67 | { \ | 67 | { \ |
| 68 | int err; \ | 68 | int err; \ |
| 69 | if ((err = _fdt_sw_check_header(fdt)) != 0) \ | 69 | if ((err = fdt_sw_check_header_(fdt)) != 0) \ |
| 70 | return err; \ | 70 | return err; \ |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static void *_fdt_grab_space(void *fdt, size_t len) | 73 | static void *fdt_grab_space_(void *fdt, size_t len) |
| 74 | { | 74 | { |
| 75 | int offset = fdt_size_dt_struct(fdt); | 75 | int offset = fdt_size_dt_struct(fdt); |
| 76 | int spaceleft; | 76 | int spaceleft; |
| @@ -82,7 +82,7 @@ static void *_fdt_grab_space(void *fdt, size_t len) | |||
| 82 | return NULL; | 82 | return NULL; |
| 83 | 83 | ||
| 84 | fdt_set_size_dt_struct(fdt, offset + len); | 84 | fdt_set_size_dt_struct(fdt, offset + len); |
| 85 | return _fdt_offset_ptr_w(fdt, offset); | 85 | return fdt_offset_ptr_w_(fdt, offset); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | int fdt_create(void *buf, int bufsize) | 88 | int fdt_create(void *buf, int bufsize) |
| @@ -174,7 +174,7 @@ int fdt_begin_node(void *fdt, const char *name) | |||
| 174 | 174 | ||
| 175 | FDT_SW_CHECK_HEADER(fdt); | 175 | FDT_SW_CHECK_HEADER(fdt); |
| 176 | 176 | ||
| 177 | nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); | 177 | nh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); |
| 178 | if (! nh) | 178 | if (! nh) |
| 179 | return -FDT_ERR_NOSPACE; | 179 | return -FDT_ERR_NOSPACE; |
| 180 | 180 | ||
| @@ -189,7 +189,7 @@ int fdt_end_node(void *fdt) | |||
| 189 | 189 | ||
| 190 | FDT_SW_CHECK_HEADER(fdt); | 190 | FDT_SW_CHECK_HEADER(fdt); |
| 191 | 191 | ||
| 192 | en = _fdt_grab_space(fdt, FDT_TAGSIZE); | 192 | en = fdt_grab_space_(fdt, FDT_TAGSIZE); |
| 193 | if (! en) | 193 | if (! en) |
| 194 | return -FDT_ERR_NOSPACE; | 194 | return -FDT_ERR_NOSPACE; |
| 195 | 195 | ||
| @@ -197,7 +197,7 @@ int fdt_end_node(void *fdt) | |||
| 197 | return 0; | 197 | return 0; |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | static int _fdt_find_add_string(void *fdt, const char *s) | 200 | static int fdt_find_add_string_(void *fdt, const char *s) |
| 201 | { | 201 | { |
| 202 | char *strtab = (char *)fdt + fdt_totalsize(fdt); | 202 | char *strtab = (char *)fdt + fdt_totalsize(fdt); |
| 203 | const char *p; | 203 | const char *p; |
| @@ -205,7 +205,7 @@ static int _fdt_find_add_string(void *fdt, const char *s) | |||
| 205 | int len = strlen(s) + 1; | 205 | int len = strlen(s) + 1; |
| 206 | int struct_top, offset; | 206 | int struct_top, offset; |
| 207 | 207 | ||
| 208 | p = _fdt_find_string(strtab - strtabsize, strtabsize, s); | 208 | p = fdt_find_string_(strtab - strtabsize, strtabsize, s); |
| 209 | if (p) | 209 | if (p) |
| 210 | return p - strtab; | 210 | return p - strtab; |
| 211 | 211 | ||
| @@ -227,11 +227,11 @@ int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) | |||
| 227 | 227 | ||
| 228 | FDT_SW_CHECK_HEADER(fdt); | 228 | FDT_SW_CHECK_HEADER(fdt); |
| 229 | 229 | ||
| 230 | nameoff = _fdt_find_add_string(fdt, name); | 230 | nameoff = fdt_find_add_string_(fdt, name); |
| 231 | if (nameoff == 0) | 231 | if (nameoff == 0) |
| 232 | return -FDT_ERR_NOSPACE; | 232 | return -FDT_ERR_NOSPACE; |
| 233 | 233 | ||
| 234 | prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len)); | 234 | prop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len)); |
| 235 | if (! prop) | 235 | if (! prop) |
| 236 | return -FDT_ERR_NOSPACE; | 236 | return -FDT_ERR_NOSPACE; |
| 237 | 237 | ||
| @@ -265,7 +265,7 @@ int fdt_finish(void *fdt) | |||
| 265 | FDT_SW_CHECK_HEADER(fdt); | 265 | FDT_SW_CHECK_HEADER(fdt); |
| 266 | 266 | ||
| 267 | /* Add terminator */ | 267 | /* Add terminator */ |
| 268 | end = _fdt_grab_space(fdt, sizeof(*end)); | 268 | end = fdt_grab_space_(fdt, sizeof(*end)); |
| 269 | if (! end) | 269 | if (! end) |
| 270 | return -FDT_ERR_NOSPACE; | 270 | return -FDT_ERR_NOSPACE; |
| 271 | *end = cpu_to_fdt32(FDT_END); | 271 | *end = cpu_to_fdt32(FDT_END); |
| @@ -281,7 +281,7 @@ int fdt_finish(void *fdt) | |||
| 281 | while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { | 281 | while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { |
| 282 | if (tag == FDT_PROP) { | 282 | if (tag == FDT_PROP) { |
| 283 | struct fdt_property *prop = | 283 | struct fdt_property *prop = |
| 284 | _fdt_offset_ptr_w(fdt, offset); | 284 | fdt_offset_ptr_w_(fdt, offset); |
| 285 | int nameoff; | 285 | int nameoff; |
| 286 | 286 | ||
| 287 | nameoff = fdt32_to_cpu(prop->nameoff); | 287 | nameoff = fdt32_to_cpu(prop->nameoff); |
diff --git a/scripts/dtc/libfdt/fdt_wip.c b/scripts/dtc/libfdt/fdt_wip.c index 5e859198622b..534c1cbbb2f3 100644 --- a/scripts/dtc/libfdt/fdt_wip.c +++ b/scripts/dtc/libfdt/fdt_wip.c | |||
| @@ -93,7 +93,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, | |||
| 93 | val, len); | 93 | val, len); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static void _fdt_nop_region(void *start, int len) | 96 | static void fdt_nop_region_(void *start, int len) |
| 97 | { | 97 | { |
| 98 | fdt32_t *p; | 98 | fdt32_t *p; |
| 99 | 99 | ||
| @@ -110,12 +110,12 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name) | |||
| 110 | if (!prop) | 110 | if (!prop) |
| 111 | return len; | 111 | return len; |
| 112 | 112 | ||
| 113 | _fdt_nop_region(prop, len + sizeof(*prop)); | 113 | fdt_nop_region_(prop, len + sizeof(*prop)); |
| 114 | 114 | ||
| 115 | return 0; | 115 | return 0; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | int _fdt_node_end_offset(void *fdt, int offset) | 118 | int fdt_node_end_offset_(void *fdt, int offset) |
| 119 | { | 119 | { |
| 120 | int depth = 0; | 120 | int depth = 0; |
| 121 | 121 | ||
| @@ -129,11 +129,11 @@ int fdt_nop_node(void *fdt, int nodeoffset) | |||
| 129 | { | 129 | { |
| 130 | int endoffset; | 130 | int endoffset; |
| 131 | 131 | ||
| 132 | endoffset = _fdt_node_end_offset(fdt, nodeoffset); | 132 | endoffset = fdt_node_end_offset_(fdt, nodeoffset); |
| 133 | if (endoffset < 0) | 133 | if (endoffset < 0) |
| 134 | return endoffset; | 134 | return endoffset; |
| 135 | 135 | ||
| 136 | _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0), | 136 | fdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0), |
| 137 | endoffset - nodeoffset); | 137 | endoffset - nodeoffset); |
| 138 | return 0; | 138 | return 0; |
| 139 | } | 139 | } |
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index 7f83023ee109..1e27780e1185 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _LIBFDT_H | 1 | #ifndef LIBFDT_H |
| 2 | #define _LIBFDT_H | 2 | #define LIBFDT_H |
| 3 | /* | 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation | 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. | 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| @@ -54,7 +54,7 @@ | |||
| 54 | #include "libfdt_env.h" | 54 | #include "libfdt_env.h" |
| 55 | #include "fdt.h" | 55 | #include "fdt.h" |
| 56 | 56 | ||
| 57 | #define FDT_FIRST_SUPPORTED_VERSION 0x10 | 57 | #define FDT_FIRST_SUPPORTED_VERSION 0x02 |
| 58 | #define FDT_LAST_SUPPORTED_VERSION 0x11 | 58 | #define FDT_LAST_SUPPORTED_VERSION 0x11 |
| 59 | 59 | ||
| 60 | /* Error codes: informative error codes */ | 60 | /* Error codes: informative error codes */ |
| @@ -225,23 +225,23 @@ int fdt_next_subnode(const void *fdt, int offset); | |||
| 225 | #define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) | 225 | #define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) |
| 226 | #define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) | 226 | #define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) |
| 227 | 227 | ||
| 228 | #define __fdt_set_hdr(name) \ | 228 | #define fdt_set_hdr_(name) \ |
| 229 | static inline void fdt_set_##name(void *fdt, uint32_t val) \ | 229 | static inline void fdt_set_##name(void *fdt, uint32_t val) \ |
| 230 | { \ | 230 | { \ |
| 231 | struct fdt_header *fdth = (struct fdt_header *)fdt; \ | 231 | struct fdt_header *fdth = (struct fdt_header *)fdt; \ |
| 232 | fdth->name = cpu_to_fdt32(val); \ | 232 | fdth->name = cpu_to_fdt32(val); \ |
| 233 | } | 233 | } |
| 234 | __fdt_set_hdr(magic); | 234 | fdt_set_hdr_(magic); |
| 235 | __fdt_set_hdr(totalsize); | 235 | fdt_set_hdr_(totalsize); |
| 236 | __fdt_set_hdr(off_dt_struct); | 236 | fdt_set_hdr_(off_dt_struct); |
| 237 | __fdt_set_hdr(off_dt_strings); | 237 | fdt_set_hdr_(off_dt_strings); |
| 238 | __fdt_set_hdr(off_mem_rsvmap); | 238 | fdt_set_hdr_(off_mem_rsvmap); |
| 239 | __fdt_set_hdr(version); | 239 | fdt_set_hdr_(version); |
| 240 | __fdt_set_hdr(last_comp_version); | 240 | fdt_set_hdr_(last_comp_version); |
| 241 | __fdt_set_hdr(boot_cpuid_phys); | 241 | fdt_set_hdr_(boot_cpuid_phys); |
| 242 | __fdt_set_hdr(size_dt_strings); | 242 | fdt_set_hdr_(size_dt_strings); |
| 243 | __fdt_set_hdr(size_dt_struct); | 243 | fdt_set_hdr_(size_dt_struct); |
| 244 | #undef __fdt_set_hdr | 244 | #undef fdt_set_hdr_ |
| 245 | 245 | ||
| 246 | /** | 246 | /** |
| 247 | * fdt_check_header - sanity check a device tree or possible device tree | 247 | * fdt_check_header - sanity check a device tree or possible device tree |
| @@ -527,6 +527,9 @@ int fdt_next_property_offset(const void *fdt, int offset); | |||
| 527 | * offset. If lenp is non-NULL, the length of the property value is | 527 | * offset. If lenp is non-NULL, the length of the property value is |
| 528 | * also returned, in the integer pointed to by lenp. | 528 | * also returned, in the integer pointed to by lenp. |
| 529 | * | 529 | * |
| 530 | * Note that this code only works on device tree versions >= 16. fdt_getprop() | ||
| 531 | * works on all versions. | ||
| 532 | * | ||
| 530 | * returns: | 533 | * returns: |
| 531 | * pointer to the structure representing the property | 534 | * pointer to the structure representing the property |
| 532 | * if lenp is non-NULL, *lenp contains the length of the property | 535 | * if lenp is non-NULL, *lenp contains the length of the property |
| @@ -1449,7 +1452,7 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, | |||
| 1449 | const void *val, int len); | 1452 | const void *val, int len); |
| 1450 | 1453 | ||
| 1451 | /** | 1454 | /** |
| 1452 | * fdt_setprop _placeholder - allocate space for a property | 1455 | * fdt_setprop_placeholder - allocate space for a property |
| 1453 | * @fdt: pointer to the device tree blob | 1456 | * @fdt: pointer to the device tree blob |
| 1454 | * @nodeoffset: offset of the node whose property to change | 1457 | * @nodeoffset: offset of the node whose property to change |
| 1455 | * @name: name of the property to change | 1458 | * @name: name of the property to change |
| @@ -1896,4 +1899,4 @@ int fdt_overlay_apply(void *fdt, void *fdto); | |||
| 1896 | 1899 | ||
| 1897 | const char *fdt_strerror(int errval); | 1900 | const char *fdt_strerror(int errval); |
| 1898 | 1901 | ||
| 1899 | #endif /* _LIBFDT_H */ | 1902 | #endif /* LIBFDT_H */ |
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h index 952056cddf09..bd2474628775 100644 --- a/scripts/dtc/libfdt/libfdt_env.h +++ b/scripts/dtc/libfdt/libfdt_env.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _LIBFDT_ENV_H | 1 | #ifndef LIBFDT_ENV_H |
| 2 | #define _LIBFDT_ENV_H | 2 | #define LIBFDT_ENV_H |
| 3 | /* | 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation | 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. | 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| @@ -109,4 +109,31 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x) | |||
| 109 | #undef CPU_TO_FDT16 | 109 | #undef CPU_TO_FDT16 |
| 110 | #undef EXTRACT_BYTE | 110 | #undef EXTRACT_BYTE |
| 111 | 111 | ||
| 112 | #endif /* _LIBFDT_ENV_H */ | 112 | #ifdef __APPLE__ |
| 113 | #include <AvailabilityMacros.h> | ||
| 114 | |||
| 115 | /* strnlen() is not available on Mac OS < 10.7 */ | ||
| 116 | # if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \ | ||
| 117 | MAC_OS_X_VERSION_10_7) | ||
| 118 | |||
| 119 | #define strnlen fdt_strnlen | ||
| 120 | |||
| 121 | /* | ||
| 122 | * fdt_strnlen: returns the length of a string or max_count - which ever is | ||
| 123 | * smallest. | ||
| 124 | * Input 1 string: the string whose size is to be determined | ||
| 125 | * Input 2 max_count: the maximum value returned by this function | ||
| 126 | * Output: length of the string or max_count (the smallest of the two) | ||
| 127 | */ | ||
| 128 | static inline size_t fdt_strnlen(const char *string, size_t max_count) | ||
| 129 | { | ||
| 130 | const char *p = memchr(string, 0, max_count); | ||
| 131 | return p ? p - string : max_count; | ||
| 132 | } | ||
| 133 | |||
| 134 | #endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < | ||
| 135 | MAC_OS_X_VERSION_10_7) */ | ||
| 136 | |||
| 137 | #endif /* __APPLE__ */ | ||
| 138 | |||
| 139 | #endif /* LIBFDT_ENV_H */ | ||
diff --git a/scripts/dtc/libfdt/libfdt_internal.h b/scripts/dtc/libfdt/libfdt_internal.h index 02cfa6fb612d..7681e192295b 100644 --- a/scripts/dtc/libfdt/libfdt_internal.h +++ b/scripts/dtc/libfdt/libfdt_internal.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _LIBFDT_INTERNAL_H | 1 | #ifndef LIBFDT_INTERNAL_H |
| 2 | #define _LIBFDT_INTERNAL_H | 2 | #define LIBFDT_INTERNAL_H |
| 3 | /* | 3 | /* |
| 4 | * libfdt - Flat Device Tree manipulation | 4 | * libfdt - Flat Device Tree manipulation |
| 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. | 5 | * Copyright (C) 2006 David Gibson, IBM Corporation. |
| @@ -57,27 +57,27 @@ | |||
| 57 | 57 | ||
| 58 | #define FDT_CHECK_HEADER(fdt) \ | 58 | #define FDT_CHECK_HEADER(fdt) \ |
| 59 | { \ | 59 | { \ |
| 60 | int __err; \ | 60 | int err_; \ |
| 61 | if ((__err = fdt_check_header(fdt)) != 0) \ | 61 | if ((err_ = fdt_check_header(fdt)) != 0) \ |
| 62 | return __err; \ | 62 | return err_; \ |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | int _fdt_check_node_offset(const void *fdt, int offset); | 65 | int fdt_check_node_offset_(const void *fdt, int offset); |
| 66 | int _fdt_check_prop_offset(const void *fdt, int offset); | 66 | int fdt_check_prop_offset_(const void *fdt, int offset); |
| 67 | const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); | 67 | const char *fdt_find_string_(const char *strtab, int tabsize, const char *s); |
| 68 | int _fdt_node_end_offset(void *fdt, int nodeoffset); | 68 | int fdt_node_end_offset_(void *fdt, int nodeoffset); |
| 69 | 69 | ||
| 70 | static inline const void *_fdt_offset_ptr(const void *fdt, int offset) | 70 | static inline const void *fdt_offset_ptr_(const void *fdt, int offset) |
| 71 | { | 71 | { |
| 72 | return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; | 72 | return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | static inline void *_fdt_offset_ptr_w(void *fdt, int offset) | 75 | static inline void *fdt_offset_ptr_w_(void *fdt, int offset) |
| 76 | { | 76 | { |
| 77 | return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset); | 77 | return (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n) | 80 | static inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n) |
| 81 | { | 81 | { |
| 82 | const struct fdt_reserve_entry *rsv_table = | 82 | const struct fdt_reserve_entry *rsv_table = |
| 83 | (const struct fdt_reserve_entry *) | 83 | (const struct fdt_reserve_entry *) |
| @@ -85,11 +85,11 @@ static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int | |||
| 85 | 85 | ||
| 86 | return rsv_table + n; | 86 | return rsv_table + n; |
| 87 | } | 87 | } |
| 88 | static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n) | 88 | static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n) |
| 89 | { | 89 | { |
| 90 | return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n); | 90 | return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | #define FDT_SW_MAGIC (~FDT_MAGIC) | 93 | #define FDT_SW_MAGIC (~FDT_MAGIC) |
| 94 | 94 | ||
| 95 | #endif /* _LIBFDT_INTERNAL_H */ | 95 | #endif /* LIBFDT_INTERNAL_H */ |
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c index 6846ad2fd6d2..57b7db2ed153 100644 --- a/scripts/dtc/livetree.c +++ b/scripts/dtc/livetree.c | |||
| @@ -216,7 +216,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |||
| 216 | return old_node; | 216 | return old_node; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | void add_orphan_node(struct node *dt, struct node *new_node, char *ref) | 219 | struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref) |
| 220 | { | 220 | { |
| 221 | static unsigned int next_orphan_fragment = 0; | 221 | static unsigned int next_orphan_fragment = 0; |
| 222 | struct node *node; | 222 | struct node *node; |
| @@ -236,6 +236,7 @@ void add_orphan_node(struct node *dt, struct node *new_node, char *ref) | |||
| 236 | name_node(node, name); | 236 | name_node(node, name); |
| 237 | 237 | ||
| 238 | add_child(dt, node); | 238 | add_child(dt, node); |
| 239 | return dt; | ||
| 239 | } | 240 | } |
| 240 | 241 | ||
| 241 | struct node *chain_node(struct node *first, struct node *list) | 242 | struct node *chain_node(struct node *first, struct node *list) |
| @@ -507,7 +508,7 @@ struct node *get_node_by_path(struct node *tree, const char *path) | |||
| 507 | 508 | ||
| 508 | for_each_child(tree, child) { | 509 | for_each_child(tree, child) { |
| 509 | if (p && (strlen(child->name) == p-path) && | 510 | if (p && (strlen(child->name) == p-path) && |
| 510 | strneq(path, child->name, p-path)) | 511 | strprefixeq(path, p - path, child->name)) |
| 511 | return get_node_by_path(child, p+1); | 512 | return get_node_by_path(child, p+1); |
| 512 | else if (!p && streq(path, child->name)) | 513 | else if (!p && streq(path, child->name)) |
| 513 | return child; | 514 | return child; |
| @@ -540,7 +541,10 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle) | |||
| 540 | { | 541 | { |
| 541 | struct node *child, *node; | 542 | struct node *child, *node; |
| 542 | 543 | ||
| 543 | assert((phandle != 0) && (phandle != -1)); | 544 | if ((phandle == 0) || (phandle == -1)) { |
| 545 | assert(generate_fixups); | ||
| 546 | return NULL; | ||
| 547 | } | ||
| 544 | 548 | ||
| 545 | if (tree->phandle == phandle) { | 549 | if (tree->phandle == phandle) { |
| 546 | if (tree->deleted) | 550 | if (tree->deleted) |
diff --git a/scripts/dtc/srcpos.c b/scripts/dtc/srcpos.c index 9d38459902f3..cb6ed0e3e5e4 100644 --- a/scripts/dtc/srcpos.c +++ b/scripts/dtc/srcpos.c | |||
| @@ -209,8 +209,6 @@ struct srcpos srcpos_empty = { | |||
| 209 | .file = NULL, | 209 | .file = NULL, |
| 210 | }; | 210 | }; |
| 211 | 211 | ||
| 212 | #define TAB_SIZE 8 | ||
| 213 | |||
| 214 | void srcpos_update(struct srcpos *pos, const char *text, int len) | 212 | void srcpos_update(struct srcpos *pos, const char *text, int len) |
| 215 | { | 213 | { |
| 216 | int i; | 214 | int i; |
| @@ -224,9 +222,6 @@ void srcpos_update(struct srcpos *pos, const char *text, int len) | |||
| 224 | if (text[i] == '\n') { | 222 | if (text[i] == '\n') { |
| 225 | current_srcfile->lineno++; | 223 | current_srcfile->lineno++; |
| 226 | current_srcfile->colno = 1; | 224 | current_srcfile->colno = 1; |
| 227 | } else if (text[i] == '\t') { | ||
| 228 | current_srcfile->colno = | ||
| 229 | ALIGN(current_srcfile->colno, TAB_SIZE); | ||
| 230 | } else { | 225 | } else { |
| 231 | current_srcfile->colno++; | 226 | current_srcfile->colno++; |
| 232 | } | 227 | } |
diff --git a/scripts/dtc/srcpos.h b/scripts/dtc/srcpos.h index 7caca8257c6d..9ded12a3830a 100644 --- a/scripts/dtc/srcpos.h +++ b/scripts/dtc/srcpos.h | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | * USA | 17 | * USA |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #ifndef _SRCPOS_H_ | 20 | #ifndef SRCPOS_H |
| 21 | #define _SRCPOS_H_ | 21 | #define SRCPOS_H |
| 22 | 22 | ||
| 23 | #include <stdio.h> | 23 | #include <stdio.h> |
| 24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
| @@ -114,4 +114,4 @@ extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix, | |||
| 114 | 114 | ||
| 115 | extern void srcpos_set_line(char *f, int l); | 115 | extern void srcpos_set_line(char *f, int l); |
| 116 | 116 | ||
| 117 | #endif /* _SRCPOS_H_ */ | 117 | #endif /* SRCPOS_H */ |
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh index fe8926bb3b54..1a009fd195d0 100755 --- a/scripts/dtc/update-dtc-source.sh +++ b/scripts/dtc/update-dtc-source.sh | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | # | 4 | # |
| 5 | # This script assumes that the dtc and the linux git trees are in the | 5 | # This script assumes that the dtc and the linux git trees are in the |
| 6 | # same directory. After building dtc in the dtc directory, it copies the | 6 | # same directory. After building dtc in the dtc directory, it copies the |
| 7 | # source files and generated source files into the scripts/dtc directory | 7 | # source files and generated source file(s) into the scripts/dtc directory |
| 8 | # in the kernel and creates a git commit updating them to the new | 8 | # in the kernel and creates a git commit updating them to the new |
| 9 | # version. | 9 | # version. |
| 10 | # | 10 | # |
| @@ -34,7 +34,6 @@ DTC_LINUX_PATH=`pwd`/scripts/dtc | |||
| 34 | DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ | 34 | DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ |
| 35 | srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ | 35 | srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ |
| 36 | dtc-lexer.l dtc-parser.y" | 36 | dtc-lexer.l dtc-parser.y" |
| 37 | DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" | ||
| 38 | LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ | 37 | LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ |
| 39 | fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ | 38 | fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ |
| 40 | fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" | 39 | fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" |
| @@ -59,10 +58,6 @@ for f in $DTC_SOURCE; do | |||
| 59 | cp ${DTC_UPSTREAM_PATH}/${f} ${f} | 58 | cp ${DTC_UPSTREAM_PATH}/${f} ${f} |
| 60 | git add ${f} | 59 | git add ${f} |
| 61 | done | 60 | done |
| 62 | for f in $DTC_GENERATED; do | ||
| 63 | cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped | ||
| 64 | git add ${f}_shipped | ||
| 65 | done | ||
| 66 | for f in $LIBFDT_SOURCE; do | 61 | for f in $LIBFDT_SOURCE; do |
| 67 | cp ${DTC_UPSTREAM_PATH}/libfdt/${f} libfdt/${f} | 62 | cp ${DTC_UPSTREAM_PATH}/libfdt/${f} libfdt/${f} |
| 68 | git add libfdt/${f} | 63 | git add libfdt/${f} |
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index ad5f41199edb..66fba8ea709b 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _UTIL_H | 1 | #ifndef UTIL_H |
| 2 | #define _UTIL_H | 2 | #define UTIL_H |
| 3 | 3 | ||
| 4 | #include <stdarg.h> | 4 | #include <stdarg.h> |
| 5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
| @@ -35,6 +35,9 @@ | |||
| 35 | 35 | ||
| 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 37 | 37 | ||
| 38 | #define stringify(s) stringify_(s) | ||
| 39 | #define stringify_(s) #s | ||
| 40 | |||
| 38 | static inline void NORETURN PRINTF(1, 2) die(const char *str, ...) | 41 | static inline void NORETURN PRINTF(1, 2) die(const char *str, ...) |
| 39 | { | 42 | { |
| 40 | va_list ap; | 43 | va_list ap; |
| @@ -260,4 +263,4 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis, | |||
| 260 | case 'V': util_version(); \ | 263 | case 'V': util_version(); \ |
| 261 | case '?': usage("unknown option"); | 264 | case '?': usage("unknown option"); |
| 262 | 265 | ||
| 263 | #endif /* _UTIL_H */ | 266 | #endif /* UTIL_H */ |
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h index 6a4e84798966..ad87849e333b 100644 --- a/scripts/dtc/version_gen.h +++ b/scripts/dtc/version_gen.h | |||
| @@ -1 +1 @@ | |||
| #define DTC_VERSION "DTC 1.4.5-gc1e55a55" | #define DTC_VERSION "DTC 1.4.6-gaadd0b65" | ||
diff --git a/scripts/faddr2line b/scripts/faddr2line index 7721d5b2b0c0..9e5735a4d3a5 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line | |||
| @@ -163,7 +163,17 @@ __faddr2line() { | |||
| 163 | 163 | ||
| 164 | # pass real address to addr2line | 164 | # pass real address to addr2line |
| 165 | echo "$func+$offset/$sym_size:" | 165 | echo "$func+$offset/$sym_size:" |
| 166 | ${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" | 166 | local file_lines=$(${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;") |
| 167 | [[ -z $file_lines ]] && return | ||
| 168 | |||
| 169 | # show each line with context | ||
| 170 | echo "$file_lines" | while read -r line | ||
| 171 | do | ||
| 172 | echo $line | ||
| 173 | eval $(echo $line | awk -F "[ :]" '{printf("n1=%d;n2=%d;f=%s",$NF-5, $NF+5, $(NF-1))}') | ||
| 174 | awk 'NR>=strtonum("'$n1'") && NR<=strtonum("'$n2'") {printf("%d\t%s\n", NR, $0)}' $f | ||
| 175 | done | ||
| 176 | |||
| 167 | DONE=1 | 177 | DONE=1 |
| 168 | 178 | ||
| 169 | done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') | 179 | done < <(${NM} -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }') |
diff --git a/scripts/file-size.sh b/scripts/file-size.sh new file mode 100755 index 000000000000..7eb7423416b5 --- /dev/null +++ b/scripts/file-size.sh | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # SPDX-License-Identifier: GPL-2.0 | ||
| 3 | set -- $(ls -dn "$1") | ||
| 4 | printf '%s\n' "$5" | ||
diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index c4a345c3715b..6d5bbd31db7f 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c | |||
| @@ -52,8 +52,8 @@ static const struct whitelist_entry whitelist[] = { | |||
| 52 | { "net/unix/af_unix.c", "unix_skb_parms", "char" }, | 52 | { "net/unix/af_unix.c", "unix_skb_parms", "char" }, |
| 53 | /* big_key payload.data struct splashing */ | 53 | /* big_key payload.data struct splashing */ |
| 54 | { "security/keys/big_key.c", "path", "void *" }, | 54 | { "security/keys/big_key.c", "path", "void *" }, |
| 55 | /* walk struct security_hook_heads as an array of struct list_head */ | 55 | /* walk struct security_hook_heads as an array of struct hlist_head */ |
| 56 | { "security/security.c", "list_head", "security_hook_heads" }, | 56 | { "security/security.c", "hlist_head", "security_hook_heads" }, |
| 57 | { } | 57 | { } |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 86a3c0e5cfbc..10e528b3a08f 100755 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh | |||
| @@ -194,7 +194,7 @@ input_file() { | |||
| 194 | source="$1" | 194 | source="$1" |
| 195 | if [ -f "$1" ]; then | 195 | if [ -f "$1" ]; then |
| 196 | ${dep_list}header "$1" | 196 | ${dep_list}header "$1" |
| 197 | is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" | 197 | is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\{0,1\}/cpio/')" |
| 198 | if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then | 198 | if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then |
| 199 | cpio_file=$1 | 199 | cpio_file=$1 |
| 200 | echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" | 200 | echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" |
diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore index e7836b47f060..b119c7da2863 100644 --- a/scripts/genksyms/.gitignore +++ b/scripts/genksyms/.gitignore | |||
| @@ -1,4 +1 @@ | |||
| 1 | *.lex.c | ||
| 2 | *.tab.c | ||
| 3 | *.tab.h | ||
| 4 | genksyms | genksyms | |
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index 34d6ab1811a4..ef0287e42957 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile | |||
| @@ -5,11 +5,34 @@ always := $(hostprogs-y) | |||
| 5 | 5 | ||
| 6 | genksyms-objs := genksyms.o parse.tab.o lex.lex.o | 6 | genksyms-objs := genksyms.o parse.tab.o lex.lex.o |
| 7 | 7 | ||
| 8 | # FIXME: fix the ambiguous grammar in parse.y and delete this hack | ||
| 9 | # | ||
| 10 | # Suppress shift/reduce, reduce/reduce conflicts warnings | ||
| 11 | # unless W=1 is specified. | ||
| 12 | # | ||
| 13 | # Just in case, run "$(YACC) --version" without suppressing stderr | ||
| 14 | # so that 'bison: not found' will be displayed if it is missing. | ||
| 15 | ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) | ||
| 16 | |||
| 17 | quiet_cmd_bison_no_warn = $(quet_cmd_bison) | ||
| 18 | cmd_bison_no_warn = $(YACC) --version >/dev/null; \ | ||
| 19 | $(cmd_bison) 2>/dev/null | ||
| 20 | |||
| 21 | $(obj)/parse.tab.c: $(src)/parse.y FORCE | ||
| 22 | $(call if_changed,bison_no_warn) | ||
| 23 | |||
| 24 | quiet_cmd_bison_h_no_warn = $(quet_cmd_bison_h) | ||
| 25 | cmd_bison_h_no_warn = $(YACC) --version >/dev/null; \ | ||
| 26 | $(cmd_bison_h) 2>/dev/null | ||
| 27 | |||
| 28 | $(obj)/parse.tab.h: $(src)/parse.y FORCE | ||
| 29 | $(call if_changed,bison_h_no_warn) | ||
| 30 | |||
| 31 | endif | ||
| 32 | |||
| 8 | # -I needed for generated C source (shipped source) | 33 | # -I needed for generated C source (shipped source) |
| 9 | HOSTCFLAGS_parse.tab.o := -I$(src) | 34 | HOSTCFLAGS_parse.tab.o := -I$(src) |
| 10 | HOSTCFLAGS_lex.lex.o := -I$(src) | 35 | HOSTCFLAGS_lex.lex.o := -I$(src) |
| 11 | 36 | ||
| 12 | # dependencies on generated files need to be listed explicitly | 37 | # dependencies on generated files need to be listed explicitly |
| 13 | $(obj)/lex.lex.o: $(obj)/parse.tab.h | 38 | $(obj)/lex.lex.o: $(obj)/parse.tab.h |
| 14 | |||
| 15 | clean-files := lex.lex.c parse.tab.c parse.tab.h | ||
diff --git a/scripts/genksyms/lex.lex.c_shipped b/scripts/genksyms/lex.lex.c_shipped deleted file mode 100644 index ba2fda8dfdb2..000000000000 --- a/scripts/genksyms/lex.lex.c_shipped +++ /dev/null | |||
| @@ -1,2291 +0,0 @@ | |||
| 1 | |||
| 2 | #line 3 "scripts/genksyms/lex.lex.c_shipped" | ||
| 3 | |||
| 4 | #define YY_INT_ALIGNED short int | ||
| 5 | |||
| 6 | /* A lexical scanner generated by flex */ | ||
| 7 | |||
| 8 | #define FLEX_SCANNER | ||
| 9 | #define YY_FLEX_MAJOR_VERSION 2 | ||
| 10 | #define YY_FLEX_MINOR_VERSION 5 | ||
| 11 | #define YY_FLEX_SUBMINOR_VERSION 35 | ||
| 12 | #if YY_FLEX_SUBMINOR_VERSION > 0 | ||
| 13 | #define FLEX_BETA | ||
| 14 | #endif | ||
| 15 | |||
| 16 | /* First, we deal with platform-specific or compiler-specific issues. */ | ||
| 17 | |||
| 18 | /* begin standard C headers. */ | ||
| 19 | #include <stdio.h> | ||
| 20 | #include <string.h> | ||
| 21 | #include <errno.h> | ||
| 22 | #include <stdlib.h> | ||
| 23 | |||
| 24 | /* end standard C headers. */ | ||
| 25 | |||
| 26 | /* flex integer type definitions */ | ||
| 27 | |||
| 28 | #ifndef FLEXINT_H | ||
| 29 | #define FLEXINT_H | ||
| 30 | |||
| 31 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ | ||
| 32 | |||
| 33 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
| 34 | |||
| 35 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, | ||
| 36 | * if you want the limit (max/min) macros for int types. | ||
| 37 | */ | ||
| 38 | #ifndef __STDC_LIMIT_MACROS | ||
| 39 | #define __STDC_LIMIT_MACROS 1 | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #include <inttypes.h> | ||
| 43 | typedef int8_t flex_int8_t; | ||
| 44 | typedef uint8_t flex_uint8_t; | ||
| 45 | typedef int16_t flex_int16_t; | ||
| 46 | typedef uint16_t flex_uint16_t; | ||
| 47 | typedef int32_t flex_int32_t; | ||
| 48 | typedef uint32_t flex_uint32_t; | ||
| 49 | #else | ||
| 50 | typedef signed char flex_int8_t; | ||
| 51 | typedef short int flex_int16_t; | ||
| 52 | typedef int flex_int32_t; | ||
| 53 | typedef unsigned char flex_uint8_t; | ||
| 54 | typedef unsigned short int flex_uint16_t; | ||
| 55 | typedef unsigned int flex_uint32_t; | ||
| 56 | #endif /* ! C99 */ | ||
| 57 | |||
| 58 | /* Limits of integral types. */ | ||
| 59 | #ifndef INT8_MIN | ||
| 60 | #define INT8_MIN (-128) | ||
| 61 | #endif | ||
| 62 | #ifndef INT16_MIN | ||
| 63 | #define INT16_MIN (-32767-1) | ||
| 64 | #endif | ||
| 65 | #ifndef INT32_MIN | ||
| 66 | #define INT32_MIN (-2147483647-1) | ||
| 67 | #endif | ||
| 68 | #ifndef INT8_MAX | ||
| 69 | #define INT8_MAX (127) | ||
| 70 | #endif | ||
| 71 | #ifndef INT16_MAX | ||
| 72 | #define INT16_MAX (32767) | ||
| 73 | #endif | ||
| 74 | #ifndef INT32_MAX | ||
| 75 | #define INT32_MAX (2147483647) | ||
| 76 | #endif | ||
| 77 | #ifndef UINT8_MAX | ||
| 78 | #define UINT8_MAX (255U) | ||
| 79 | #endif | ||
| 80 | #ifndef UINT16_MAX | ||
| 81 | #define UINT16_MAX (65535U) | ||
| 82 | #endif | ||
| 83 | #ifndef UINT32_MAX | ||
| 84 | #define UINT32_MAX (4294967295U) | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #endif /* ! FLEXINT_H */ | ||
| 88 | |||
| 89 | #ifdef __cplusplus | ||
| 90 | |||
| 91 | /* The "const" storage-class-modifier is valid. */ | ||
| 92 | #define YY_USE_CONST | ||
| 93 | |||
| 94 | #else /* ! __cplusplus */ | ||
| 95 | |||
| 96 | /* C99 requires __STDC__ to be defined as 1. */ | ||
| 97 | #if defined (__STDC__) | ||
| 98 | |||
| 99 | #define YY_USE_CONST | ||
| 100 | |||
| 101 | #endif /* defined (__STDC__) */ | ||
| 102 | #endif /* ! __cplusplus */ | ||
| 103 | |||
| 104 | #ifdef YY_USE_CONST | ||
| 105 | #define yyconst const | ||
| 106 | #else | ||
| 107 | #define yyconst | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /* Returned upon end-of-file. */ | ||
| 111 | #define YY_NULL 0 | ||
| 112 | |||
| 113 | /* Promotes a possibly negative, possibly signed char to an unsigned | ||
| 114 | * integer for use as an array index. If the signed char is negative, | ||
| 115 | * we want to instead treat it as an 8-bit unsigned char, hence the | ||
| 116 | * double cast. | ||
| 117 | */ | ||
| 118 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | ||
| 119 | |||
| 120 | /* Enter a start condition. This macro really ought to take a parameter, | ||
| 121 | * but we do it the disgusting crufty way forced on us by the ()-less | ||
| 122 | * definition of BEGIN. | ||
| 123 | */ | ||
| 124 | #define BEGIN (yy_start) = 1 + 2 * | ||
| 125 | |||
| 126 | /* Translate the current start state into a value that can be later handed | ||
| 127 | * to BEGIN to return to the state. The YYSTATE alias is for lex | ||
| 128 | * compatibility. | ||
| 129 | */ | ||
| 130 | #define YY_START (((yy_start) - 1) / 2) | ||
| 131 | #define YYSTATE YY_START | ||
| 132 | |||
| 133 | /* Action number for EOF rule of a given start state. */ | ||
| 134 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | ||
| 135 | |||
| 136 | /* Special action meaning "start processing a new file". */ | ||
| 137 | #define YY_NEW_FILE yyrestart(yyin ) | ||
| 138 | |||
| 139 | #define YY_END_OF_BUFFER_CHAR 0 | ||
| 140 | |||
| 141 | /* Size of default input buffer. */ | ||
| 142 | #ifndef YY_BUF_SIZE | ||
| 143 | #define YY_BUF_SIZE 16384 | ||
| 144 | #endif | ||
| 145 | |||
| 146 | /* The state buf must be large enough to hold one state per character in the main buffer. | ||
| 147 | */ | ||
| 148 | #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) | ||
| 149 | |||
| 150 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE | ||
| 151 | #define YY_TYPEDEF_YY_BUFFER_STATE | ||
| 152 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
| 153 | #endif | ||
| 154 | |||
| 155 | extern int yyleng; | ||
| 156 | |||
| 157 | extern FILE *yyin, *yyout; | ||
| 158 | |||
| 159 | #define EOB_ACT_CONTINUE_SCAN 0 | ||
| 160 | #define EOB_ACT_END_OF_FILE 1 | ||
| 161 | #define EOB_ACT_LAST_MATCH 2 | ||
| 162 | |||
| 163 | #define YY_LESS_LINENO(n) | ||
| 164 | |||
| 165 | /* Return all but the first "n" matched characters back to the input stream. */ | ||
| 166 | #define yyless(n) \ | ||
| 167 | do \ | ||
| 168 | { \ | ||
| 169 | /* Undo effects of setting up yytext. */ \ | ||
| 170 | int yyless_macro_arg = (n); \ | ||
| 171 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
| 172 | *yy_cp = (yy_hold_char); \ | ||
| 173 | YY_RESTORE_YY_MORE_OFFSET \ | ||
| 174 | (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ | ||
| 175 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ | ||
| 176 | } \ | ||
| 177 | while ( 0 ) | ||
| 178 | |||
| 179 | #define unput(c) yyunput( c, (yytext_ptr) ) | ||
| 180 | |||
| 181 | #ifndef YY_TYPEDEF_YY_SIZE_T | ||
| 182 | #define YY_TYPEDEF_YY_SIZE_T | ||
| 183 | typedef size_t yy_size_t; | ||
| 184 | #endif | ||
| 185 | |||
| 186 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
| 187 | #define YY_STRUCT_YY_BUFFER_STATE | ||
| 188 | struct yy_buffer_state | ||
| 189 | { | ||
| 190 | FILE *yy_input_file; | ||
| 191 | |||
| 192 | char *yy_ch_buf; /* input buffer */ | ||
| 193 | char *yy_buf_pos; /* current position in input buffer */ | ||
| 194 | |||
| 195 | /* Size of input buffer in bytes, not including room for EOB | ||
| 196 | * characters. | ||
| 197 | */ | ||
| 198 | yy_size_t yy_buf_size; | ||
| 199 | |||
| 200 | /* Number of characters read into yy_ch_buf, not including EOB | ||
| 201 | * characters. | ||
| 202 | */ | ||
| 203 | int yy_n_chars; | ||
| 204 | |||
| 205 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
| 206 | * and can realloc() it to grow it, and should free() it to | ||
| 207 | * delete it. | ||
| 208 | */ | ||
| 209 | int yy_is_our_buffer; | ||
| 210 | |||
| 211 | /* Whether this is an "interactive" input source; if so, and | ||
| 212 | * if we're using stdio for input, then we want to use getc() | ||
| 213 | * instead of fread(), to make sure we stop fetching input after | ||
| 214 | * each newline. | ||
| 215 | */ | ||
| 216 | int yy_is_interactive; | ||
| 217 | |||
| 218 | /* Whether we're considered to be at the beginning of a line. | ||
| 219 | * If so, '^' rules will be active on the next match, otherwise | ||
| 220 | * not. | ||
| 221 | */ | ||
| 222 | int yy_at_bol; | ||
| 223 | |||
| 224 | int yy_bs_lineno; /**< The line count. */ | ||
| 225 | int yy_bs_column; /**< The column count. */ | ||
| 226 | |||
| 227 | /* Whether to try to fill the input buffer when we reach the | ||
| 228 | * end of it. | ||
| 229 | */ | ||
| 230 | int yy_fill_buffer; | ||
| 231 | |||
| 232 | int yy_buffer_status; | ||
| 233 | |||
| 234 | #define YY_BUFFER_NEW 0 | ||
| 235 | #define YY_BUFFER_NORMAL 1 | ||
| 236 | /* When an EOF's been seen but there's still some text to process | ||
| 237 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | ||
| 238 | * shouldn't try reading from the input source any more. We might | ||
| 239 | * still have a bunch of tokens to match, though, because of | ||
| 240 | * possible backing-up. | ||
| 241 | * | ||
| 242 | * When we actually see the EOF, we change the status to "new" | ||
| 243 | * (via yyrestart()), so that the user can continue scanning by | ||
| 244 | * just pointing yyin at a new input file. | ||
| 245 | */ | ||
| 246 | #define YY_BUFFER_EOF_PENDING 2 | ||
| 247 | |||
| 248 | }; | ||
| 249 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ | ||
| 250 | |||
| 251 | /* Stack of input buffers. */ | ||
| 252 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | ||
| 253 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | ||
| 254 | static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ | ||
| 255 | |||
| 256 | /* We provide macros for accessing buffer states in case in the | ||
| 257 | * future we want to put the buffer states in a more general | ||
| 258 | * "scanner state". | ||
| 259 | * | ||
| 260 | * Returns the top of the stack, or NULL. | ||
| 261 | */ | ||
| 262 | #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ | ||
| 263 | ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ | ||
| 264 | : NULL) | ||
| 265 | |||
| 266 | /* Same as previous macro, but useful when we know that the buffer stack is not | ||
| 267 | * NULL or when we need an lvalue. For internal use only. | ||
| 268 | */ | ||
| 269 | #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] | ||
| 270 | |||
| 271 | /* yy_hold_char holds the character lost when yytext is formed. */ | ||
| 272 | static char yy_hold_char; | ||
| 273 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
| 274 | int yyleng; | ||
| 275 | |||
| 276 | /* Points to current character in buffer. */ | ||
| 277 | static char *yy_c_buf_p = (char *) 0; | ||
| 278 | static int yy_init = 0; /* whether we need to initialize */ | ||
| 279 | static int yy_start = 0; /* start state number */ | ||
| 280 | |||
| 281 | /* Flag which is used to allow yywrap()'s to do buffer switches | ||
| 282 | * instead of setting up a fresh yyin. A bit of a hack ... | ||
| 283 | */ | ||
| 284 | static int yy_did_buffer_switch_on_eof; | ||
| 285 | |||
| 286 | void yyrestart (FILE *input_file ); | ||
| 287 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
| 288 | YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); | ||
| 289 | void yy_delete_buffer (YY_BUFFER_STATE b ); | ||
| 290 | void yy_flush_buffer (YY_BUFFER_STATE b ); | ||
| 291 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
| 292 | void yypop_buffer_state (void ); | ||
| 293 | |||
| 294 | static void yyensure_buffer_stack (void ); | ||
| 295 | static void yy_load_buffer_state (void ); | ||
| 296 | static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); | ||
| 297 | |||
| 298 | #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) | ||
| 299 | |||
| 300 | YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); | ||
| 301 | YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); | ||
| 302 | YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); | ||
| 303 | |||
| 304 | void *yyalloc (yy_size_t ); | ||
| 305 | void *yyrealloc (void *,yy_size_t ); | ||
| 306 | void yyfree (void * ); | ||
| 307 | |||
| 308 | #define yy_new_buffer yy_create_buffer | ||
| 309 | |||
| 310 | #define yy_set_interactive(is_interactive) \ | ||
| 311 | { \ | ||
| 312 | if ( ! YY_CURRENT_BUFFER ){ \ | ||
| 313 | yyensure_buffer_stack (); \ | ||
| 314 | YY_CURRENT_BUFFER_LVALUE = \ | ||
| 315 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ | ||
| 316 | } \ | ||
| 317 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ | ||
| 318 | } | ||
| 319 | |||
| 320 | #define yy_set_bol(at_bol) \ | ||
| 321 | { \ | ||
| 322 | if ( ! YY_CURRENT_BUFFER ){\ | ||
| 323 | yyensure_buffer_stack (); \ | ||
| 324 | YY_CURRENT_BUFFER_LVALUE = \ | ||
| 325 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ | ||
| 326 | } \ | ||
| 327 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ | ||
| 328 | } | ||
| 329 | |||
| 330 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) | ||
| 331 | |||
| 332 | /* Begin user sect3 */ | ||
| 333 | |||
| 334 | #define yywrap(n) 1 | ||
| 335 | #define YY_SKIP_YYWRAP | ||
| 336 | |||
| 337 | typedef unsigned char YY_CHAR; | ||
| 338 | |||
| 339 | FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; | ||
| 340 | |||
| 341 | typedef int yy_state_type; | ||
| 342 | |||
| 343 | extern int yylineno; | ||
| 344 | |||
| 345 | int yylineno = 1; | ||
| 346 | |||
| 347 | extern char *yytext; | ||
| 348 | #define yytext_ptr yytext | ||
| 349 | |||
| 350 | static yy_state_type yy_get_previous_state (void ); | ||
| 351 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | ||
| 352 | static int yy_get_next_buffer (void ); | ||
| 353 | static void yy_fatal_error (yyconst char msg[] ); | ||
| 354 | |||
| 355 | /* Done after the current pattern has been matched and before the | ||
| 356 | * corresponding action - sets up yytext. | ||
| 357 | */ | ||
| 358 | #define YY_DO_BEFORE_ACTION \ | ||
| 359 | (yytext_ptr) = yy_bp; \ | ||
| 360 | yyleng = (size_t) (yy_cp - yy_bp); \ | ||
| 361 | (yy_hold_char) = *yy_cp; \ | ||
| 362 | *yy_cp = '\0'; \ | ||
| 363 | (yy_c_buf_p) = yy_cp; | ||
| 364 | |||
| 365 | #define YY_NUM_RULES 13 | ||
| 366 | #define YY_END_OF_BUFFER 14 | ||
| 367 | /* This struct is not used in this scanner, | ||
| 368 | but its presence is necessary. */ | ||
| 369 | struct yy_trans_info | ||
| 370 | { | ||
| 371 | flex_int32_t yy_verify; | ||
| 372 | flex_int32_t yy_nxt; | ||
| 373 | }; | ||
| 374 | static yyconst flex_int16_t yy_accept[73] = | ||
| 375 | { 0, | ||
| 376 | 0, 0, 14, 12, 4, 3, 12, 7, 12, 12, | ||
| 377 | 12, 12, 12, 9, 9, 12, 12, 7, 12, 12, | ||
| 378 | 4, 0, 5, 0, 7, 8, 0, 6, 0, 0, | ||
| 379 | 10, 10, 9, 0, 0, 9, 9, 0, 9, 0, | ||
| 380 | 0, 0, 0, 2, 0, 0, 11, 0, 10, 0, | ||
| 381 | 10, 9, 9, 0, 0, 0, 10, 10, 0, 0, | ||
| 382 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 383 | 1, 0 | ||
| 384 | } ; | ||
| 385 | |||
| 386 | static yyconst flex_int32_t yy_ec[256] = | ||
| 387 | { 0, | ||
| 388 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | ||
| 389 | 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, | ||
| 390 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 391 | 1, 2, 1, 5, 6, 7, 8, 9, 10, 1, | ||
| 392 | 1, 8, 11, 1, 12, 13, 8, 14, 15, 15, | ||
| 393 | 15, 15, 15, 15, 15, 16, 16, 1, 1, 17, | ||
| 394 | 18, 19, 1, 1, 20, 20, 20, 20, 21, 22, | ||
| 395 | 7, 7, 7, 7, 7, 23, 7, 7, 7, 7, | ||
| 396 | 7, 7, 7, 7, 24, 7, 7, 25, 7, 7, | ||
| 397 | 1, 26, 1, 8, 7, 1, 20, 20, 20, 20, | ||
| 398 | |||
| 399 | 21, 22, 7, 7, 7, 7, 7, 27, 7, 7, | ||
| 400 | 7, 7, 7, 7, 7, 7, 24, 7, 7, 25, | ||
| 401 | 7, 7, 1, 28, 1, 8, 1, 1, 1, 1, | ||
| 402 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 403 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 404 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 405 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 406 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 407 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 408 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 409 | |||
| 410 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 411 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 412 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 413 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 414 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 415 | 1, 1, 1, 1, 1 | ||
| 416 | } ; | ||
| 417 | |||
| 418 | static yyconst flex_int32_t yy_meta[29] = | ||
| 419 | { 0, | ||
| 420 | 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, | ||
| 421 | 4, 4, 5, 6, 6, 6, 1, 1, 1, 7, | ||
| 422 | 8, 7, 3, 3, 3, 1, 3, 1 | ||
| 423 | } ; | ||
| 424 | |||
| 425 | static yyconst flex_int16_t yy_base[85] = | ||
| 426 | { 0, | ||
| 427 | 0, 145, 150, 266, 27, 266, 25, 0, 131, 23, | ||
| 428 | 23, 16, 23, 39, 31, 25, 39, 60, 22, 65, | ||
| 429 | 57, 43, 266, 0, 0, 266, 61, 266, 0, 128, | ||
| 430 | 74, 0, 113, 59, 62, 113, 52, 0, 0, 72, | ||
| 431 | 66, 110, 100, 266, 73, 74, 266, 70, 266, 90, | ||
| 432 | 103, 266, 84, 129, 108, 113, 143, 266, 107, 66, | ||
| 433 | 118, 137, 168, 120, 80, 91, 145, 143, 83, 41, | ||
| 434 | 266, 266, 190, 196, 204, 212, 220, 228, 232, 237, | ||
| 435 | 238, 243, 249, 257 | ||
| 436 | } ; | ||
| 437 | |||
| 438 | static yyconst flex_int16_t yy_def[85] = | ||
| 439 | { 0, | ||
| 440 | 72, 1, 72, 72, 72, 72, 73, 74, 72, 72, | ||
| 441 | 75, 72, 72, 72, 14, 72, 72, 74, 72, 76, | ||
| 442 | 72, 73, 72, 77, 74, 72, 75, 72, 78, 72, | ||
| 443 | 72, 31, 14, 79, 80, 72, 72, 81, 15, 73, | ||
| 444 | 75, 76, 76, 72, 73, 75, 72, 82, 72, 72, | ||
| 445 | 72, 72, 81, 76, 54, 72, 72, 72, 76, 54, | ||
| 446 | 76, 76, 76, 54, 83, 76, 63, 83, 84, 84, | ||
| 447 | 72, 0, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 448 | 72, 72, 72, 72 | ||
| 449 | } ; | ||
| 450 | |||
| 451 | static yyconst flex_int16_t yy_nxt[295] = | ||
| 452 | { 0, | ||
| 453 | 4, 5, 6, 5, 7, 4, 8, 9, 10, 11, | ||
| 454 | 9, 12, 13, 14, 15, 15, 16, 9, 17, 8, | ||
| 455 | 8, 8, 18, 8, 8, 4, 8, 19, 21, 23, | ||
| 456 | 21, 26, 28, 26, 26, 30, 31, 31, 31, 26, | ||
| 457 | 26, 26, 26, 71, 39, 39, 39, 23, 29, 26, | ||
| 458 | 24, 32, 33, 33, 34, 72, 26, 26, 21, 35, | ||
| 459 | 21, 36, 37, 38, 40, 36, 43, 44, 24, 41, | ||
| 460 | 28, 32, 50, 50, 52, 28, 23, 23, 52, 35, | ||
| 461 | 56, 56, 44, 28, 42, 71, 29, 31, 31, 31, | ||
| 462 | 42, 29, 59, 44, 48, 49, 49, 24, 24, 29, | ||
| 463 | |||
| 464 | 49, 43, 44, 51, 51, 51, 36, 37, 59, 44, | ||
| 465 | 36, 65, 44, 54, 55, 55, 51, 51, 51, 59, | ||
| 466 | 44, 64, 64, 64, 58, 58, 57, 57, 57, 58, | ||
| 467 | 59, 44, 42, 64, 64, 64, 52, 72, 59, 44, | ||
| 468 | 47, 66, 60, 60, 42, 44, 59, 69, 26, 72, | ||
| 469 | 20, 61, 62, 63, 72, 61, 57, 57, 57, 66, | ||
| 470 | 72, 72, 72, 66, 49, 49, 72, 61, 62, 49, | ||
| 471 | 44, 61, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 472 | 72, 67, 67, 67, 72, 72, 72, 67, 67, 67, | ||
| 473 | 22, 22, 22, 22, 22, 22, 22, 22, 25, 72, | ||
| 474 | |||
| 475 | 72, 25, 25, 25, 27, 27, 27, 27, 27, 27, | ||
| 476 | 27, 27, 42, 42, 42, 42, 42, 42, 42, 42, | ||
| 477 | 45, 72, 45, 45, 45, 45, 45, 45, 46, 72, | ||
| 478 | 46, 46, 46, 46, 46, 46, 34, 34, 72, 34, | ||
| 479 | 51, 72, 51, 53, 53, 53, 57, 72, 57, 68, | ||
| 480 | 68, 68, 68, 68, 68, 68, 68, 70, 70, 70, | ||
| 481 | 70, 70, 70, 70, 70, 3, 72, 72, 72, 72, | ||
| 482 | 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 483 | 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 484 | 72, 72, 72, 72 | ||
| 485 | |||
| 486 | } ; | ||
| 487 | |||
| 488 | static yyconst flex_int16_t yy_chk[295] = | ||
| 489 | { 0, | ||
| 490 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 491 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 492 | 1, 1, 1, 1, 1, 1, 1, 1, 5, 7, | ||
| 493 | 5, 10, 11, 12, 12, 13, 13, 13, 13, 19, | ||
| 494 | 10, 16, 16, 70, 15, 15, 15, 22, 11, 19, | ||
| 495 | 7, 14, 14, 14, 14, 15, 17, 17, 21, 14, | ||
| 496 | 21, 14, 14, 14, 18, 14, 20, 20, 22, 18, | ||
| 497 | 27, 34, 35, 35, 37, 41, 40, 45, 37, 34, | ||
| 498 | 48, 48, 65, 46, 65, 69, 27, 31, 31, 31, | ||
| 499 | 60, 41, 66, 66, 31, 31, 31, 40, 45, 46, | ||
| 500 | |||
| 501 | 31, 43, 43, 50, 50, 50, 53, 53, 59, 59, | ||
| 502 | 53, 59, 42, 43, 43, 43, 51, 51, 51, 61, | ||
| 503 | 61, 55, 55, 55, 51, 51, 56, 56, 56, 51, | ||
| 504 | 54, 54, 55, 64, 64, 64, 36, 33, 62, 62, | ||
| 505 | 30, 61, 54, 54, 64, 68, 67, 68, 9, 3, | ||
| 506 | 2, 54, 54, 54, 0, 54, 57, 57, 57, 62, | ||
| 507 | 0, 0, 0, 62, 57, 57, 0, 67, 67, 57, | ||
| 508 | 63, 67, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 509 | 0, 63, 63, 63, 0, 0, 0, 63, 63, 63, | ||
| 510 | 73, 73, 73, 73, 73, 73, 73, 73, 74, 0, | ||
| 511 | |||
| 512 | 0, 74, 74, 74, 75, 75, 75, 75, 75, 75, | ||
| 513 | 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, | ||
| 514 | 77, 0, 77, 77, 77, 77, 77, 77, 78, 0, | ||
| 515 | 78, 78, 78, 78, 78, 78, 79, 79, 0, 79, | ||
| 516 | 80, 0, 80, 81, 81, 81, 82, 0, 82, 83, | ||
| 517 | 83, 83, 83, 83, 83, 83, 83, 84, 84, 84, | ||
| 518 | 84, 84, 84, 84, 84, 72, 72, 72, 72, 72, | ||
| 519 | 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 520 | 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, | ||
| 521 | 72, 72, 72, 72 | ||
| 522 | |||
| 523 | } ; | ||
| 524 | |||
| 525 | static yy_state_type yy_last_accepting_state; | ||
| 526 | static char *yy_last_accepting_cpos; | ||
| 527 | |||
| 528 | extern int yy_flex_debug; | ||
| 529 | int yy_flex_debug = 0; | ||
| 530 | |||
| 531 | /* The intent behind this definition is that it'll catch | ||
| 532 | * any uses of REJECT which flex missed. | ||
| 533 | */ | ||
| 534 | #define REJECT reject_used_but_not_detected | ||
| 535 | #define yymore() yymore_used_but_not_detected | ||
| 536 | #define YY_MORE_ADJ 0 | ||
| 537 | #define YY_RESTORE_YY_MORE_OFFSET | ||
| 538 | char *yytext; | ||
| 539 | /* Lexical analysis for genksyms. | ||
| 540 | Copyright 1996, 1997 Linux International. | ||
| 541 | |||
| 542 | New implementation contributed by Richard Henderson <rth@tamu.edu> | ||
| 543 | Based on original work by Bjorn Ekwall <bj0rn@blox.se> | ||
| 544 | |||
| 545 | Taken from Linux modutils 2.4.22. | ||
| 546 | |||
| 547 | This program is free software; you can redistribute it and/or modify it | ||
| 548 | under the terms of the GNU General Public License as published by the | ||
| 549 | Free Software Foundation; either version 2 of the License, or (at your | ||
| 550 | option) any later version. | ||
| 551 | |||
| 552 | This program is distributed in the hope that it will be useful, but | ||
| 553 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 554 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 555 | General Public License for more details. | ||
| 556 | |||
| 557 | You should have received a copy of the GNU General Public License | ||
| 558 | along with this program; if not, write to the Free Software Foundation, | ||
| 559 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
| 560 | |||
| 561 | #include <limits.h> | ||
| 562 | #include <stdlib.h> | ||
| 563 | #include <string.h> | ||
| 564 | #include <ctype.h> | ||
| 565 | |||
| 566 | #include "genksyms.h" | ||
| 567 | #include "parse.tab.h" | ||
| 568 | |||
| 569 | /* We've got a two-level lexer here. We let flex do basic tokenization | ||
| 570 | and then we categorize those basic tokens in the second stage. */ | ||
| 571 | #define YY_DECL static int yylex1(void) | ||
| 572 | |||
| 573 | /* We don't do multiple input files. */ | ||
| 574 | #define YY_NO_INPUT 1 | ||
| 575 | |||
| 576 | #define INITIAL 0 | ||
| 577 | |||
| 578 | #ifndef YY_NO_UNISTD_H | ||
| 579 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | ||
| 580 | * down here because we want the user's section 1 to have been scanned first. | ||
| 581 | * The user has a chance to override it with an option. | ||
| 582 | */ | ||
| 583 | #include <unistd.h> | ||
| 584 | #endif | ||
| 585 | |||
| 586 | #ifndef YY_EXTRA_TYPE | ||
| 587 | #define YY_EXTRA_TYPE void * | ||
| 588 | #endif | ||
| 589 | |||
| 590 | static int yy_init_globals (void ); | ||
| 591 | |||
| 592 | /* Accessor methods to globals. | ||
| 593 | These are made visible to non-reentrant scanners for convenience. */ | ||
| 594 | |||
| 595 | int yylex_destroy (void ); | ||
| 596 | |||
| 597 | int yyget_debug (void ); | ||
| 598 | |||
| 599 | void yyset_debug (int debug_flag ); | ||
| 600 | |||
| 601 | YY_EXTRA_TYPE yyget_extra (void ); | ||
| 602 | |||
| 603 | void yyset_extra (YY_EXTRA_TYPE user_defined ); | ||
| 604 | |||
| 605 | FILE *yyget_in (void ); | ||
| 606 | |||
| 607 | void yyset_in (FILE * in_str ); | ||
| 608 | |||
| 609 | FILE *yyget_out (void ); | ||
| 610 | |||
| 611 | void yyset_out (FILE * out_str ); | ||
| 612 | |||
| 613 | int yyget_leng (void ); | ||
| 614 | |||
| 615 | char *yyget_text (void ); | ||
| 616 | |||
| 617 | int yyget_lineno (void ); | ||
| 618 | |||
| 619 | void yyset_lineno (int line_number ); | ||
| 620 | |||
| 621 | /* Macros after this point can all be overridden by user definitions in | ||
| 622 | * section 1. | ||
| 623 | */ | ||
| 624 | |||
| 625 | #ifndef YY_SKIP_YYWRAP | ||
| 626 | #ifdef __cplusplus | ||
| 627 | extern "C" int yywrap (void ); | ||
| 628 | #else | ||
| 629 | extern int yywrap (void ); | ||
| 630 | #endif | ||
| 631 | #endif | ||
| 632 | |||
| 633 | static void yyunput (int c,char *buf_ptr ); | ||
| 634 | |||
| 635 | #ifndef yytext_ptr | ||
| 636 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
| 637 | #endif | ||
| 638 | |||
| 639 | #ifdef YY_NEED_STRLEN | ||
| 640 | static int yy_flex_strlen (yyconst char * ); | ||
| 641 | #endif | ||
| 642 | |||
| 643 | #ifndef YY_NO_INPUT | ||
| 644 | |||
| 645 | #ifdef __cplusplus | ||
| 646 | static int yyinput (void ); | ||
| 647 | #else | ||
| 648 | static int input (void ); | ||
| 649 | #endif | ||
| 650 | |||
| 651 | #endif | ||
| 652 | |||
| 653 | /* Amount of stuff to slurp up with each read. */ | ||
| 654 | #ifndef YY_READ_BUF_SIZE | ||
| 655 | #define YY_READ_BUF_SIZE 8192 | ||
| 656 | #endif | ||
| 657 | |||
| 658 | /* Copy whatever the last rule matched to the standard output. */ | ||
| 659 | #ifndef ECHO | ||
| 660 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
| 661 | * we now use fwrite(). | ||
| 662 | */ | ||
| 663 | #define ECHO fwrite( yytext, yyleng, 1, yyout ) | ||
| 664 | #endif | ||
| 665 | |||
| 666 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
| 667 | * is returned in "result". | ||
| 668 | */ | ||
| 669 | #ifndef YY_INPUT | ||
| 670 | #define YY_INPUT(buf,result,max_size) \ | ||
| 671 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | ||
| 672 | { \ | ||
| 673 | int c = '*'; \ | ||
| 674 | int n; \ | ||
| 675 | for ( n = 0; n < max_size && \ | ||
| 676 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ | ||
| 677 | buf[n] = (char) c; \ | ||
| 678 | if ( c == '\n' ) \ | ||
| 679 | buf[n++] = (char) c; \ | ||
| 680 | if ( c == EOF && ferror( yyin ) ) \ | ||
| 681 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
| 682 | result = n; \ | ||
| 683 | } \ | ||
| 684 | else \ | ||
| 685 | { \ | ||
| 686 | errno=0; \ | ||
| 687 | while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ | ||
| 688 | { \ | ||
| 689 | if( errno != EINTR) \ | ||
| 690 | { \ | ||
| 691 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
| 692 | break; \ | ||
| 693 | } \ | ||
| 694 | errno=0; \ | ||
| 695 | clearerr(yyin); \ | ||
| 696 | } \ | ||
| 697 | }\ | ||
| 698 | \ | ||
| 699 | |||
| 700 | #endif | ||
| 701 | |||
| 702 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
| 703 | * we don't want an extra ';' after the "return" because that will cause | ||
| 704 | * some compilers to complain about unreachable statements. | ||
| 705 | */ | ||
| 706 | #ifndef yyterminate | ||
| 707 | #define yyterminate() return YY_NULL | ||
| 708 | #endif | ||
| 709 | |||
| 710 | /* Number of entries by which start-condition stack grows. */ | ||
| 711 | #ifndef YY_START_STACK_INCR | ||
| 712 | #define YY_START_STACK_INCR 25 | ||
| 713 | #endif | ||
| 714 | |||
| 715 | /* Report a fatal error. */ | ||
| 716 | #ifndef YY_FATAL_ERROR | ||
| 717 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
| 718 | #endif | ||
| 719 | |||
| 720 | /* end tables serialization structures and prototypes */ | ||
| 721 | |||
| 722 | /* Default declaration of generated scanner - a define so the user can | ||
| 723 | * easily add parameters. | ||
| 724 | */ | ||
| 725 | #ifndef YY_DECL | ||
| 726 | #define YY_DECL_IS_OURS 1 | ||
| 727 | |||
| 728 | extern int yylex (void); | ||
| 729 | |||
| 730 | #define YY_DECL int yylex (void) | ||
| 731 | #endif /* !YY_DECL */ | ||
| 732 | |||
| 733 | /* Code executed at the beginning of each rule, after yytext and yyleng | ||
| 734 | * have been set up. | ||
| 735 | */ | ||
| 736 | #ifndef YY_USER_ACTION | ||
| 737 | #define YY_USER_ACTION | ||
| 738 | #endif | ||
| 739 | |||
| 740 | /* Code executed at the end of each rule. */ | ||
| 741 | #ifndef YY_BREAK | ||
| 742 | #define YY_BREAK break; | ||
| 743 | #endif | ||
| 744 | |||
| 745 | #define YY_RULE_SETUP \ | ||
| 746 | if ( yyleng > 0 ) \ | ||
| 747 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ | ||
| 748 | (yytext[yyleng - 1] == '\n'); \ | ||
| 749 | YY_USER_ACTION | ||
| 750 | |||
| 751 | /** The main scanner function which does all the work. | ||
| 752 | */ | ||
| 753 | YY_DECL | ||
| 754 | { | ||
| 755 | register yy_state_type yy_current_state; | ||
| 756 | register char *yy_cp, *yy_bp; | ||
| 757 | register int yy_act; | ||
| 758 | |||
| 759 | /* Keep track of our location in the original source files. */ | ||
| 760 | |||
| 761 | if ( !(yy_init) ) | ||
| 762 | { | ||
| 763 | (yy_init) = 1; | ||
| 764 | |||
| 765 | #ifdef YY_USER_INIT | ||
| 766 | YY_USER_INIT; | ||
| 767 | #endif | ||
| 768 | |||
| 769 | if ( ! (yy_start) ) | ||
| 770 | (yy_start) = 1; /* first start state */ | ||
| 771 | |||
| 772 | if ( ! yyin ) | ||
| 773 | yyin = stdin; | ||
| 774 | |||
| 775 | if ( ! yyout ) | ||
| 776 | yyout = stdout; | ||
| 777 | |||
| 778 | if ( ! YY_CURRENT_BUFFER ) { | ||
| 779 | yyensure_buffer_stack (); | ||
| 780 | YY_CURRENT_BUFFER_LVALUE = | ||
| 781 | yy_create_buffer(yyin,YY_BUF_SIZE ); | ||
| 782 | } | ||
| 783 | |||
| 784 | yy_load_buffer_state( ); | ||
| 785 | } | ||
| 786 | |||
| 787 | while ( 1 ) /* loops until end-of-file is reached */ | ||
| 788 | { | ||
| 789 | yy_cp = (yy_c_buf_p); | ||
| 790 | |||
| 791 | /* Support of yytext. */ | ||
| 792 | *yy_cp = (yy_hold_char); | ||
| 793 | |||
| 794 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
| 795 | * the current run. | ||
| 796 | */ | ||
| 797 | yy_bp = yy_cp; | ||
| 798 | |||
| 799 | yy_current_state = (yy_start); | ||
| 800 | yy_current_state += YY_AT_BOL(); | ||
| 801 | yy_match: | ||
| 802 | do | ||
| 803 | { | ||
| 804 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; | ||
| 805 | if ( yy_accept[yy_current_state] ) | ||
| 806 | { | ||
| 807 | (yy_last_accepting_state) = yy_current_state; | ||
| 808 | (yy_last_accepting_cpos) = yy_cp; | ||
| 809 | } | ||
| 810 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 811 | { | ||
| 812 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 813 | if ( yy_current_state >= 73 ) | ||
| 814 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 815 | } | ||
| 816 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 817 | ++yy_cp; | ||
| 818 | } | ||
| 819 | while ( yy_base[yy_current_state] != 266 ); | ||
| 820 | |||
| 821 | yy_find_action: | ||
| 822 | yy_act = yy_accept[yy_current_state]; | ||
| 823 | if ( yy_act == 0 ) | ||
| 824 | { /* have to back up */ | ||
| 825 | yy_cp = (yy_last_accepting_cpos); | ||
| 826 | yy_current_state = (yy_last_accepting_state); | ||
| 827 | yy_act = yy_accept[yy_current_state]; | ||
| 828 | } | ||
| 829 | |||
| 830 | YY_DO_BEFORE_ACTION; | ||
| 831 | |||
| 832 | do_action: /* This label is used only to access EOF actions. */ | ||
| 833 | |||
| 834 | switch ( yy_act ) | ||
| 835 | { /* beginning of action switch */ | ||
| 836 | case 0: /* must back up */ | ||
| 837 | /* undo the effects of YY_DO_BEFORE_ACTION */ | ||
| 838 | *yy_cp = (yy_hold_char); | ||
| 839 | yy_cp = (yy_last_accepting_cpos); | ||
| 840 | yy_current_state = (yy_last_accepting_state); | ||
| 841 | goto yy_find_action; | ||
| 842 | |||
| 843 | case 1: | ||
| 844 | /* rule 1 can match eol */ | ||
| 845 | YY_RULE_SETUP | ||
| 846 | return FILENAME; | ||
| 847 | YY_BREAK | ||
| 848 | case 2: | ||
| 849 | /* rule 2 can match eol */ | ||
| 850 | YY_RULE_SETUP | ||
| 851 | cur_line++; | ||
| 852 | YY_BREAK | ||
| 853 | case 3: | ||
| 854 | /* rule 3 can match eol */ | ||
| 855 | YY_RULE_SETUP | ||
| 856 | cur_line++; | ||
| 857 | YY_BREAK | ||
| 858 | /* Ignore all other whitespace. */ | ||
| 859 | case 4: | ||
| 860 | YY_RULE_SETUP | ||
| 861 | ; | ||
| 862 | YY_BREAK | ||
| 863 | case 5: | ||
| 864 | /* rule 5 can match eol */ | ||
| 865 | YY_RULE_SETUP | ||
| 866 | return STRING; | ||
| 867 | YY_BREAK | ||
| 868 | case 6: | ||
| 869 | /* rule 6 can match eol */ | ||
| 870 | YY_RULE_SETUP | ||
| 871 | return CHAR; | ||
| 872 | YY_BREAK | ||
| 873 | case 7: | ||
| 874 | YY_RULE_SETUP | ||
| 875 | return IDENT; | ||
| 876 | YY_BREAK | ||
| 877 | /* The Pedant requires that the other C multi-character tokens be | ||
| 878 | recognized as tokens. We don't actually use them since we don't | ||
| 879 | parse expressions, but we do want whitespace to be arranged | ||
| 880 | around them properly. */ | ||
| 881 | case 8: | ||
| 882 | YY_RULE_SETUP | ||
| 883 | return OTHER; | ||
| 884 | YY_BREAK | ||
| 885 | case 9: | ||
| 886 | YY_RULE_SETUP | ||
| 887 | return INT; | ||
| 888 | YY_BREAK | ||
| 889 | case 10: | ||
| 890 | YY_RULE_SETUP | ||
| 891 | return REAL; | ||
| 892 | YY_BREAK | ||
| 893 | case 11: | ||
| 894 | YY_RULE_SETUP | ||
| 895 | return DOTS; | ||
| 896 | YY_BREAK | ||
| 897 | /* All other tokens are single characters. */ | ||
| 898 | case 12: | ||
| 899 | YY_RULE_SETUP | ||
| 900 | return yytext[0]; | ||
| 901 | YY_BREAK | ||
| 902 | case 13: | ||
| 903 | YY_RULE_SETUP | ||
| 904 | ECHO; | ||
| 905 | YY_BREAK | ||
| 906 | case YY_STATE_EOF(INITIAL): | ||
| 907 | yyterminate(); | ||
| 908 | |||
| 909 | case YY_END_OF_BUFFER: | ||
| 910 | { | ||
| 911 | /* Amount of text matched not including the EOB char. */ | ||
| 912 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | ||
| 913 | |||
| 914 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
| 915 | *yy_cp = (yy_hold_char); | ||
| 916 | YY_RESTORE_YY_MORE_OFFSET | ||
| 917 | |||
| 918 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | ||
| 919 | { | ||
| 920 | /* We're scanning a new file or input source. It's | ||
| 921 | * possible that this happened because the user | ||
| 922 | * just pointed yyin at a new source and called | ||
| 923 | * yylex(). If so, then we have to assure | ||
| 924 | * consistency between YY_CURRENT_BUFFER and our | ||
| 925 | * globals. Here is the right place to do so, because | ||
| 926 | * this is the first action (other than possibly a | ||
| 927 | * back-up) that will match for the new input source. | ||
| 928 | */ | ||
| 929 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
| 930 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; | ||
| 931 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | ||
| 932 | } | ||
| 933 | |||
| 934 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
| 935 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
| 936 | * already have been incremented past the NUL character | ||
| 937 | * (since all states make transitions on EOB to the | ||
| 938 | * end-of-buffer state). Contrast this with the test | ||
| 939 | * in input(). | ||
| 940 | */ | ||
| 941 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
| 942 | { /* This was really a NUL. */ | ||
| 943 | yy_state_type yy_next_state; | ||
| 944 | |||
| 945 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | ||
| 946 | |||
| 947 | yy_current_state = yy_get_previous_state( ); | ||
| 948 | |||
| 949 | /* Okay, we're now positioned to make the NUL | ||
| 950 | * transition. We couldn't have | ||
| 951 | * yy_get_previous_state() go ahead and do it | ||
| 952 | * for us because it doesn't know how to deal | ||
| 953 | * with the possibility of jamming (and we don't | ||
| 954 | * want to build jamming into it because then it | ||
| 955 | * will run more slowly). | ||
| 956 | */ | ||
| 957 | |||
| 958 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
| 959 | |||
| 960 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 961 | |||
| 962 | if ( yy_next_state ) | ||
| 963 | { | ||
| 964 | /* Consume the NUL. */ | ||
| 965 | yy_cp = ++(yy_c_buf_p); | ||
| 966 | yy_current_state = yy_next_state; | ||
| 967 | goto yy_match; | ||
| 968 | } | ||
| 969 | |||
| 970 | else | ||
| 971 | { | ||
| 972 | yy_cp = (yy_c_buf_p); | ||
| 973 | goto yy_find_action; | ||
| 974 | } | ||
| 975 | } | ||
| 976 | |||
| 977 | else switch ( yy_get_next_buffer( ) ) | ||
| 978 | { | ||
| 979 | case EOB_ACT_END_OF_FILE: | ||
| 980 | { | ||
| 981 | (yy_did_buffer_switch_on_eof) = 0; | ||
| 982 | |||
| 983 | if ( yywrap( ) ) | ||
| 984 | { | ||
| 985 | /* Note: because we've taken care in | ||
| 986 | * yy_get_next_buffer() to have set up | ||
| 987 | * yytext, we can now set up | ||
| 988 | * yy_c_buf_p so that if some total | ||
| 989 | * hoser (like flex itself) wants to | ||
| 990 | * call the scanner after we return the | ||
| 991 | * YY_NULL, it'll still work - another | ||
| 992 | * YY_NULL will get returned. | ||
| 993 | */ | ||
| 994 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | ||
| 995 | |||
| 996 | yy_act = YY_STATE_EOF(YY_START); | ||
| 997 | goto do_action; | ||
| 998 | } | ||
| 999 | |||
| 1000 | else | ||
| 1001 | { | ||
| 1002 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
| 1003 | YY_NEW_FILE; | ||
| 1004 | } | ||
| 1005 | break; | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | case EOB_ACT_CONTINUE_SCAN: | ||
| 1009 | (yy_c_buf_p) = | ||
| 1010 | (yytext_ptr) + yy_amount_of_matched_text; | ||
| 1011 | |||
| 1012 | yy_current_state = yy_get_previous_state( ); | ||
| 1013 | |||
| 1014 | yy_cp = (yy_c_buf_p); | ||
| 1015 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1016 | goto yy_match; | ||
| 1017 | |||
| 1018 | case EOB_ACT_LAST_MATCH: | ||
| 1019 | (yy_c_buf_p) = | ||
| 1020 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | ||
| 1021 | |||
| 1022 | yy_current_state = yy_get_previous_state( ); | ||
| 1023 | |||
| 1024 | yy_cp = (yy_c_buf_p); | ||
| 1025 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
| 1026 | goto yy_find_action; | ||
| 1027 | } | ||
| 1028 | break; | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | default: | ||
| 1032 | YY_FATAL_ERROR( | ||
| 1033 | "fatal flex scanner internal error--no action found" ); | ||
| 1034 | } /* end of action switch */ | ||
| 1035 | } /* end of scanning one token */ | ||
| 1036 | } /* end of yylex */ | ||
| 1037 | |||
| 1038 | /* yy_get_next_buffer - try to read in a new buffer | ||
| 1039 | * | ||
| 1040 | * Returns a code representing an action: | ||
| 1041 | * EOB_ACT_LAST_MATCH - | ||
| 1042 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
| 1043 | * EOB_ACT_END_OF_FILE - end of file | ||
| 1044 | */ | ||
| 1045 | static int yy_get_next_buffer (void) | ||
| 1046 | { | ||
| 1047 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | ||
| 1048 | register char *source = (yytext_ptr); | ||
| 1049 | register int number_to_move, i; | ||
| 1050 | int ret_val; | ||
| 1051 | |||
| 1052 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | ||
| 1053 | YY_FATAL_ERROR( | ||
| 1054 | "fatal flex scanner internal error--end of buffer missed" ); | ||
| 1055 | |||
| 1056 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | ||
| 1057 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
| 1058 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | ||
| 1059 | { | ||
| 1060 | /* We matched a single character, the EOB, so | ||
| 1061 | * treat this as a final EOF. | ||
| 1062 | */ | ||
| 1063 | return EOB_ACT_END_OF_FILE; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | else | ||
| 1067 | { | ||
| 1068 | /* We matched some text prior to the EOB, first | ||
| 1069 | * process it. | ||
| 1070 | */ | ||
| 1071 | return EOB_ACT_LAST_MATCH; | ||
| 1072 | } | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | /* Try to read more data. */ | ||
| 1076 | |||
| 1077 | /* First move last chars to start of buffer. */ | ||
| 1078 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; | ||
| 1079 | |||
| 1080 | for ( i = 0; i < number_to_move; ++i ) | ||
| 1081 | *(dest++) = *(source++); | ||
| 1082 | |||
| 1083 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
| 1084 | /* don't do the read, it's not guaranteed to return an EOF, | ||
| 1085 | * just force an EOF | ||
| 1086 | */ | ||
| 1087 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | ||
| 1088 | |||
| 1089 | else | ||
| 1090 | { | ||
| 1091 | int num_to_read = | ||
| 1092 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | ||
| 1093 | |||
| 1094 | while ( num_to_read <= 0 ) | ||
| 1095 | { /* Not enough room in the buffer - grow it. */ | ||
| 1096 | |||
| 1097 | /* just a shorter name for the current buffer */ | ||
| 1098 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; | ||
| 1099 | |||
| 1100 | int yy_c_buf_p_offset = | ||
| 1101 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | ||
| 1102 | |||
| 1103 | if ( b->yy_is_our_buffer ) | ||
| 1104 | { | ||
| 1105 | int new_size = b->yy_buf_size * 2; | ||
| 1106 | |||
| 1107 | if ( new_size <= 0 ) | ||
| 1108 | b->yy_buf_size += b->yy_buf_size / 8; | ||
| 1109 | else | ||
| 1110 | b->yy_buf_size *= 2; | ||
| 1111 | |||
| 1112 | b->yy_ch_buf = (char *) | ||
| 1113 | /* Include room in for 2 EOB chars. */ | ||
| 1114 | yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | ||
| 1115 | } | ||
| 1116 | else | ||
| 1117 | /* Can't grow it, we don't own it. */ | ||
| 1118 | b->yy_ch_buf = 0; | ||
| 1119 | |||
| 1120 | if ( ! b->yy_ch_buf ) | ||
| 1121 | YY_FATAL_ERROR( | ||
| 1122 | "fatal error - scanner input buffer overflow" ); | ||
| 1123 | |||
| 1124 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
| 1125 | |||
| 1126 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | ||
| 1127 | number_to_move - 1; | ||
| 1128 | |||
| 1129 | } | ||
| 1130 | |||
| 1131 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
| 1132 | num_to_read = YY_READ_BUF_SIZE; | ||
| 1133 | |||
| 1134 | /* Read in more data. */ | ||
| 1135 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | ||
| 1136 | (yy_n_chars), (size_t) num_to_read ); | ||
| 1137 | |||
| 1138 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | if ( (yy_n_chars) == 0 ) | ||
| 1142 | { | ||
| 1143 | if ( number_to_move == YY_MORE_ADJ ) | ||
| 1144 | { | ||
| 1145 | ret_val = EOB_ACT_END_OF_FILE; | ||
| 1146 | yyrestart(yyin ); | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | else | ||
| 1150 | { | ||
| 1151 | ret_val = EOB_ACT_LAST_MATCH; | ||
| 1152 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | ||
| 1153 | YY_BUFFER_EOF_PENDING; | ||
| 1154 | } | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | else | ||
| 1158 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
| 1159 | |||
| 1160 | if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { | ||
| 1161 | /* Extend the array by 50%, plus the number we really need. */ | ||
| 1162 | yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); | ||
| 1163 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); | ||
| 1164 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
| 1165 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); | ||
| 1166 | } | ||
| 1167 | |||
| 1168 | (yy_n_chars) += number_to_move; | ||
| 1169 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | ||
| 1170 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | ||
| 1171 | |||
| 1172 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | ||
| 1173 | |||
| 1174 | return ret_val; | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
| 1178 | |||
| 1179 | static yy_state_type yy_get_previous_state (void) | ||
| 1180 | { | ||
| 1181 | register yy_state_type yy_current_state; | ||
| 1182 | register char *yy_cp; | ||
| 1183 | |||
| 1184 | yy_current_state = (yy_start); | ||
| 1185 | yy_current_state += YY_AT_BOL(); | ||
| 1186 | |||
| 1187 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | ||
| 1188 | { | ||
| 1189 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | ||
| 1190 | if ( yy_accept[yy_current_state] ) | ||
| 1191 | { | ||
| 1192 | (yy_last_accepting_state) = yy_current_state; | ||
| 1193 | (yy_last_accepting_cpos) = yy_cp; | ||
| 1194 | } | ||
| 1195 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1196 | { | ||
| 1197 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1198 | if ( yy_current_state >= 73 ) | ||
| 1199 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1200 | } | ||
| 1201 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | return yy_current_state; | ||
| 1205 | } | ||
| 1206 | |||
| 1207 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
| 1208 | * | ||
| 1209 | * synopsis | ||
| 1210 | * next_state = yy_try_NUL_trans( current_state ); | ||
| 1211 | */ | ||
| 1212 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | ||
| 1213 | { | ||
| 1214 | register int yy_is_jam; | ||
| 1215 | register char *yy_cp = (yy_c_buf_p); | ||
| 1216 | |||
| 1217 | register YY_CHAR yy_c = 1; | ||
| 1218 | if ( yy_accept[yy_current_state] ) | ||
| 1219 | { | ||
| 1220 | (yy_last_accepting_state) = yy_current_state; | ||
| 1221 | (yy_last_accepting_cpos) = yy_cp; | ||
| 1222 | } | ||
| 1223 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1224 | { | ||
| 1225 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1226 | if ( yy_current_state >= 73 ) | ||
| 1227 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1228 | } | ||
| 1229 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 1230 | yy_is_jam = (yy_current_state == 72); | ||
| 1231 | |||
| 1232 | return yy_is_jam ? 0 : yy_current_state; | ||
| 1233 | } | ||
| 1234 | |||
| 1235 | static void yyunput (int c, register char * yy_bp ) | ||
| 1236 | { | ||
| 1237 | register char *yy_cp; | ||
| 1238 | |||
| 1239 | yy_cp = (yy_c_buf_p); | ||
| 1240 | |||
| 1241 | /* undo effects of setting up yytext */ | ||
| 1242 | *yy_cp = (yy_hold_char); | ||
| 1243 | |||
| 1244 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
| 1245 | { /* need to shift things up to make room */ | ||
| 1246 | /* +2 for EOB chars. */ | ||
| 1247 | register int number_to_move = (yy_n_chars) + 2; | ||
| 1248 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ | ||
| 1249 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; | ||
| 1250 | register char *source = | ||
| 1251 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; | ||
| 1252 | |||
| 1253 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
| 1254 | *--dest = *--source; | ||
| 1255 | |||
| 1256 | yy_cp += (int) (dest - source); | ||
| 1257 | yy_bp += (int) (dest - source); | ||
| 1258 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = | ||
| 1259 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; | ||
| 1260 | |||
| 1261 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
| 1262 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | ||
| 1263 | } | ||
| 1264 | |||
| 1265 | *--yy_cp = (char) c; | ||
| 1266 | |||
| 1267 | (yytext_ptr) = yy_bp; | ||
| 1268 | (yy_hold_char) = *yy_cp; | ||
| 1269 | (yy_c_buf_p) = yy_cp; | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | #ifndef YY_NO_INPUT | ||
| 1273 | #ifdef __cplusplus | ||
| 1274 | static int yyinput (void) | ||
| 1275 | #else | ||
| 1276 | static int input (void) | ||
| 1277 | #endif | ||
| 1278 | |||
| 1279 | { | ||
| 1280 | int c; | ||
| 1281 | |||
| 1282 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1283 | |||
| 1284 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | ||
| 1285 | { | ||
| 1286 | /* yy_c_buf_p now points to the character we want to return. | ||
| 1287 | * If this occurs *before* the EOB characters, then it's a | ||
| 1288 | * valid NUL; if not, then we've hit the end of the buffer. | ||
| 1289 | */ | ||
| 1290 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
| 1291 | /* This was really a NUL. */ | ||
| 1292 | *(yy_c_buf_p) = '\0'; | ||
| 1293 | |||
| 1294 | else | ||
| 1295 | { /* need more input */ | ||
| 1296 | int offset = (yy_c_buf_p) - (yytext_ptr); | ||
| 1297 | ++(yy_c_buf_p); | ||
| 1298 | |||
| 1299 | switch ( yy_get_next_buffer( ) ) | ||
| 1300 | { | ||
| 1301 | case EOB_ACT_LAST_MATCH: | ||
| 1302 | /* This happens because yy_g_n_b() | ||
| 1303 | * sees that we've accumulated a | ||
| 1304 | * token and flags that we need to | ||
| 1305 | * try matching the token before | ||
| 1306 | * proceeding. But for input(), | ||
| 1307 | * there's no matching to consider. | ||
| 1308 | * So convert the EOB_ACT_LAST_MATCH | ||
| 1309 | * to EOB_ACT_END_OF_FILE. | ||
| 1310 | */ | ||
| 1311 | |||
| 1312 | /* Reset buffer status. */ | ||
| 1313 | yyrestart(yyin ); | ||
| 1314 | |||
| 1315 | /*FALLTHROUGH*/ | ||
| 1316 | |||
| 1317 | case EOB_ACT_END_OF_FILE: | ||
| 1318 | { | ||
| 1319 | if ( yywrap( ) ) | ||
| 1320 | return EOF; | ||
| 1321 | |||
| 1322 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
| 1323 | YY_NEW_FILE; | ||
| 1324 | #ifdef __cplusplus | ||
| 1325 | return yyinput(); | ||
| 1326 | #else | ||
| 1327 | return input(); | ||
| 1328 | #endif | ||
| 1329 | } | ||
| 1330 | |||
| 1331 | case EOB_ACT_CONTINUE_SCAN: | ||
| 1332 | (yy_c_buf_p) = (yytext_ptr) + offset; | ||
| 1333 | break; | ||
| 1334 | } | ||
| 1335 | } | ||
| 1336 | } | ||
| 1337 | |||
| 1338 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | ||
| 1339 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ | ||
| 1340 | (yy_hold_char) = *++(yy_c_buf_p); | ||
| 1341 | |||
| 1342 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); | ||
| 1343 | |||
| 1344 | return c; | ||
| 1345 | } | ||
| 1346 | #endif /* ifndef YY_NO_INPUT */ | ||
| 1347 | |||
| 1348 | /** Immediately switch to a different input stream. | ||
| 1349 | * @param input_file A readable stream. | ||
| 1350 | * | ||
| 1351 | * @note This function does not reset the start condition to @c INITIAL . | ||
| 1352 | */ | ||
| 1353 | void yyrestart (FILE * input_file ) | ||
| 1354 | { | ||
| 1355 | |||
| 1356 | if ( ! YY_CURRENT_BUFFER ){ | ||
| 1357 | yyensure_buffer_stack (); | ||
| 1358 | YY_CURRENT_BUFFER_LVALUE = | ||
| 1359 | yy_create_buffer(yyin,YY_BUF_SIZE ); | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | yy_init_buffer(YY_CURRENT_BUFFER,input_file ); | ||
| 1363 | yy_load_buffer_state( ); | ||
| 1364 | } | ||
| 1365 | |||
| 1366 | /** Switch to a different input buffer. | ||
| 1367 | * @param new_buffer The new input buffer. | ||
| 1368 | * | ||
| 1369 | */ | ||
| 1370 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) | ||
| 1371 | { | ||
| 1372 | |||
| 1373 | /* TODO. We should be able to replace this entire function body | ||
| 1374 | * with | ||
| 1375 | * yypop_buffer_state(); | ||
| 1376 | * yypush_buffer_state(new_buffer); | ||
| 1377 | */ | ||
| 1378 | yyensure_buffer_stack (); | ||
| 1379 | if ( YY_CURRENT_BUFFER == new_buffer ) | ||
| 1380 | return; | ||
| 1381 | |||
| 1382 | if ( YY_CURRENT_BUFFER ) | ||
| 1383 | { | ||
| 1384 | /* Flush out information for old buffer. */ | ||
| 1385 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1386 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
| 1387 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
| 1391 | yy_load_buffer_state( ); | ||
| 1392 | |||
| 1393 | /* We don't actually know whether we did this switch during | ||
| 1394 | * EOF (yywrap()) processing, but the only time this flag | ||
| 1395 | * is looked at is after yywrap() is called, so it's safe | ||
| 1396 | * to go ahead and always set it. | ||
| 1397 | */ | ||
| 1398 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1399 | } | ||
| 1400 | |||
| 1401 | static void yy_load_buffer_state (void) | ||
| 1402 | { | ||
| 1403 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
| 1404 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | ||
| 1405 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | ||
| 1406 | (yy_hold_char) = *(yy_c_buf_p); | ||
| 1407 | } | ||
| 1408 | |||
| 1409 | /** Allocate and initialize an input buffer state. | ||
| 1410 | * @param file A readable stream. | ||
| 1411 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | ||
| 1412 | * | ||
| 1413 | * @return the allocated buffer state. | ||
| 1414 | */ | ||
| 1415 | YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) | ||
| 1416 | { | ||
| 1417 | YY_BUFFER_STATE b; | ||
| 1418 | |||
| 1419 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); | ||
| 1420 | if ( ! b ) | ||
| 1421 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1422 | |||
| 1423 | b->yy_buf_size = size; | ||
| 1424 | |||
| 1425 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
| 1426 | * we need to put in 2 end-of-buffer characters. | ||
| 1427 | */ | ||
| 1428 | b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); | ||
| 1429 | if ( ! b->yy_ch_buf ) | ||
| 1430 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1431 | |||
| 1432 | b->yy_is_our_buffer = 1; | ||
| 1433 | |||
| 1434 | yy_init_buffer(b,file ); | ||
| 1435 | |||
| 1436 | return b; | ||
| 1437 | } | ||
| 1438 | |||
| 1439 | /** Destroy the buffer. | ||
| 1440 | * @param b a buffer created with yy_create_buffer() | ||
| 1441 | * | ||
| 1442 | */ | ||
| 1443 | void yy_delete_buffer (YY_BUFFER_STATE b ) | ||
| 1444 | { | ||
| 1445 | |||
| 1446 | if ( ! b ) | ||
| 1447 | return; | ||
| 1448 | |||
| 1449 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | ||
| 1450 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | ||
| 1451 | |||
| 1452 | if ( b->yy_is_our_buffer ) | ||
| 1453 | yyfree((void *) b->yy_ch_buf ); | ||
| 1454 | |||
| 1455 | yyfree((void *) b ); | ||
| 1456 | } | ||
| 1457 | |||
| 1458 | #ifndef __cplusplus | ||
| 1459 | extern int isatty (int ); | ||
| 1460 | #endif /* __cplusplus */ | ||
| 1461 | |||
| 1462 | /* Initializes or reinitializes a buffer. | ||
| 1463 | * This function is sometimes called more than once on the same buffer, | ||
| 1464 | * such as during a yyrestart() or at EOF. | ||
| 1465 | */ | ||
| 1466 | static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) | ||
| 1467 | |||
| 1468 | { | ||
| 1469 | int oerrno = errno; | ||
| 1470 | |||
| 1471 | yy_flush_buffer(b ); | ||
| 1472 | |||
| 1473 | b->yy_input_file = file; | ||
| 1474 | b->yy_fill_buffer = 1; | ||
| 1475 | |||
| 1476 | /* If b is the current buffer, then yy_init_buffer was _probably_ | ||
| 1477 | * called from yyrestart() or through yy_get_next_buffer. | ||
| 1478 | * In that case, we don't want to reset the lineno or column. | ||
| 1479 | */ | ||
| 1480 | if (b != YY_CURRENT_BUFFER){ | ||
| 1481 | b->yy_bs_lineno = 1; | ||
| 1482 | b->yy_bs_column = 0; | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | ||
| 1486 | |||
| 1487 | errno = oerrno; | ||
| 1488 | } | ||
| 1489 | |||
| 1490 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | ||
| 1491 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | ||
| 1492 | * | ||
| 1493 | */ | ||
| 1494 | void yy_flush_buffer (YY_BUFFER_STATE b ) | ||
| 1495 | { | ||
| 1496 | if ( ! b ) | ||
| 1497 | return; | ||
| 1498 | |||
| 1499 | b->yy_n_chars = 0; | ||
| 1500 | |||
| 1501 | /* We always need two end-of-buffer characters. The first causes | ||
| 1502 | * a transition to the end-of-buffer state. The second causes | ||
| 1503 | * a jam in that state. | ||
| 1504 | */ | ||
| 1505 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
| 1506 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
| 1507 | |||
| 1508 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
| 1509 | |||
| 1510 | b->yy_at_bol = 1; | ||
| 1511 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1512 | |||
| 1513 | if ( b == YY_CURRENT_BUFFER ) | ||
| 1514 | yy_load_buffer_state( ); | ||
| 1515 | } | ||
| 1516 | |||
| 1517 | /** Pushes the new state onto the stack. The new state becomes | ||
| 1518 | * the current state. This function will allocate the stack | ||
| 1519 | * if necessary. | ||
| 1520 | * @param new_buffer The new state. | ||
| 1521 | * | ||
| 1522 | */ | ||
| 1523 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) | ||
| 1524 | { | ||
| 1525 | if (new_buffer == NULL) | ||
| 1526 | return; | ||
| 1527 | |||
| 1528 | yyensure_buffer_stack(); | ||
| 1529 | |||
| 1530 | /* This block is copied from yy_switch_to_buffer. */ | ||
| 1531 | if ( YY_CURRENT_BUFFER ) | ||
| 1532 | { | ||
| 1533 | /* Flush out information for old buffer. */ | ||
| 1534 | *(yy_c_buf_p) = (yy_hold_char); | ||
| 1535 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
| 1536 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | /* Only push if top exists. Otherwise, replace top. */ | ||
| 1540 | if (YY_CURRENT_BUFFER) | ||
| 1541 | (yy_buffer_stack_top)++; | ||
| 1542 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
| 1543 | |||
| 1544 | /* copied from yy_switch_to_buffer. */ | ||
| 1545 | yy_load_buffer_state( ); | ||
| 1546 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1547 | } | ||
| 1548 | |||
| 1549 | /** Removes and deletes the top of the stack, if present. | ||
| 1550 | * The next element becomes the new top. | ||
| 1551 | * | ||
| 1552 | */ | ||
| 1553 | void yypop_buffer_state (void) | ||
| 1554 | { | ||
| 1555 | if (!YY_CURRENT_BUFFER) | ||
| 1556 | return; | ||
| 1557 | |||
| 1558 | yy_delete_buffer(YY_CURRENT_BUFFER ); | ||
| 1559 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
| 1560 | if ((yy_buffer_stack_top) > 0) | ||
| 1561 | --(yy_buffer_stack_top); | ||
| 1562 | |||
| 1563 | if (YY_CURRENT_BUFFER) { | ||
| 1564 | yy_load_buffer_state( ); | ||
| 1565 | (yy_did_buffer_switch_on_eof) = 1; | ||
| 1566 | } | ||
| 1567 | } | ||
| 1568 | |||
| 1569 | /* Allocates the stack if it does not exist. | ||
| 1570 | * Guarantees space for at least one push. | ||
| 1571 | */ | ||
| 1572 | static void yyensure_buffer_stack (void) | ||
| 1573 | { | ||
| 1574 | int num_to_alloc; | ||
| 1575 | |||
| 1576 | if (!(yy_buffer_stack)) { | ||
| 1577 | |||
| 1578 | /* First allocation is just for 2 elements, since we don't know if this | ||
| 1579 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | ||
| 1580 | * immediate realloc on the next call. | ||
| 1581 | */ | ||
| 1582 | num_to_alloc = 1; | ||
| 1583 | (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc | ||
| 1584 | (num_to_alloc * sizeof(struct yy_buffer_state*) | ||
| 1585 | ); | ||
| 1586 | if ( ! (yy_buffer_stack) ) | ||
| 1587 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); | ||
| 1588 | |||
| 1589 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | ||
| 1590 | |||
| 1591 | (yy_buffer_stack_max) = num_to_alloc; | ||
| 1592 | (yy_buffer_stack_top) = 0; | ||
| 1593 | return; | ||
| 1594 | } | ||
| 1595 | |||
| 1596 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | ||
| 1597 | |||
| 1598 | /* Increase the buffer to prepare for a possible push. */ | ||
| 1599 | int grow_size = 8 /* arbitrary grow size */; | ||
| 1600 | |||
| 1601 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | ||
| 1602 | (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc | ||
| 1603 | ((yy_buffer_stack), | ||
| 1604 | num_to_alloc * sizeof(struct yy_buffer_state*) | ||
| 1605 | ); | ||
| 1606 | if ( ! (yy_buffer_stack) ) | ||
| 1607 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); | ||
| 1608 | |||
| 1609 | /* zero only the new slots.*/ | ||
| 1610 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | ||
| 1611 | (yy_buffer_stack_max) = num_to_alloc; | ||
| 1612 | } | ||
| 1613 | } | ||
| 1614 | |||
| 1615 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | ||
| 1616 | * @param base the character buffer | ||
| 1617 | * @param size the size in bytes of the character buffer | ||
| 1618 | * | ||
| 1619 | * @return the newly allocated buffer state object. | ||
| 1620 | */ | ||
| 1621 | YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) | ||
| 1622 | { | ||
| 1623 | YY_BUFFER_STATE b; | ||
| 1624 | |||
| 1625 | if ( size < 2 || | ||
| 1626 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
| 1627 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
| 1628 | /* They forgot to leave room for the EOB's. */ | ||
| 1629 | return 0; | ||
| 1630 | |||
| 1631 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); | ||
| 1632 | if ( ! b ) | ||
| 1633 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); | ||
| 1634 | |||
| 1635 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
| 1636 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
| 1637 | b->yy_is_our_buffer = 0; | ||
| 1638 | b->yy_input_file = 0; | ||
| 1639 | b->yy_n_chars = b->yy_buf_size; | ||
| 1640 | b->yy_is_interactive = 0; | ||
| 1641 | b->yy_at_bol = 1; | ||
| 1642 | b->yy_fill_buffer = 0; | ||
| 1643 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1644 | |||
| 1645 | yy_switch_to_buffer(b ); | ||
| 1646 | |||
| 1647 | return b; | ||
| 1648 | } | ||
| 1649 | |||
| 1650 | /** Setup the input buffer state to scan a string. The next call to yylex() will | ||
| 1651 | * scan from a @e copy of @a str. | ||
| 1652 | * @param yystr a NUL-terminated string to scan | ||
| 1653 | * | ||
| 1654 | * @return the newly allocated buffer state object. | ||
| 1655 | * @note If you want to scan bytes that may contain NUL values, then use | ||
| 1656 | * yy_scan_bytes() instead. | ||
| 1657 | */ | ||
| 1658 | YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) | ||
| 1659 | { | ||
| 1660 | |||
| 1661 | return yy_scan_bytes(yystr,strlen(yystr) ); | ||
| 1662 | } | ||
| 1663 | |||
| 1664 | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will | ||
| 1665 | * scan from a @e copy of @a bytes. | ||
| 1666 | * @param bytes the byte buffer to scan | ||
| 1667 | * @param len the number of bytes in the buffer pointed to by @a bytes. | ||
| 1668 | * | ||
| 1669 | * @return the newly allocated buffer state object. | ||
| 1670 | */ | ||
| 1671 | YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) | ||
| 1672 | { | ||
| 1673 | YY_BUFFER_STATE b; | ||
| 1674 | char *buf; | ||
| 1675 | yy_size_t n; | ||
| 1676 | int i; | ||
| 1677 | |||
| 1678 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
| 1679 | n = _yybytes_len + 2; | ||
| 1680 | buf = (char *) yyalloc(n ); | ||
| 1681 | if ( ! buf ) | ||
| 1682 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); | ||
| 1683 | |||
| 1684 | for ( i = 0; i < _yybytes_len; ++i ) | ||
| 1685 | buf[i] = yybytes[i]; | ||
| 1686 | |||
| 1687 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; | ||
| 1688 | |||
| 1689 | b = yy_scan_buffer(buf,n ); | ||
| 1690 | if ( ! b ) | ||
| 1691 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); | ||
| 1692 | |||
| 1693 | /* It's okay to grow etc. this buffer, and we should throw it | ||
| 1694 | * away when we're done. | ||
| 1695 | */ | ||
| 1696 | b->yy_is_our_buffer = 1; | ||
| 1697 | |||
| 1698 | return b; | ||
| 1699 | } | ||
| 1700 | |||
| 1701 | #ifndef YY_EXIT_FAILURE | ||
| 1702 | #define YY_EXIT_FAILURE 2 | ||
| 1703 | #endif | ||
| 1704 | |||
| 1705 | static void yy_fatal_error (yyconst char* msg ) | ||
| 1706 | { | ||
| 1707 | (void) fprintf( stderr, "%s\n", msg ); | ||
| 1708 | exit( YY_EXIT_FAILURE ); | ||
| 1709 | } | ||
| 1710 | |||
| 1711 | /* Redefine yyless() so it works in section 3 code. */ | ||
| 1712 | |||
| 1713 | #undef yyless | ||
| 1714 | #define yyless(n) \ | ||
| 1715 | do \ | ||
| 1716 | { \ | ||
| 1717 | /* Undo effects of setting up yytext. */ \ | ||
| 1718 | int yyless_macro_arg = (n); \ | ||
| 1719 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
| 1720 | yytext[yyleng] = (yy_hold_char); \ | ||
| 1721 | (yy_c_buf_p) = yytext + yyless_macro_arg; \ | ||
| 1722 | (yy_hold_char) = *(yy_c_buf_p); \ | ||
| 1723 | *(yy_c_buf_p) = '\0'; \ | ||
| 1724 | yyleng = yyless_macro_arg; \ | ||
| 1725 | } \ | ||
| 1726 | while ( 0 ) | ||
| 1727 | |||
| 1728 | /* Accessor methods (get/set functions) to struct members. */ | ||
| 1729 | |||
| 1730 | /** Get the current line number. | ||
| 1731 | * | ||
| 1732 | */ | ||
| 1733 | int yyget_lineno (void) | ||
| 1734 | { | ||
| 1735 | |||
| 1736 | return yylineno; | ||
| 1737 | } | ||
| 1738 | |||
| 1739 | /** Get the input stream. | ||
| 1740 | * | ||
| 1741 | */ | ||
| 1742 | FILE *yyget_in (void) | ||
| 1743 | { | ||
| 1744 | return yyin; | ||
| 1745 | } | ||
| 1746 | |||
| 1747 | /** Get the output stream. | ||
| 1748 | * | ||
| 1749 | */ | ||
| 1750 | FILE *yyget_out (void) | ||
| 1751 | { | ||
| 1752 | return yyout; | ||
| 1753 | } | ||
| 1754 | |||
| 1755 | /** Get the length of the current token. | ||
| 1756 | * | ||
| 1757 | */ | ||
| 1758 | int yyget_leng (void) | ||
| 1759 | { | ||
| 1760 | return yyleng; | ||
| 1761 | } | ||
| 1762 | |||
| 1763 | /** Get the current token. | ||
| 1764 | * | ||
| 1765 | */ | ||
| 1766 | |||
| 1767 | char *yyget_text (void) | ||
| 1768 | { | ||
| 1769 | return yytext; | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | /** Set the current line number. | ||
| 1773 | * @param line_number | ||
| 1774 | * | ||
| 1775 | */ | ||
| 1776 | void yyset_lineno (int line_number ) | ||
| 1777 | { | ||
| 1778 | |||
| 1779 | yylineno = line_number; | ||
| 1780 | } | ||
| 1781 | |||
| 1782 | /** Set the input stream. This does not discard the current | ||
| 1783 | * input buffer. | ||
| 1784 | * @param in_str A readable stream. | ||
| 1785 | * | ||
| 1786 | * @see yy_switch_to_buffer | ||
| 1787 | */ | ||
| 1788 | void yyset_in (FILE * in_str ) | ||
| 1789 | { | ||
| 1790 | yyin = in_str ; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | void yyset_out (FILE * out_str ) | ||
| 1794 | { | ||
| 1795 | yyout = out_str ; | ||
| 1796 | } | ||
| 1797 | |||
| 1798 | int yyget_debug (void) | ||
| 1799 | { | ||
| 1800 | return yy_flex_debug; | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | void yyset_debug (int bdebug ) | ||
| 1804 | { | ||
| 1805 | yy_flex_debug = bdebug ; | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | static int yy_init_globals (void) | ||
| 1809 | { | ||
| 1810 | /* Initialization is the same as for the non-reentrant scanner. | ||
| 1811 | * This function is called from yylex_destroy(), so don't allocate here. | ||
| 1812 | */ | ||
| 1813 | |||
| 1814 | (yy_buffer_stack) = 0; | ||
| 1815 | (yy_buffer_stack_top) = 0; | ||
| 1816 | (yy_buffer_stack_max) = 0; | ||
| 1817 | (yy_c_buf_p) = (char *) 0; | ||
| 1818 | (yy_init) = 0; | ||
| 1819 | (yy_start) = 0; | ||
| 1820 | |||
| 1821 | /* Defined in main.c */ | ||
| 1822 | #ifdef YY_STDINIT | ||
| 1823 | yyin = stdin; | ||
| 1824 | yyout = stdout; | ||
| 1825 | #else | ||
| 1826 | yyin = (FILE *) 0; | ||
| 1827 | yyout = (FILE *) 0; | ||
| 1828 | #endif | ||
| 1829 | |||
| 1830 | /* For future reference: Set errno on error, since we are called by | ||
| 1831 | * yylex_init() | ||
| 1832 | */ | ||
| 1833 | return 0; | ||
| 1834 | } | ||
| 1835 | |||
| 1836 | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ | ||
| 1837 | int yylex_destroy (void) | ||
| 1838 | { | ||
| 1839 | |||
| 1840 | /* Pop the buffer stack, destroying each element. */ | ||
| 1841 | while(YY_CURRENT_BUFFER){ | ||
| 1842 | yy_delete_buffer(YY_CURRENT_BUFFER ); | ||
| 1843 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
| 1844 | yypop_buffer_state(); | ||
| 1845 | } | ||
| 1846 | |||
| 1847 | /* Destroy the stack itself. */ | ||
| 1848 | yyfree((yy_buffer_stack) ); | ||
| 1849 | (yy_buffer_stack) = NULL; | ||
| 1850 | |||
| 1851 | /* Reset the globals. This is important in a non-reentrant scanner so the next time | ||
| 1852 | * yylex() is called, initialization will occur. */ | ||
| 1853 | yy_init_globals( ); | ||
| 1854 | |||
| 1855 | return 0; | ||
| 1856 | } | ||
| 1857 | |||
| 1858 | /* | ||
| 1859 | * Internal utility routines. | ||
| 1860 | */ | ||
| 1861 | |||
| 1862 | #ifndef yytext_ptr | ||
| 1863 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | ||
| 1864 | { | ||
| 1865 | register int i; | ||
| 1866 | for ( i = 0; i < n; ++i ) | ||
| 1867 | s1[i] = s2[i]; | ||
| 1868 | } | ||
| 1869 | #endif | ||
| 1870 | |||
| 1871 | #ifdef YY_NEED_STRLEN | ||
| 1872 | static int yy_flex_strlen (yyconst char * s ) | ||
| 1873 | { | ||
| 1874 | register int n; | ||
| 1875 | for ( n = 0; s[n]; ++n ) | ||
| 1876 | ; | ||
| 1877 | |||
| 1878 | return n; | ||
| 1879 | } | ||
| 1880 | #endif | ||
| 1881 | |||
| 1882 | void *yyalloc (yy_size_t size ) | ||
| 1883 | { | ||
| 1884 | return (void *) malloc( size ); | ||
| 1885 | } | ||
| 1886 | |||
| 1887 | void *yyrealloc (void * ptr, yy_size_t size ) | ||
| 1888 | { | ||
| 1889 | /* The cast to (char *) in the following accommodates both | ||
| 1890 | * implementations that use char* generic pointers, and those | ||
| 1891 | * that use void* generic pointers. It works with the latter | ||
| 1892 | * because both ANSI C and C++ allow castless assignment from | ||
| 1893 | * any pointer type to void*, and deal with argument conversions | ||
| 1894 | * as though doing an assignment. | ||
| 1895 | */ | ||
| 1896 | return (void *) realloc( (char *) ptr, size ); | ||
| 1897 | } | ||
| 1898 | |||
| 1899 | void yyfree (void * ptr ) | ||
| 1900 | { | ||
| 1901 | free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ | ||
| 1902 | } | ||
| 1903 | |||
| 1904 | #define YYTABLES_NAME "yytables" | ||
| 1905 | |||
| 1906 | /* Bring in the keyword recognizer. */ | ||
| 1907 | |||
| 1908 | #include "keywords.c" | ||
| 1909 | |||
| 1910 | /* Macros to append to our phrase collection list. */ | ||
| 1911 | |||
| 1912 | /* | ||
| 1913 | * We mark any token, that that equals to a known enumerator, as | ||
| 1914 | * SYM_ENUM_CONST. The parser will change this for struct and union tags later, | ||
| 1915 | * the only problem is struct and union members: | ||
| 1916 | * enum e { a, b }; struct s { int a, b; } | ||
| 1917 | * but in this case, the only effect will be, that the ABI checksums become | ||
| 1918 | * more volatile, which is acceptable. Also, such collisions are quite rare, | ||
| 1919 | * so far it was only observed in include/linux/telephony.h. | ||
| 1920 | */ | ||
| 1921 | #define _APP(T,L) do { \ | ||
| 1922 | cur_node = next_node; \ | ||
| 1923 | next_node = xmalloc(sizeof(*next_node)); \ | ||
| 1924 | next_node->next = cur_node; \ | ||
| 1925 | cur_node->string = memcpy(xmalloc(L+1), T, L+1); \ | ||
| 1926 | cur_node->tag = \ | ||
| 1927 | find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\ | ||
| 1928 | SYM_ENUM_CONST : SYM_NORMAL ; \ | ||
| 1929 | cur_node->in_source_file = in_source_file; \ | ||
| 1930 | } while (0) | ||
| 1931 | |||
| 1932 | #define APP _APP(yytext, yyleng) | ||
| 1933 | |||
| 1934 | /* The second stage lexer. Here we incorporate knowledge of the state | ||
| 1935 | of the parser to tailor the tokens that are returned. */ | ||
| 1936 | |||
| 1937 | int | ||
| 1938 | yylex(void) | ||
| 1939 | { | ||
| 1940 | static enum { | ||
| 1941 | ST_NOTSTARTED, ST_NORMAL, ST_ATTRIBUTE, ST_ASM, ST_TYPEOF, ST_TYPEOF_1, | ||
| 1942 | ST_BRACKET, ST_BRACE, ST_EXPRESSION, | ||
| 1943 | ST_TABLE_1, ST_TABLE_2, ST_TABLE_3, ST_TABLE_4, | ||
| 1944 | ST_TABLE_5, ST_TABLE_6 | ||
| 1945 | } lexstate = ST_NOTSTARTED; | ||
| 1946 | |||
| 1947 | static int suppress_type_lookup, dont_want_brace_phrase; | ||
| 1948 | static struct string_list *next_node; | ||
| 1949 | |||
| 1950 | int token, count = 0; | ||
| 1951 | struct string_list *cur_node; | ||
| 1952 | |||
| 1953 | if (lexstate == ST_NOTSTARTED) | ||
| 1954 | { | ||
| 1955 | next_node = xmalloc(sizeof(*next_node)); | ||
| 1956 | next_node->next = NULL; | ||
| 1957 | lexstate = ST_NORMAL; | ||
| 1958 | } | ||
| 1959 | |||
| 1960 | repeat: | ||
| 1961 | token = yylex1(); | ||
| 1962 | |||
| 1963 | if (token == 0) | ||
| 1964 | return 0; | ||
| 1965 | else if (token == FILENAME) | ||
| 1966 | { | ||
| 1967 | char *file, *e; | ||
| 1968 | |||
| 1969 | /* Save the filename and line number for later error messages. */ | ||
| 1970 | |||
| 1971 | if (cur_filename) | ||
| 1972 | free(cur_filename); | ||
| 1973 | |||
| 1974 | file = strchr(yytext, '\"')+1; | ||
| 1975 | e = strchr(file, '\"'); | ||
| 1976 | *e = '\0'; | ||
| 1977 | cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); | ||
| 1978 | cur_line = atoi(yytext+2); | ||
| 1979 | |||
| 1980 | if (!source_file) { | ||
| 1981 | source_file = xstrdup(cur_filename); | ||
| 1982 | in_source_file = 1; | ||
| 1983 | } else { | ||
| 1984 | in_source_file = (strcmp(cur_filename, source_file) == 0); | ||
| 1985 | } | ||
| 1986 | |||
| 1987 | goto repeat; | ||
| 1988 | } | ||
| 1989 | |||
| 1990 | switch (lexstate) | ||
| 1991 | { | ||
| 1992 | case ST_NORMAL: | ||
| 1993 | switch (token) | ||
| 1994 | { | ||
| 1995 | case IDENT: | ||
| 1996 | APP; | ||
| 1997 | { | ||
| 1998 | int r = is_reserved_word(yytext, yyleng); | ||
| 1999 | if (r >= 0) | ||
| 2000 | { | ||
| 2001 | switch (token = r) | ||
| 2002 | { | ||
| 2003 | case ATTRIBUTE_KEYW: | ||
| 2004 | lexstate = ST_ATTRIBUTE; | ||
| 2005 | count = 0; | ||
| 2006 | goto repeat; | ||
| 2007 | case ASM_KEYW: | ||
| 2008 | lexstate = ST_ASM; | ||
| 2009 | count = 0; | ||
| 2010 | goto repeat; | ||
| 2011 | case TYPEOF_KEYW: | ||
| 2012 | lexstate = ST_TYPEOF; | ||
| 2013 | count = 0; | ||
| 2014 | goto repeat; | ||
| 2015 | |||
| 2016 | case STRUCT_KEYW: | ||
| 2017 | case UNION_KEYW: | ||
| 2018 | case ENUM_KEYW: | ||
| 2019 | dont_want_brace_phrase = 3; | ||
| 2020 | suppress_type_lookup = 2; | ||
| 2021 | goto fini; | ||
| 2022 | |||
| 2023 | case EXPORT_SYMBOL_KEYW: | ||
| 2024 | goto fini; | ||
| 2025 | } | ||
| 2026 | } | ||
| 2027 | if (!suppress_type_lookup) | ||
| 2028 | { | ||
| 2029 | if (find_symbol(yytext, SYM_TYPEDEF, 1)) | ||
| 2030 | token = TYPE; | ||
| 2031 | } | ||
| 2032 | } | ||
| 2033 | break; | ||
| 2034 | |||
| 2035 | case '[': | ||
| 2036 | APP; | ||
| 2037 | lexstate = ST_BRACKET; | ||
| 2038 | count = 1; | ||
| 2039 | goto repeat; | ||
| 2040 | |||
| 2041 | case '{': | ||
| 2042 | APP; | ||
| 2043 | if (dont_want_brace_phrase) | ||
| 2044 | break; | ||
| 2045 | lexstate = ST_BRACE; | ||
| 2046 | count = 1; | ||
| 2047 | goto repeat; | ||
| 2048 | |||
| 2049 | case '=': case ':': | ||
| 2050 | APP; | ||
| 2051 | lexstate = ST_EXPRESSION; | ||
| 2052 | break; | ||
| 2053 | |||
| 2054 | case DOTS: | ||
| 2055 | default: | ||
| 2056 | APP; | ||
| 2057 | break; | ||
| 2058 | } | ||
| 2059 | break; | ||
| 2060 | |||
| 2061 | case ST_ATTRIBUTE: | ||
| 2062 | APP; | ||
| 2063 | switch (token) | ||
| 2064 | { | ||
| 2065 | case '(': | ||
| 2066 | ++count; | ||
| 2067 | goto repeat; | ||
| 2068 | case ')': | ||
| 2069 | if (--count == 0) | ||
| 2070 | { | ||
| 2071 | lexstate = ST_NORMAL; | ||
| 2072 | token = ATTRIBUTE_PHRASE; | ||
| 2073 | break; | ||
| 2074 | } | ||
| 2075 | goto repeat; | ||
| 2076 | default: | ||
| 2077 | goto repeat; | ||
| 2078 | } | ||
| 2079 | break; | ||
| 2080 | |||
| 2081 | case ST_ASM: | ||
| 2082 | APP; | ||
| 2083 | switch (token) | ||
| 2084 | { | ||
| 2085 | case '(': | ||
| 2086 | ++count; | ||
| 2087 | goto repeat; | ||
| 2088 | case ')': | ||
| 2089 | if (--count == 0) | ||
| 2090 | { | ||
| 2091 | lexstate = ST_NORMAL; | ||
| 2092 | token = ASM_PHRASE; | ||
| 2093 | break; | ||
| 2094 | } | ||
| 2095 | goto repeat; | ||
| 2096 | default: | ||
| 2097 | goto repeat; | ||
| 2098 | } | ||
| 2099 | break; | ||
| 2100 | |||
| 2101 | case ST_TYPEOF_1: | ||
| 2102 | if (token == IDENT) | ||
| 2103 | { | ||
| 2104 | if (is_reserved_word(yytext, yyleng) >= 0 | ||
| 2105 | || find_symbol(yytext, SYM_TYPEDEF, 1)) | ||
| 2106 | { | ||
| 2107 | yyless(0); | ||
| 2108 | unput('('); | ||
| 2109 | lexstate = ST_NORMAL; | ||
| 2110 | token = TYPEOF_KEYW; | ||
| 2111 | break; | ||
| 2112 | } | ||
| 2113 | _APP("(", 1); | ||
| 2114 | } | ||
| 2115 | lexstate = ST_TYPEOF; | ||
| 2116 | /* FALLTHRU */ | ||
| 2117 | |||
| 2118 | case ST_TYPEOF: | ||
| 2119 | switch (token) | ||
| 2120 | { | ||
| 2121 | case '(': | ||
| 2122 | if ( ++count == 1 ) | ||
| 2123 | lexstate = ST_TYPEOF_1; | ||
| 2124 | else | ||
| 2125 | APP; | ||
| 2126 | goto repeat; | ||
| 2127 | case ')': | ||
| 2128 | APP; | ||
| 2129 | if (--count == 0) | ||
| 2130 | { | ||
| 2131 | lexstate = ST_NORMAL; | ||
| 2132 | token = TYPEOF_PHRASE; | ||
| 2133 | break; | ||
| 2134 | } | ||
| 2135 | goto repeat; | ||
| 2136 | default: | ||
| 2137 | APP; | ||
| 2138 | goto repeat; | ||
| 2139 | } | ||
| 2140 | break; | ||
| 2141 | |||
| 2142 | case ST_BRACKET: | ||
| 2143 | APP; | ||
| 2144 | switch (token) | ||
| 2145 | { | ||
| 2146 | case '[': | ||
| 2147 | ++count; | ||
| 2148 | goto repeat; | ||
| 2149 | case ']': | ||
| 2150 | if (--count == 0) | ||
| 2151 | { | ||
| 2152 | lexstate = ST_NORMAL; | ||
| 2153 | token = BRACKET_PHRASE; | ||
| 2154 | break; | ||
| 2155 | } | ||
| 2156 | goto repeat; | ||
| 2157 | default: | ||
| 2158 | goto repeat; | ||
| 2159 | } | ||
| 2160 | break; | ||
| 2161 | |||
| 2162 | case ST_BRACE: | ||
| 2163 | APP; | ||
| 2164 | switch (token) | ||
| 2165 | { | ||
| 2166 | case '{': | ||
| 2167 | ++count; | ||
| 2168 | goto repeat; | ||
| 2169 | case '}': | ||
| 2170 | if (--count == 0) | ||
| 2171 | { | ||
| 2172 | lexstate = ST_NORMAL; | ||
| 2173 | token = BRACE_PHRASE; | ||
| 2174 | break; | ||
| 2175 | } | ||
| 2176 | goto repeat; | ||
| 2177 | default: | ||
| 2178 | goto repeat; | ||
| 2179 | } | ||
| 2180 | break; | ||
| 2181 | |||
| 2182 | case ST_EXPRESSION: | ||
| 2183 | switch (token) | ||
| 2184 | { | ||
| 2185 | case '(': case '[': case '{': | ||
| 2186 | ++count; | ||
| 2187 | APP; | ||
| 2188 | goto repeat; | ||
| 2189 | case '}': | ||
| 2190 | /* is this the last line of an enum declaration? */ | ||
| 2191 | if (count == 0) | ||
| 2192 | { | ||
| 2193 | /* Put back the token we just read so's we can find it again | ||
| 2194 | after registering the expression. */ | ||
| 2195 | unput(token); | ||
| 2196 | |||
| 2197 | lexstate = ST_NORMAL; | ||
| 2198 | token = EXPRESSION_PHRASE; | ||
| 2199 | break; | ||
| 2200 | } | ||
| 2201 | /* FALLTHRU */ | ||
| 2202 | case ')': case ']': | ||
| 2203 | --count; | ||
| 2204 | APP; | ||
| 2205 | goto repeat; | ||
| 2206 | case ',': case ';': | ||
| 2207 | if (count == 0) | ||
| 2208 | { | ||
| 2209 | /* Put back the token we just read so's we can find it again | ||
| 2210 | after registering the expression. */ | ||
| 2211 | unput(token); | ||
| 2212 | |||
| 2213 | lexstate = ST_NORMAL; | ||
| 2214 | token = EXPRESSION_PHRASE; | ||
| 2215 | break; | ||
| 2216 | } | ||
| 2217 | APP; | ||
| 2218 | goto repeat; | ||
| 2219 | default: | ||
| 2220 | APP; | ||
| 2221 | goto repeat; | ||
| 2222 | } | ||
| 2223 | break; | ||
| 2224 | |||
| 2225 | case ST_TABLE_1: | ||
| 2226 | goto repeat; | ||
| 2227 | |||
| 2228 | case ST_TABLE_2: | ||
| 2229 | if (token == IDENT && yyleng == 1 && yytext[0] == 'X') | ||
| 2230 | { | ||
| 2231 | token = EXPORT_SYMBOL_KEYW; | ||
| 2232 | lexstate = ST_TABLE_5; | ||
| 2233 | APP; | ||
| 2234 | break; | ||
| 2235 | } | ||
| 2236 | lexstate = ST_TABLE_6; | ||
| 2237 | /* FALLTHRU */ | ||
| 2238 | |||
| 2239 | case ST_TABLE_6: | ||
| 2240 | switch (token) | ||
| 2241 | { | ||
| 2242 | case '{': case '[': case '(': | ||
| 2243 | ++count; | ||
| 2244 | break; | ||
| 2245 | case '}': case ']': case ')': | ||
| 2246 | --count; | ||
| 2247 | break; | ||
| 2248 | case ',': | ||
| 2249 | if (count == 0) | ||
| 2250 | lexstate = ST_TABLE_2; | ||
| 2251 | break; | ||
| 2252 | }; | ||
| 2253 | goto repeat; | ||
| 2254 | |||
| 2255 | case ST_TABLE_3: | ||
| 2256 | goto repeat; | ||
| 2257 | |||
| 2258 | case ST_TABLE_4: | ||
| 2259 | if (token == ';') | ||
| 2260 | lexstate = ST_NORMAL; | ||
| 2261 | goto repeat; | ||
| 2262 | |||
| 2263 | case ST_TABLE_5: | ||
| 2264 | switch (token) | ||
| 2265 | { | ||
| 2266 | case ',': | ||
| 2267 | token = ';'; | ||
| 2268 | lexstate = ST_TABLE_2; | ||
| 2269 | APP; | ||
| 2270 | break; | ||
| 2271 | default: | ||
| 2272 | APP; | ||
| 2273 | break; | ||
| 2274 | } | ||
| 2275 | break; | ||
| 2276 | |||
| 2277 | default: | ||
| 2278 | exit(1); | ||
| 2279 | } | ||
| 2280 | fini: | ||
| 2281 | |||
| 2282 | if (suppress_type_lookup > 0) | ||
| 2283 | --suppress_type_lookup; | ||
| 2284 | if (dont_want_brace_phrase > 0) | ||
| 2285 | --dont_want_brace_phrase; | ||
| 2286 | |||
| 2287 | yylval = &next_node->next; | ||
| 2288 | |||
| 2289 | return token; | ||
| 2290 | } | ||
| 2291 | |||
diff --git a/scripts/genksyms/parse.tab.c_shipped b/scripts/genksyms/parse.tab.c_shipped deleted file mode 100644 index d02258bafe7b..000000000000 --- a/scripts/genksyms/parse.tab.c_shipped +++ /dev/null | |||
| @@ -1,2394 +0,0 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 2.7. */ | ||
| 2 | |||
| 3 | /* Bison implementation for Yacc-like parsers in C | ||
| 4 | |||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (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 | ||
| 15 | GNU 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, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* As a special exception, you may create a larger work that contains | ||
| 21 | part or all of the Bison parser skeleton and distribute that work | ||
| 22 | under terms of your choice, so long as that work isn't itself a | ||
| 23 | parser generator using the skeleton or a modified version thereof | ||
| 24 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
| 25 | the parser skeleton itself, you may (at your option) remove this | ||
| 26 | special exception, which will cause the skeleton and the resulting | ||
| 27 | Bison output files to be licensed under the GNU General Public | ||
| 28 | License without this special exception. | ||
| 29 | |||
| 30 | This special exception was added by the Free Software Foundation in | ||
| 31 | version 2.2 of Bison. */ | ||
| 32 | |||
| 33 | /* C LALR(1) parser skeleton written by Richard Stallman, by | ||
| 34 | simplifying the original so-called "semantic" parser. */ | ||
| 35 | |||
| 36 | /* All symbols defined below should begin with yy or YY, to avoid | ||
| 37 | infringing on user name space. This should be done even for local | ||
| 38 | variables, as they might otherwise be expanded by user macros. | ||
| 39 | There are some unavoidable exceptions within include files to | ||
| 40 | define necessary library symbols; they are noted "INFRINGES ON | ||
| 41 | USER NAME SPACE" below. */ | ||
| 42 | |||
| 43 | /* Identify Bison output. */ | ||
| 44 | #define YYBISON 1 | ||
| 45 | |||
| 46 | /* Bison version. */ | ||
| 47 | #define YYBISON_VERSION "2.7" | ||
| 48 | |||
| 49 | /* Skeleton name. */ | ||
| 50 | #define YYSKELETON_NAME "yacc.c" | ||
| 51 | |||
| 52 | /* Pure parsers. */ | ||
| 53 | #define YYPURE 0 | ||
| 54 | |||
| 55 | /* Push parsers. */ | ||
| 56 | #define YYPUSH 0 | ||
| 57 | |||
| 58 | /* Pull parsers. */ | ||
| 59 | #define YYPULL 1 | ||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | /* Copy the first part of user declarations. */ | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | #include <assert.h> | ||
| 69 | #include <stdlib.h> | ||
| 70 | #include <string.h> | ||
| 71 | #include "genksyms.h" | ||
| 72 | |||
| 73 | static int is_typedef; | ||
| 74 | static int is_extern; | ||
| 75 | static char *current_name; | ||
| 76 | static struct string_list *decl_spec; | ||
| 77 | |||
| 78 | static void yyerror(const char *); | ||
| 79 | |||
| 80 | static inline void | ||
| 81 | remove_node(struct string_list **p) | ||
| 82 | { | ||
| 83 | struct string_list *node = *p; | ||
| 84 | *p = node->next; | ||
| 85 | free_node(node); | ||
| 86 | } | ||
| 87 | |||
| 88 | static inline void | ||
| 89 | remove_list(struct string_list **pb, struct string_list **pe) | ||
| 90 | { | ||
| 91 | struct string_list *b = *pb, *e = *pe; | ||
| 92 | *pb = e; | ||
| 93 | free_list(b, e); | ||
| 94 | } | ||
| 95 | |||
| 96 | /* Record definition of a struct/union/enum */ | ||
| 97 | static void record_compound(struct string_list **keyw, | ||
| 98 | struct string_list **ident, | ||
| 99 | struct string_list **body, | ||
| 100 | enum symbol_type type) | ||
| 101 | { | ||
| 102 | struct string_list *b = *body, *i = *ident, *r; | ||
| 103 | |||
| 104 | if (i->in_source_file) { | ||
| 105 | remove_node(keyw); | ||
| 106 | (*ident)->tag = type; | ||
| 107 | remove_list(body, ident); | ||
| 108 | return; | ||
| 109 | } | ||
| 110 | r = copy_node(i); r->tag = type; | ||
| 111 | r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; | ||
| 112 | add_symbol(i->string, type, b, is_extern); | ||
| 113 | } | ||
| 114 | |||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | # ifndef YY_NULL | ||
| 119 | # if defined __cplusplus && 201103L <= __cplusplus | ||
| 120 | # define YY_NULL nullptr | ||
| 121 | # else | ||
| 122 | # define YY_NULL 0 | ||
| 123 | # endif | ||
| 124 | # endif | ||
| 125 | |||
| 126 | /* Enabling verbose error messages. */ | ||
| 127 | #ifdef YYERROR_VERBOSE | ||
| 128 | # undef YYERROR_VERBOSE | ||
| 129 | # define YYERROR_VERBOSE 1 | ||
| 130 | #else | ||
| 131 | # define YYERROR_VERBOSE 0 | ||
| 132 | #endif | ||
| 133 | |||
| 134 | |||
| 135 | /* Enabling traces. */ | ||
| 136 | #ifndef YYDEBUG | ||
| 137 | # define YYDEBUG 1 | ||
| 138 | #endif | ||
| 139 | #if YYDEBUG | ||
| 140 | extern int yydebug; | ||
| 141 | #endif | ||
| 142 | |||
| 143 | /* Tokens. */ | ||
| 144 | #ifndef YYTOKENTYPE | ||
| 145 | # define YYTOKENTYPE | ||
| 146 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
| 147 | know about them. */ | ||
| 148 | enum yytokentype { | ||
| 149 | ASM_KEYW = 258, | ||
| 150 | ATTRIBUTE_KEYW = 259, | ||
| 151 | AUTO_KEYW = 260, | ||
| 152 | BOOL_KEYW = 261, | ||
| 153 | CHAR_KEYW = 262, | ||
| 154 | CONST_KEYW = 263, | ||
| 155 | DOUBLE_KEYW = 264, | ||
| 156 | ENUM_KEYW = 265, | ||
| 157 | EXTERN_KEYW = 266, | ||
| 158 | EXTENSION_KEYW = 267, | ||
| 159 | FLOAT_KEYW = 268, | ||
| 160 | INLINE_KEYW = 269, | ||
| 161 | INT_KEYW = 270, | ||
| 162 | LONG_KEYW = 271, | ||
| 163 | REGISTER_KEYW = 272, | ||
| 164 | RESTRICT_KEYW = 273, | ||
| 165 | SHORT_KEYW = 274, | ||
| 166 | SIGNED_KEYW = 275, | ||
| 167 | STATIC_KEYW = 276, | ||
| 168 | STRUCT_KEYW = 277, | ||
| 169 | TYPEDEF_KEYW = 278, | ||
| 170 | UNION_KEYW = 279, | ||
| 171 | UNSIGNED_KEYW = 280, | ||
| 172 | VOID_KEYW = 281, | ||
| 173 | VOLATILE_KEYW = 282, | ||
| 174 | TYPEOF_KEYW = 283, | ||
| 175 | VA_LIST_KEYW = 284, | ||
| 176 | EXPORT_SYMBOL_KEYW = 285, | ||
| 177 | ASM_PHRASE = 286, | ||
| 178 | ATTRIBUTE_PHRASE = 287, | ||
| 179 | TYPEOF_PHRASE = 288, | ||
| 180 | BRACE_PHRASE = 289, | ||
| 181 | BRACKET_PHRASE = 290, | ||
| 182 | EXPRESSION_PHRASE = 291, | ||
| 183 | CHAR = 292, | ||
| 184 | DOTS = 293, | ||
| 185 | IDENT = 294, | ||
| 186 | INT = 295, | ||
| 187 | REAL = 296, | ||
| 188 | STRING = 297, | ||
| 189 | TYPE = 298, | ||
| 190 | OTHER = 299, | ||
| 191 | FILENAME = 300 | ||
| 192 | }; | ||
| 193 | #endif | ||
| 194 | |||
| 195 | |||
| 196 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
| 197 | typedef int YYSTYPE; | ||
| 198 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 199 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
| 200 | # define YYSTYPE_IS_DECLARED 1 | ||
| 201 | #endif | ||
| 202 | |||
| 203 | extern YYSTYPE yylval; | ||
| 204 | |||
| 205 | #ifdef YYPARSE_PARAM | ||
| 206 | #if defined __STDC__ || defined __cplusplus | ||
| 207 | int yyparse (void *YYPARSE_PARAM); | ||
| 208 | #else | ||
| 209 | int yyparse (); | ||
| 210 | #endif | ||
| 211 | #else /* ! YYPARSE_PARAM */ | ||
| 212 | #if defined __STDC__ || defined __cplusplus | ||
| 213 | int yyparse (void); | ||
| 214 | #else | ||
| 215 | int yyparse (); | ||
| 216 | #endif | ||
| 217 | #endif /* ! YYPARSE_PARAM */ | ||
| 218 | |||
| 219 | |||
| 220 | |||
| 221 | /* Copy the second part of user declarations. */ | ||
| 222 | |||
| 223 | |||
| 224 | |||
| 225 | #ifdef short | ||
| 226 | # undef short | ||
| 227 | #endif | ||
| 228 | |||
| 229 | #ifdef YYTYPE_UINT8 | ||
| 230 | typedef YYTYPE_UINT8 yytype_uint8; | ||
| 231 | #else | ||
| 232 | typedef unsigned char yytype_uint8; | ||
| 233 | #endif | ||
| 234 | |||
| 235 | #ifdef YYTYPE_INT8 | ||
| 236 | typedef YYTYPE_INT8 yytype_int8; | ||
| 237 | #elif (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 238 | || defined __cplusplus || defined _MSC_VER) | ||
| 239 | typedef signed char yytype_int8; | ||
| 240 | #else | ||
| 241 | typedef short int yytype_int8; | ||
| 242 | #endif | ||
| 243 | |||
| 244 | #ifdef YYTYPE_UINT16 | ||
| 245 | typedef YYTYPE_UINT16 yytype_uint16; | ||
| 246 | #else | ||
| 247 | typedef unsigned short int yytype_uint16; | ||
| 248 | #endif | ||
| 249 | |||
| 250 | #ifdef YYTYPE_INT16 | ||
| 251 | typedef YYTYPE_INT16 yytype_int16; | ||
| 252 | #else | ||
| 253 | typedef short int yytype_int16; | ||
| 254 | #endif | ||
| 255 | |||
| 256 | #ifndef YYSIZE_T | ||
| 257 | # ifdef __SIZE_TYPE__ | ||
| 258 | # define YYSIZE_T __SIZE_TYPE__ | ||
| 259 | # elif defined size_t | ||
| 260 | # define YYSIZE_T size_t | ||
| 261 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 262 | || defined __cplusplus || defined _MSC_VER) | ||
| 263 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 264 | # define YYSIZE_T size_t | ||
| 265 | # else | ||
| 266 | # define YYSIZE_T unsigned int | ||
| 267 | # endif | ||
| 268 | #endif | ||
| 269 | |||
| 270 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | ||
| 271 | |||
| 272 | #ifndef YY_ | ||
| 273 | # if defined YYENABLE_NLS && YYENABLE_NLS | ||
| 274 | # if ENABLE_NLS | ||
| 275 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 276 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) | ||
| 277 | # endif | ||
| 278 | # endif | ||
| 279 | # ifndef YY_ | ||
| 280 | # define YY_(Msgid) Msgid | ||
| 281 | # endif | ||
| 282 | #endif | ||
| 283 | |||
| 284 | /* Suppress unused-variable warnings by "using" E. */ | ||
| 285 | #if ! defined lint || defined __GNUC__ | ||
| 286 | # define YYUSE(E) ((void) (E)) | ||
| 287 | #else | ||
| 288 | # define YYUSE(E) /* empty */ | ||
| 289 | #endif | ||
| 290 | |||
| 291 | /* Identity function, used to suppress warnings about constant conditions. */ | ||
| 292 | #ifndef lint | ||
| 293 | # define YYID(N) (N) | ||
| 294 | #else | ||
| 295 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 296 | || defined __cplusplus || defined _MSC_VER) | ||
| 297 | static int | ||
| 298 | YYID (int yyi) | ||
| 299 | #else | ||
| 300 | static int | ||
| 301 | YYID (yyi) | ||
| 302 | int yyi; | ||
| 303 | #endif | ||
| 304 | { | ||
| 305 | return yyi; | ||
| 306 | } | ||
| 307 | #endif | ||
| 308 | |||
| 309 | #if ! defined yyoverflow || YYERROR_VERBOSE | ||
| 310 | |||
| 311 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
| 312 | |||
| 313 | # ifdef YYSTACK_USE_ALLOCA | ||
| 314 | # if YYSTACK_USE_ALLOCA | ||
| 315 | # ifdef __GNUC__ | ||
| 316 | # define YYSTACK_ALLOC __builtin_alloca | ||
| 317 | # elif defined __BUILTIN_VA_ARG_INCR | ||
| 318 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 319 | # elif defined _AIX | ||
| 320 | # define YYSTACK_ALLOC __alloca | ||
| 321 | # elif defined _MSC_VER | ||
| 322 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 323 | # define alloca _alloca | ||
| 324 | # else | ||
| 325 | # define YYSTACK_ALLOC alloca | ||
| 326 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 327 | || defined __cplusplus || defined _MSC_VER) | ||
| 328 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 329 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ | ||
| 330 | # ifndef EXIT_SUCCESS | ||
| 331 | # define EXIT_SUCCESS 0 | ||
| 332 | # endif | ||
| 333 | # endif | ||
| 334 | # endif | ||
| 335 | # endif | ||
| 336 | # endif | ||
| 337 | |||
| 338 | # ifdef YYSTACK_ALLOC | ||
| 339 | /* Pacify GCC's `empty if-body' warning. */ | ||
| 340 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) | ||
| 341 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
| 342 | /* The OS might guarantee only one guard page at the bottom of the stack, | ||
| 343 | and a page size can be as small as 4096 bytes. So we cannot safely | ||
| 344 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | ||
| 345 | to allow for a few compiler-allocated temporary stack slots. */ | ||
| 346 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | ||
| 347 | # endif | ||
| 348 | # else | ||
| 349 | # define YYSTACK_ALLOC YYMALLOC | ||
| 350 | # define YYSTACK_FREE YYFREE | ||
| 351 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
| 352 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | ||
| 353 | # endif | ||
| 354 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ | ||
| 355 | && ! ((defined YYMALLOC || defined malloc) \ | ||
| 356 | && (defined YYFREE || defined free))) | ||
| 357 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 358 | # ifndef EXIT_SUCCESS | ||
| 359 | # define EXIT_SUCCESS 0 | ||
| 360 | # endif | ||
| 361 | # endif | ||
| 362 | # ifndef YYMALLOC | ||
| 363 | # define YYMALLOC malloc | ||
| 364 | # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 365 | || defined __cplusplus || defined _MSC_VER) | ||
| 366 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | ||
| 367 | # endif | ||
| 368 | # endif | ||
| 369 | # ifndef YYFREE | ||
| 370 | # define YYFREE free | ||
| 371 | # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 372 | || defined __cplusplus || defined _MSC_VER) | ||
| 373 | void free (void *); /* INFRINGES ON USER NAME SPACE */ | ||
| 374 | # endif | ||
| 375 | # endif | ||
| 376 | # endif | ||
| 377 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ | ||
| 378 | |||
| 379 | |||
| 380 | #if (! defined yyoverflow \ | ||
| 381 | && (! defined __cplusplus \ | ||
| 382 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
| 383 | |||
| 384 | /* A type that is properly aligned for any stack member. */ | ||
| 385 | union yyalloc | ||
| 386 | { | ||
| 387 | yytype_int16 yyss_alloc; | ||
| 388 | YYSTYPE yyvs_alloc; | ||
| 389 | }; | ||
| 390 | |||
| 391 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
| 392 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | ||
| 393 | |||
| 394 | /* The size of an array large to enough to hold all stacks, each with | ||
| 395 | N elements. */ | ||
| 396 | # define YYSTACK_BYTES(N) \ | ||
| 397 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ | ||
| 398 | + YYSTACK_GAP_MAXIMUM) | ||
| 399 | |||
| 400 | # define YYCOPY_NEEDED 1 | ||
| 401 | |||
| 402 | /* Relocate STACK from its old location to the new one. The | ||
| 403 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
| 404 | elements in the stack, and YYPTR gives the new location of the | ||
| 405 | stack. Advance YYPTR to a properly aligned location for the next | ||
| 406 | stack. */ | ||
| 407 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | ||
| 408 | do \ | ||
| 409 | { \ | ||
| 410 | YYSIZE_T yynewbytes; \ | ||
| 411 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | ||
| 412 | Stack = &yyptr->Stack_alloc; \ | ||
| 413 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | ||
| 414 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
| 415 | } \ | ||
| 416 | while (YYID (0)) | ||
| 417 | |||
| 418 | #endif | ||
| 419 | |||
| 420 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED | ||
| 421 | /* Copy COUNT objects from SRC to DST. The source and destination do | ||
| 422 | not overlap. */ | ||
| 423 | # ifndef YYCOPY | ||
| 424 | # if defined __GNUC__ && 1 < __GNUC__ | ||
| 425 | # define YYCOPY(Dst, Src, Count) \ | ||
| 426 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) | ||
| 427 | # else | ||
| 428 | # define YYCOPY(Dst, Src, Count) \ | ||
| 429 | do \ | ||
| 430 | { \ | ||
| 431 | YYSIZE_T yyi; \ | ||
| 432 | for (yyi = 0; yyi < (Count); yyi++) \ | ||
| 433 | (Dst)[yyi] = (Src)[yyi]; \ | ||
| 434 | } \ | ||
| 435 | while (YYID (0)) | ||
| 436 | # endif | ||
| 437 | # endif | ||
| 438 | #endif /* !YYCOPY_NEEDED */ | ||
| 439 | |||
| 440 | /* YYFINAL -- State number of the termination state. */ | ||
| 441 | #define YYFINAL 4 | ||
| 442 | /* YYLAST -- Last index in YYTABLE. */ | ||
| 443 | #define YYLAST 522 | ||
| 444 | |||
| 445 | /* YYNTOKENS -- Number of terminals. */ | ||
| 446 | #define YYNTOKENS 55 | ||
| 447 | /* YYNNTS -- Number of nonterminals. */ | ||
| 448 | #define YYNNTS 49 | ||
| 449 | /* YYNRULES -- Number of rules. */ | ||
| 450 | #define YYNRULES 133 | ||
| 451 | /* YYNRULES -- Number of states. */ | ||
| 452 | #define YYNSTATES 187 | ||
| 453 | |||
| 454 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | ||
| 455 | #define YYUNDEFTOK 2 | ||
| 456 | #define YYMAXUTOK 300 | ||
| 457 | |||
| 458 | #define YYTRANSLATE(YYX) \ | ||
| 459 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | ||
| 460 | |||
| 461 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | ||
| 462 | static const yytype_uint8 yytranslate[] = | ||
| 463 | { | ||
| 464 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 465 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 466 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 467 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 468 | 49, 50, 51, 2, 48, 2, 2, 2, 2, 2, | ||
| 469 | 2, 2, 2, 2, 2, 2, 2, 2, 54, 46, | ||
| 470 | 2, 52, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 471 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 472 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 473 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 474 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 475 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 476 | 2, 2, 2, 53, 2, 47, 2, 2, 2, 2, | ||
| 477 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 478 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 479 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 480 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 481 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 482 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 483 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 484 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 485 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 486 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 487 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 488 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 489 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | ||
| 490 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | ||
| 491 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | ||
| 492 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | ||
| 493 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, | ||
| 494 | 45 | ||
| 495 | }; | ||
| 496 | |||
| 497 | #if YYDEBUG | ||
| 498 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | ||
| 499 | YYRHS. */ | ||
| 500 | static const yytype_uint16 yyprhs[] = | ||
| 501 | { | ||
| 502 | 0, 0, 3, 5, 8, 9, 12, 13, 18, 19, | ||
| 503 | 23, 25, 27, 29, 31, 34, 37, 41, 42, 44, | ||
| 504 | 46, 50, 55, 56, 58, 60, 63, 65, 67, 69, | ||
| 505 | 71, 73, 75, 77, 79, 81, 86, 88, 91, 94, | ||
| 506 | 97, 101, 105, 109, 112, 115, 118, 120, 122, 124, | ||
| 507 | 126, 128, 130, 132, 134, 136, 138, 140, 142, 145, | ||
| 508 | 146, 148, 150, 153, 155, 157, 159, 161, 164, 166, | ||
| 509 | 168, 170, 175, 180, 183, 187, 190, 192, 194, 196, | ||
| 510 | 201, 206, 209, 213, 217, 220, 222, 226, 227, 229, | ||
| 511 | 231, 235, 238, 241, 243, 244, 246, 248, 253, 258, | ||
| 512 | 261, 265, 269, 273, 274, 276, 279, 283, 287, 288, | ||
| 513 | 290, 292, 295, 299, 302, 303, 305, 307, 311, 314, | ||
| 514 | 317, 319, 322, 323, 326, 330, 335, 337, 341, 343, | ||
| 515 | 347, 350, 351, 353 | ||
| 516 | }; | ||
| 517 | |||
| 518 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | ||
| 519 | static const yytype_int8 yyrhs[] = | ||
| 520 | { | ||
| 521 | 56, 0, -1, 57, -1, 56, 57, -1, -1, 58, | ||
| 522 | 59, -1, -1, 12, 23, 60, 62, -1, -1, 23, | ||
| 523 | 61, 62, -1, 62, -1, 86, -1, 101, -1, 103, | ||
| 524 | -1, 1, 46, -1, 1, 47, -1, 66, 63, 46, | ||
| 525 | -1, -1, 64, -1, 65, -1, 64, 48, 65, -1, | ||
| 526 | 76, 102, 97, 87, -1, -1, 67, -1, 68, -1, | ||
| 527 | 67, 68, -1, 69, -1, 70, -1, 5, -1, 17, | ||
| 528 | -1, 21, -1, 11, -1, 14, -1, 71, -1, 75, | ||
| 529 | -1, 28, 49, 83, 50, -1, 33, -1, 22, 39, | ||
| 530 | -1, 24, 39, -1, 10, 39, -1, 22, 39, 89, | ||
| 531 | -1, 24, 39, 89, -1, 10, 39, 98, -1, 10, | ||
| 532 | 98, -1, 22, 89, -1, 24, 89, -1, 7, -1, | ||
| 533 | 19, -1, 15, -1, 16, -1, 20, -1, 25, -1, | ||
| 534 | 13, -1, 9, -1, 26, -1, 6, -1, 29, -1, | ||
| 535 | 43, -1, 51, 73, -1, -1, 74, -1, 75, -1, | ||
| 536 | 74, 75, -1, 8, -1, 27, -1, 32, -1, 18, | ||
| 537 | -1, 72, 76, -1, 77, -1, 39, -1, 43, -1, | ||
| 538 | 77, 49, 80, 50, -1, 77, 49, 1, 50, -1, | ||
| 539 | 77, 35, -1, 49, 76, 50, -1, 72, 78, -1, | ||
| 540 | 79, -1, 39, -1, 43, -1, 79, 49, 80, 50, | ||
| 541 | -1, 79, 49, 1, 50, -1, 79, 35, -1, 49, | ||
| 542 | 78, 50, -1, 49, 1, 50, -1, 81, 38, -1, | ||
| 543 | 81, -1, 82, 48, 38, -1, -1, 82, -1, 83, | ||
| 544 | -1, 82, 48, 83, -1, 67, 84, -1, 72, 84, | ||
| 545 | -1, 85, -1, -1, 39, -1, 43, -1, 85, 49, | ||
| 546 | 80, 50, -1, 85, 49, 1, 50, -1, 85, 35, | ||
| 547 | -1, 49, 84, 50, -1, 49, 1, 50, -1, 66, | ||
| 548 | 76, 34, -1, -1, 88, -1, 52, 36, -1, 53, | ||
| 549 | 90, 47, -1, 53, 1, 47, -1, -1, 91, -1, | ||
| 550 | 92, -1, 91, 92, -1, 66, 93, 46, -1, 1, | ||
| 551 | 46, -1, -1, 94, -1, 95, -1, 94, 48, 95, | ||
| 552 | -1, 78, 97, -1, 39, 96, -1, 96, -1, 54, | ||
| 553 | 36, -1, -1, 97, 32, -1, 53, 99, 47, -1, | ||
| 554 | 53, 99, 48, 47, -1, 100, -1, 99, 48, 100, | ||
| 555 | -1, 39, -1, 39, 52, 36, -1, 31, 46, -1, | ||
| 556 | -1, 31, -1, 30, 49, 39, 50, 46, -1 | ||
| 557 | }; | ||
| 558 | |||
| 559 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | ||
| 560 | static const yytype_uint16 yyrline[] = | ||
| 561 | { | ||
| 562 | 0, 125, 125, 126, 130, 130, 136, 136, 138, 138, | ||
| 563 | 140, 141, 142, 143, 144, 145, 149, 163, 164, 168, | ||
| 564 | 176, 189, 195, 196, 200, 201, 205, 211, 215, 216, | ||
| 565 | 217, 218, 219, 223, 224, 225, 226, 230, 232, 234, | ||
| 566 | 238, 240, 242, 247, 250, 251, 255, 256, 257, 258, | ||
| 567 | 259, 260, 261, 262, 263, 264, 265, 266, 270, 275, | ||
| 568 | 276, 280, 281, 285, 285, 285, 286, 294, 295, 299, | ||
| 569 | 308, 317, 319, 321, 323, 330, 331, 335, 336, 337, | ||
| 570 | 339, 341, 343, 345, 350, 351, 352, 356, 357, 361, | ||
| 571 | 362, 367, 372, 374, 378, 379, 387, 391, 393, 395, | ||
| 572 | 397, 399, 404, 413, 414, 419, 424, 425, 429, 430, | ||
| 573 | 434, 435, 439, 441, 446, 447, 451, 452, 456, 457, | ||
| 574 | 458, 462, 466, 467, 471, 472, 476, 477, 480, 485, | ||
| 575 | 493, 497, 498, 502 | ||
| 576 | }; | ||
| 577 | #endif | ||
| 578 | |||
| 579 | #if YYDEBUG || YYERROR_VERBOSE || 0 | ||
| 580 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
| 581 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
| 582 | static const char *const yytname[] = | ||
| 583 | { | ||
| 584 | "$end", "error", "$undefined", "ASM_KEYW", "ATTRIBUTE_KEYW", | ||
| 585 | "AUTO_KEYW", "BOOL_KEYW", "CHAR_KEYW", "CONST_KEYW", "DOUBLE_KEYW", | ||
| 586 | "ENUM_KEYW", "EXTERN_KEYW", "EXTENSION_KEYW", "FLOAT_KEYW", | ||
| 587 | "INLINE_KEYW", "INT_KEYW", "LONG_KEYW", "REGISTER_KEYW", "RESTRICT_KEYW", | ||
| 588 | "SHORT_KEYW", "SIGNED_KEYW", "STATIC_KEYW", "STRUCT_KEYW", | ||
| 589 | "TYPEDEF_KEYW", "UNION_KEYW", "UNSIGNED_KEYW", "VOID_KEYW", | ||
| 590 | "VOLATILE_KEYW", "TYPEOF_KEYW", "VA_LIST_KEYW", "EXPORT_SYMBOL_KEYW", | ||
| 591 | "ASM_PHRASE", "ATTRIBUTE_PHRASE", "TYPEOF_PHRASE", "BRACE_PHRASE", | ||
| 592 | "BRACKET_PHRASE", "EXPRESSION_PHRASE", "CHAR", "DOTS", "IDENT", "INT", | ||
| 593 | "REAL", "STRING", "TYPE", "OTHER", "FILENAME", "';'", "'}'", "','", | ||
| 594 | "'('", "')'", "'*'", "'='", "'{'", "':'", "$accept", "declaration_seq", | ||
| 595 | "declaration", "$@1", "declaration1", "$@2", "$@3", "simple_declaration", | ||
| 596 | "init_declarator_list_opt", "init_declarator_list", "init_declarator", | ||
| 597 | "decl_specifier_seq_opt", "decl_specifier_seq", "decl_specifier", | ||
| 598 | "storage_class_specifier", "type_specifier", "simple_type_specifier", | ||
| 599 | "ptr_operator", "cvar_qualifier_seq_opt", "cvar_qualifier_seq", | ||
| 600 | "cvar_qualifier", "declarator", "direct_declarator", "nested_declarator", | ||
| 601 | "direct_nested_declarator", "parameter_declaration_clause", | ||
| 602 | "parameter_declaration_list_opt", "parameter_declaration_list", | ||
| 603 | "parameter_declaration", "m_abstract_declarator", | ||
| 604 | "direct_m_abstract_declarator", "function_definition", "initializer_opt", | ||
| 605 | "initializer", "class_body", "member_specification_opt", | ||
| 606 | "member_specification", "member_declaration", | ||
| 607 | "member_declarator_list_opt", "member_declarator_list", | ||
| 608 | "member_declarator", "member_bitfield_declarator", "attribute_opt", | ||
| 609 | "enum_body", "enumerator_list", "enumerator", "asm_definition", | ||
| 610 | "asm_phrase_opt", "export_definition", YY_NULL | ||
| 611 | }; | ||
| 612 | #endif | ||
| 613 | |||
| 614 | # ifdef YYPRINT | ||
| 615 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | ||
| 616 | token YYLEX-NUM. */ | ||
| 617 | static const yytype_uint16 yytoknum[] = | ||
| 618 | { | ||
| 619 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||
| 620 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | ||
| 621 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, | ||
| 622 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, | ||
| 623 | 295, 296, 297, 298, 299, 300, 59, 125, 44, 40, | ||
| 624 | 41, 42, 61, 123, 58 | ||
| 625 | }; | ||
| 626 | # endif | ||
| 627 | |||
| 628 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
| 629 | static const yytype_uint8 yyr1[] = | ||
| 630 | { | ||
| 631 | 0, 55, 56, 56, 58, 57, 60, 59, 61, 59, | ||
| 632 | 59, 59, 59, 59, 59, 59, 62, 63, 63, 64, | ||
| 633 | 64, 65, 66, 66, 67, 67, 68, 68, 69, 69, | ||
| 634 | 69, 69, 69, 70, 70, 70, 70, 70, 70, 70, | ||
| 635 | 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, | ||
| 636 | 71, 71, 71, 71, 71, 71, 71, 71, 72, 73, | ||
| 637 | 73, 74, 74, 75, 75, 75, 75, 76, 76, 77, | ||
| 638 | 77, 77, 77, 77, 77, 78, 78, 79, 79, 79, | ||
| 639 | 79, 79, 79, 79, 80, 80, 80, 81, 81, 82, | ||
| 640 | 82, 83, 84, 84, 85, 85, 85, 85, 85, 85, | ||
| 641 | 85, 85, 86, 87, 87, 88, 89, 89, 90, 90, | ||
| 642 | 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, | ||
| 643 | 95, 96, 97, 97, 98, 98, 99, 99, 100, 100, | ||
| 644 | 101, 102, 102, 103 | ||
| 645 | }; | ||
| 646 | |||
| 647 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | ||
| 648 | static const yytype_uint8 yyr2[] = | ||
| 649 | { | ||
| 650 | 0, 2, 1, 2, 0, 2, 0, 4, 0, 3, | ||
| 651 | 1, 1, 1, 1, 2, 2, 3, 0, 1, 1, | ||
| 652 | 3, 4, 0, 1, 1, 2, 1, 1, 1, 1, | ||
| 653 | 1, 1, 1, 1, 1, 4, 1, 2, 2, 2, | ||
| 654 | 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, | ||
| 655 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, | ||
| 656 | 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, | ||
| 657 | 1, 4, 4, 2, 3, 2, 1, 1, 1, 4, | ||
| 658 | 4, 2, 3, 3, 2, 1, 3, 0, 1, 1, | ||
| 659 | 3, 2, 2, 1, 0, 1, 1, 4, 4, 2, | ||
| 660 | 3, 3, 3, 0, 1, 2, 3, 3, 0, 1, | ||
| 661 | 1, 2, 3, 2, 0, 1, 1, 3, 2, 2, | ||
| 662 | 1, 2, 0, 2, 3, 4, 1, 3, 1, 3, | ||
| 663 | 2, 0, 1, 5 | ||
| 664 | }; | ||
| 665 | |||
| 666 | /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. | ||
| 667 | Performed when YYTABLE doesn't specify something else to do. Zero | ||
| 668 | means the default is an error. */ | ||
| 669 | static const yytype_uint8 yydefact[] = | ||
| 670 | { | ||
| 671 | 4, 4, 2, 0, 1, 3, 0, 28, 55, 46, | ||
| 672 | 63, 53, 0, 31, 0, 52, 32, 48, 49, 29, | ||
| 673 | 66, 47, 50, 30, 0, 8, 0, 51, 54, 64, | ||
| 674 | 0, 56, 0, 0, 65, 36, 57, 5, 10, 17, | ||
| 675 | 23, 24, 26, 27, 33, 34, 11, 12, 13, 14, | ||
| 676 | 15, 39, 0, 43, 6, 37, 0, 44, 22, 38, | ||
| 677 | 45, 0, 0, 130, 69, 70, 0, 59, 0, 18, | ||
| 678 | 19, 0, 131, 68, 25, 42, 128, 0, 126, 22, | ||
| 679 | 40, 0, 114, 0, 0, 110, 9, 17, 41, 94, | ||
| 680 | 0, 0, 0, 58, 60, 61, 16, 0, 67, 132, | ||
| 681 | 102, 122, 73, 0, 0, 124, 0, 7, 113, 107, | ||
| 682 | 77, 78, 0, 0, 0, 122, 76, 0, 115, 116, | ||
| 683 | 120, 106, 0, 111, 131, 95, 57, 0, 94, 91, | ||
| 684 | 93, 35, 0, 74, 62, 20, 103, 0, 0, 85, | ||
| 685 | 88, 89, 129, 125, 127, 119, 0, 77, 0, 121, | ||
| 686 | 75, 118, 81, 0, 112, 0, 0, 96, 0, 92, | ||
| 687 | 99, 0, 133, 123, 0, 21, 104, 72, 71, 84, | ||
| 688 | 0, 83, 82, 0, 0, 117, 101, 100, 0, 0, | ||
| 689 | 105, 86, 90, 80, 79, 98, 97 | ||
| 690 | }; | ||
| 691 | |||
| 692 | /* YYDEFGOTO[NTERM-NUM]. */ | ||
| 693 | static const yytype_int16 yydefgoto[] = | ||
| 694 | { | ||
| 695 | -1, 1, 2, 3, 37, 79, 58, 38, 68, 69, | ||
| 696 | 70, 82, 40, 41, 42, 43, 44, 71, 93, 94, | ||
| 697 | 45, 124, 73, 115, 116, 138, 139, 140, 141, 129, | ||
| 698 | 130, 46, 165, 166, 57, 83, 84, 85, 117, 118, | ||
| 699 | 119, 120, 136, 53, 77, 78, 47, 101, 48 | ||
| 700 | }; | ||
| 701 | |||
| 702 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
| 703 | STATE-NUM. */ | ||
| 704 | #define YYPACT_NINF -94 | ||
| 705 | static const yytype_int16 yypact[] = | ||
| 706 | { | ||
| 707 | -94, 15, -94, 208, -94, -94, 34, -94, -94, -94, | ||
| 708 | -94, -94, -27, -94, -5, -94, -94, -94, -94, -94, | ||
| 709 | -94, -94, -94, -94, -25, -94, -16, -94, -94, -94, | ||
| 710 | -4, -94, 19, -24, -94, -94, -94, -94, -94, 24, | ||
| 711 | 479, -94, -94, -94, -94, -94, -94, -94, -94, -94, | ||
| 712 | -94, 29, 48, -94, -94, 37, 106, -94, 479, 37, | ||
| 713 | -94, 479, 54, -94, -94, -94, 24, -2, 49, 53, | ||
| 714 | -94, 24, -14, -11, -94, -94, 47, 38, -94, 479, | ||
| 715 | -94, 51, 23, 55, 157, -94, -94, 24, -94, 393, | ||
| 716 | 56, 58, 68, -94, -2, -94, -94, 24, -94, -94, | ||
| 717 | -94, -94, -94, 255, 67, -94, 5, -94, -94, -94, | ||
| 718 | 50, -94, 7, 69, 40, -94, -8, 83, 88, -94, | ||
| 719 | -94, -94, 91, -94, 109, -94, -94, 4, 45, -94, | ||
| 720 | 16, -94, 95, -94, -94, -94, -23, 92, 93, 108, | ||
| 721 | 96, -94, -94, -94, -94, -94, 97, -94, 98, -94, | ||
| 722 | -94, 118, -94, 301, -94, 23, 101, -94, 104, -94, | ||
| 723 | -94, 347, -94, -94, 120, -94, -94, -94, -94, -94, | ||
| 724 | 440, -94, -94, 111, 119, -94, -94, -94, 130, 137, | ||
| 725 | -94, -94, -94, -94, -94, -94, -94 | ||
| 726 | }; | ||
| 727 | |||
| 728 | /* YYPGOTO[NTERM-NUM]. */ | ||
| 729 | static const yytype_int16 yypgoto[] = | ||
| 730 | { | ||
| 731 | -94, -94, 158, -94, -94, -94, -94, -45, -94, -94, | ||
| 732 | 94, -1, -61, -29, -94, -94, -94, -79, -94, -94, | ||
| 733 | -63, -7, -94, -93, -94, -92, -94, -94, -60, -57, | ||
| 734 | -94, -94, -94, -94, -19, -94, -94, 110, -94, -94, | ||
| 735 | 33, 82, 78, 144, -94, 99, -94, -94, -94 | ||
| 736 | }; | ||
| 737 | |||
| 738 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | ||
| 739 | positive, shift that token. If negative, reduce the rule which | ||
| 740 | number is the opposite. If YYTABLE_NINF, syntax error. */ | ||
| 741 | #define YYTABLE_NINF -110 | ||
| 742 | static const yytype_int16 yytable[] = | ||
| 743 | { | ||
| 744 | 89, 90, 39, 114, 95, 156, 10, 60, 146, 163, | ||
| 745 | 128, 74, 51, 86, 55, 4, 20, 99, 54, 148, | ||
| 746 | 100, 150, 63, 59, 102, 29, 52, 152, 56, 164, | ||
| 747 | 34, 134, 72, 114, 107, 114, 80, 56, 103, -94, | ||
| 748 | 88, 153, 89, 125, 76, 61, 147, 157, 128, 128, | ||
| 749 | 111, 160, 143, 127, -94, 67, 112, 87, 67, 92, | ||
| 750 | 74, 174, 110, 64, 98, 161, 111, 65, 62, 179, | ||
| 751 | 158, 159, 112, 66, 67, 67, 114, 113, 87, 147, | ||
| 752 | 49, 50, 52, 111, 125, 105, 106, 76, 157, 112, | ||
| 753 | 56, 67, 89, 91, 127, 96, 67, 108, 109, 104, | ||
| 754 | 89, 97, 121, 142, 113, 149, 131, 81, 132, 89, | ||
| 755 | 182, 7, 8, 9, 10, 11, 12, 13, 133, 15, | ||
| 756 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 154, | ||
| 757 | 26, 27, 28, 29, 30, 31, 155, 108, 34, 35, | ||
| 758 | 99, 162, 167, 168, 170, -22, 169, 171, 172, 36, | ||
| 759 | 163, 176, -22, -108, 177, -22, 180, -22, 122, 5, | ||
| 760 | -22, 183, 7, 8, 9, 10, 11, 12, 13, 184, | ||
| 761 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | ||
| 762 | 185, 26, 27, 28, 29, 30, 31, 186, 175, 34, | ||
| 763 | 35, 135, 145, 151, 123, 75, -22, 0, 0, 0, | ||
| 764 | 36, 0, 0, -22, -109, 144, -22, 0, -22, 6, | ||
| 765 | 0, -22, 0, 7, 8, 9, 10, 11, 12, 13, | ||
| 766 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, | ||
| 767 | 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, | ||
| 768 | 34, 35, 0, 0, 0, 0, 0, -22, 0, 0, | ||
| 769 | 0, 36, 0, 0, -22, 0, 137, -22, 0, -22, | ||
| 770 | 7, 8, 9, 10, 11, 12, 13, 0, 15, 16, | ||
| 771 | 17, 18, 19, 20, 21, 22, 23, 24, 0, 26, | ||
| 772 | 27, 28, 29, 30, 31, 0, 0, 34, 35, 0, | ||
| 773 | 0, 0, 0, -87, 0, 0, 0, 0, 36, 0, | ||
| 774 | 0, 0, 173, 0, 0, -87, 7, 8, 9, 10, | ||
| 775 | 11, 12, 13, 0, 15, 16, 17, 18, 19, 20, | ||
| 776 | 21, 22, 23, 24, 0, 26, 27, 28, 29, 30, | ||
| 777 | 31, 0, 0, 34, 35, 0, 0, 0, 0, -87, | ||
| 778 | 0, 0, 0, 0, 36, 0, 0, 0, 178, 0, | ||
| 779 | 0, -87, 7, 8, 9, 10, 11, 12, 13, 0, | ||
| 780 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | ||
| 781 | 0, 26, 27, 28, 29, 30, 31, 0, 0, 34, | ||
| 782 | 35, 0, 0, 0, 0, -87, 0, 0, 0, 0, | ||
| 783 | 36, 0, 0, 0, 0, 0, 0, -87, 7, 8, | ||
| 784 | 9, 10, 11, 12, 13, 0, 15, 16, 17, 18, | ||
| 785 | 19, 20, 21, 22, 23, 24, 0, 26, 27, 28, | ||
| 786 | 29, 30, 31, 0, 0, 34, 35, 0, 0, 0, | ||
| 787 | 0, 0, 125, 0, 0, 0, 126, 0, 0, 0, | ||
| 788 | 0, 0, 127, 0, 67, 7, 8, 9, 10, 11, | ||
| 789 | 12, 13, 0, 15, 16, 17, 18, 19, 20, 21, | ||
| 790 | 22, 23, 24, 0, 26, 27, 28, 29, 30, 31, | ||
| 791 | 0, 0, 34, 35, 0, 0, 0, 0, 181, 0, | ||
| 792 | 0, 0, 0, 36, 7, 8, 9, 10, 11, 12, | ||
| 793 | 13, 0, 15, 16, 17, 18, 19, 20, 21, 22, | ||
| 794 | 23, 24, 0, 26, 27, 28, 29, 30, 31, 0, | ||
| 795 | 0, 34, 35, 0, 0, 0, 0, 0, 0, 0, | ||
| 796 | 0, 0, 36 | ||
| 797 | }; | ||
| 798 | |||
| 799 | #define yypact_value_is_default(Yystate) \ | ||
| 800 | (!!((Yystate) == (-94))) | ||
| 801 | |||
| 802 | #define yytable_value_is_error(Yytable_value) \ | ||
| 803 | YYID (0) | ||
| 804 | |||
| 805 | static const yytype_int16 yycheck[] = | ||
| 806 | { | ||
| 807 | 61, 61, 3, 82, 67, 1, 8, 26, 1, 32, | ||
| 808 | 89, 40, 39, 58, 39, 0, 18, 31, 23, 112, | ||
| 809 | 34, 114, 46, 39, 35, 27, 53, 35, 53, 52, | ||
| 810 | 32, 94, 39, 112, 79, 114, 55, 53, 49, 35, | ||
| 811 | 59, 49, 103, 39, 39, 49, 39, 43, 127, 128, | ||
| 812 | 43, 35, 47, 49, 50, 51, 49, 58, 51, 66, | ||
| 813 | 89, 153, 39, 39, 71, 49, 43, 43, 49, 161, | ||
| 814 | 127, 128, 49, 49, 51, 51, 155, 54, 79, 39, | ||
| 815 | 46, 47, 53, 43, 39, 47, 48, 39, 43, 49, | ||
| 816 | 53, 51, 153, 39, 49, 46, 51, 46, 47, 52, | ||
| 817 | 161, 48, 47, 36, 54, 36, 50, 1, 50, 170, | ||
| 818 | 170, 5, 6, 7, 8, 9, 10, 11, 50, 13, | ||
| 819 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 46, | ||
| 820 | 24, 25, 26, 27, 28, 29, 48, 46, 32, 33, | ||
| 821 | 31, 46, 50, 50, 48, 39, 38, 50, 50, 43, | ||
| 822 | 32, 50, 46, 47, 50, 49, 36, 51, 1, 1, | ||
| 823 | 54, 50, 5, 6, 7, 8, 9, 10, 11, 50, | ||
| 824 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, | ||
| 825 | 50, 24, 25, 26, 27, 28, 29, 50, 155, 32, | ||
| 826 | 33, 97, 110, 115, 84, 51, 39, -1, -1, -1, | ||
| 827 | 43, -1, -1, 46, 47, 106, 49, -1, 51, 1, | ||
| 828 | -1, 54, -1, 5, 6, 7, 8, 9, 10, 11, | ||
| 829 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | ||
| 830 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | ||
| 831 | 32, 33, -1, -1, -1, -1, -1, 39, -1, -1, | ||
| 832 | -1, 43, -1, -1, 46, -1, 1, 49, -1, 51, | ||
| 833 | 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, | ||
| 834 | 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, | ||
| 835 | 25, 26, 27, 28, 29, -1, -1, 32, 33, -1, | ||
| 836 | -1, -1, -1, 38, -1, -1, -1, -1, 43, -1, | ||
| 837 | -1, -1, 1, -1, -1, 50, 5, 6, 7, 8, | ||
| 838 | 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, | ||
| 839 | 19, 20, 21, 22, -1, 24, 25, 26, 27, 28, | ||
| 840 | 29, -1, -1, 32, 33, -1, -1, -1, -1, 38, | ||
| 841 | -1, -1, -1, -1, 43, -1, -1, -1, 1, -1, | ||
| 842 | -1, 50, 5, 6, 7, 8, 9, 10, 11, -1, | ||
| 843 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, | ||
| 844 | -1, 24, 25, 26, 27, 28, 29, -1, -1, 32, | ||
| 845 | 33, -1, -1, -1, -1, 38, -1, -1, -1, -1, | ||
| 846 | 43, -1, -1, -1, -1, -1, -1, 50, 5, 6, | ||
| 847 | 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, | ||
| 848 | 17, 18, 19, 20, 21, 22, -1, 24, 25, 26, | ||
| 849 | 27, 28, 29, -1, -1, 32, 33, -1, -1, -1, | ||
| 850 | -1, -1, 39, -1, -1, -1, 43, -1, -1, -1, | ||
| 851 | -1, -1, 49, -1, 51, 5, 6, 7, 8, 9, | ||
| 852 | 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, | ||
| 853 | 20, 21, 22, -1, 24, 25, 26, 27, 28, 29, | ||
| 854 | -1, -1, 32, 33, -1, -1, -1, -1, 38, -1, | ||
| 855 | -1, -1, -1, 43, 5, 6, 7, 8, 9, 10, | ||
| 856 | 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, | ||
| 857 | 21, 22, -1, 24, 25, 26, 27, 28, 29, -1, | ||
| 858 | -1, 32, 33, -1, -1, -1, -1, -1, -1, -1, | ||
| 859 | -1, -1, 43 | ||
| 860 | }; | ||
| 861 | |||
| 862 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
| 863 | symbol of state STATE-NUM. */ | ||
| 864 | static const yytype_uint8 yystos[] = | ||
| 865 | { | ||
| 866 | 0, 56, 57, 58, 0, 57, 1, 5, 6, 7, | ||
| 867 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, | ||
| 868 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, | ||
| 869 | 28, 29, 30, 31, 32, 33, 43, 59, 62, 66, | ||
| 870 | 67, 68, 69, 70, 71, 75, 86, 101, 103, 46, | ||
| 871 | 47, 39, 53, 98, 23, 39, 53, 89, 61, 39, | ||
| 872 | 89, 49, 49, 46, 39, 43, 49, 51, 63, 64, | ||
| 873 | 65, 72, 76, 77, 68, 98, 39, 99, 100, 60, | ||
| 874 | 89, 1, 66, 90, 91, 92, 62, 66, 89, 67, | ||
| 875 | 83, 39, 76, 73, 74, 75, 46, 48, 76, 31, | ||
| 876 | 34, 102, 35, 49, 52, 47, 48, 62, 46, 47, | ||
| 877 | 39, 43, 49, 54, 72, 78, 79, 93, 94, 95, | ||
| 878 | 96, 47, 1, 92, 76, 39, 43, 49, 72, 84, | ||
| 879 | 85, 50, 50, 50, 75, 65, 97, 1, 80, 81, | ||
| 880 | 82, 83, 36, 47, 100, 96, 1, 39, 78, 36, | ||
| 881 | 78, 97, 35, 49, 46, 48, 1, 43, 84, 84, | ||
| 882 | 35, 49, 46, 32, 52, 87, 88, 50, 50, 38, | ||
| 883 | 48, 50, 50, 1, 80, 95, 50, 50, 1, 80, | ||
| 884 | 36, 38, 83, 50, 50, 50, 50 | ||
| 885 | }; | ||
| 886 | |||
| 887 | #define yyerrok (yyerrstatus = 0) | ||
| 888 | #define yyclearin (yychar = YYEMPTY) | ||
| 889 | #define YYEMPTY (-2) | ||
| 890 | #define YYEOF 0 | ||
| 891 | |||
| 892 | #define YYACCEPT goto yyacceptlab | ||
| 893 | #define YYABORT goto yyabortlab | ||
| 894 | #define YYERROR goto yyerrorlab | ||
| 895 | |||
| 896 | |||
| 897 | /* Like YYERROR except do call yyerror. This remains here temporarily | ||
| 898 | to ease the transition to the new meaning of YYERROR, for GCC. | ||
| 899 | Once GCC version 2 has supplanted version 1, this can go. However, | ||
| 900 | YYFAIL appears to be in use. Nevertheless, it is formally deprecated | ||
| 901 | in Bison 2.4.2's NEWS entry, where a plan to phase it out is | ||
| 902 | discussed. */ | ||
| 903 | |||
| 904 | #define YYFAIL goto yyerrlab | ||
| 905 | #if defined YYFAIL | ||
| 906 | /* This is here to suppress warnings from the GCC cpp's | ||
| 907 | -Wunused-macros. Normally we don't worry about that warning, but | ||
| 908 | some users do, and we want to make it easy for users to remove | ||
| 909 | YYFAIL uses, which will produce warnings from Bison 2.5. */ | ||
| 910 | #endif | ||
| 911 | |||
| 912 | #define YYRECOVERING() (!!yyerrstatus) | ||
| 913 | |||
| 914 | #define YYBACKUP(Token, Value) \ | ||
| 915 | do \ | ||
| 916 | if (yychar == YYEMPTY) \ | ||
| 917 | { \ | ||
| 918 | yychar = (Token); \ | ||
| 919 | yylval = (Value); \ | ||
| 920 | YYPOPSTACK (yylen); \ | ||
| 921 | yystate = *yyssp; \ | ||
| 922 | goto yybackup; \ | ||
| 923 | } \ | ||
| 924 | else \ | ||
| 925 | { \ | ||
| 926 | yyerror (YY_("syntax error: cannot back up")); \ | ||
| 927 | YYERROR; \ | ||
| 928 | } \ | ||
| 929 | while (YYID (0)) | ||
| 930 | |||
| 931 | /* Error token number */ | ||
| 932 | #define YYTERROR 1 | ||
| 933 | #define YYERRCODE 256 | ||
| 934 | |||
| 935 | |||
| 936 | /* This macro is provided for backward compatibility. */ | ||
| 937 | #ifndef YY_LOCATION_PRINT | ||
| 938 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | ||
| 939 | #endif | ||
| 940 | |||
| 941 | |||
| 942 | /* YYLEX -- calling `yylex' with the right arguments. */ | ||
| 943 | #ifdef YYLEX_PARAM | ||
| 944 | # define YYLEX yylex (YYLEX_PARAM) | ||
| 945 | #else | ||
| 946 | # define YYLEX yylex () | ||
| 947 | #endif | ||
| 948 | |||
| 949 | /* Enable debugging if requested. */ | ||
| 950 | #if YYDEBUG | ||
| 951 | |||
| 952 | # ifndef YYFPRINTF | ||
| 953 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 954 | # define YYFPRINTF fprintf | ||
| 955 | # endif | ||
| 956 | |||
| 957 | # define YYDPRINTF(Args) \ | ||
| 958 | do { \ | ||
| 959 | if (yydebug) \ | ||
| 960 | YYFPRINTF Args; \ | ||
| 961 | } while (YYID (0)) | ||
| 962 | |||
| 963 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | ||
| 964 | do { \ | ||
| 965 | if (yydebug) \ | ||
| 966 | { \ | ||
| 967 | YYFPRINTF (stderr, "%s ", Title); \ | ||
| 968 | yy_symbol_print (stderr, \ | ||
| 969 | Type, Value); \ | ||
| 970 | YYFPRINTF (stderr, "\n"); \ | ||
| 971 | } \ | ||
| 972 | } while (YYID (0)) | ||
| 973 | |||
| 974 | |||
| 975 | /*--------------------------------. | ||
| 976 | | Print this symbol on YYOUTPUT. | | ||
| 977 | `--------------------------------*/ | ||
| 978 | |||
| 979 | /*ARGSUSED*/ | ||
| 980 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 981 | || defined __cplusplus || defined _MSC_VER) | ||
| 982 | static void | ||
| 983 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | ||
| 984 | #else | ||
| 985 | static void | ||
| 986 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) | ||
| 987 | FILE *yyoutput; | ||
| 988 | int yytype; | ||
| 989 | YYSTYPE const * const yyvaluep; | ||
| 990 | #endif | ||
| 991 | { | ||
| 992 | FILE *yyo = yyoutput; | ||
| 993 | YYUSE (yyo); | ||
| 994 | if (!yyvaluep) | ||
| 995 | return; | ||
| 996 | # ifdef YYPRINT | ||
| 997 | if (yytype < YYNTOKENS) | ||
| 998 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
| 999 | # else | ||
| 1000 | YYUSE (yyoutput); | ||
| 1001 | # endif | ||
| 1002 | switch (yytype) | ||
| 1003 | { | ||
| 1004 | default: | ||
| 1005 | break; | ||
| 1006 | } | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | |||
| 1010 | /*--------------------------------. | ||
| 1011 | | Print this symbol on YYOUTPUT. | | ||
| 1012 | `--------------------------------*/ | ||
| 1013 | |||
| 1014 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1015 | || defined __cplusplus || defined _MSC_VER) | ||
| 1016 | static void | ||
| 1017 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | ||
| 1018 | #else | ||
| 1019 | static void | ||
| 1020 | yy_symbol_print (yyoutput, yytype, yyvaluep) | ||
| 1021 | FILE *yyoutput; | ||
| 1022 | int yytype; | ||
| 1023 | YYSTYPE const * const yyvaluep; | ||
| 1024 | #endif | ||
| 1025 | { | ||
| 1026 | if (yytype < YYNTOKENS) | ||
| 1027 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | ||
| 1028 | else | ||
| 1029 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | ||
| 1030 | |||
| 1031 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); | ||
| 1032 | YYFPRINTF (yyoutput, ")"); | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | /*------------------------------------------------------------------. | ||
| 1036 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | ||
| 1037 | | TOP (included). | | ||
| 1038 | `------------------------------------------------------------------*/ | ||
| 1039 | |||
| 1040 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1041 | || defined __cplusplus || defined _MSC_VER) | ||
| 1042 | static void | ||
| 1043 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | ||
| 1044 | #else | ||
| 1045 | static void | ||
| 1046 | yy_stack_print (yybottom, yytop) | ||
| 1047 | yytype_int16 *yybottom; | ||
| 1048 | yytype_int16 *yytop; | ||
| 1049 | #endif | ||
| 1050 | { | ||
| 1051 | YYFPRINTF (stderr, "Stack now"); | ||
| 1052 | for (; yybottom <= yytop; yybottom++) | ||
| 1053 | { | ||
| 1054 | int yybot = *yybottom; | ||
| 1055 | YYFPRINTF (stderr, " %d", yybot); | ||
| 1056 | } | ||
| 1057 | YYFPRINTF (stderr, "\n"); | ||
| 1058 | } | ||
| 1059 | |||
| 1060 | # define YY_STACK_PRINT(Bottom, Top) \ | ||
| 1061 | do { \ | ||
| 1062 | if (yydebug) \ | ||
| 1063 | yy_stack_print ((Bottom), (Top)); \ | ||
| 1064 | } while (YYID (0)) | ||
| 1065 | |||
| 1066 | |||
| 1067 | /*------------------------------------------------. | ||
| 1068 | | Report that the YYRULE is going to be reduced. | | ||
| 1069 | `------------------------------------------------*/ | ||
| 1070 | |||
| 1071 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1072 | || defined __cplusplus || defined _MSC_VER) | ||
| 1073 | static void | ||
| 1074 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) | ||
| 1075 | #else | ||
| 1076 | static void | ||
| 1077 | yy_reduce_print (yyvsp, yyrule) | ||
| 1078 | YYSTYPE *yyvsp; | ||
| 1079 | int yyrule; | ||
| 1080 | #endif | ||
| 1081 | { | ||
| 1082 | int yynrhs = yyr2[yyrule]; | ||
| 1083 | int yyi; | ||
| 1084 | unsigned long int yylno = yyrline[yyrule]; | ||
| 1085 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | ||
| 1086 | yyrule - 1, yylno); | ||
| 1087 | /* The symbols being reduced. */ | ||
| 1088 | for (yyi = 0; yyi < yynrhs; yyi++) | ||
| 1089 | { | ||
| 1090 | YYFPRINTF (stderr, " $%d = ", yyi + 1); | ||
| 1091 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], | ||
| 1092 | &(yyvsp[(yyi + 1) - (yynrhs)]) | ||
| 1093 | ); | ||
| 1094 | YYFPRINTF (stderr, "\n"); | ||
| 1095 | } | ||
| 1096 | } | ||
| 1097 | |||
| 1098 | # define YY_REDUCE_PRINT(Rule) \ | ||
| 1099 | do { \ | ||
| 1100 | if (yydebug) \ | ||
| 1101 | yy_reduce_print (yyvsp, Rule); \ | ||
| 1102 | } while (YYID (0)) | ||
| 1103 | |||
| 1104 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
| 1105 | multiple parsers can coexist. */ | ||
| 1106 | int yydebug; | ||
| 1107 | #else /* !YYDEBUG */ | ||
| 1108 | # define YYDPRINTF(Args) | ||
| 1109 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) | ||
| 1110 | # define YY_STACK_PRINT(Bottom, Top) | ||
| 1111 | # define YY_REDUCE_PRINT(Rule) | ||
| 1112 | #endif /* !YYDEBUG */ | ||
| 1113 | |||
| 1114 | |||
| 1115 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
| 1116 | #ifndef YYINITDEPTH | ||
| 1117 | # define YYINITDEPTH 200 | ||
| 1118 | #endif | ||
| 1119 | |||
| 1120 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
| 1121 | if the built-in stack extension method is used). | ||
| 1122 | |||
| 1123 | Do not make this value too large; the results are undefined if | ||
| 1124 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | ||
| 1125 | evaluated with infinite-precision integer arithmetic. */ | ||
| 1126 | |||
| 1127 | #ifndef YYMAXDEPTH | ||
| 1128 | # define YYMAXDEPTH 10000 | ||
| 1129 | #endif | ||
| 1130 | |||
| 1131 | |||
| 1132 | #if YYERROR_VERBOSE | ||
| 1133 | |||
| 1134 | # ifndef yystrlen | ||
| 1135 | # if defined __GLIBC__ && defined _STRING_H | ||
| 1136 | # define yystrlen strlen | ||
| 1137 | # else | ||
| 1138 | /* Return the length of YYSTR. */ | ||
| 1139 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1140 | || defined __cplusplus || defined _MSC_VER) | ||
| 1141 | static YYSIZE_T | ||
| 1142 | yystrlen (const char *yystr) | ||
| 1143 | #else | ||
| 1144 | static YYSIZE_T | ||
| 1145 | yystrlen (yystr) | ||
| 1146 | const char *yystr; | ||
| 1147 | #endif | ||
| 1148 | { | ||
| 1149 | YYSIZE_T yylen; | ||
| 1150 | for (yylen = 0; yystr[yylen]; yylen++) | ||
| 1151 | continue; | ||
| 1152 | return yylen; | ||
| 1153 | } | ||
| 1154 | # endif | ||
| 1155 | # endif | ||
| 1156 | |||
| 1157 | # ifndef yystpcpy | ||
| 1158 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | ||
| 1159 | # define yystpcpy stpcpy | ||
| 1160 | # else | ||
| 1161 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
| 1162 | YYDEST. */ | ||
| 1163 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1164 | || defined __cplusplus || defined _MSC_VER) | ||
| 1165 | static char * | ||
| 1166 | yystpcpy (char *yydest, const char *yysrc) | ||
| 1167 | #else | ||
| 1168 | static char * | ||
| 1169 | yystpcpy (yydest, yysrc) | ||
| 1170 | char *yydest; | ||
| 1171 | const char *yysrc; | ||
| 1172 | #endif | ||
| 1173 | { | ||
| 1174 | char *yyd = yydest; | ||
| 1175 | const char *yys = yysrc; | ||
| 1176 | |||
| 1177 | while ((*yyd++ = *yys++) != '\0') | ||
| 1178 | continue; | ||
| 1179 | |||
| 1180 | return yyd - 1; | ||
| 1181 | } | ||
| 1182 | # endif | ||
| 1183 | # endif | ||
| 1184 | |||
| 1185 | # ifndef yytnamerr | ||
| 1186 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | ||
| 1187 | quotes and backslashes, so that it's suitable for yyerror. The | ||
| 1188 | heuristic is that double-quoting is unnecessary unless the string | ||
| 1189 | contains an apostrophe, a comma, or backslash (other than | ||
| 1190 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | ||
| 1191 | null, do not copy; instead, return the length of what the result | ||
| 1192 | would have been. */ | ||
| 1193 | static YYSIZE_T | ||
| 1194 | yytnamerr (char *yyres, const char *yystr) | ||
| 1195 | { | ||
| 1196 | if (*yystr == '"') | ||
| 1197 | { | ||
| 1198 | YYSIZE_T yyn = 0; | ||
| 1199 | char const *yyp = yystr; | ||
| 1200 | |||
| 1201 | for (;;) | ||
| 1202 | switch (*++yyp) | ||
| 1203 | { | ||
| 1204 | case '\'': | ||
| 1205 | case ',': | ||
| 1206 | goto do_not_strip_quotes; | ||
| 1207 | |||
| 1208 | case '\\': | ||
| 1209 | if (*++yyp != '\\') | ||
| 1210 | goto do_not_strip_quotes; | ||
| 1211 | /* Fall through. */ | ||
| 1212 | default: | ||
| 1213 | if (yyres) | ||
| 1214 | yyres[yyn] = *yyp; | ||
| 1215 | yyn++; | ||
| 1216 | break; | ||
| 1217 | |||
| 1218 | case '"': | ||
| 1219 | if (yyres) | ||
| 1220 | yyres[yyn] = '\0'; | ||
| 1221 | return yyn; | ||
| 1222 | } | ||
| 1223 | do_not_strip_quotes: ; | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | if (! yyres) | ||
| 1227 | return yystrlen (yystr); | ||
| 1228 | |||
| 1229 | return yystpcpy (yyres, yystr) - yyres; | ||
| 1230 | } | ||
| 1231 | # endif | ||
| 1232 | |||
| 1233 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message | ||
| 1234 | about the unexpected token YYTOKEN for the state stack whose top is | ||
| 1235 | YYSSP. | ||
| 1236 | |||
| 1237 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is | ||
| 1238 | not large enough to hold the message. In that case, also set | ||
| 1239 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the | ||
| 1240 | required number of bytes is too large to store. */ | ||
| 1241 | static int | ||
| 1242 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | ||
| 1243 | yytype_int16 *yyssp, int yytoken) | ||
| 1244 | { | ||
| 1245 | YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); | ||
| 1246 | YYSIZE_T yysize = yysize0; | ||
| 1247 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | ||
| 1248 | /* Internationalized format string. */ | ||
| 1249 | const char *yyformat = YY_NULL; | ||
| 1250 | /* Arguments of yyformat. */ | ||
| 1251 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | ||
| 1252 | /* Number of reported tokens (one for the "unexpected", one per | ||
| 1253 | "expected"). */ | ||
| 1254 | int yycount = 0; | ||
| 1255 | |||
| 1256 | /* There are many possibilities here to consider: | ||
| 1257 | - Assume YYFAIL is not used. It's too flawed to consider. See | ||
| 1258 | <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> | ||
| 1259 | for details. YYERROR is fine as it does not invoke this | ||
| 1260 | function. | ||
| 1261 | - If this state is a consistent state with a default action, then | ||
| 1262 | the only way this function was invoked is if the default action | ||
| 1263 | is an error action. In that case, don't check for expected | ||
| 1264 | tokens because there are none. | ||
| 1265 | - The only way there can be no lookahead present (in yychar) is if | ||
| 1266 | this state is a consistent state with a default action. Thus, | ||
| 1267 | detecting the absence of a lookahead is sufficient to determine | ||
| 1268 | that there is no unexpected or expected token to report. In that | ||
| 1269 | case, just report a simple "syntax error". | ||
| 1270 | - Don't assume there isn't a lookahead just because this state is a | ||
| 1271 | consistent state with a default action. There might have been a | ||
| 1272 | previous inconsistent state, consistent state with a non-default | ||
| 1273 | action, or user semantic action that manipulated yychar. | ||
| 1274 | - Of course, the expected token list depends on states to have | ||
| 1275 | correct lookahead information, and it depends on the parser not | ||
| 1276 | to perform extra reductions after fetching a lookahead from the | ||
| 1277 | scanner and before detecting a syntax error. Thus, state merging | ||
| 1278 | (from LALR or IELR) and default reductions corrupt the expected | ||
| 1279 | token list. However, the list is correct for canonical LR with | ||
| 1280 | one exception: it will still contain any token that will not be | ||
| 1281 | accepted due to an error action in a later state. | ||
| 1282 | */ | ||
| 1283 | if (yytoken != YYEMPTY) | ||
| 1284 | { | ||
| 1285 | int yyn = yypact[*yyssp]; | ||
| 1286 | yyarg[yycount++] = yytname[yytoken]; | ||
| 1287 | if (!yypact_value_is_default (yyn)) | ||
| 1288 | { | ||
| 1289 | /* Start YYX at -YYN if negative to avoid negative indexes in | ||
| 1290 | YYCHECK. In other words, skip the first -YYN actions for | ||
| 1291 | this state because they are default actions. */ | ||
| 1292 | int yyxbegin = yyn < 0 ? -yyn : 0; | ||
| 1293 | /* Stay within bounds of both yycheck and yytname. */ | ||
| 1294 | int yychecklim = YYLAST - yyn + 1; | ||
| 1295 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | ||
| 1296 | int yyx; | ||
| 1297 | |||
| 1298 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | ||
| 1299 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR | ||
| 1300 | && !yytable_value_is_error (yytable[yyx + yyn])) | ||
| 1301 | { | ||
| 1302 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | ||
| 1303 | { | ||
| 1304 | yycount = 1; | ||
| 1305 | yysize = yysize0; | ||
| 1306 | break; | ||
| 1307 | } | ||
| 1308 | yyarg[yycount++] = yytname[yyx]; | ||
| 1309 | { | ||
| 1310 | YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); | ||
| 1311 | if (! (yysize <= yysize1 | ||
| 1312 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1313 | return 2; | ||
| 1314 | yysize = yysize1; | ||
| 1315 | } | ||
| 1316 | } | ||
| 1317 | } | ||
| 1318 | } | ||
| 1319 | |||
| 1320 | switch (yycount) | ||
| 1321 | { | ||
| 1322 | # define YYCASE_(N, S) \ | ||
| 1323 | case N: \ | ||
| 1324 | yyformat = S; \ | ||
| 1325 | break | ||
| 1326 | YYCASE_(0, YY_("syntax error")); | ||
| 1327 | YYCASE_(1, YY_("syntax error, unexpected %s")); | ||
| 1328 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | ||
| 1329 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | ||
| 1330 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | ||
| 1331 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | ||
| 1332 | # undef YYCASE_ | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | { | ||
| 1336 | YYSIZE_T yysize1 = yysize + yystrlen (yyformat); | ||
| 1337 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1338 | return 2; | ||
| 1339 | yysize = yysize1; | ||
| 1340 | } | ||
| 1341 | |||
| 1342 | if (*yymsg_alloc < yysize) | ||
| 1343 | { | ||
| 1344 | *yymsg_alloc = 2 * yysize; | ||
| 1345 | if (! (yysize <= *yymsg_alloc | ||
| 1346 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) | ||
| 1347 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; | ||
| 1348 | return 1; | ||
| 1349 | } | ||
| 1350 | |||
| 1351 | /* Avoid sprintf, as that infringes on the user's name space. | ||
| 1352 | Don't have undefined behavior even if the translation | ||
| 1353 | produced a string with the wrong number of "%s"s. */ | ||
| 1354 | { | ||
| 1355 | char *yyp = *yymsg; | ||
| 1356 | int yyi = 0; | ||
| 1357 | while ((*yyp = *yyformat) != '\0') | ||
| 1358 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) | ||
| 1359 | { | ||
| 1360 | yyp += yytnamerr (yyp, yyarg[yyi++]); | ||
| 1361 | yyformat += 2; | ||
| 1362 | } | ||
| 1363 | else | ||
| 1364 | { | ||
| 1365 | yyp++; | ||
| 1366 | yyformat++; | ||
| 1367 | } | ||
| 1368 | } | ||
| 1369 | return 0; | ||
| 1370 | } | ||
| 1371 | #endif /* YYERROR_VERBOSE */ | ||
| 1372 | |||
| 1373 | /*-----------------------------------------------. | ||
| 1374 | | Release the memory associated to this symbol. | | ||
| 1375 | `-----------------------------------------------*/ | ||
| 1376 | |||
| 1377 | /*ARGSUSED*/ | ||
| 1378 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1379 | || defined __cplusplus || defined _MSC_VER) | ||
| 1380 | static void | ||
| 1381 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) | ||
| 1382 | #else | ||
| 1383 | static void | ||
| 1384 | yydestruct (yymsg, yytype, yyvaluep) | ||
| 1385 | const char *yymsg; | ||
| 1386 | int yytype; | ||
| 1387 | YYSTYPE *yyvaluep; | ||
| 1388 | #endif | ||
| 1389 | { | ||
| 1390 | YYUSE (yyvaluep); | ||
| 1391 | |||
| 1392 | if (!yymsg) | ||
| 1393 | yymsg = "Deleting"; | ||
| 1394 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | ||
| 1395 | |||
| 1396 | switch (yytype) | ||
| 1397 | { | ||
| 1398 | |||
| 1399 | default: | ||
| 1400 | break; | ||
| 1401 | } | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | |||
| 1405 | |||
| 1406 | |||
| 1407 | /* The lookahead symbol. */ | ||
| 1408 | int yychar; | ||
| 1409 | |||
| 1410 | |||
| 1411 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1412 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1413 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1414 | #endif | ||
| 1415 | #ifndef YY_INITIAL_VALUE | ||
| 1416 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ | ||
| 1417 | #endif | ||
| 1418 | |||
| 1419 | /* The semantic value of the lookahead symbol. */ | ||
| 1420 | YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); | ||
| 1421 | |||
| 1422 | /* Number of syntax errors so far. */ | ||
| 1423 | int yynerrs; | ||
| 1424 | |||
| 1425 | |||
| 1426 | /*----------. | ||
| 1427 | | yyparse. | | ||
| 1428 | `----------*/ | ||
| 1429 | |||
| 1430 | #ifdef YYPARSE_PARAM | ||
| 1431 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1432 | || defined __cplusplus || defined _MSC_VER) | ||
| 1433 | int | ||
| 1434 | yyparse (void *YYPARSE_PARAM) | ||
| 1435 | #else | ||
| 1436 | int | ||
| 1437 | yyparse (YYPARSE_PARAM) | ||
| 1438 | void *YYPARSE_PARAM; | ||
| 1439 | #endif | ||
| 1440 | #else /* ! YYPARSE_PARAM */ | ||
| 1441 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
| 1442 | || defined __cplusplus || defined _MSC_VER) | ||
| 1443 | int | ||
| 1444 | yyparse (void) | ||
| 1445 | #else | ||
| 1446 | int | ||
| 1447 | yyparse () | ||
| 1448 | |||
| 1449 | #endif | ||
| 1450 | #endif | ||
| 1451 | { | ||
| 1452 | int yystate; | ||
| 1453 | /* Number of tokens to shift before error messages enabled. */ | ||
| 1454 | int yyerrstatus; | ||
| 1455 | |||
| 1456 | /* The stacks and their tools: | ||
| 1457 | `yyss': related to states. | ||
| 1458 | `yyvs': related to semantic values. | ||
| 1459 | |||
| 1460 | Refer to the stacks through separate pointers, to allow yyoverflow | ||
| 1461 | to reallocate them elsewhere. */ | ||
| 1462 | |||
| 1463 | /* The state stack. */ | ||
| 1464 | yytype_int16 yyssa[YYINITDEPTH]; | ||
| 1465 | yytype_int16 *yyss; | ||
| 1466 | yytype_int16 *yyssp; | ||
| 1467 | |||
| 1468 | /* The semantic value stack. */ | ||
| 1469 | YYSTYPE yyvsa[YYINITDEPTH]; | ||
| 1470 | YYSTYPE *yyvs; | ||
| 1471 | YYSTYPE *yyvsp; | ||
| 1472 | |||
| 1473 | YYSIZE_T yystacksize; | ||
| 1474 | |||
| 1475 | int yyn; | ||
| 1476 | int yyresult; | ||
| 1477 | /* Lookahead token as an internal (translated) token number. */ | ||
| 1478 | int yytoken = 0; | ||
| 1479 | /* The variables used to return semantic value and location from the | ||
| 1480 | action routines. */ | ||
| 1481 | YYSTYPE yyval; | ||
| 1482 | |||
| 1483 | #if YYERROR_VERBOSE | ||
| 1484 | /* Buffer for error messages, and its allocated size. */ | ||
| 1485 | char yymsgbuf[128]; | ||
| 1486 | char *yymsg = yymsgbuf; | ||
| 1487 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | ||
| 1488 | #endif | ||
| 1489 | |||
| 1490 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) | ||
| 1491 | |||
| 1492 | /* The number of symbols on the RHS of the reduced rule. | ||
| 1493 | Keep to zero when no symbol should be popped. */ | ||
| 1494 | int yylen = 0; | ||
| 1495 | |||
| 1496 | yyssp = yyss = yyssa; | ||
| 1497 | yyvsp = yyvs = yyvsa; | ||
| 1498 | yystacksize = YYINITDEPTH; | ||
| 1499 | |||
| 1500 | YYDPRINTF ((stderr, "Starting parse\n")); | ||
| 1501 | |||
| 1502 | yystate = 0; | ||
| 1503 | yyerrstatus = 0; | ||
| 1504 | yynerrs = 0; | ||
| 1505 | yychar = YYEMPTY; /* Cause a token to be read. */ | ||
| 1506 | goto yysetstate; | ||
| 1507 | |||
| 1508 | /*------------------------------------------------------------. | ||
| 1509 | | yynewstate -- Push a new state, which is found in yystate. | | ||
| 1510 | `------------------------------------------------------------*/ | ||
| 1511 | yynewstate: | ||
| 1512 | /* In all cases, when you get here, the value and location stacks | ||
| 1513 | have just been pushed. So pushing a state here evens the stacks. */ | ||
| 1514 | yyssp++; | ||
| 1515 | |||
| 1516 | yysetstate: | ||
| 1517 | *yyssp = yystate; | ||
| 1518 | |||
| 1519 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 1520 | { | ||
| 1521 | /* Get the current used size of the three stacks, in elements. */ | ||
| 1522 | YYSIZE_T yysize = yyssp - yyss + 1; | ||
| 1523 | |||
| 1524 | #ifdef yyoverflow | ||
| 1525 | { | ||
| 1526 | /* Give user a chance to reallocate the stack. Use copies of | ||
| 1527 | these so that the &'s don't force the real ones into | ||
| 1528 | memory. */ | ||
| 1529 | YYSTYPE *yyvs1 = yyvs; | ||
| 1530 | yytype_int16 *yyss1 = yyss; | ||
| 1531 | |||
| 1532 | /* Each stack pointer address is followed by the size of the | ||
| 1533 | data in use in that stack, in bytes. This used to be a | ||
| 1534 | conditional around just the two extra args, but that might | ||
| 1535 | be undefined if yyoverflow is a macro. */ | ||
| 1536 | yyoverflow (YY_("memory exhausted"), | ||
| 1537 | &yyss1, yysize * sizeof (*yyssp), | ||
| 1538 | &yyvs1, yysize * sizeof (*yyvsp), | ||
| 1539 | &yystacksize); | ||
| 1540 | |||
| 1541 | yyss = yyss1; | ||
| 1542 | yyvs = yyvs1; | ||
| 1543 | } | ||
| 1544 | #else /* no yyoverflow */ | ||
| 1545 | # ifndef YYSTACK_RELOCATE | ||
| 1546 | goto yyexhaustedlab; | ||
| 1547 | # else | ||
| 1548 | /* Extend the stack our own way. */ | ||
| 1549 | if (YYMAXDEPTH <= yystacksize) | ||
| 1550 | goto yyexhaustedlab; | ||
| 1551 | yystacksize *= 2; | ||
| 1552 | if (YYMAXDEPTH < yystacksize) | ||
| 1553 | yystacksize = YYMAXDEPTH; | ||
| 1554 | |||
| 1555 | { | ||
| 1556 | yytype_int16 *yyss1 = yyss; | ||
| 1557 | union yyalloc *yyptr = | ||
| 1558 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
| 1559 | if (! yyptr) | ||
| 1560 | goto yyexhaustedlab; | ||
| 1561 | YYSTACK_RELOCATE (yyss_alloc, yyss); | ||
| 1562 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); | ||
| 1563 | # undef YYSTACK_RELOCATE | ||
| 1564 | if (yyss1 != yyssa) | ||
| 1565 | YYSTACK_FREE (yyss1); | ||
| 1566 | } | ||
| 1567 | # endif | ||
| 1568 | #endif /* no yyoverflow */ | ||
| 1569 | |||
| 1570 | yyssp = yyss + yysize - 1; | ||
| 1571 | yyvsp = yyvs + yysize - 1; | ||
| 1572 | |||
| 1573 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
| 1574 | (unsigned long int) yystacksize)); | ||
| 1575 | |||
| 1576 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 1577 | YYABORT; | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
| 1581 | |||
| 1582 | if (yystate == YYFINAL) | ||
| 1583 | YYACCEPT; | ||
| 1584 | |||
| 1585 | goto yybackup; | ||
| 1586 | |||
| 1587 | /*-----------. | ||
| 1588 | | yybackup. | | ||
| 1589 | `-----------*/ | ||
| 1590 | yybackup: | ||
| 1591 | |||
| 1592 | /* Do appropriate processing given the current state. Read a | ||
| 1593 | lookahead token if we need one and don't already have one. */ | ||
| 1594 | |||
| 1595 | /* First try to decide what to do without reference to lookahead token. */ | ||
| 1596 | yyn = yypact[yystate]; | ||
| 1597 | if (yypact_value_is_default (yyn)) | ||
| 1598 | goto yydefault; | ||
| 1599 | |||
| 1600 | /* Not known => get a lookahead token if don't already have one. */ | ||
| 1601 | |||
| 1602 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | ||
| 1603 | if (yychar == YYEMPTY) | ||
| 1604 | { | ||
| 1605 | YYDPRINTF ((stderr, "Reading a token: ")); | ||
| 1606 | yychar = YYLEX; | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | if (yychar <= YYEOF) | ||
| 1610 | { | ||
| 1611 | yychar = yytoken = YYEOF; | ||
| 1612 | YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
| 1613 | } | ||
| 1614 | else | ||
| 1615 | { | ||
| 1616 | yytoken = YYTRANSLATE (yychar); | ||
| 1617 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | ||
| 1618 | } | ||
| 1619 | |||
| 1620 | /* If the proper action on seeing token YYTOKEN is to reduce or to | ||
| 1621 | detect an error, take that action. */ | ||
| 1622 | yyn += yytoken; | ||
| 1623 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | ||
| 1624 | goto yydefault; | ||
| 1625 | yyn = yytable[yyn]; | ||
| 1626 | if (yyn <= 0) | ||
| 1627 | { | ||
| 1628 | if (yytable_value_is_error (yyn)) | ||
| 1629 | goto yyerrlab; | ||
| 1630 | yyn = -yyn; | ||
| 1631 | goto yyreduce; | ||
| 1632 | } | ||
| 1633 | |||
| 1634 | /* Count tokens shifted since error; after three, turn off error | ||
| 1635 | status. */ | ||
| 1636 | if (yyerrstatus) | ||
| 1637 | yyerrstatus--; | ||
| 1638 | |||
| 1639 | /* Shift the lookahead token. */ | ||
| 1640 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | ||
| 1641 | |||
| 1642 | /* Discard the shifted token. */ | ||
| 1643 | yychar = YYEMPTY; | ||
| 1644 | |||
| 1645 | yystate = yyn; | ||
| 1646 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 1647 | *++yyvsp = yylval; | ||
| 1648 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 1649 | |||
| 1650 | goto yynewstate; | ||
| 1651 | |||
| 1652 | |||
| 1653 | /*-----------------------------------------------------------. | ||
| 1654 | | yydefault -- do the default action for the current state. | | ||
| 1655 | `-----------------------------------------------------------*/ | ||
| 1656 | yydefault: | ||
| 1657 | yyn = yydefact[yystate]; | ||
| 1658 | if (yyn == 0) | ||
| 1659 | goto yyerrlab; | ||
| 1660 | goto yyreduce; | ||
| 1661 | |||
| 1662 | |||
| 1663 | /*-----------------------------. | ||
| 1664 | | yyreduce -- Do a reduction. | | ||
| 1665 | `-----------------------------*/ | ||
| 1666 | yyreduce: | ||
| 1667 | /* yyn is the number of a rule to reduce with. */ | ||
| 1668 | yylen = yyr2[yyn]; | ||
| 1669 | |||
| 1670 | /* If YYLEN is nonzero, implement the default value of the action: | ||
| 1671 | `$$ = $1'. | ||
| 1672 | |||
| 1673 | Otherwise, the following line sets YYVAL to garbage. | ||
| 1674 | This behavior is undocumented and Bison | ||
| 1675 | users should not rely upon it. Assigning to YYVAL | ||
| 1676 | unconditionally makes the parser a bit smaller, and it avoids a | ||
| 1677 | GCC warning that YYVAL may be used uninitialized. */ | ||
| 1678 | yyval = yyvsp[1-yylen]; | ||
| 1679 | |||
| 1680 | |||
| 1681 | YY_REDUCE_PRINT (yyn); | ||
| 1682 | switch (yyn) | ||
| 1683 | { | ||
| 1684 | case 4: | ||
| 1685 | |||
| 1686 | { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; } | ||
| 1687 | break; | ||
| 1688 | |||
| 1689 | case 5: | ||
| 1690 | |||
| 1691 | { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; } | ||
| 1692 | break; | ||
| 1693 | |||
| 1694 | case 6: | ||
| 1695 | |||
| 1696 | { is_typedef = 1; } | ||
| 1697 | break; | ||
| 1698 | |||
| 1699 | case 7: | ||
| 1700 | |||
| 1701 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 1702 | break; | ||
| 1703 | |||
| 1704 | case 8: | ||
| 1705 | |||
| 1706 | { is_typedef = 1; } | ||
| 1707 | break; | ||
| 1708 | |||
| 1709 | case 9: | ||
| 1710 | |||
| 1711 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1712 | break; | ||
| 1713 | |||
| 1714 | case 14: | ||
| 1715 | |||
| 1716 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1717 | break; | ||
| 1718 | |||
| 1719 | case 15: | ||
| 1720 | |||
| 1721 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1722 | break; | ||
| 1723 | |||
| 1724 | case 16: | ||
| 1725 | |||
| 1726 | { if (current_name) { | ||
| 1727 | struct string_list *decl = (*(yyvsp[(3) - (3)]))->next; | ||
| 1728 | (*(yyvsp[(3) - (3)]))->next = NULL; | ||
| 1729 | add_symbol(current_name, | ||
| 1730 | is_typedef ? SYM_TYPEDEF : SYM_NORMAL, | ||
| 1731 | decl, is_extern); | ||
| 1732 | current_name = NULL; | ||
| 1733 | } | ||
| 1734 | (yyval) = (yyvsp[(3) - (3)]); | ||
| 1735 | } | ||
| 1736 | break; | ||
| 1737 | |||
| 1738 | case 17: | ||
| 1739 | |||
| 1740 | { (yyval) = NULL; } | ||
| 1741 | break; | ||
| 1742 | |||
| 1743 | case 19: | ||
| 1744 | |||
| 1745 | { struct string_list *decl = *(yyvsp[(1) - (1)]); | ||
| 1746 | *(yyvsp[(1) - (1)]) = NULL; | ||
| 1747 | add_symbol(current_name, | ||
| 1748 | is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); | ||
| 1749 | current_name = NULL; | ||
| 1750 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1751 | } | ||
| 1752 | break; | ||
| 1753 | |||
| 1754 | case 20: | ||
| 1755 | |||
| 1756 | { struct string_list *decl = *(yyvsp[(3) - (3)]); | ||
| 1757 | *(yyvsp[(3) - (3)]) = NULL; | ||
| 1758 | free_list(*(yyvsp[(2) - (3)]), NULL); | ||
| 1759 | *(yyvsp[(2) - (3)]) = decl_spec; | ||
| 1760 | add_symbol(current_name, | ||
| 1761 | is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); | ||
| 1762 | current_name = NULL; | ||
| 1763 | (yyval) = (yyvsp[(3) - (3)]); | ||
| 1764 | } | ||
| 1765 | break; | ||
| 1766 | |||
| 1767 | case 21: | ||
| 1768 | |||
| 1769 | { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); } | ||
| 1770 | break; | ||
| 1771 | |||
| 1772 | case 22: | ||
| 1773 | |||
| 1774 | { decl_spec = NULL; } | ||
| 1775 | break; | ||
| 1776 | |||
| 1777 | case 24: | ||
| 1778 | |||
| 1779 | { decl_spec = *(yyvsp[(1) - (1)]); } | ||
| 1780 | break; | ||
| 1781 | |||
| 1782 | case 25: | ||
| 1783 | |||
| 1784 | { decl_spec = *(yyvsp[(2) - (2)]); } | ||
| 1785 | break; | ||
| 1786 | |||
| 1787 | case 26: | ||
| 1788 | |||
| 1789 | { /* Version 2 checksumming ignores storage class, as that | ||
| 1790 | is really irrelevant to the linkage. */ | ||
| 1791 | remove_node((yyvsp[(1) - (1)])); | ||
| 1792 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1793 | } | ||
| 1794 | break; | ||
| 1795 | |||
| 1796 | case 31: | ||
| 1797 | |||
| 1798 | { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); } | ||
| 1799 | break; | ||
| 1800 | |||
| 1801 | case 32: | ||
| 1802 | |||
| 1803 | { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); } | ||
| 1804 | break; | ||
| 1805 | |||
| 1806 | case 37: | ||
| 1807 | |||
| 1808 | { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1809 | break; | ||
| 1810 | |||
| 1811 | case 38: | ||
| 1812 | |||
| 1813 | { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1814 | break; | ||
| 1815 | |||
| 1816 | case 39: | ||
| 1817 | |||
| 1818 | { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1819 | break; | ||
| 1820 | |||
| 1821 | case 40: | ||
| 1822 | |||
| 1823 | { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_STRUCT); (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1824 | break; | ||
| 1825 | |||
| 1826 | case 41: | ||
| 1827 | |||
| 1828 | { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_UNION); (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1829 | break; | ||
| 1830 | |||
| 1831 | case 42: | ||
| 1832 | |||
| 1833 | { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_ENUM); (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1834 | break; | ||
| 1835 | |||
| 1836 | case 43: | ||
| 1837 | |||
| 1838 | { add_symbol(NULL, SYM_ENUM, NULL, 0); (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1839 | break; | ||
| 1840 | |||
| 1841 | case 44: | ||
| 1842 | |||
| 1843 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1844 | break; | ||
| 1845 | |||
| 1846 | case 45: | ||
| 1847 | |||
| 1848 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1849 | break; | ||
| 1850 | |||
| 1851 | case 57: | ||
| 1852 | |||
| 1853 | { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); } | ||
| 1854 | break; | ||
| 1855 | |||
| 1856 | case 58: | ||
| 1857 | |||
| 1858 | { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } | ||
| 1859 | break; | ||
| 1860 | |||
| 1861 | case 59: | ||
| 1862 | |||
| 1863 | { (yyval) = NULL; } | ||
| 1864 | break; | ||
| 1865 | |||
| 1866 | case 62: | ||
| 1867 | |||
| 1868 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1869 | break; | ||
| 1870 | |||
| 1871 | case 66: | ||
| 1872 | |||
| 1873 | { /* restrict has no effect in prototypes so ignore it */ | ||
| 1874 | remove_node((yyvsp[(1) - (1)])); | ||
| 1875 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1876 | } | ||
| 1877 | break; | ||
| 1878 | |||
| 1879 | case 67: | ||
| 1880 | |||
| 1881 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1882 | break; | ||
| 1883 | |||
| 1884 | case 69: | ||
| 1885 | |||
| 1886 | { if (current_name != NULL) { | ||
| 1887 | error_with_pos("unexpected second declaration name"); | ||
| 1888 | YYERROR; | ||
| 1889 | } else { | ||
| 1890 | current_name = (*(yyvsp[(1) - (1)]))->string; | ||
| 1891 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1892 | } | ||
| 1893 | } | ||
| 1894 | break; | ||
| 1895 | |||
| 1896 | case 70: | ||
| 1897 | |||
| 1898 | { if (current_name != NULL) { | ||
| 1899 | error_with_pos("unexpected second declaration name"); | ||
| 1900 | YYERROR; | ||
| 1901 | } else { | ||
| 1902 | current_name = (*(yyvsp[(1) - (1)]))->string; | ||
| 1903 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1904 | } | ||
| 1905 | } | ||
| 1906 | break; | ||
| 1907 | |||
| 1908 | case 71: | ||
| 1909 | |||
| 1910 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 1911 | break; | ||
| 1912 | |||
| 1913 | case 72: | ||
| 1914 | |||
| 1915 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 1916 | break; | ||
| 1917 | |||
| 1918 | case 73: | ||
| 1919 | |||
| 1920 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1921 | break; | ||
| 1922 | |||
| 1923 | case 74: | ||
| 1924 | |||
| 1925 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1926 | break; | ||
| 1927 | |||
| 1928 | case 75: | ||
| 1929 | |||
| 1930 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1931 | break; | ||
| 1932 | |||
| 1933 | case 79: | ||
| 1934 | |||
| 1935 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 1936 | break; | ||
| 1937 | |||
| 1938 | case 80: | ||
| 1939 | |||
| 1940 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 1941 | break; | ||
| 1942 | |||
| 1943 | case 81: | ||
| 1944 | |||
| 1945 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1946 | break; | ||
| 1947 | |||
| 1948 | case 82: | ||
| 1949 | |||
| 1950 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1951 | break; | ||
| 1952 | |||
| 1953 | case 83: | ||
| 1954 | |||
| 1955 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1956 | break; | ||
| 1957 | |||
| 1958 | case 84: | ||
| 1959 | |||
| 1960 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 1961 | break; | ||
| 1962 | |||
| 1963 | case 86: | ||
| 1964 | |||
| 1965 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1966 | break; | ||
| 1967 | |||
| 1968 | case 87: | ||
| 1969 | |||
| 1970 | { (yyval) = NULL; } | ||
| 1971 | break; | ||
| 1972 | |||
| 1973 | case 90: | ||
| 1974 | |||
| 1975 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 1976 | break; | ||
| 1977 | |||
| 1978 | case 91: | ||
| 1979 | |||
| 1980 | { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } | ||
| 1981 | break; | ||
| 1982 | |||
| 1983 | case 92: | ||
| 1984 | |||
| 1985 | { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } | ||
| 1986 | break; | ||
| 1987 | |||
| 1988 | case 94: | ||
| 1989 | |||
| 1990 | { (yyval) = NULL; } | ||
| 1991 | break; | ||
| 1992 | |||
| 1993 | case 95: | ||
| 1994 | |||
| 1995 | { /* For version 2 checksums, we don't want to remember | ||
| 1996 | private parameter names. */ | ||
| 1997 | remove_node((yyvsp[(1) - (1)])); | ||
| 1998 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 1999 | } | ||
| 2000 | break; | ||
| 2001 | |||
| 2002 | case 96: | ||
| 2003 | |||
| 2004 | { remove_node((yyvsp[(1) - (1)])); | ||
| 2005 | (yyval) = (yyvsp[(1) - (1)]); | ||
| 2006 | } | ||
| 2007 | break; | ||
| 2008 | |||
| 2009 | case 97: | ||
| 2010 | |||
| 2011 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 2012 | break; | ||
| 2013 | |||
| 2014 | case 98: | ||
| 2015 | |||
| 2016 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 2017 | break; | ||
| 2018 | |||
| 2019 | case 99: | ||
| 2020 | |||
| 2021 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2022 | break; | ||
| 2023 | |||
| 2024 | case 100: | ||
| 2025 | |||
| 2026 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2027 | break; | ||
| 2028 | |||
| 2029 | case 101: | ||
| 2030 | |||
| 2031 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2032 | break; | ||
| 2033 | |||
| 2034 | case 102: | ||
| 2035 | |||
| 2036 | { struct string_list *decl = *(yyvsp[(2) - (3)]); | ||
| 2037 | *(yyvsp[(2) - (3)]) = NULL; | ||
| 2038 | add_symbol(current_name, SYM_NORMAL, decl, is_extern); | ||
| 2039 | (yyval) = (yyvsp[(3) - (3)]); | ||
| 2040 | } | ||
| 2041 | break; | ||
| 2042 | |||
| 2043 | case 103: | ||
| 2044 | |||
| 2045 | { (yyval) = NULL; } | ||
| 2046 | break; | ||
| 2047 | |||
| 2048 | case 105: | ||
| 2049 | |||
| 2050 | { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2051 | break; | ||
| 2052 | |||
| 2053 | case 106: | ||
| 2054 | |||
| 2055 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2056 | break; | ||
| 2057 | |||
| 2058 | case 107: | ||
| 2059 | |||
| 2060 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2061 | break; | ||
| 2062 | |||
| 2063 | case 108: | ||
| 2064 | |||
| 2065 | { (yyval) = NULL; } | ||
| 2066 | break; | ||
| 2067 | |||
| 2068 | case 111: | ||
| 2069 | |||
| 2070 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2071 | break; | ||
| 2072 | |||
| 2073 | case 112: | ||
| 2074 | |||
| 2075 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2076 | break; | ||
| 2077 | |||
| 2078 | case 113: | ||
| 2079 | |||
| 2080 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2081 | break; | ||
| 2082 | |||
| 2083 | case 114: | ||
| 2084 | |||
| 2085 | { (yyval) = NULL; } | ||
| 2086 | break; | ||
| 2087 | |||
| 2088 | case 117: | ||
| 2089 | |||
| 2090 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2091 | break; | ||
| 2092 | |||
| 2093 | case 118: | ||
| 2094 | |||
| 2095 | { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } | ||
| 2096 | break; | ||
| 2097 | |||
| 2098 | case 119: | ||
| 2099 | |||
| 2100 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2101 | break; | ||
| 2102 | |||
| 2103 | case 121: | ||
| 2104 | |||
| 2105 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2106 | break; | ||
| 2107 | |||
| 2108 | case 122: | ||
| 2109 | |||
| 2110 | { (yyval) = NULL; } | ||
| 2111 | break; | ||
| 2112 | |||
| 2113 | case 124: | ||
| 2114 | |||
| 2115 | { (yyval) = (yyvsp[(3) - (3)]); } | ||
| 2116 | break; | ||
| 2117 | |||
| 2118 | case 125: | ||
| 2119 | |||
| 2120 | { (yyval) = (yyvsp[(4) - (4)]); } | ||
| 2121 | break; | ||
| 2122 | |||
| 2123 | case 128: | ||
| 2124 | |||
| 2125 | { | ||
| 2126 | const char *name = strdup((*(yyvsp[(1) - (1)]))->string); | ||
| 2127 | add_symbol(name, SYM_ENUM_CONST, NULL, 0); | ||
| 2128 | } | ||
| 2129 | break; | ||
| 2130 | |||
| 2131 | case 129: | ||
| 2132 | |||
| 2133 | { | ||
| 2134 | const char *name = strdup((*(yyvsp[(1) - (3)]))->string); | ||
| 2135 | struct string_list *expr = copy_list_range(*(yyvsp[(3) - (3)]), *(yyvsp[(2) - (3)])); | ||
| 2136 | add_symbol(name, SYM_ENUM_CONST, expr, 0); | ||
| 2137 | } | ||
| 2138 | break; | ||
| 2139 | |||
| 2140 | case 130: | ||
| 2141 | |||
| 2142 | { (yyval) = (yyvsp[(2) - (2)]); } | ||
| 2143 | break; | ||
| 2144 | |||
| 2145 | case 131: | ||
| 2146 | |||
| 2147 | { (yyval) = NULL; } | ||
| 2148 | break; | ||
| 2149 | |||
| 2150 | case 133: | ||
| 2151 | |||
| 2152 | { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); } | ||
| 2153 | break; | ||
| 2154 | |||
| 2155 | |||
| 2156 | |||
| 2157 | default: break; | ||
| 2158 | } | ||
| 2159 | /* User semantic actions sometimes alter yychar, and that requires | ||
| 2160 | that yytoken be updated with the new translation. We take the | ||
| 2161 | approach of translating immediately before every use of yytoken. | ||
| 2162 | One alternative is translating here after every semantic action, | ||
| 2163 | but that translation would be missed if the semantic action invokes | ||
| 2164 | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or | ||
| 2165 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an | ||
| 2166 | incorrect destructor might then be invoked immediately. In the | ||
| 2167 | case of YYERROR or YYBACKUP, subsequent parser actions might lead | ||
| 2168 | to an incorrect destructor call or verbose syntax error message | ||
| 2169 | before the lookahead is translated. */ | ||
| 2170 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | ||
| 2171 | |||
| 2172 | YYPOPSTACK (yylen); | ||
| 2173 | yylen = 0; | ||
| 2174 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2175 | |||
| 2176 | *++yyvsp = yyval; | ||
| 2177 | |||
| 2178 | /* Now `shift' the result of the reduction. Determine what state | ||
| 2179 | that goes to, based on the state we popped back to and the rule | ||
| 2180 | number reduced by. */ | ||
| 2181 | |||
| 2182 | yyn = yyr1[yyn]; | ||
| 2183 | |||
| 2184 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
| 2185 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
| 2186 | yystate = yytable[yystate]; | ||
| 2187 | else | ||
| 2188 | yystate = yydefgoto[yyn - YYNTOKENS]; | ||
| 2189 | |||
| 2190 | goto yynewstate; | ||
| 2191 | |||
| 2192 | |||
| 2193 | /*------------------------------------. | ||
| 2194 | | yyerrlab -- here on detecting error | | ||
| 2195 | `------------------------------------*/ | ||
| 2196 | yyerrlab: | ||
| 2197 | /* Make sure we have latest lookahead translation. See comments at | ||
| 2198 | user semantic actions for why this is necessary. */ | ||
| 2199 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); | ||
| 2200 | |||
| 2201 | /* If not already recovering from an error, report this error. */ | ||
| 2202 | if (!yyerrstatus) | ||
| 2203 | { | ||
| 2204 | ++yynerrs; | ||
| 2205 | #if ! YYERROR_VERBOSE | ||
| 2206 | yyerror (YY_("syntax error")); | ||
| 2207 | #else | ||
| 2208 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ | ||
| 2209 | yyssp, yytoken) | ||
| 2210 | { | ||
| 2211 | char const *yymsgp = YY_("syntax error"); | ||
| 2212 | int yysyntax_error_status; | ||
| 2213 | yysyntax_error_status = YYSYNTAX_ERROR; | ||
| 2214 | if (yysyntax_error_status == 0) | ||
| 2215 | yymsgp = yymsg; | ||
| 2216 | else if (yysyntax_error_status == 1) | ||
| 2217 | { | ||
| 2218 | if (yymsg != yymsgbuf) | ||
| 2219 | YYSTACK_FREE (yymsg); | ||
| 2220 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); | ||
| 2221 | if (!yymsg) | ||
| 2222 | { | ||
| 2223 | yymsg = yymsgbuf; | ||
| 2224 | yymsg_alloc = sizeof yymsgbuf; | ||
| 2225 | yysyntax_error_status = 2; | ||
| 2226 | } | ||
| 2227 | else | ||
| 2228 | { | ||
| 2229 | yysyntax_error_status = YYSYNTAX_ERROR; | ||
| 2230 | yymsgp = yymsg; | ||
| 2231 | } | ||
| 2232 | } | ||
| 2233 | yyerror (yymsgp); | ||
| 2234 | if (yysyntax_error_status == 2) | ||
| 2235 | goto yyexhaustedlab; | ||
| 2236 | } | ||
| 2237 | # undef YYSYNTAX_ERROR | ||
| 2238 | #endif | ||
| 2239 | } | ||
| 2240 | |||
| 2241 | |||
| 2242 | |||
| 2243 | if (yyerrstatus == 3) | ||
| 2244 | { | ||
| 2245 | /* If just tried and failed to reuse lookahead token after an | ||
| 2246 | error, discard it. */ | ||
| 2247 | |||
| 2248 | if (yychar <= YYEOF) | ||
| 2249 | { | ||
| 2250 | /* Return failure if at end of input. */ | ||
| 2251 | if (yychar == YYEOF) | ||
| 2252 | YYABORT; | ||
| 2253 | } | ||
| 2254 | else | ||
| 2255 | { | ||
| 2256 | yydestruct ("Error: discarding", | ||
| 2257 | yytoken, &yylval); | ||
| 2258 | yychar = YYEMPTY; | ||
| 2259 | } | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | /* Else will try to reuse lookahead token after shifting the error | ||
| 2263 | token. */ | ||
| 2264 | goto yyerrlab1; | ||
| 2265 | |||
| 2266 | |||
| 2267 | /*---------------------------------------------------. | ||
| 2268 | | yyerrorlab -- error raised explicitly by YYERROR. | | ||
| 2269 | `---------------------------------------------------*/ | ||
| 2270 | yyerrorlab: | ||
| 2271 | |||
| 2272 | /* Pacify compilers like GCC when the user code never invokes | ||
| 2273 | YYERROR and the label yyerrorlab therefore never appears in user | ||
| 2274 | code. */ | ||
| 2275 | if (/*CONSTCOND*/ 0) | ||
| 2276 | goto yyerrorlab; | ||
| 2277 | |||
| 2278 | /* Do not reclaim the symbols of the rule which action triggered | ||
| 2279 | this YYERROR. */ | ||
| 2280 | YYPOPSTACK (yylen); | ||
| 2281 | yylen = 0; | ||
| 2282 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2283 | yystate = *yyssp; | ||
| 2284 | goto yyerrlab1; | ||
| 2285 | |||
| 2286 | |||
| 2287 | /*-------------------------------------------------------------. | ||
| 2288 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | ||
| 2289 | `-------------------------------------------------------------*/ | ||
| 2290 | yyerrlab1: | ||
| 2291 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
| 2292 | |||
| 2293 | for (;;) | ||
| 2294 | { | ||
| 2295 | yyn = yypact[yystate]; | ||
| 2296 | if (!yypact_value_is_default (yyn)) | ||
| 2297 | { | ||
| 2298 | yyn += YYTERROR; | ||
| 2299 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
| 2300 | { | ||
| 2301 | yyn = yytable[yyn]; | ||
| 2302 | if (0 < yyn) | ||
| 2303 | break; | ||
| 2304 | } | ||
| 2305 | } | ||
| 2306 | |||
| 2307 | /* Pop the current state because it cannot handle the error token. */ | ||
| 2308 | if (yyssp == yyss) | ||
| 2309 | YYABORT; | ||
| 2310 | |||
| 2311 | |||
| 2312 | yydestruct ("Error: popping", | ||
| 2313 | yystos[yystate], yyvsp); | ||
| 2314 | YYPOPSTACK (1); | ||
| 2315 | yystate = *yyssp; | ||
| 2316 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2317 | } | ||
| 2318 | |||
| 2319 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | ||
| 2320 | *++yyvsp = yylval; | ||
| 2321 | YY_IGNORE_MAYBE_UNINITIALIZED_END | ||
| 2322 | |||
| 2323 | |||
| 2324 | /* Shift the error token. */ | ||
| 2325 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | ||
| 2326 | |||
| 2327 | yystate = yyn; | ||
| 2328 | goto yynewstate; | ||
| 2329 | |||
| 2330 | |||
| 2331 | /*-------------------------------------. | ||
| 2332 | | yyacceptlab -- YYACCEPT comes here. | | ||
| 2333 | `-------------------------------------*/ | ||
| 2334 | yyacceptlab: | ||
| 2335 | yyresult = 0; | ||
| 2336 | goto yyreturn; | ||
| 2337 | |||
| 2338 | /*-----------------------------------. | ||
| 2339 | | yyabortlab -- YYABORT comes here. | | ||
| 2340 | `-----------------------------------*/ | ||
| 2341 | yyabortlab: | ||
| 2342 | yyresult = 1; | ||
| 2343 | goto yyreturn; | ||
| 2344 | |||
| 2345 | #if !defined yyoverflow || YYERROR_VERBOSE | ||
| 2346 | /*-------------------------------------------------. | ||
| 2347 | | yyexhaustedlab -- memory exhaustion comes here. | | ||
| 2348 | `-------------------------------------------------*/ | ||
| 2349 | yyexhaustedlab: | ||
| 2350 | yyerror (YY_("memory exhausted")); | ||
| 2351 | yyresult = 2; | ||
| 2352 | /* Fall through. */ | ||
| 2353 | #endif | ||
| 2354 | |||
| 2355 | yyreturn: | ||
| 2356 | if (yychar != YYEMPTY) | ||
| 2357 | { | ||
| 2358 | /* Make sure we have latest lookahead translation. See comments at | ||
| 2359 | user semantic actions for why this is necessary. */ | ||
| 2360 | yytoken = YYTRANSLATE (yychar); | ||
| 2361 | yydestruct ("Cleanup: discarding lookahead", | ||
| 2362 | yytoken, &yylval); | ||
| 2363 | } | ||
| 2364 | /* Do not reclaim the symbols of the rule which action triggered | ||
| 2365 | this YYABORT or YYACCEPT. */ | ||
| 2366 | YYPOPSTACK (yylen); | ||
| 2367 | YY_STACK_PRINT (yyss, yyssp); | ||
| 2368 | while (yyssp != yyss) | ||
| 2369 | { | ||
| 2370 | yydestruct ("Cleanup: popping", | ||
| 2371 | yystos[*yyssp], yyvsp); | ||
| 2372 | YYPOPSTACK (1); | ||
| 2373 | } | ||
| 2374 | #ifndef yyoverflow | ||
| 2375 | if (yyss != yyssa) | ||
| 2376 | YYSTACK_FREE (yyss); | ||
| 2377 | #endif | ||
| 2378 | #if YYERROR_VERBOSE | ||
| 2379 | if (yymsg != yymsgbuf) | ||
| 2380 | YYSTACK_FREE (yymsg); | ||
| 2381 | #endif | ||
| 2382 | /* Make sure YYID is used. */ | ||
| 2383 | return YYID (yyresult); | ||
| 2384 | } | ||
| 2385 | |||
| 2386 | |||
| 2387 | |||
| 2388 | |||
| 2389 | |||
| 2390 | static void | ||
| 2391 | yyerror(const char *e) | ||
| 2392 | { | ||
| 2393 | error_with_pos("%s", e); | ||
| 2394 | } | ||
diff --git a/scripts/genksyms/parse.tab.h_shipped b/scripts/genksyms/parse.tab.h_shipped deleted file mode 100644 index 46a5e124eda1..000000000000 --- a/scripts/genksyms/parse.tab.h_shipped +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 2.7. */ | ||
| 2 | |||
| 3 | /* Bison interface for Yacc-like parsers in C | ||
| 4 | |||
| 5 | Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (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 | ||
| 15 | GNU 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, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* As a special exception, you may create a larger work that contains | ||
| 21 | part or all of the Bison parser skeleton and distribute that work | ||
| 22 | under terms of your choice, so long as that work isn't itself a | ||
| 23 | parser generator using the skeleton or a modified version thereof | ||
| 24 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
| 25 | the parser skeleton itself, you may (at your option) remove this | ||
| 26 | special exception, which will cause the skeleton and the resulting | ||
| 27 | Bison output files to be licensed under the GNU General Public | ||
| 28 | License without this special exception. | ||
| 29 | |||
| 30 | This special exception was added by the Free Software Foundation in | ||
| 31 | version 2.2 of Bison. */ | ||
| 32 | |||
| 33 | #ifndef YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED | ||
| 34 | # define YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED | ||
| 35 | /* Enabling traces. */ | ||
| 36 | #ifndef YYDEBUG | ||
| 37 | # define YYDEBUG 1 | ||
| 38 | #endif | ||
| 39 | #if YYDEBUG | ||
| 40 | extern int yydebug; | ||
| 41 | #endif | ||
| 42 | |||
| 43 | /* Tokens. */ | ||
| 44 | #ifndef YYTOKENTYPE | ||
| 45 | # define YYTOKENTYPE | ||
| 46 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
| 47 | know about them. */ | ||
| 48 | enum yytokentype { | ||
| 49 | ASM_KEYW = 258, | ||
| 50 | ATTRIBUTE_KEYW = 259, | ||
| 51 | AUTO_KEYW = 260, | ||
| 52 | BOOL_KEYW = 261, | ||
| 53 | CHAR_KEYW = 262, | ||
| 54 | CONST_KEYW = 263, | ||
| 55 | DOUBLE_KEYW = 264, | ||
| 56 | ENUM_KEYW = 265, | ||
| 57 | EXTERN_KEYW = 266, | ||
| 58 | EXTENSION_KEYW = 267, | ||
| 59 | FLOAT_KEYW = 268, | ||
| 60 | INLINE_KEYW = 269, | ||
| 61 | INT_KEYW = 270, | ||
| 62 | LONG_KEYW = 271, | ||
| 63 | REGISTER_KEYW = 272, | ||
| 64 | RESTRICT_KEYW = 273, | ||
| 65 | SHORT_KEYW = 274, | ||
| 66 | SIGNED_KEYW = 275, | ||
| 67 | STATIC_KEYW = 276, | ||
| 68 | STRUCT_KEYW = 277, | ||
| 69 | TYPEDEF_KEYW = 278, | ||
| 70 | UNION_KEYW = 279, | ||
| 71 | UNSIGNED_KEYW = 280, | ||
| 72 | VOID_KEYW = 281, | ||
| 73 | VOLATILE_KEYW = 282, | ||
| 74 | TYPEOF_KEYW = 283, | ||
| 75 | VA_LIST_KEYW = 284, | ||
| 76 | EXPORT_SYMBOL_KEYW = 285, | ||
| 77 | ASM_PHRASE = 286, | ||
| 78 | ATTRIBUTE_PHRASE = 287, | ||
| 79 | TYPEOF_PHRASE = 288, | ||
| 80 | BRACE_PHRASE = 289, | ||
| 81 | BRACKET_PHRASE = 290, | ||
| 82 | EXPRESSION_PHRASE = 291, | ||
| 83 | CHAR = 292, | ||
| 84 | DOTS = 293, | ||
| 85 | IDENT = 294, | ||
| 86 | INT = 295, | ||
| 87 | REAL = 296, | ||
| 88 | STRING = 297, | ||
| 89 | TYPE = 298, | ||
| 90 | OTHER = 299, | ||
| 91 | FILENAME = 300 | ||
| 92 | }; | ||
| 93 | #endif | ||
| 94 | |||
| 95 | |||
| 96 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
| 97 | typedef int YYSTYPE; | ||
| 98 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 99 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
| 100 | # define YYSTYPE_IS_DECLARED 1 | ||
| 101 | #endif | ||
| 102 | |||
| 103 | extern YYSTYPE yylval; | ||
| 104 | |||
| 105 | #ifdef YYPARSE_PARAM | ||
| 106 | #if defined __STDC__ || defined __cplusplus | ||
| 107 | int yyparse (void *YYPARSE_PARAM); | ||
| 108 | #else | ||
| 109 | int yyparse (); | ||
| 110 | #endif | ||
| 111 | #else /* ! YYPARSE_PARAM */ | ||
| 112 | #if defined __STDC__ || defined __cplusplus | ||
| 113 | int yyparse (void); | ||
| 114 | #else | ||
| 115 | int yyparse (); | ||
| 116 | #endif | ||
| 117 | #endif /* ! YYPARSE_PARAM */ | ||
| 118 | |||
| 119 | #endif /* !YY_YY_SCRIPTS_GENKSYMS_PARSE_TAB_H_SHIPPED_INCLUDED */ | ||
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index a18bca720995..593f8879c641 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh | |||
| @@ -31,13 +31,13 @@ trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT | |||
| 31 | for i in "$@" | 31 | for i in "$@" |
| 32 | do | 32 | do |
| 33 | FILE="$(basename "$i")" | 33 | FILE="$(basename "$i")" |
| 34 | sed -r \ | 34 | sed -E \ |
| 35 | -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \ | 35 | -e 's/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g' \ |
| 36 | -e 's/__attribute_const__([ \t]|$)/\1/g' \ | 36 | -e 's/__attribute_const__([[:space:]]|$)/\1/g' \ |
| 37 | -e 's@^#include <linux/compiler(|_types).h>@@' \ | 37 | -e 's@^#include <linux/compiler(|_types).h>@@' \ |
| 38 | -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ | 38 | -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ |
| 39 | -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ | 39 | -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \ |
| 40 | -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ | 40 | -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \ |
| 41 | "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 | 41 | "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 |
| 42 | scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ | 42 | scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ |
| 43 | > "$OUTDIR/$FILE" | 43 | > "$OUTDIR/$FILE" |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 65792650c630..5abfbf1b8fe2 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
| @@ -221,6 +221,7 @@ static int symbol_valid(struct sym_entry *s) | |||
| 221 | 221 | ||
| 222 | static char *special_prefixes[] = { | 222 | static char *special_prefixes[] = { |
| 223 | "__crc_", /* modversions */ | 223 | "__crc_", /* modversions */ |
| 224 | "__efistub_", /* arm64 EFI stub namespace */ | ||
| 224 | NULL }; | 225 | NULL }; |
| 225 | 226 | ||
| 226 | static char *special_suffixes[] = { | 227 | static char *special_suffixes[] = { |
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index a76856e559c0..2da579edcbaf 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | # | 1 | # |
| 2 | # Generated files | 2 | # Generated files |
| 3 | # | 3 | # |
| 4 | *.lex.c | ||
| 5 | *.tab.c | ||
| 6 | *.tab.h | ||
| 7 | *.moc | 4 | *.moc |
| 8 | gconf.glade.h | 5 | gconf.glade.h |
| 9 | *.pot | 6 | *.pot |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index cb3ec53a7c29..5def8779d7d8 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | # Kernel configuration targets | 3 | # Kernel configuration targets |
| 4 | # These targets are used from top-level makefile | 4 | # These targets are used from top-level makefile |
| 5 | 5 | ||
| 6 | PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \ | 6 | PHONY += xconfig gconfig menuconfig config syncconfig update-po-config \ |
| 7 | localmodconfig localyesconfig | 7 | localmodconfig localyesconfig |
| 8 | 8 | ||
| 9 | ifdef KBUILD_KCONFIG | 9 | ifdef KBUILD_KCONFIG |
| @@ -36,24 +36,22 @@ nconfig: $(obj)/nconf | |||
| 36 | 36 | ||
| 37 | # This has become an internal implementation detail and is now deprecated | 37 | # This has become an internal implementation detail and is now deprecated |
| 38 | # for external use. | 38 | # for external use. |
| 39 | silentoldconfig: $(obj)/conf | 39 | syncconfig: $(obj)/conf |
| 40 | $(Q)mkdir -p include/config include/generated | 40 | $(Q)mkdir -p include/config include/generated |
| 41 | $(Q)test -e include/generated/autoksyms.h || \ | ||
| 42 | touch include/generated/autoksyms.h | ||
| 43 | $< $(silent) --$@ $(Kconfig) | 41 | $< $(silent) --$@ $(Kconfig) |
| 44 | 42 | ||
| 45 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | 43 | localyesconfig localmodconfig: $(obj)/conf |
| 46 | $(Q)mkdir -p include/config include/generated | 44 | $(Q)mkdir -p include/config include/generated |
| 47 | $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config | 45 | $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config |
| 48 | $(Q)if [ -f .config ]; then \ | 46 | $(Q)if [ -f .config ]; then \ |
| 49 | cmp -s .tmp.config .config || \ | 47 | cmp -s .tmp.config .config || \ |
| 50 | (mv -f .config .config.old.1; \ | 48 | (mv -f .config .config.old.1; \ |
| 51 | mv -f .tmp.config .config; \ | 49 | mv -f .tmp.config .config; \ |
| 52 | $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ | 50 | $< $(silent) --oldconfig $(Kconfig); \ |
| 53 | mv -f .config.old.1 .config.old) \ | 51 | mv -f .config.old.1 .config.old) \ |
| 54 | else \ | 52 | else \ |
| 55 | mv -f .tmp.config .config; \ | 53 | mv -f .tmp.config .config; \ |
| 56 | $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ | 54 | $< $(silent) --oldconfig $(Kconfig); \ |
| 57 | fi | 55 | fi |
| 58 | $(Q)rm -f .tmp.config | 56 | $(Q)rm -f .tmp.config |
| 59 | 57 | ||
| @@ -88,7 +86,7 @@ PHONY += $(simple-targets) | |||
| 88 | $(simple-targets): $(obj)/conf | 86 | $(simple-targets): $(obj)/conf |
| 89 | $< $(silent) --$@ $(Kconfig) | 87 | $< $(silent) --$@ $(Kconfig) |
| 90 | 88 | ||
| 91 | PHONY += oldnoconfig savedefconfig defconfig | 89 | PHONY += oldnoconfig silentoldconfig savedefconfig defconfig |
| 92 | 90 | ||
| 93 | # oldnoconfig is an alias of olddefconfig, because people already are dependent | 91 | # oldnoconfig is an alias of olddefconfig, because people already are dependent |
| 94 | # on its behavior (sets new symbols to their default value but not 'n') with the | 92 | # on its behavior (sets new symbols to their default value but not 'n') with the |
| @@ -97,6 +95,13 @@ oldnoconfig: olddefconfig | |||
| 97 | @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19" | 95 | @echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19" |
| 98 | @echo " Please use \"olddefconfig\" instead, which is an alias." | 96 | @echo " Please use \"olddefconfig\" instead, which is an alias." |
| 99 | 97 | ||
| 98 | # We do not expect manual invokcation of "silentoldcofig" (or "syncconfig"). | ||
| 99 | silentoldconfig: syncconfig | ||
| 100 | @echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\"" | ||
| 101 | @echo " and is now an internal implementation detail." | ||
| 102 | @echo " What you want is probably \"oldconfig\"." | ||
| 103 | @echo " \"silentoldconfig\" will be removed after Linux 4.19" | ||
| 104 | |||
| 100 | savedefconfig: $(obj)/conf | 105 | savedefconfig: $(obj)/conf |
| 101 | $< $(silent) --$@=defconfig $(Kconfig) | 106 | $< $(silent) --$@=defconfig $(Kconfig) |
| 102 | 107 | ||
| @@ -135,6 +140,14 @@ PHONY += tinyconfig | |||
| 135 | tinyconfig: | 140 | tinyconfig: |
| 136 | $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config | 141 | $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config |
| 137 | 142 | ||
| 143 | # CHECK: -o cache_dir=<path> working? | ||
| 144 | PHONY += testconfig | ||
| 145 | testconfig: $(obj)/conf | ||
| 146 | $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ | ||
| 147 | -o cache_dir=$(abspath $(obj)/tests/.cache) \ | ||
| 148 | $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) | ||
| 149 | clean-dirs += tests/.cache | ||
| 150 | |||
| 138 | # Help text used by make help | 151 | # Help text used by make help |
| 139 | help: | 152 | help: |
| 140 | @echo ' config - Update current config utilising a line-oriented program' | 153 | @echo ' config - Update current config utilising a line-oriented program' |
| @@ -194,9 +207,9 @@ gconf-objs := gconf.o zconf.tab.o | |||
| 194 | 207 | ||
| 195 | hostprogs-y := conf nconf mconf kxgettext qconf gconf | 208 | hostprogs-y := conf nconf mconf kxgettext qconf gconf |
| 196 | 209 | ||
| 197 | targets += zconf.tab.c zconf.lex.c | 210 | targets += zconf.lex.c |
| 198 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck | 211 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck |
| 199 | clean-files += zconf.tab.c zconf.lex.c gconf.glade.h | 212 | clean-files += gconf.glade.h |
| 200 | clean-files += config.pot linux.pot | 213 | clean-files += config.pot linux.pot |
| 201 | 214 | ||
| 202 | # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) | 215 | # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 822dc51923d6..283eeedaa4fa 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
| @@ -23,7 +23,7 @@ static void check_conf(struct menu *menu); | |||
| 23 | 23 | ||
| 24 | enum input_mode { | 24 | enum input_mode { |
| 25 | oldaskconfig, | 25 | oldaskconfig, |
| 26 | silentoldconfig, | 26 | syncconfig, |
| 27 | oldconfig, | 27 | oldconfig, |
| 28 | allnoconfig, | 28 | allnoconfig, |
| 29 | allyesconfig, | 29 | allyesconfig, |
| @@ -100,7 +100,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
| 100 | 100 | ||
| 101 | switch (input_mode) { | 101 | switch (input_mode) { |
| 102 | case oldconfig: | 102 | case oldconfig: |
| 103 | case silentoldconfig: | 103 | case syncconfig: |
| 104 | if (sym_has_value(sym)) { | 104 | if (sym_has_value(sym)) { |
| 105 | printf("%s\n", def); | 105 | printf("%s\n", def); |
| 106 | return 0; | 106 | return 0; |
| @@ -293,7 +293,7 @@ static int conf_choice(struct menu *menu) | |||
| 293 | printf("[1-%d?]: ", cnt); | 293 | printf("[1-%d?]: ", cnt); |
| 294 | switch (input_mode) { | 294 | switch (input_mode) { |
| 295 | case oldconfig: | 295 | case oldconfig: |
| 296 | case silentoldconfig: | 296 | case syncconfig: |
| 297 | if (!is_new) { | 297 | if (!is_new) { |
| 298 | cnt = def; | 298 | cnt = def; |
| 299 | printf("%d\n", cnt); | 299 | printf("%d\n", cnt); |
| @@ -358,10 +358,11 @@ static void conf(struct menu *menu) | |||
| 358 | 358 | ||
| 359 | switch (prop->type) { | 359 | switch (prop->type) { |
| 360 | case P_MENU: | 360 | case P_MENU: |
| 361 | if ((input_mode == silentoldconfig || | 361 | /* |
| 362 | input_mode == listnewconfig || | 362 | * Except in oldaskconfig mode, we show only menus that |
| 363 | input_mode == olddefconfig) && | 363 | * contain new symbols. |
| 364 | rootEntry != menu) { | 364 | */ |
| 365 | if (input_mode != oldaskconfig && rootEntry != menu) { | ||
| 365 | check_conf(menu); | 366 | check_conf(menu); |
| 366 | return; | 367 | return; |
| 367 | } | 368 | } |
| @@ -421,10 +422,20 @@ static void check_conf(struct menu *menu) | |||
| 421 | if (sym_is_changable(sym) || | 422 | if (sym_is_changable(sym) || |
| 422 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { | 423 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { |
| 423 | if (input_mode == listnewconfig) { | 424 | if (input_mode == listnewconfig) { |
| 424 | if (sym->name && !sym_is_choice_value(sym)) { | 425 | if (sym->name) { |
| 425 | printf("%s%s\n", CONFIG_, sym->name); | 426 | const char *str; |
| 427 | |||
| 428 | if (sym->type == S_STRING) { | ||
| 429 | str = sym_get_string_value(sym); | ||
| 430 | str = sym_escape_string_value(str); | ||
| 431 | printf("%s%s=%s\n", CONFIG_, sym->name, str); | ||
| 432 | free((void *)str); | ||
| 433 | } else { | ||
| 434 | str = sym_get_string_value(sym); | ||
| 435 | printf("%s%s=%s\n", CONFIG_, sym->name, str); | ||
| 436 | } | ||
| 426 | } | 437 | } |
| 427 | } else if (input_mode != olddefconfig) { | 438 | } else { |
| 428 | if (!conf_cnt++) | 439 | if (!conf_cnt++) |
| 429 | printf(_("*\n* Restart config...\n*\n")); | 440 | printf(_("*\n* Restart config...\n*\n")); |
| 430 | rootEntry = menu_get_parent_menu(menu); | 441 | rootEntry = menu_get_parent_menu(menu); |
| @@ -440,7 +451,7 @@ static void check_conf(struct menu *menu) | |||
| 440 | static struct option long_opts[] = { | 451 | static struct option long_opts[] = { |
| 441 | {"oldaskconfig", no_argument, NULL, oldaskconfig}, | 452 | {"oldaskconfig", no_argument, NULL, oldaskconfig}, |
| 442 | {"oldconfig", no_argument, NULL, oldconfig}, | 453 | {"oldconfig", no_argument, NULL, oldconfig}, |
| 443 | {"silentoldconfig", no_argument, NULL, silentoldconfig}, | 454 | {"syncconfig", no_argument, NULL, syncconfig}, |
| 444 | {"defconfig", optional_argument, NULL, defconfig}, | 455 | {"defconfig", optional_argument, NULL, defconfig}, |
| 445 | {"savedefconfig", required_argument, NULL, savedefconfig}, | 456 | {"savedefconfig", required_argument, NULL, savedefconfig}, |
| 446 | {"allnoconfig", no_argument, NULL, allnoconfig}, | 457 | {"allnoconfig", no_argument, NULL, allnoconfig}, |
| @@ -467,8 +478,8 @@ static void conf_usage(const char *progname) | |||
| 467 | printf(" --listnewconfig List new options\n"); | 478 | printf(" --listnewconfig List new options\n"); |
| 468 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); | 479 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); |
| 469 | printf(" --oldconfig Update a configuration using a provided .config as base\n"); | 480 | printf(" --oldconfig Update a configuration using a provided .config as base\n"); |
| 470 | printf(" --silentoldconfig Similar to oldconfig but generates configuration in\n" | 481 | printf(" --syncconfig Similar to oldconfig but generates configuration in\n" |
| 471 | " include/{generated/,config/} (oldconfig used to be more verbose)\n"); | 482 | " include/{generated/,config/}\n"); |
| 472 | printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n"); | 483 | printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n"); |
| 473 | printf(" --oldnoconfig An alias of olddefconfig\n"); | 484 | printf(" --oldnoconfig An alias of olddefconfig\n"); |
| 474 | printf(" --defconfig <file> New config with default defined in <file>\n"); | 485 | printf(" --defconfig <file> New config with default defined in <file>\n"); |
| @@ -500,7 +511,7 @@ int main(int ac, char **av) | |||
| 500 | } | 511 | } |
| 501 | input_mode = (enum input_mode)opt; | 512 | input_mode = (enum input_mode)opt; |
| 502 | switch (opt) { | 513 | switch (opt) { |
| 503 | case silentoldconfig: | 514 | case syncconfig: |
| 504 | sync_kconfig = 1; | 515 | sync_kconfig = 1; |
| 505 | break; | 516 | break; |
| 506 | case defconfig: | 517 | case defconfig: |
| @@ -582,7 +593,7 @@ int main(int ac, char **av) | |||
| 582 | } | 593 | } |
| 583 | break; | 594 | break; |
| 584 | case savedefconfig: | 595 | case savedefconfig: |
| 585 | case silentoldconfig: | 596 | case syncconfig: |
| 586 | case oldaskconfig: | 597 | case oldaskconfig: |
| 587 | case oldconfig: | 598 | case oldconfig: |
| 588 | case listnewconfig: | 599 | case listnewconfig: |
| @@ -662,24 +673,24 @@ int main(int ac, char **av) | |||
| 662 | case oldaskconfig: | 673 | case oldaskconfig: |
| 663 | rootEntry = &rootmenu; | 674 | rootEntry = &rootmenu; |
| 664 | conf(&rootmenu); | 675 | conf(&rootmenu); |
| 665 | input_mode = silentoldconfig; | 676 | input_mode = oldconfig; |
| 666 | /* fall through */ | 677 | /* fall through */ |
| 667 | case oldconfig: | 678 | case oldconfig: |
| 668 | case listnewconfig: | 679 | case listnewconfig: |
| 669 | case olddefconfig: | 680 | case syncconfig: |
| 670 | case silentoldconfig: | ||
| 671 | /* Update until a loop caused no more changes */ | 681 | /* Update until a loop caused no more changes */ |
| 672 | do { | 682 | do { |
| 673 | conf_cnt = 0; | 683 | conf_cnt = 0; |
| 674 | check_conf(&rootmenu); | 684 | check_conf(&rootmenu); |
| 675 | } while (conf_cnt && | 685 | } while (conf_cnt); |
| 676 | (input_mode != listnewconfig && | 686 | break; |
| 677 | input_mode != olddefconfig)); | 687 | case olddefconfig: |
| 688 | default: | ||
| 678 | break; | 689 | break; |
| 679 | } | 690 | } |
| 680 | 691 | ||
| 681 | if (sync_kconfig) { | 692 | if (sync_kconfig) { |
| 682 | /* silentoldconfig is used during the build so we shall update autoconf. | 693 | /* syncconfig is used during the build so we shall update autoconf. |
| 683 | * All other commands are only used to generate a config. | 694 | * All other commands are only used to generate a config. |
| 684 | */ | 695 | */ |
| 685 | if (conf_get_changed() && conf_write(NULL)) { | 696 | if (conf_get_changed() && conf_write(NULL)) { |
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d45381986ac7..e1a39e90841d 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
| @@ -1137,49 +1137,9 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) | |||
| 1137 | return 0; | 1137 | return 0; |
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | static inline struct expr * | 1140 | void expr_print(struct expr *e, |
| 1141 | expr_get_leftmost_symbol(const struct expr *e) | 1141 | void (*fn)(void *, struct symbol *, const char *), |
| 1142 | { | 1142 | void *data, int prevtoken) |
| 1143 | |||
| 1144 | if (e == NULL) | ||
| 1145 | return NULL; | ||
| 1146 | |||
| 1147 | while (e->type != E_SYMBOL) | ||
| 1148 | e = e->left.expr; | ||
| 1149 | |||
| 1150 | return expr_copy(e); | ||
| 1151 | } | ||
| 1152 | |||
| 1153 | /* | ||
| 1154 | * Given expression `e1' and `e2', returns the leaf of the longest | ||
| 1155 | * sub-expression of `e1' not containing 'e2. | ||
| 1156 | */ | ||
| 1157 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) | ||
| 1158 | { | ||
| 1159 | struct expr *ret; | ||
| 1160 | |||
| 1161 | switch (e1->type) { | ||
| 1162 | case E_OR: | ||
| 1163 | return expr_alloc_and( | ||
| 1164 | expr_simplify_unmet_dep(e1->left.expr, e2), | ||
| 1165 | expr_simplify_unmet_dep(e1->right.expr, e2)); | ||
| 1166 | case E_AND: { | ||
| 1167 | struct expr *e; | ||
| 1168 | e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); | ||
| 1169 | e = expr_eliminate_dups(e); | ||
| 1170 | ret = (!expr_eq(e, e1)) ? e1 : NULL; | ||
| 1171 | expr_free(e); | ||
| 1172 | break; | ||
| 1173 | } | ||
| 1174 | default: | ||
| 1175 | ret = e1; | ||
| 1176 | break; | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | return expr_get_leftmost_symbol(ret); | ||
| 1180 | } | ||
| 1181 | |||
| 1182 | static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep) | ||
| 1183 | { | 1143 | { |
| 1184 | if (!e) { | 1144 | if (!e) { |
| 1185 | fn(data, NULL, "y"); | 1145 | fn(data, NULL, "y"); |
| @@ -1234,14 +1194,9 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con | |||
| 1234 | fn(data, e->right.sym, e->right.sym->name); | 1194 | fn(data, e->right.sym, e->right.sym->name); |
| 1235 | break; | 1195 | break; |
| 1236 | case E_OR: | 1196 | case E_OR: |
| 1237 | if (revdep && e->left.expr->type != E_OR) | 1197 | expr_print(e->left.expr, fn, data, E_OR); |
| 1238 | fn(data, NULL, "\n - "); | 1198 | fn(data, NULL, " || "); |
| 1239 | __expr_print(e->left.expr, fn, data, E_OR, revdep); | 1199 | expr_print(e->right.expr, fn, data, E_OR); |
| 1240 | if (revdep) | ||
| 1241 | fn(data, NULL, "\n - "); | ||
| 1242 | else | ||
| 1243 | fn(data, NULL, " || "); | ||
| 1244 | __expr_print(e->right.expr, fn, data, E_OR, revdep); | ||
| 1245 | break; | 1200 | break; |
| 1246 | case E_AND: | 1201 | case E_AND: |
| 1247 | expr_print(e->left.expr, fn, data, E_AND); | 1202 | expr_print(e->left.expr, fn, data, E_AND); |
| @@ -1274,11 +1229,6 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con | |||
| 1274 | fn(data, NULL, ")"); | 1229 | fn(data, NULL, ")"); |
| 1275 | } | 1230 | } |
| 1276 | 1231 | ||
| 1277 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) | ||
| 1278 | { | ||
| 1279 | __expr_print(e, fn, data, prevtoken, false); | ||
| 1280 | } | ||
| 1281 | |||
| 1282 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) | 1232 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) |
| 1283 | { | 1233 | { |
| 1284 | xfwrite(str, strlen(str), 1, data); | 1234 | xfwrite(str, strlen(str), 1, data); |
| @@ -1329,7 +1279,27 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) | |||
| 1329 | * line with a minus. This makes expressions much easier to read. | 1279 | * line with a minus. This makes expressions much easier to read. |
| 1330 | * Suitable for reverse dependency expressions. | 1280 | * Suitable for reverse dependency expressions. |
| 1331 | */ | 1281 | */ |
| 1332 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs) | 1282 | static void expr_print_revdep(struct expr *e, |
| 1283 | void (*fn)(void *, struct symbol *, const char *), | ||
| 1284 | void *data, tristate pr_type, const char **title) | ||
| 1285 | { | ||
| 1286 | if (e->type == E_OR) { | ||
| 1287 | expr_print_revdep(e->left.expr, fn, data, pr_type, title); | ||
| 1288 | expr_print_revdep(e->right.expr, fn, data, pr_type, title); | ||
| 1289 | } else if (expr_calc_value(e) == pr_type) { | ||
| 1290 | if (*title) { | ||
| 1291 | fn(data, NULL, *title); | ||
| 1292 | *title = NULL; | ||
| 1293 | } | ||
| 1294 | |||
| 1295 | fn(data, NULL, " - "); | ||
| 1296 | expr_print(e, fn, data, E_NONE); | ||
| 1297 | fn(data, NULL, "\n"); | ||
| 1298 | } | ||
| 1299 | } | ||
| 1300 | |||
| 1301 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, | ||
| 1302 | tristate pr_type, const char *title) | ||
| 1333 | { | 1303 | { |
| 1334 | __expr_print(e, expr_print_gstr_helper, gs, E_NONE, true); | 1304 | expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title); |
| 1335 | } | 1305 | } |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index c16e82e302a2..94a383b21df6 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
| @@ -305,12 +305,12 @@ struct expr *expr_transform(struct expr *e); | |||
| 305 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); | 305 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); |
| 306 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); | 306 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); |
| 307 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | 307 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); |
| 308 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); | ||
| 309 | 308 | ||
| 310 | void expr_fprint(struct expr *e, FILE *out); | 309 | void expr_fprint(struct expr *e, FILE *out); |
| 311 | struct gstr; /* forward */ | 310 | struct gstr; /* forward */ |
| 312 | void expr_gstr_print(struct expr *e, struct gstr *gs); | 311 | void expr_gstr_print(struct expr *e, struct gstr *gs); |
| 313 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs); | 312 | void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, |
| 313 | tristate pr_type, const char *title); | ||
| 314 | 314 | ||
| 315 | static inline int expr_is_yes(struct expr *e) | 315 | static inline int expr_is_yes(struct expr *e) |
| 316 | { | 316 | { |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 2d5ec2d0e952..f4394af6e4b8 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
| @@ -68,6 +68,7 @@ struct kconf_id { | |||
| 68 | enum symbol_type stype; | 68 | enum symbol_type stype; |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | extern int yylineno; | ||
| 71 | void zconfdump(FILE *out); | 72 | void zconfdump(FILE *out); |
| 72 | void zconf_starthelp(void); | 73 | void zconf_starthelp(void); |
| 73 | FILE *zconf_fopen(const char *name); | 74 | FILE *zconf_fopen(const char *name); |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 36cd3e1f1c28..5c5c1374b151 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
| @@ -828,16 +828,16 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, | |||
| 828 | 828 | ||
| 829 | get_symbol_props_str(r, sym, P_SELECT, _(" Selects: ")); | 829 | get_symbol_props_str(r, sym, P_SELECT, _(" Selects: ")); |
| 830 | if (sym->rev_dep.expr) { | 830 | if (sym->rev_dep.expr) { |
| 831 | str_append(r, _(" Selected by: ")); | 831 | expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n"); |
| 832 | expr_gstr_print_revdep(sym->rev_dep.expr, r); | 832 | expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n"); |
| 833 | str_append(r, "\n"); | 833 | expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n"); |
| 834 | } | 834 | } |
| 835 | 835 | ||
| 836 | get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: ")); | 836 | get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: ")); |
| 837 | if (sym->implied.expr) { | 837 | if (sym->implied.expr) { |
| 838 | str_append(r, _(" Implied by: ")); | 838 | expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n"); |
| 839 | expr_gstr_print_revdep(sym->implied.expr, r); | 839 | expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n"); |
| 840 | str_append(r, "\n"); | 840 | expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n"); |
| 841 | } | 841 | } |
| 842 | 842 | ||
| 843 | str_append(r, "\n\n"); | 843 | str_append(r, "\n\n"); |
diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h index 0d5261705ef5..9f6f21d3b0d4 100644 --- a/scripts/kconfig/nconf.h +++ b/scripts/kconfig/nconf.h | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #include <string.h> | 15 | #include <string.h> |
| 16 | #include <unistd.h> | 16 | #include <unistd.h> |
| 17 | #include <locale.h> | 17 | #include <locale.h> |
| 18 | #include <curses.h> | 18 | #include <ncurses.h> |
| 19 | #include <menu.h> | 19 | #include <menu.h> |
| 20 | #include <panel.h> | 20 | #include <panel.h> |
| 21 | #include <form.h> | 21 | #include <form.h> |
| @@ -24,8 +24,6 @@ | |||
| 24 | #include <time.h> | 24 | #include <time.h> |
| 25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
| 26 | 26 | ||
| 27 | #include "ncurses.h" | ||
| 28 | |||
| 29 | #define max(a, b) ({\ | 27 | #define max(a, b) ({\ |
| 30 | typeof(a) _a = a;\ | 28 | typeof(a) _a = a;\ |
| 31 | typeof(b) _b = b;\ | 29 | typeof(b) _b = b;\ |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 2220bc4b051b..f0b2e3b3102d 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
| @@ -243,7 +243,7 @@ static void sym_calc_visibility(struct symbol *sym) | |||
| 243 | tri = yes; | 243 | tri = yes; |
| 244 | if (sym->dir_dep.expr) | 244 | if (sym->dir_dep.expr) |
| 245 | tri = expr_calc_value(sym->dir_dep.expr); | 245 | tri = expr_calc_value(sym->dir_dep.expr); |
| 246 | if (tri == mod) | 246 | if (tri == mod && sym_get_type(sym) == S_BOOLEAN) |
| 247 | tri = yes; | 247 | tri = yes; |
| 248 | if (sym->dir_dep.tri != tri) { | 248 | if (sym->dir_dep.tri != tri) { |
| 249 | sym->dir_dep.tri = tri; | 249 | sym->dir_dep.tri = tri; |
| @@ -333,6 +333,27 @@ static struct symbol *sym_calc_choice(struct symbol *sym) | |||
| 333 | return def_sym; | 333 | return def_sym; |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | static void sym_warn_unmet_dep(struct symbol *sym) | ||
| 337 | { | ||
| 338 | struct gstr gs = str_new(); | ||
| 339 | |||
| 340 | str_printf(&gs, | ||
| 341 | "\nWARNING: unmet direct dependencies detected for %s\n", | ||
| 342 | sym->name); | ||
| 343 | str_printf(&gs, | ||
| 344 | " Depends on [%c]: ", | ||
| 345 | sym->dir_dep.tri == mod ? 'm' : 'n'); | ||
| 346 | expr_gstr_print(sym->dir_dep.expr, &gs); | ||
| 347 | str_printf(&gs, "\n"); | ||
| 348 | |||
| 349 | expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, | ||
| 350 | " Selected by [y]:\n"); | ||
| 351 | expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, | ||
| 352 | " Selected by [m]:\n"); | ||
| 353 | |||
| 354 | fputs(str_get(&gs), stderr); | ||
| 355 | } | ||
| 356 | |||
| 336 | void sym_calc_value(struct symbol *sym) | 357 | void sym_calc_value(struct symbol *sym) |
| 337 | { | 358 | { |
| 338 | struct symbol_value newval, oldval; | 359 | struct symbol_value newval, oldval; |
| @@ -403,9 +424,10 @@ void sym_calc_value(struct symbol *sym) | |||
| 403 | if (!sym_is_choice(sym)) { | 424 | if (!sym_is_choice(sym)) { |
| 404 | prop = sym_get_default_prop(sym); | 425 | prop = sym_get_default_prop(sym); |
| 405 | if (prop) { | 426 | if (prop) { |
| 406 | sym->flags |= SYMBOL_WRITE; | ||
| 407 | newval.tri = EXPR_AND(expr_calc_value(prop->expr), | 427 | newval.tri = EXPR_AND(expr_calc_value(prop->expr), |
| 408 | prop->visible.tri); | 428 | prop->visible.tri); |
| 429 | if (newval.tri != no) | ||
| 430 | sym->flags |= SYMBOL_WRITE; | ||
| 409 | } | 431 | } |
| 410 | if (sym->implied.tri != no) { | 432 | if (sym->implied.tri != no) { |
| 411 | sym->flags |= SYMBOL_WRITE; | 433 | sym->flags |= SYMBOL_WRITE; |
| @@ -413,18 +435,8 @@ void sym_calc_value(struct symbol *sym) | |||
| 413 | } | 435 | } |
| 414 | } | 436 | } |
| 415 | calc_newval: | 437 | calc_newval: |
| 416 | if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { | 438 | if (sym->dir_dep.tri < sym->rev_dep.tri) |
| 417 | struct expr *e; | 439 | sym_warn_unmet_dep(sym); |
| 418 | e = expr_simplify_unmet_dep(sym->rev_dep.expr, | ||
| 419 | sym->dir_dep.expr); | ||
| 420 | fprintf(stderr, "warning: ("); | ||
| 421 | expr_fprint(e, stderr); | ||
| 422 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", | ||
| 423 | sym->name); | ||
| 424 | expr_fprint(sym->dir_dep.expr, stderr); | ||
| 425 | fprintf(stderr, ")\n"); | ||
| 426 | expr_free(e); | ||
| 427 | } | ||
| 428 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 440 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); |
| 429 | } | 441 | } |
| 430 | if (newval.tri == mod && | 442 | if (newval.tri == mod && |
diff --git a/scripts/kconfig/tests/auto_submenu/Kconfig b/scripts/kconfig/tests/auto_submenu/Kconfig new file mode 100644 index 000000000000..c17bf2caa7e6 --- /dev/null +++ b/scripts/kconfig/tests/auto_submenu/Kconfig | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | config A | ||
| 2 | bool "A" | ||
| 3 | default y | ||
| 4 | |||
| 5 | config A0 | ||
| 6 | bool "A0" | ||
| 7 | depends on A | ||
| 8 | default y | ||
| 9 | help | ||
| 10 | This depends on A, so should be a submenu of A. | ||
| 11 | |||
| 12 | config A0_0 | ||
| 13 | bool "A1_0" | ||
| 14 | depends on A0 | ||
| 15 | help | ||
| 16 | Submenus are created recursively. | ||
| 17 | This should be a submenu of A0. | ||
| 18 | |||
| 19 | config A1 | ||
| 20 | bool "A1" | ||
| 21 | depends on A | ||
| 22 | default y | ||
| 23 | help | ||
| 24 | This should line up with A0. | ||
| 25 | |||
| 26 | choice | ||
| 27 | prompt "choice" | ||
| 28 | depends on A1 | ||
| 29 | help | ||
| 30 | Choice should become a submenu as well. | ||
| 31 | |||
| 32 | config A1_0 | ||
| 33 | bool "A1_0" | ||
| 34 | |||
| 35 | config A1_1 | ||
| 36 | bool "A1_1" | ||
| 37 | |||
| 38 | endchoice | ||
| 39 | |||
| 40 | config B | ||
| 41 | bool "B" | ||
| 42 | help | ||
| 43 | This is independent of A. | ||
| 44 | |||
| 45 | config C | ||
| 46 | bool "C" | ||
| 47 | depends on A | ||
| 48 | help | ||
| 49 | This depends on A, but not a consecutive item, so can/should not | ||
| 50 | be a submenu. | ||
diff --git a/scripts/kconfig/tests/auto_submenu/__init__.py b/scripts/kconfig/tests/auto_submenu/__init__.py new file mode 100644 index 000000000000..32e79b85faeb --- /dev/null +++ b/scripts/kconfig/tests/auto_submenu/__init__.py | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | """ | ||
| 2 | Create submenu for symbols that depend on the preceding one. | ||
| 3 | |||
| 4 | If a symbols has dependency on the preceding symbol, the menu entry | ||
| 5 | should become the submenu of the preceding one, and displayed with | ||
| 6 | deeper indentation. | ||
| 7 | """ | ||
| 8 | |||
| 9 | |||
| 10 | def test(conf): | ||
| 11 | assert conf.oldaskconfig() == 0 | ||
| 12 | assert conf.stdout_contains('expected_stdout') | ||
diff --git a/scripts/kconfig/tests/auto_submenu/expected_stdout b/scripts/kconfig/tests/auto_submenu/expected_stdout new file mode 100644 index 000000000000..bf5236f39a56 --- /dev/null +++ b/scripts/kconfig/tests/auto_submenu/expected_stdout | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | A (A) [Y/n/?] (NEW) | ||
| 2 | A0 (A0) [Y/n/?] (NEW) | ||
| 3 | A1_0 (A0_0) [N/y/?] (NEW) | ||
| 4 | A1 (A1) [Y/n/?] (NEW) | ||
| 5 | choice | ||
| 6 | > 1. A1_0 (A1_0) (NEW) | ||
| 7 | 2. A1_1 (A1_1) (NEW) | ||
| 8 | choice[1-2?]: | ||
| 9 | B (B) [N/y/?] (NEW) | ||
| 10 | C (C) [N/y/?] (NEW) | ||
diff --git a/scripts/kconfig/tests/choice/Kconfig b/scripts/kconfig/tests/choice/Kconfig new file mode 100644 index 000000000000..cc60e9ce2c03 --- /dev/null +++ b/scripts/kconfig/tests/choice/Kconfig | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | config MODULES | ||
| 2 | bool "Enable loadable module support" | ||
| 3 | option modules | ||
| 4 | default y | ||
| 5 | |||
| 6 | choice | ||
| 7 | prompt "boolean choice" | ||
| 8 | default BOOL_CHOICE1 | ||
| 9 | |||
| 10 | config BOOL_CHOICE0 | ||
| 11 | bool "choice 0" | ||
| 12 | |||
| 13 | config BOOL_CHOICE1 | ||
| 14 | bool "choice 1" | ||
| 15 | |||
| 16 | endchoice | ||
| 17 | |||
| 18 | choice | ||
| 19 | prompt "optional boolean choice" | ||
| 20 | optional | ||
| 21 | default OPT_BOOL_CHOICE1 | ||
| 22 | |||
| 23 | config OPT_BOOL_CHOICE0 | ||
| 24 | bool "choice 0" | ||
| 25 | |||
| 26 | config OPT_BOOL_CHOICE1 | ||
| 27 | bool "choice 1" | ||
| 28 | |||
| 29 | endchoice | ||
| 30 | |||
| 31 | choice | ||
| 32 | prompt "tristate choice" | ||
| 33 | default TRI_CHOICE1 | ||
| 34 | |||
| 35 | config TRI_CHOICE0 | ||
| 36 | tristate "choice 0" | ||
| 37 | |||
| 38 | config TRI_CHOICE1 | ||
| 39 | tristate "choice 1" | ||
| 40 | |||
| 41 | endchoice | ||
| 42 | |||
| 43 | choice | ||
| 44 | prompt "optional tristate choice" | ||
| 45 | optional | ||
| 46 | default OPT_TRI_CHOICE1 | ||
| 47 | |||
| 48 | config OPT_TRI_CHOICE0 | ||
| 49 | tristate "choice 0" | ||
| 50 | |||
| 51 | config OPT_TRI_CHOICE1 | ||
| 52 | tristate "choice 1" | ||
| 53 | |||
| 54 | endchoice | ||
diff --git a/scripts/kconfig/tests/choice/__init__.py b/scripts/kconfig/tests/choice/__init__.py new file mode 100644 index 000000000000..9edcc5262134 --- /dev/null +++ b/scripts/kconfig/tests/choice/__init__.py | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | """ | ||
| 2 | Basic choice tests. | ||
| 3 | |||
| 4 | The handling of 'choice' is a bit complicated part in Kconfig. | ||
| 5 | |||
| 6 | The behavior of 'y' choice is intuitive. If choice values are tristate, | ||
| 7 | the choice can be 'm' where each value can be enabled independently. | ||
| 8 | Also, if a choice is marked as 'optional', the whole choice can be | ||
| 9 | invisible. | ||
| 10 | """ | ||
| 11 | |||
| 12 | |||
| 13 | def test_oldask0(conf): | ||
| 14 | assert conf.oldaskconfig() == 0 | ||
| 15 | assert conf.stdout_contains('oldask0_expected_stdout') | ||
| 16 | |||
| 17 | |||
| 18 | def test_oldask1(conf): | ||
| 19 | assert conf.oldaskconfig('oldask1_config') == 0 | ||
| 20 | assert conf.stdout_contains('oldask1_expected_stdout') | ||
| 21 | |||
| 22 | |||
| 23 | def test_allyes(conf): | ||
| 24 | assert conf.allyesconfig() == 0 | ||
| 25 | assert conf.config_contains('allyes_expected_config') | ||
| 26 | |||
| 27 | |||
| 28 | def test_allmod(conf): | ||
| 29 | assert conf.allmodconfig() == 0 | ||
| 30 | assert conf.config_contains('allmod_expected_config') | ||
| 31 | |||
| 32 | |||
| 33 | def test_allno(conf): | ||
| 34 | assert conf.allnoconfig() == 0 | ||
| 35 | assert conf.config_contains('allno_expected_config') | ||
| 36 | |||
| 37 | |||
| 38 | def test_alldef(conf): | ||
| 39 | assert conf.alldefconfig() == 0 | ||
| 40 | assert conf.config_contains('alldef_expected_config') | ||
diff --git a/scripts/kconfig/tests/choice/alldef_expected_config b/scripts/kconfig/tests/choice/alldef_expected_config new file mode 100644 index 000000000000..7a754bf4be94 --- /dev/null +++ b/scripts/kconfig/tests/choice/alldef_expected_config | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | CONFIG_MODULES=y | ||
| 2 | # CONFIG_BOOL_CHOICE0 is not set | ||
| 3 | CONFIG_BOOL_CHOICE1=y | ||
| 4 | # CONFIG_TRI_CHOICE0 is not set | ||
| 5 | # CONFIG_TRI_CHOICE1 is not set | ||
diff --git a/scripts/kconfig/tests/choice/allmod_expected_config b/scripts/kconfig/tests/choice/allmod_expected_config new file mode 100644 index 000000000000..f1f5dcdb7923 --- /dev/null +++ b/scripts/kconfig/tests/choice/allmod_expected_config | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | CONFIG_MODULES=y | ||
| 2 | # CONFIG_BOOL_CHOICE0 is not set | ||
| 3 | CONFIG_BOOL_CHOICE1=y | ||
| 4 | # CONFIG_OPT_BOOL_CHOICE0 is not set | ||
| 5 | CONFIG_OPT_BOOL_CHOICE1=y | ||
| 6 | CONFIG_TRI_CHOICE0=m | ||
| 7 | CONFIG_TRI_CHOICE1=m | ||
| 8 | CONFIG_OPT_TRI_CHOICE0=m | ||
| 9 | CONFIG_OPT_TRI_CHOICE1=m | ||
diff --git a/scripts/kconfig/tests/choice/allno_expected_config b/scripts/kconfig/tests/choice/allno_expected_config new file mode 100644 index 000000000000..b88ee7a43136 --- /dev/null +++ b/scripts/kconfig/tests/choice/allno_expected_config | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # CONFIG_MODULES is not set | ||
| 2 | # CONFIG_BOOL_CHOICE0 is not set | ||
| 3 | CONFIG_BOOL_CHOICE1=y | ||
| 4 | # CONFIG_TRI_CHOICE0 is not set | ||
| 5 | CONFIG_TRI_CHOICE1=y | ||
diff --git a/scripts/kconfig/tests/choice/allyes_expected_config b/scripts/kconfig/tests/choice/allyes_expected_config new file mode 100644 index 000000000000..e5a062a1157c --- /dev/null +++ b/scripts/kconfig/tests/choice/allyes_expected_config | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | CONFIG_MODULES=y | ||
| 2 | # CONFIG_BOOL_CHOICE0 is not set | ||
| 3 | CONFIG_BOOL_CHOICE1=y | ||
| 4 | # CONFIG_OPT_BOOL_CHOICE0 is not set | ||
| 5 | CONFIG_OPT_BOOL_CHOICE1=y | ||
| 6 | # CONFIG_TRI_CHOICE0 is not set | ||
| 7 | CONFIG_TRI_CHOICE1=y | ||
| 8 | # CONFIG_OPT_TRI_CHOICE0 is not set | ||
| 9 | CONFIG_OPT_TRI_CHOICE1=y | ||
diff --git a/scripts/kconfig/tests/choice/oldask0_expected_stdout b/scripts/kconfig/tests/choice/oldask0_expected_stdout new file mode 100644 index 000000000000..b251bba9698b --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask0_expected_stdout | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Enable loadable module support (MODULES) [Y/n/?] (NEW) | ||
| 2 | boolean choice | ||
| 3 | 1. choice 0 (BOOL_CHOICE0) (NEW) | ||
| 4 | > 2. choice 1 (BOOL_CHOICE1) (NEW) | ||
| 5 | choice[1-2?]: | ||
| 6 | optional boolean choice [N/y/?] (NEW) | ||
| 7 | tristate choice [M/y/?] (NEW) | ||
| 8 | choice 0 (TRI_CHOICE0) [N/m/?] (NEW) | ||
| 9 | choice 1 (TRI_CHOICE1) [N/m/?] (NEW) | ||
| 10 | optional tristate choice [N/m/y/?] (NEW) | ||
diff --git a/scripts/kconfig/tests/choice/oldask1_config b/scripts/kconfig/tests/choice/oldask1_config new file mode 100644 index 000000000000..b67bfe3c641f --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask1_config | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | # CONFIG_MODULES is not set | ||
| 2 | CONFIG_OPT_BOOL_CHOICE0=y | ||
diff --git a/scripts/kconfig/tests/choice/oldask1_expected_stdout b/scripts/kconfig/tests/choice/oldask1_expected_stdout new file mode 100644 index 000000000000..c2125e9bf96a --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask1_expected_stdout | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | Enable loadable module support (MODULES) [N/y/?] | ||
| 2 | boolean choice | ||
| 3 | 1. choice 0 (BOOL_CHOICE0) (NEW) | ||
| 4 | > 2. choice 1 (BOOL_CHOICE1) (NEW) | ||
| 5 | choice[1-2?]: | ||
| 6 | optional boolean choice [Y/n/?] (NEW) | ||
| 7 | optional boolean choice | ||
| 8 | > 1. choice 0 (OPT_BOOL_CHOICE0) | ||
| 9 | 2. choice 1 (OPT_BOOL_CHOICE1) (NEW) | ||
| 10 | choice[1-2?]: | ||
| 11 | tristate choice | ||
| 12 | 1. choice 0 (TRI_CHOICE0) (NEW) | ||
| 13 | > 2. choice 1 (TRI_CHOICE1) (NEW) | ||
| 14 | choice[1-2?]: | ||
| 15 | optional tristate choice [N/y/?] | ||
diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig new file mode 100644 index 000000000000..11ac25c26040 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | config MODULES | ||
| 2 | def_bool y | ||
| 3 | option modules | ||
| 4 | |||
| 5 | config DEP | ||
| 6 | tristate | ||
| 7 | default m | ||
| 8 | |||
| 9 | choice | ||
| 10 | prompt "Tristate Choice" | ||
| 11 | |||
| 12 | config CHOICE0 | ||
| 13 | tristate "Choice 0" | ||
| 14 | |||
| 15 | config CHOICE1 | ||
| 16 | tristate "Choice 1" | ||
| 17 | depends on DEP | ||
| 18 | |||
| 19 | endchoice | ||
diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py new file mode 100644 index 000000000000..f8d728c7b101 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | """ | ||
| 2 | Hide tristate choice values with mod dependency in y choice. | ||
| 3 | |||
| 4 | If tristate choice values depend on symbols set to 'm', they should be | ||
| 5 | hidden when the choice containing them is changed from 'm' to 'y' | ||
| 6 | (i.e. exclusive choice). | ||
| 7 | |||
| 8 | Related Linux commit: fa64e5f6a35efd5e77d639125d973077ca506074 | ||
| 9 | """ | ||
| 10 | |||
| 11 | |||
| 12 | def test(conf): | ||
| 13 | assert conf.oldaskconfig('config', 'y') == 0 | ||
| 14 | assert conf.config_contains('expected_config') | ||
| 15 | assert conf.stdout_contains('expected_stdout') | ||
diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/config b/scripts/kconfig/tests/choice_value_with_m_dep/config new file mode 100644 index 000000000000..3a126b7a2546 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/config | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | CONFIG_CHOICE0=m | ||
| 2 | CONFIG_CHOICE1=m | ||
diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/expected_config b/scripts/kconfig/tests/choice_value_with_m_dep/expected_config new file mode 100644 index 000000000000..4d07b449540e --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/expected_config | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | CONFIG_MODULES=y | ||
| 2 | CONFIG_DEP=m | ||
| 3 | CONFIG_CHOICE0=y | ||
diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout b/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout new file mode 100644 index 000000000000..2b50ab65c86a --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | Tristate Choice [M/y/?] y | ||
| 2 | Tristate Choice | ||
| 3 | > 1. Choice 0 (CHOICE0) | ||
| 4 | choice[1]: 1 | ||
diff --git a/scripts/kconfig/tests/conftest.py b/scripts/kconfig/tests/conftest.py new file mode 100644 index 000000000000..0345ef6e3273 --- /dev/null +++ b/scripts/kconfig/tests/conftest.py | |||
| @@ -0,0 +1,291 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | # | ||
| 3 | # Copyright (C) 2018 Masahiro Yamada <yamada.masahiro@socionext.com> | ||
| 4 | # | ||
| 5 | |||
| 6 | """ | ||
| 7 | Kconfig unit testing framework. | ||
| 8 | |||
| 9 | This provides fixture functions commonly used from test files. | ||
| 10 | """ | ||
| 11 | |||
| 12 | import os | ||
| 13 | import pytest | ||
| 14 | import shutil | ||
| 15 | import subprocess | ||
| 16 | import tempfile | ||
| 17 | |||
| 18 | CONF_PATH = os.path.abspath(os.path.join('scripts', 'kconfig', 'conf')) | ||
| 19 | |||
| 20 | |||
| 21 | class Conf: | ||
| 22 | """Kconfig runner and result checker. | ||
| 23 | |||
| 24 | This class provides methods to run text-based interface of Kconfig | ||
| 25 | (scripts/kconfig/conf) and retrieve the resulted configuration, | ||
| 26 | stdout, and stderr. It also provides methods to compare those | ||
| 27 | results with expectations. | ||
| 28 | """ | ||
| 29 | |||
| 30 | def __init__(self, request): | ||
| 31 | """Create a new Conf instance. | ||
| 32 | |||
| 33 | request: object to introspect the requesting test module | ||
| 34 | """ | ||
| 35 | # the directory of the test being run | ||
| 36 | self._test_dir = os.path.dirname(str(request.fspath)) | ||
| 37 | |||
| 38 | # runners | ||
| 39 | def _run_conf(self, mode, dot_config=None, out_file='.config', | ||
| 40 | interactive=False, in_keys=None, extra_env={}): | ||
| 41 | """Run text-based Kconfig executable and save the result. | ||
| 42 | |||
| 43 | mode: input mode option (--oldaskconfig, --defconfig=<file> etc.) | ||
| 44 | dot_config: .config file to use for configuration base | ||
| 45 | out_file: file name to contain the output config data | ||
| 46 | interactive: flag to specify the interactive mode | ||
| 47 | in_keys: key inputs for interactive modes | ||
| 48 | extra_env: additional environments | ||
| 49 | returncode: exit status of the Kconfig executable | ||
| 50 | """ | ||
| 51 | command = [CONF_PATH, mode, 'Kconfig'] | ||
| 52 | |||
| 53 | # Override 'srctree' environment to make the test as the top directory | ||
| 54 | extra_env['srctree'] = self._test_dir | ||
| 55 | |||
| 56 | # Run Kconfig in a temporary directory. | ||
| 57 | # This directory is automatically removed when done. | ||
| 58 | with tempfile.TemporaryDirectory() as temp_dir: | ||
| 59 | |||
| 60 | # if .config is given, copy it to the working directory | ||
| 61 | if dot_config: | ||
| 62 | shutil.copyfile(os.path.join(self._test_dir, dot_config), | ||
| 63 | os.path.join(temp_dir, '.config')) | ||
| 64 | |||
| 65 | ps = subprocess.Popen(command, | ||
| 66 | stdin=subprocess.PIPE, | ||
| 67 | stdout=subprocess.PIPE, | ||
| 68 | stderr=subprocess.PIPE, | ||
| 69 | cwd=temp_dir, | ||
| 70 | env=dict(os.environ, **extra_env)) | ||
| 71 | |||
| 72 | # If input key sequence is given, feed it to stdin. | ||
| 73 | if in_keys: | ||
| 74 | ps.stdin.write(in_keys.encode('utf-8')) | ||
| 75 | |||
| 76 | while ps.poll() is None: | ||
| 77 | # For interactive modes such as oldaskconfig, oldconfig, | ||
| 78 | # send 'Enter' key until the program finishes. | ||
| 79 | if interactive: | ||
| 80 | ps.stdin.write(b'\n') | ||
| 81 | |||
| 82 | self.retcode = ps.returncode | ||
| 83 | self.stdout = ps.stdout.read().decode() | ||
| 84 | self.stderr = ps.stderr.read().decode() | ||
| 85 | |||
| 86 | # Retrieve the resulted config data only when .config is supposed | ||
| 87 | # to exist. If the command fails, the .config does not exist. | ||
| 88 | # 'listnewconfig' does not produce .config in the first place. | ||
| 89 | if self.retcode == 0 and out_file: | ||
| 90 | with open(os.path.join(temp_dir, out_file)) as f: | ||
| 91 | self.config = f.read() | ||
| 92 | else: | ||
| 93 | self.config = None | ||
| 94 | |||
| 95 | # Logging: | ||
| 96 | # Pytest captures the following information by default. In failure | ||
| 97 | # of tests, the captured log will be displayed. This will be useful to | ||
| 98 | # figure out what has happened. | ||
| 99 | |||
| 100 | print("[command]\n{}\n".format(' '.join(command))) | ||
| 101 | |||
| 102 | print("[retcode]\n{}\n".format(self.retcode)) | ||
| 103 | |||
| 104 | print("[stdout]") | ||
| 105 | print(self.stdout) | ||
| 106 | |||
| 107 | print("[stderr]") | ||
| 108 | print(self.stderr) | ||
| 109 | |||
| 110 | if self.config is not None: | ||
| 111 | print("[output for '{}']".format(out_file)) | ||
| 112 | print(self.config) | ||
| 113 | |||
| 114 | return self.retcode | ||
| 115 | |||
| 116 | def oldaskconfig(self, dot_config=None, in_keys=None): | ||
| 117 | """Run oldaskconfig. | ||
| 118 | |||
| 119 | dot_config: .config file to use for configuration base (optional) | ||
| 120 | in_key: key inputs (optional) | ||
| 121 | returncode: exit status of the Kconfig executable | ||
| 122 | """ | ||
| 123 | return self._run_conf('--oldaskconfig', dot_config=dot_config, | ||
| 124 | interactive=True, in_keys=in_keys) | ||
| 125 | |||
| 126 | def oldconfig(self, dot_config=None, in_keys=None): | ||
| 127 | """Run oldconfig. | ||
| 128 | |||
| 129 | dot_config: .config file to use for configuration base (optional) | ||
| 130 | in_key: key inputs (optional) | ||
| 131 | returncode: exit status of the Kconfig executable | ||
| 132 | """ | ||
| 133 | return self._run_conf('--oldconfig', dot_config=dot_config, | ||
| 134 | interactive=True, in_keys=in_keys) | ||
| 135 | |||
| 136 | def olddefconfig(self, dot_config=None): | ||
| 137 | """Run olddefconfig. | ||
| 138 | |||
| 139 | dot_config: .config file to use for configuration base (optional) | ||
| 140 | returncode: exit status of the Kconfig executable | ||
| 141 | """ | ||
| 142 | return self._run_conf('--olddefconfig', dot_config=dot_config) | ||
| 143 | |||
| 144 | def defconfig(self, defconfig): | ||
| 145 | """Run defconfig. | ||
| 146 | |||
| 147 | defconfig: defconfig file for input | ||
| 148 | returncode: exit status of the Kconfig executable | ||
| 149 | """ | ||
| 150 | defconfig_path = os.path.join(self._test_dir, defconfig) | ||
| 151 | return self._run_conf('--defconfig={}'.format(defconfig_path)) | ||
| 152 | |||
| 153 | def _allconfig(self, mode, all_config): | ||
| 154 | if all_config: | ||
| 155 | all_config_path = os.path.join(self._test_dir, all_config) | ||
| 156 | extra_env = {'KCONFIG_ALLCONFIG': all_config_path} | ||
| 157 | else: | ||
| 158 | extra_env = {} | ||
| 159 | |||
| 160 | return self._run_conf('--{}config'.format(mode), extra_env=extra_env) | ||
| 161 | |||
| 162 | def allyesconfig(self, all_config=None): | ||
| 163 | """Run allyesconfig. | ||
| 164 | |||
| 165 | all_config: fragment config file for KCONFIG_ALLCONFIG (optional) | ||
| 166 | returncode: exit status of the Kconfig executable | ||
| 167 | """ | ||
| 168 | return self._allconfig('allyes', all_config) | ||
| 169 | |||
| 170 | def allmodconfig(self, all_config=None): | ||
| 171 | """Run allmodconfig. | ||
| 172 | |||
| 173 | all_config: fragment config file for KCONFIG_ALLCONFIG (optional) | ||
| 174 | returncode: exit status of the Kconfig executable | ||
| 175 | """ | ||
| 176 | return self._allconfig('allmod', all_config) | ||
| 177 | |||
| 178 | def allnoconfig(self, all_config=None): | ||
| 179 | """Run allnoconfig. | ||
| 180 | |||
| 181 | all_config: fragment config file for KCONFIG_ALLCONFIG (optional) | ||
| 182 | returncode: exit status of the Kconfig executable | ||
| 183 | """ | ||
| 184 | return self._allconfig('allno', all_config) | ||
| 185 | |||
| 186 | def alldefconfig(self, all_config=None): | ||
| 187 | """Run alldefconfig. | ||
| 188 | |||
| 189 | all_config: fragment config file for KCONFIG_ALLCONFIG (optional) | ||
| 190 | returncode: exit status of the Kconfig executable | ||
| 191 | """ | ||
| 192 | return self._allconfig('alldef', all_config) | ||
| 193 | |||
| 194 | def randconfig(self, all_config=None): | ||
| 195 | """Run randconfig. | ||
| 196 | |||
| 197 | all_config: fragment config file for KCONFIG_ALLCONFIG (optional) | ||
| 198 | returncode: exit status of the Kconfig executable | ||
| 199 | """ | ||
| 200 | return self._allconfig('rand', all_config) | ||
| 201 | |||
| 202 | def savedefconfig(self, dot_config): | ||
| 203 | """Run savedefconfig. | ||
| 204 | |||
| 205 | dot_config: .config file for input | ||
| 206 | returncode: exit status of the Kconfig executable | ||
| 207 | """ | ||
| 208 | return self._run_conf('--savedefconfig', out_file='defconfig') | ||
| 209 | |||
| 210 | def listnewconfig(self, dot_config=None): | ||
| 211 | """Run listnewconfig. | ||
| 212 | |||
| 213 | dot_config: .config file to use for configuration base (optional) | ||
| 214 | returncode: exit status of the Kconfig executable | ||
| 215 | """ | ||
| 216 | return self._run_conf('--listnewconfig', dot_config=dot_config, | ||
| 217 | out_file=None) | ||
| 218 | |||
| 219 | # checkers | ||
| 220 | def _read_and_compare(self, compare, expected): | ||
| 221 | """Compare the result with expectation. | ||
| 222 | |||
| 223 | compare: function to compare the result with expectation | ||
| 224 | expected: file that contains the expected data | ||
| 225 | """ | ||
| 226 | with open(os.path.join(self._test_dir, expected)) as f: | ||
| 227 | expected_data = f.read() | ||
| 228 | return compare(self, expected_data) | ||
| 229 | |||
| 230 | def _contains(self, attr, expected): | ||
| 231 | return self._read_and_compare( | ||
| 232 | lambda s, e: getattr(s, attr).find(e) >= 0, | ||
| 233 | expected) | ||
| 234 | |||
| 235 | def _matches(self, attr, expected): | ||
| 236 | return self._read_and_compare(lambda s, e: getattr(s, attr) == e, | ||
| 237 | expected) | ||
| 238 | |||
| 239 | def config_contains(self, expected): | ||
| 240 | """Check if resulted configuration contains expected data. | ||
| 241 | |||
| 242 | expected: file that contains the expected data | ||
| 243 | returncode: True if result contains the expected data, False otherwise | ||
| 244 | """ | ||
| 245 | return self._contains('config', expected) | ||
| 246 | |||
| 247 | def config_matches(self, expected): | ||
| 248 | """Check if resulted configuration exactly matches expected data. | ||
| 249 | |||
| 250 | expected: file that contains the expected data | ||
| 251 | returncode: True if result matches the expected data, False otherwise | ||
| 252 | """ | ||
| 253 | return self._matches('config', expected) | ||
| 254 | |||
| 255 | def stdout_contains(self, expected): | ||
| 256 | """Check if resulted stdout contains expected data. | ||
| 257 | |||
| 258 | expected: file that contains the expected data | ||
| 259 | returncode: True if result contains the expected data, False otherwise | ||
| 260 | """ | ||
| 261 | return self._contains('stdout', expected) | ||
| 262 | |||
| 263 | def stdout_matches(self, expected): | ||
| 264 | """Check if resulted stdout exactly matches expected data. | ||
| 265 | |||
| 266 | expected: file that contains the expected data | ||
| 267 | returncode: True if result matches the expected data, False otherwise | ||
| 268 | """ | ||
| 269 | return self._matches('stdout', expected) | ||
| 270 | |||
| 271 | def stderr_contains(self, expected): | ||
| 272 | """Check if resulted stderr contains expected data. | ||
| 273 | |||
| 274 | expected: file that contains the expected data | ||
| 275 | returncode: True if result contains the expected data, False otherwise | ||
| 276 | """ | ||
| 277 | return self._contains('stderr', expected) | ||
| 278 | |||
| 279 | def stderr_matches(self, expected): | ||
| 280 | """Check if resulted stderr exactly matches expected data. | ||
| 281 | |||
| 282 | expected: file that contains the expected data | ||
| 283 | returncode: True if result matches the expected data, False otherwise | ||
| 284 | """ | ||
| 285 | return self._matches('stderr', expected) | ||
| 286 | |||
| 287 | |||
| 288 | @pytest.fixture(scope="module") | ||
| 289 | def conf(request): | ||
| 290 | """Create a Conf instance and provide it to test functions.""" | ||
| 291 | return Conf(request) | ||
diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig b/scripts/kconfig/tests/err_recursive_inc/Kconfig new file mode 100644 index 000000000000..0e4c8750ab65 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig | |||
| @@ -0,0 +1 @@ | |||
| source "Kconfig.inc1" | |||
diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc1 b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc1 new file mode 100644 index 000000000000..00e408d653fc --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc1 | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | source "Kconfig.inc2" | ||
diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc2 b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc2 new file mode 100644 index 000000000000..349ea2db15dc --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc2 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | |||
| 3 | source "Kconfig.inc3" | ||
diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc3 b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc3 new file mode 100644 index 000000000000..0e4c8750ab65 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig.inc3 | |||
| @@ -0,0 +1 @@ | |||
| source "Kconfig.inc1" | |||
diff --git a/scripts/kconfig/tests/err_recursive_inc/__init__.py b/scripts/kconfig/tests/err_recursive_inc/__init__.py new file mode 100644 index 000000000000..0e4c839c54aa --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/__init__.py | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | """ | ||
| 2 | Detect recursive inclusion error. | ||
| 3 | |||
| 4 | If recursive inclusion is detected, it should fail with error messages. | ||
| 5 | """ | ||
| 6 | |||
| 7 | |||
| 8 | def test(conf): | ||
| 9 | assert conf.oldaskconfig() != 0 | ||
| 10 | assert conf.stderr_contains('expected_stderr') | ||
diff --git a/scripts/kconfig/tests/err_recursive_inc/expected_stderr b/scripts/kconfig/tests/err_recursive_inc/expected_stderr new file mode 100644 index 000000000000..6b582eee2176 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/expected_stderr | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | Recursive inclusion detected. | ||
| 2 | Inclusion path: | ||
| 3 | current file : Kconfig.inc1 | ||
| 4 | included from: Kconfig.inc3:1 | ||
| 5 | included from: Kconfig.inc2:3 | ||
| 6 | included from: Kconfig.inc1:4 | ||
diff --git a/scripts/kconfig/tests/inter_choice/Kconfig b/scripts/kconfig/tests/inter_choice/Kconfig new file mode 100644 index 000000000000..e44449f075df --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/Kconfig | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | config MODULES | ||
| 2 | def_bool y | ||
| 3 | option modules | ||
| 4 | |||
| 5 | choice | ||
| 6 | prompt "Choice" | ||
| 7 | |||
| 8 | config CHOICE_VAL0 | ||
| 9 | tristate "Choice 0" | ||
| 10 | |||
| 11 | config CHOIVE_VAL1 | ||
| 12 | tristate "Choice 1" | ||
| 13 | |||
| 14 | endchoice | ||
| 15 | |||
| 16 | choice | ||
| 17 | prompt "Another choice" | ||
| 18 | depends on CHOICE_VAL0 | ||
| 19 | |||
| 20 | config DUMMY | ||
| 21 | bool "dummy" | ||
| 22 | |||
| 23 | endchoice | ||
diff --git a/scripts/kconfig/tests/inter_choice/__init__.py b/scripts/kconfig/tests/inter_choice/__init__.py new file mode 100644 index 000000000000..5c7fc365ed40 --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/__init__.py | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | """ | ||
| 2 | Do not affect user-assigned choice value by another choice. | ||
| 3 | |||
| 4 | Handling of state flags for choices is complecated. In old days, | ||
| 5 | the defconfig result of a choice could be affected by another choice | ||
| 6 | if those choices interact by 'depends on', 'select', etc. | ||
| 7 | |||
| 8 | Related Linux commit: fbe98bb9ed3dae23e320c6b113e35f129538d14a | ||
| 9 | """ | ||
| 10 | |||
| 11 | |||
| 12 | def test(conf): | ||
| 13 | assert conf.defconfig('defconfig') == 0 | ||
| 14 | assert conf.config_contains('expected_config') | ||
diff --git a/scripts/kconfig/tests/inter_choice/defconfig b/scripts/kconfig/tests/inter_choice/defconfig new file mode 100644 index 000000000000..162c4148e2a5 --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/defconfig | |||
| @@ -0,0 +1 @@ | |||
| CONFIG_CHOICE_VAL0=y | |||
diff --git a/scripts/kconfig/tests/inter_choice/expected_config b/scripts/kconfig/tests/inter_choice/expected_config new file mode 100644 index 000000000000..5dceefb054e3 --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/expected_config | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | CONFIG_MODULES=y | ||
| 2 | CONFIG_CHOICE_VAL0=y | ||
| 3 | # CONFIG_CHOIVE_VAL1 is not set | ||
| 4 | CONFIG_DUMMY=y | ||
diff --git a/scripts/kconfig/tests/new_choice_with_dep/Kconfig b/scripts/kconfig/tests/new_choice_with_dep/Kconfig new file mode 100644 index 000000000000..53ef1b86e7bf --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/Kconfig | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | config A | ||
| 2 | bool "A" | ||
| 3 | help | ||
| 4 | This is a new symbol. | ||
| 5 | |||
| 6 | choice | ||
| 7 | prompt "Choice ?" | ||
| 8 | depends on A | ||
| 9 | help | ||
| 10 | "depends on A" has been newly added. | ||
| 11 | |||
| 12 | config CHOICE_B | ||
| 13 | bool "Choice B" | ||
| 14 | |||
| 15 | config CHOICE_C | ||
| 16 | bool "Choice C" | ||
| 17 | help | ||
| 18 | This is a new symbol, so should be asked. | ||
| 19 | |||
| 20 | endchoice | ||
| 21 | |||
| 22 | choice | ||
| 23 | prompt "Choice2 ?" | ||
| 24 | |||
| 25 | config CHOICE_D | ||
| 26 | bool "Choice D" | ||
| 27 | |||
| 28 | config CHOICE_E | ||
| 29 | bool "Choice E" | ||
| 30 | |||
| 31 | config CHOICE_F | ||
| 32 | bool "Choice F" | ||
| 33 | depends on A | ||
| 34 | help | ||
| 35 | This is a new symbol, so should be asked. | ||
| 36 | |||
| 37 | endchoice | ||
diff --git a/scripts/kconfig/tests/new_choice_with_dep/__init__.py b/scripts/kconfig/tests/new_choice_with_dep/__init__.py new file mode 100644 index 000000000000..f0e0ead0f32f --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/__init__.py | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | """ | ||
| 2 | Ask new choice values when they become visible. | ||
| 3 | |||
| 4 | If new choice values are added with new dependency, and they become | ||
| 5 | visible during user configuration, oldconfig should recognize them | ||
| 6 | as (NEW), and ask the user for choice. | ||
| 7 | |||
| 8 | Related Linux commit: 5d09598d488f081e3be23f885ed65cbbe2d073b5 | ||
| 9 | """ | ||
| 10 | |||
| 11 | |||
| 12 | def test(conf): | ||
| 13 | assert conf.oldconfig('config', 'y') == 0 | ||
| 14 | assert conf.stdout_contains('expected_stdout') | ||
diff --git a/scripts/kconfig/tests/new_choice_with_dep/config b/scripts/kconfig/tests/new_choice_with_dep/config new file mode 100644 index 000000000000..47ef95d567fd --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/config | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | CONFIG_CHOICE_B=y | ||
| 2 | # CONFIG_CHOICE_D is not set | ||
| 3 | CONFIG_CHOICE_E=y | ||
diff --git a/scripts/kconfig/tests/new_choice_with_dep/expected_stdout b/scripts/kconfig/tests/new_choice_with_dep/expected_stdout new file mode 100644 index 000000000000..74dc0bcb22bc --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/expected_stdout | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | A (A) [N/y/?] (NEW) y | ||
| 2 | Choice ? | ||
| 3 | > 1. Choice B (CHOICE_B) | ||
| 4 | 2. Choice C (CHOICE_C) (NEW) | ||
| 5 | choice[1-2?]: | ||
| 6 | Choice2 ? | ||
| 7 | 1. Choice D (CHOICE_D) | ||
| 8 | > 2. Choice E (CHOICE_E) | ||
| 9 | 3. Choice F (CHOICE_F) (NEW) | ||
| 10 | choice[1-3?]: | ||
diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig new file mode 100644 index 000000000000..c00b8fe54f45 --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | config A | ||
| 2 | bool "A" | ||
| 3 | |||
| 4 | choice | ||
| 5 | prompt "Choice ?" | ||
| 6 | depends on A | ||
| 7 | |||
| 8 | config CHOICE_B | ||
| 9 | bool "Choice B" | ||
| 10 | |||
| 11 | config CHOICE_C | ||
| 12 | bool "Choice C" | ||
| 13 | |||
| 14 | endchoice | ||
diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py new file mode 100644 index 000000000000..207261b0fe00 --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | """ | ||
| 2 | Do not write choice values to .config if the dependency is unmet. | ||
| 3 | |||
| 4 | "# CONFIG_... is not set" should not be written into the .config file | ||
| 5 | for symbols with unmet dependency. | ||
| 6 | |||
| 7 | This was not working correctly for choice values because choice needs | ||
| 8 | a bit different symbol computation. | ||
| 9 | |||
| 10 | This checks that no unneeded "# COFIG_... is not set" is contained in | ||
| 11 | the .config file. | ||
| 12 | |||
| 13 | Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59 | ||
| 14 | """ | ||
| 15 | |||
| 16 | |||
| 17 | def test(conf): | ||
| 18 | assert conf.oldaskconfig('config', 'n') == 0 | ||
| 19 | assert conf.config_matches('expected_config') | ||
diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/config b/scripts/kconfig/tests/no_write_if_dep_unmet/config new file mode 100644 index 000000000000..abd280e2f616 --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/config | |||
| @@ -0,0 +1 @@ | |||
| CONFIG_A=y | |||
diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config b/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config new file mode 100644 index 000000000000..0d15e41da475 --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # | ||
| 2 | # Automatically generated file; DO NOT EDIT. | ||
| 3 | # Linux Kernel Configuration | ||
| 4 | # | ||
| 5 | # CONFIG_A is not set | ||
diff --git a/scripts/kconfig/tests/pytest.ini b/scripts/kconfig/tests/pytest.ini new file mode 100644 index 000000000000..85d7ce8e448b --- /dev/null +++ b/scripts/kconfig/tests/pytest.ini | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | [pytest] | ||
| 2 | addopts = --verbose | ||
| 3 | |||
| 4 | # Pytest requires that test files have unique names, because pytest imports | ||
| 5 | # them as top-level modules. It is silly to prefix or suffix a test file with | ||
| 6 | # the directory name that contains it. Use __init__.py for all test files. | ||
| 7 | python_files = __init__.py | ||
diff --git a/scripts/kconfig/tests/rand_nested_choice/Kconfig b/scripts/kconfig/tests/rand_nested_choice/Kconfig new file mode 100644 index 000000000000..c591d512929f --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/Kconfig | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | choice | ||
| 2 | prompt "choice" | ||
| 3 | |||
| 4 | config A | ||
| 5 | bool "A" | ||
| 6 | |||
| 7 | config B | ||
| 8 | bool "B" | ||
| 9 | |||
| 10 | if B | ||
| 11 | choice | ||
| 12 | prompt "sub choice" | ||
| 13 | |||
| 14 | config C | ||
| 15 | bool "C" | ||
| 16 | |||
| 17 | config D | ||
| 18 | bool "D" | ||
| 19 | |||
| 20 | if D | ||
| 21 | choice | ||
| 22 | prompt "subsub choice" | ||
| 23 | |||
| 24 | config E | ||
| 25 | bool "E" | ||
| 26 | |||
| 27 | endchoice | ||
| 28 | endif # D | ||
| 29 | |||
| 30 | endchoice | ||
| 31 | endif # B | ||
| 32 | |||
| 33 | endchoice | ||
diff --git a/scripts/kconfig/tests/rand_nested_choice/__init__.py b/scripts/kconfig/tests/rand_nested_choice/__init__.py new file mode 100644 index 000000000000..e729a4e85218 --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/__init__.py | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | """ | ||
| 2 | Set random values recursively in nested choices. | ||
| 3 | |||
| 4 | Kconfig can create a choice-in-choice structure by using 'if' statement. | ||
| 5 | randconfig should correctly set random choice values. | ||
| 6 | |||
| 7 | Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29 | ||
| 8 | """ | ||
| 9 | |||
| 10 | |||
| 11 | def test(conf): | ||
| 12 | for i in range(20): | ||
| 13 | assert conf.randconfig() == 0 | ||
| 14 | assert (conf.config_contains('expected_stdout0') or | ||
| 15 | conf.config_contains('expected_stdout1') or | ||
| 16 | conf.config_contains('expected_stdout2')) | ||
diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 new file mode 100644 index 000000000000..05450f3d4eb5 --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | CONFIG_A=y | ||
| 2 | # CONFIG_B is not set | ||
diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 new file mode 100644 index 000000000000..37ab29584157 --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | # CONFIG_A is not set | ||
| 2 | CONFIG_B=y | ||
| 3 | CONFIG_C=y | ||
| 4 | # CONFIG_D is not set | ||
diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 new file mode 100644 index 000000000000..849ff47e9848 --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # CONFIG_A is not set | ||
| 2 | CONFIG_B=y | ||
| 3 | # CONFIG_C is not set | ||
| 4 | CONFIG_D=y | ||
| 5 | CONFIG_E=y | ||
diff --git a/scripts/kconfig/tests/warn_recursive_dep/Kconfig b/scripts/kconfig/tests/warn_recursive_dep/Kconfig new file mode 100644 index 000000000000..a65bfcb7137e --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/Kconfig | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | # depends on itself | ||
| 2 | |||
| 3 | config A | ||
| 4 | bool "A" | ||
| 5 | depends on A | ||
| 6 | |||
| 7 | # select itself | ||
| 8 | |||
| 9 | config B | ||
| 10 | bool | ||
| 11 | select B | ||
| 12 | |||
| 13 | # depends on each other | ||
| 14 | |||
| 15 | config C1 | ||
| 16 | bool "C1" | ||
| 17 | depends on C2 | ||
| 18 | |||
| 19 | config C2 | ||
| 20 | bool "C2" | ||
| 21 | depends on C1 | ||
| 22 | |||
| 23 | # depends on and select | ||
| 24 | |||
| 25 | config D1 | ||
| 26 | bool "D1" | ||
| 27 | depends on D2 | ||
| 28 | select D2 | ||
| 29 | |||
| 30 | config D2 | ||
| 31 | bool | ||
| 32 | |||
| 33 | # depends on and imply | ||
| 34 | # This is not recursive dependency | ||
| 35 | |||
| 36 | config E1 | ||
| 37 | bool "E1" | ||
| 38 | depends on E2 | ||
| 39 | imply E2 | ||
| 40 | |||
| 41 | config E2 | ||
| 42 | bool "E2" | ||
| 43 | |||
| 44 | # property | ||
| 45 | |||
| 46 | config F1 | ||
| 47 | bool "F1" | ||
| 48 | default F2 | ||
| 49 | |||
| 50 | config F2 | ||
| 51 | bool "F2" | ||
| 52 | depends on F1 | ||
| 53 | |||
| 54 | # menu | ||
| 55 | |||
| 56 | menu "menu depending on its content" | ||
| 57 | depends on G | ||
| 58 | |||
| 59 | config G | ||
| 60 | bool "G" | ||
| 61 | |||
| 62 | endmenu | ||
diff --git a/scripts/kconfig/tests/warn_recursive_dep/__init__.py b/scripts/kconfig/tests/warn_recursive_dep/__init__.py new file mode 100644 index 000000000000..adb21951ba41 --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/__init__.py | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | """ | ||
| 2 | Warn recursive inclusion. | ||
| 3 | |||
| 4 | Recursive dependency should be warned. | ||
| 5 | """ | ||
| 6 | |||
| 7 | def test(conf): | ||
| 8 | assert conf.oldaskconfig() == 0 | ||
| 9 | assert conf.stderr_contains('expected_stderr') | ||
diff --git a/scripts/kconfig/tests/warn_recursive_dep/expected_stderr b/scripts/kconfig/tests/warn_recursive_dep/expected_stderr new file mode 100644 index 000000000000..3de807dd9cb2 --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/expected_stderr | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | Kconfig:9:error: recursive dependency detected! | ||
| 2 | Kconfig:9: symbol B is selected by B | ||
| 3 | For a resolution refer to Documentation/kbuild/kconfig-language.txt | ||
| 4 | subsection "Kconfig recursive dependency limitations" | ||
| 5 | |||
| 6 | Kconfig:3:error: recursive dependency detected! | ||
| 7 | Kconfig:3: symbol A depends on A | ||
| 8 | For a resolution refer to Documentation/kbuild/kconfig-language.txt | ||
| 9 | subsection "Kconfig recursive dependency limitations" | ||
| 10 | |||
| 11 | Kconfig:15:error: recursive dependency detected! | ||
| 12 | Kconfig:15: symbol C1 depends on C2 | ||
| 13 | Kconfig:19: symbol C2 depends on C1 | ||
| 14 | For a resolution refer to Documentation/kbuild/kconfig-language.txt | ||
| 15 | subsection "Kconfig recursive dependency limitations" | ||
| 16 | |||
| 17 | Kconfig:30:error: recursive dependency detected! | ||
| 18 | Kconfig:30: symbol D2 is selected by D1 | ||
| 19 | Kconfig:25: symbol D1 depends on D2 | ||
| 20 | For a resolution refer to Documentation/kbuild/kconfig-language.txt | ||
| 21 | subsection "Kconfig recursive dependency limitations" | ||
| 22 | |||
| 23 | Kconfig:59:error: recursive dependency detected! | ||
| 24 | Kconfig:59: symbol G depends on G | ||
| 25 | For a resolution refer to Documentation/kbuild/kconfig-language.txt | ||
| 26 | subsection "Kconfig recursive dependency limitations" | ||
| 27 | |||
| 28 | Kconfig:50:error: recursive dependency detected! | ||
| 29 | Kconfig:50: symbol F2 depends on F1 | ||
| 30 | Kconfig:48: symbol F1 default value contains F2 | ||
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 88b650eb9cc9..045093d827e1 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | %option nostdinit noyywrap never-interactive full ecs | 1 | %option nostdinit noyywrap never-interactive full ecs |
| 2 | %option 8bit nodefault perf-report perf-report | 2 | %option 8bit nodefault yylineno |
| 3 | %option noinput | 3 | %option noinput |
| 4 | %x COMMAND HELP STRING PARAM | 4 | %x COMMAND HELP STRING PARAM |
| 5 | %{ | 5 | %{ |
| @@ -83,7 +83,6 @@ n [A-Za-z0-9_-] | |||
| 83 | 83 | ||
| 84 | [ \t]*#.*\n | | 84 | [ \t]*#.*\n | |
| 85 | [ \t]*\n { | 85 | [ \t]*\n { |
| 86 | current_file->lineno++; | ||
| 87 | return T_EOL; | 86 | return T_EOL; |
| 88 | } | 87 | } |
| 89 | [ \t]*#.* | 88 | [ \t]*#.* |
| @@ -104,7 +103,7 @@ n [A-Za-z0-9_-] | |||
| 104 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 103 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
| 105 | BEGIN(PARAM); | 104 | BEGIN(PARAM); |
| 106 | current_pos.file = current_file; | 105 | current_pos.file = current_file; |
| 107 | current_pos.lineno = current_file->lineno; | 106 | current_pos.lineno = yylineno; |
| 108 | if (id && id->flags & TF_COMMAND) { | 107 | if (id && id->flags & TF_COMMAND) { |
| 109 | yylval.id = id; | 108 | yylval.id = id; |
| 110 | return id->token; | 109 | return id->token; |
| @@ -116,7 +115,6 @@ n [A-Za-z0-9_-] | |||
| 116 | . warn_ignored_character(*yytext); | 115 | . warn_ignored_character(*yytext); |
| 117 | \n { | 116 | \n { |
| 118 | BEGIN(INITIAL); | 117 | BEGIN(INITIAL); |
| 119 | current_file->lineno++; | ||
| 120 | return T_EOL; | 118 | return T_EOL; |
| 121 | } | 119 | } |
| 122 | } | 120 | } |
| @@ -138,7 +136,7 @@ n [A-Za-z0-9_-] | |||
| 138 | new_string(); | 136 | new_string(); |
| 139 | BEGIN(STRING); | 137 | BEGIN(STRING); |
| 140 | } | 138 | } |
| 141 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; | 139 | \n BEGIN(INITIAL); return T_EOL; |
| 142 | ({n}|[/.])+ { | 140 | ({n}|[/.])+ { |
| 143 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 141 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
| 144 | if (id && id->flags & TF_PARAM) { | 142 | if (id && id->flags & TF_PARAM) { |
| @@ -150,7 +148,7 @@ n [A-Za-z0-9_-] | |||
| 150 | return T_WORD; | 148 | return T_WORD; |
| 151 | } | 149 | } |
| 152 | #.* /* comment */ | 150 | #.* /* comment */ |
| 153 | \\\n current_file->lineno++; | 151 | \\\n ; |
| 154 | [[:blank:]]+ | 152 | [[:blank:]]+ |
| 155 | . warn_ignored_character(*yytext); | 153 | . warn_ignored_character(*yytext); |
| 156 | <<EOF>> { | 154 | <<EOF>> { |
| @@ -187,7 +185,6 @@ n [A-Za-z0-9_-] | |||
| 187 | fprintf(stderr, | 185 | fprintf(stderr, |
| 188 | "%s:%d:warning: multi-line strings not supported\n", | 186 | "%s:%d:warning: multi-line strings not supported\n", |
| 189 | zconf_curname(), zconf_lineno()); | 187 | zconf_curname(), zconf_lineno()); |
| 190 | current_file->lineno++; | ||
| 191 | BEGIN(INITIAL); | 188 | BEGIN(INITIAL); |
| 192 | return T_EOL; | 189 | return T_EOL; |
| 193 | } | 190 | } |
| @@ -220,12 +217,10 @@ n [A-Za-z0-9_-] | |||
| 220 | } | 217 | } |
| 221 | } | 218 | } |
| 222 | [ \t]*\n/[^ \t\n] { | 219 | [ \t]*\n/[^ \t\n] { |
| 223 | current_file->lineno++; | ||
| 224 | zconf_endhelp(); | 220 | zconf_endhelp(); |
| 225 | return T_HELPTEXT; | 221 | return T_HELPTEXT; |
| 226 | } | 222 | } |
| 227 | [ \t]*\n { | 223 | [ \t]*\n { |
| 228 | current_file->lineno++; | ||
| 229 | append_string("\n", 1); | 224 | append_string("\n", 1); |
| 230 | } | 225 | } |
| 231 | [^ \t\n].* { | 226 | [^ \t\n].* { |
| @@ -304,7 +299,7 @@ void zconf_initscan(const char *name) | |||
| 304 | memset(current_buf, 0, sizeof(*current_buf)); | 299 | memset(current_buf, 0, sizeof(*current_buf)); |
| 305 | 300 | ||
| 306 | current_file = file_lookup(name); | 301 | current_file = file_lookup(name); |
| 307 | current_file->lineno = 1; | 302 | yylineno = 1; |
| 308 | } | 303 | } |
| 309 | 304 | ||
| 310 | void zconf_nextfile(const char *name) | 305 | void zconf_nextfile(const char *name) |
| @@ -325,24 +320,26 @@ void zconf_nextfile(const char *name) | |||
| 325 | buf->parent = current_buf; | 320 | buf->parent = current_buf; |
| 326 | current_buf = buf; | 321 | current_buf = buf; |
| 327 | 322 | ||
| 328 | for (iter = current_file->parent; iter; iter = iter->parent ) { | 323 | current_file->lineno = yylineno; |
| 329 | if (!strcmp(current_file->name,iter->name) ) { | 324 | file->parent = current_file; |
| 325 | |||
| 326 | for (iter = current_file; iter; iter = iter->parent) { | ||
| 327 | if (!strcmp(iter->name, file->name)) { | ||
| 330 | fprintf(stderr, | 328 | fprintf(stderr, |
| 331 | "%s:%d: recursive inclusion detected. " | 329 | "Recursive inclusion detected.\n" |
| 332 | "Inclusion path:\n current file : '%s'\n", | 330 | "Inclusion path:\n" |
| 333 | zconf_curname(), zconf_lineno(), | 331 | " current file : %s\n", file->name); |
| 334 | zconf_curname()); | 332 | iter = file; |
| 335 | iter = current_file; | ||
| 336 | do { | 333 | do { |
| 337 | iter = iter->parent; | 334 | iter = iter->parent; |
| 338 | fprintf(stderr, " included from: '%s:%d'\n", | 335 | fprintf(stderr, " included from: %s:%d\n", |
| 339 | iter->name, iter->lineno - 1); | 336 | iter->name, iter->lineno - 1); |
| 340 | } while (strcmp(iter->name, current_file->name)); | 337 | } while (strcmp(iter->name, file->name)); |
| 341 | exit(1); | 338 | exit(1); |
| 342 | } | 339 | } |
| 343 | } | 340 | } |
| 344 | file->lineno = 1; | 341 | |
| 345 | file->parent = current_file; | 342 | yylineno = 1; |
| 346 | current_file = file; | 343 | current_file = file; |
| 347 | } | 344 | } |
| 348 | 345 | ||
| @@ -351,6 +348,8 @@ static void zconf_endfile(void) | |||
| 351 | struct buffer *parent; | 348 | struct buffer *parent; |
| 352 | 349 | ||
| 353 | current_file = current_file->parent; | 350 | current_file = current_file->parent; |
| 351 | if (current_file) | ||
| 352 | yylineno = current_file->lineno; | ||
| 354 | 353 | ||
| 355 | parent = current_buf->parent; | 354 | parent = current_buf->parent; |
| 356 | if (parent) { | 355 | if (parent) { |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fee8952037b1..0057d8eafcc1 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #!/usr/bin/env perl | 1 | #!/usr/bin/env perl |
| 2 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | 3 | ||
| 3 | use warnings; | 4 | use warnings; |
| 4 | use strict; | 5 | use strict; |
| @@ -328,13 +329,15 @@ my $lineprefix=""; | |||
| 328 | use constant { | 329 | use constant { |
| 329 | STATE_NORMAL => 0, # normal code | 330 | STATE_NORMAL => 0, # normal code |
| 330 | STATE_NAME => 1, # looking for function name | 331 | STATE_NAME => 1, # looking for function name |
| 331 | STATE_FIELD => 2, # scanning field start | 332 | STATE_BODY_MAYBE => 2, # body - or maybe more description |
| 332 | STATE_PROTO => 3, # scanning prototype | 333 | STATE_BODY => 3, # the body of the comment |
| 333 | STATE_DOCBLOCK => 4, # documentation block | 334 | STATE_PROTO => 4, # scanning prototype |
| 334 | STATE_INLINE => 5, # gathering documentation outside main block | 335 | STATE_DOCBLOCK => 5, # documentation block |
| 336 | STATE_INLINE => 6, # gathering documentation outside main block | ||
| 335 | }; | 337 | }; |
| 336 | my $state; | 338 | my $state; |
| 337 | my $in_doc_sect; | 339 | my $in_doc_sect; |
| 340 | my $leading_space; | ||
| 338 | 341 | ||
| 339 | # Inline documentation state | 342 | # Inline documentation state |
| 340 | use constant { | 343 | use constant { |
| @@ -363,7 +366,7 @@ my $doc_sect = $doc_com . | |||
| 363 | my $doc_content = $doc_com_body . '(.*)'; | 366 | my $doc_content = $doc_com_body . '(.*)'; |
| 364 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; | 367 | my $doc_block = $doc_com . 'DOC:\s*(.*)?'; |
| 365 | my $doc_inline_start = '^\s*/\*\*\s*$'; | 368 | my $doc_inline_start = '^\s*/\*\*\s*$'; |
| 366 | my $doc_inline_sect = '\s*\*\s*(@[\w\s]+):(.*)'; | 369 | my $doc_inline_sect = '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)'; |
| 367 | my $doc_inline_end = '^\s*\*/\s*$'; | 370 | my $doc_inline_end = '^\s*\*/\s*$'; |
| 368 | my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$'; | 371 | my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$'; |
| 369 | my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;'; | 372 | my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;'; |
| @@ -553,10 +556,9 @@ sub output_highlight { | |||
| 553 | } | 556 | } |
| 554 | if ($line eq ""){ | 557 | if ($line eq ""){ |
| 555 | if (! $output_preformatted) { | 558 | if (! $output_preformatted) { |
| 556 | print $lineprefix, local_unescape($blankline); | 559 | print $lineprefix, $blankline; |
| 557 | } | 560 | } |
| 558 | } else { | 561 | } else { |
| 559 | $line =~ s/\\\\\\/\&/g; | ||
| 560 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { | 562 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
| 561 | print "\\&$line"; | 563 | print "\\&$line"; |
| 562 | } else { | 564 | } else { |
| @@ -747,17 +749,73 @@ sub output_blockhead_rst(%) { | |||
| 747 | } | 749 | } |
| 748 | } | 750 | } |
| 749 | 751 | ||
| 750 | sub output_highlight_rst { | 752 | # |
| 751 | my $contents = join "\n",@_; | 753 | # Apply the RST highlights to a sub-block of text. |
| 752 | my $line; | 754 | # |
| 753 | 755 | sub highlight_block($) { | |
| 754 | # undo the evil effects of xml_escape() earlier | 756 | # The dohighlight kludge requires the text be called $contents |
| 755 | $contents = xml_unescape($contents); | 757 | my $contents = shift; |
| 756 | |||
| 757 | eval $dohighlight; | 758 | eval $dohighlight; |
| 758 | die $@ if $@; | 759 | die $@ if $@; |
| 760 | return $contents; | ||
| 761 | } | ||
| 759 | 762 | ||
| 760 | foreach $line (split "\n", $contents) { | 763 | # |
| 764 | # Regexes used only here. | ||
| 765 | # | ||
| 766 | my $sphinx_literal = '^[^.].*::$'; | ||
| 767 | my $sphinx_cblock = '^\.\.\ +code-block::'; | ||
| 768 | |||
| 769 | sub output_highlight_rst { | ||
| 770 | my $input = join "\n",@_; | ||
| 771 | my $output = ""; | ||
| 772 | my $line; | ||
| 773 | my $in_literal = 0; | ||
| 774 | my $litprefix; | ||
| 775 | my $block = ""; | ||
| 776 | |||
| 777 | foreach $line (split "\n",$input) { | ||
| 778 | # | ||
| 779 | # If we're in a literal block, see if we should drop out | ||
| 780 | # of it. Otherwise pass the line straight through unmunged. | ||
| 781 | # | ||
| 782 | if ($in_literal) { | ||
| 783 | if (! ($line =~ /^\s*$/)) { | ||
| 784 | # | ||
| 785 | # If this is the first non-blank line in a literal | ||
| 786 | # block we need to figure out what the proper indent is. | ||
| 787 | # | ||
| 788 | if ($litprefix eq "") { | ||
| 789 | $line =~ /^(\s*)/; | ||
| 790 | $litprefix = '^' . $1; | ||
| 791 | $output .= $line . "\n"; | ||
| 792 | } elsif (! ($line =~ /$litprefix/)) { | ||
| 793 | $in_literal = 0; | ||
| 794 | } else { | ||
| 795 | $output .= $line . "\n"; | ||
| 796 | } | ||
| 797 | } else { | ||
| 798 | $output .= $line . "\n"; | ||
| 799 | } | ||
| 800 | } | ||
| 801 | # | ||
| 802 | # Not in a literal block (or just dropped out) | ||
| 803 | # | ||
| 804 | if (! $in_literal) { | ||
| 805 | $block .= $line . "\n"; | ||
| 806 | if (($line =~ /$sphinx_literal/) || ($line =~ /$sphinx_cblock/)) { | ||
| 807 | $in_literal = 1; | ||
| 808 | $litprefix = ""; | ||
| 809 | $output .= highlight_block($block); | ||
| 810 | $block = "" | ||
| 811 | } | ||
| 812 | } | ||
| 813 | } | ||
| 814 | |||
| 815 | if ($block) { | ||
| 816 | $output .= highlight_block($block); | ||
| 817 | } | ||
| 818 | foreach $line (split "\n", $output) { | ||
| 761 | print $lineprefix . $line . "\n"; | 819 | print $lineprefix . $line . "\n"; |
| 762 | } | 820 | } |
| 763 | } | 821 | } |
| @@ -1062,7 +1120,7 @@ sub dump_struct($$) { | |||
| 1062 | # Handle bitmaps | 1120 | # Handle bitmaps |
| 1063 | $arg =~ s/:\s*\d+\s*//g; | 1121 | $arg =~ s/:\s*\d+\s*//g; |
| 1064 | # Handle arrays | 1122 | # Handle arrays |
| 1065 | $arg =~ s/\[\S+\]//g; | 1123 | $arg =~ s/\[.*\]//g; |
| 1066 | # The type may have multiple words, | 1124 | # The type may have multiple words, |
| 1067 | # and multiple IDs can be defined, like: | 1125 | # and multiple IDs can be defined, like: |
| 1068 | # const struct foo, *bar, foobar | 1126 | # const struct foo, *bar, foobar |
| @@ -1422,8 +1480,6 @@ sub push_parameter($$$$) { | |||
| 1422 | } | 1480 | } |
| 1423 | } | 1481 | } |
| 1424 | 1482 | ||
| 1425 | $param = xml_escape($param); | ||
| 1426 | |||
| 1427 | # strip spaces from $param so that it is one continuous string | 1483 | # strip spaces from $param so that it is one continuous string |
| 1428 | # on @parameterlist; | 1484 | # on @parameterlist; |
| 1429 | # this fixes a problem where check_sections() cannot find | 1485 | # this fixes a problem where check_sections() cannot find |
| @@ -1522,6 +1578,7 @@ sub dump_function($$) { | |||
| 1522 | $prototype =~ s/__meminit +//; | 1578 | $prototype =~ s/__meminit +//; |
| 1523 | $prototype =~ s/__must_check +//; | 1579 | $prototype =~ s/__must_check +//; |
| 1524 | $prototype =~ s/__weak +//; | 1580 | $prototype =~ s/__weak +//; |
| 1581 | $prototype =~ s/__sched +//; | ||
| 1525 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added | 1582 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added |
| 1526 | $prototype =~ s/__attribute__\s*\(\( | 1583 | $prototype =~ s/__attribute__\s*\(\( |
| 1527 | (?: | 1584 | (?: |
| @@ -1748,47 +1805,6 @@ sub process_proto_type($$) { | |||
| 1748 | } | 1805 | } |
| 1749 | } | 1806 | } |
| 1750 | 1807 | ||
| 1751 | # xml_escape: replace <, >, and & in the text stream; | ||
| 1752 | # | ||
| 1753 | # however, formatting controls that are generated internally/locally in the | ||
| 1754 | # kernel-doc script are not escaped here; instead, they begin life like | ||
| 1755 | # $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings | ||
| 1756 | # are converted to their mnemonic-expected output, without the 4 * '\' & ':', | ||
| 1757 | # just before actual output; (this is done by local_unescape()) | ||
| 1758 | sub xml_escape($) { | ||
| 1759 | my $text = shift; | ||
| 1760 | if ($output_mode eq "man") { | ||
| 1761 | return $text; | ||
| 1762 | } | ||
| 1763 | $text =~ s/\&/\\\\\\amp;/g; | ||
| 1764 | $text =~ s/\</\\\\\\lt;/g; | ||
| 1765 | $text =~ s/\>/\\\\\\gt;/g; | ||
| 1766 | return $text; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | # xml_unescape: reverse the effects of xml_escape | ||
| 1770 | sub xml_unescape($) { | ||
| 1771 | my $text = shift; | ||
| 1772 | if ($output_mode eq "man") { | ||
| 1773 | return $text; | ||
| 1774 | } | ||
| 1775 | $text =~ s/\\\\\\amp;/\&/g; | ||
| 1776 | $text =~ s/\\\\\\lt;/</g; | ||
| 1777 | $text =~ s/\\\\\\gt;/>/g; | ||
| 1778 | return $text; | ||
| 1779 | } | ||
| 1780 | |||
| 1781 | # convert local escape strings to html | ||
| 1782 | # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) | ||
| 1783 | sub local_unescape($) { | ||
| 1784 | my $text = shift; | ||
| 1785 | if ($output_mode eq "man") { | ||
| 1786 | return $text; | ||
| 1787 | } | ||
| 1788 | $text =~ s/\\\\\\\\lt:/</g; | ||
| 1789 | $text =~ s/\\\\\\\\gt:/>/g; | ||
| 1790 | return $text; | ||
| 1791 | } | ||
| 1792 | 1808 | ||
| 1793 | sub map_filename($) { | 1809 | sub map_filename($) { |
| 1794 | my $file; | 1810 | my $file; |
| @@ -1826,15 +1842,291 @@ sub process_export_file($) { | |||
| 1826 | close(IN); | 1842 | close(IN); |
| 1827 | } | 1843 | } |
| 1828 | 1844 | ||
| 1829 | sub process_file($) { | 1845 | # |
| 1830 | my $file; | 1846 | # Parsers for the various processing states. |
| 1847 | # | ||
| 1848 | # STATE_NORMAL: looking for the /** to begin everything. | ||
| 1849 | # | ||
| 1850 | sub process_normal() { | ||
| 1851 | if (/$doc_start/o) { | ||
| 1852 | $state = STATE_NAME; # next line is always the function name | ||
| 1853 | $in_doc_sect = 0; | ||
| 1854 | $declaration_start_line = $. + 1; | ||
| 1855 | } | ||
| 1856 | } | ||
| 1857 | |||
| 1858 | # | ||
| 1859 | # STATE_NAME: Looking for the "name - description" line | ||
| 1860 | # | ||
| 1861 | sub process_name($$) { | ||
| 1862 | my $file = shift; | ||
| 1831 | my $identifier; | 1863 | my $identifier; |
| 1832 | my $func; | ||
| 1833 | my $descr; | 1864 | my $descr; |
| 1834 | my $in_purpose = 0; | 1865 | |
| 1866 | if (/$doc_block/o) { | ||
| 1867 | $state = STATE_DOCBLOCK; | ||
| 1868 | $contents = ""; | ||
| 1869 | $new_start_line = $. + 1; | ||
| 1870 | |||
| 1871 | if ( $1 eq "" ) { | ||
| 1872 | $section = $section_intro; | ||
| 1873 | } else { | ||
| 1874 | $section = $1; | ||
| 1875 | } | ||
| 1876 | } | ||
| 1877 | elsif (/$doc_decl/o) { | ||
| 1878 | $identifier = $1; | ||
| 1879 | if (/\s*([\w\s]+?)(\(\))?\s*-/) { | ||
| 1880 | $identifier = $1; | ||
| 1881 | } | ||
| 1882 | |||
| 1883 | $state = STATE_BODY; | ||
| 1884 | # if there's no @param blocks need to set up default section | ||
| 1885 | # here | ||
| 1886 | $contents = ""; | ||
| 1887 | $section = $section_default; | ||
| 1888 | $new_start_line = $. + 1; | ||
| 1889 | if (/-(.*)/) { | ||
| 1890 | # strip leading/trailing/multiple spaces | ||
| 1891 | $descr= $1; | ||
| 1892 | $descr =~ s/^\s*//; | ||
| 1893 | $descr =~ s/\s*$//; | ||
| 1894 | $descr =~ s/\s+/ /g; | ||
| 1895 | $declaration_purpose = $descr; | ||
| 1896 | $state = STATE_BODY_MAYBE; | ||
| 1897 | } else { | ||
| 1898 | $declaration_purpose = ""; | ||
| 1899 | } | ||
| 1900 | |||
| 1901 | if (($declaration_purpose eq "") && $verbose) { | ||
| 1902 | print STDERR "${file}:$.: warning: missing initial short description on line:\n"; | ||
| 1903 | print STDERR $_; | ||
| 1904 | ++$warnings; | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | if ($identifier =~ m/^struct/) { | ||
| 1908 | $decl_type = 'struct'; | ||
| 1909 | } elsif ($identifier =~ m/^union/) { | ||
| 1910 | $decl_type = 'union'; | ||
| 1911 | } elsif ($identifier =~ m/^enum/) { | ||
| 1912 | $decl_type = 'enum'; | ||
| 1913 | } elsif ($identifier =~ m/^typedef/) { | ||
| 1914 | $decl_type = 'typedef'; | ||
| 1915 | } else { | ||
| 1916 | $decl_type = 'function'; | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | if ($verbose) { | ||
| 1920 | print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; | ||
| 1921 | } | ||
| 1922 | } else { | ||
| 1923 | print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", | ||
| 1924 | " - I thought it was a doc line\n"; | ||
| 1925 | ++$warnings; | ||
| 1926 | $state = STATE_NORMAL; | ||
| 1927 | } | ||
| 1928 | } | ||
| 1929 | |||
| 1930 | |||
| 1931 | # | ||
| 1932 | # STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment. | ||
| 1933 | # | ||
| 1934 | sub process_body($$) { | ||
| 1935 | my $file = shift; | ||
| 1936 | |||
| 1937 | if (/$doc_sect/i) { # case insensitive for supported section names | ||
| 1938 | $newsection = $1; | ||
| 1939 | $newcontents = $2; | ||
| 1940 | |||
| 1941 | # map the supported section names to the canonical names | ||
| 1942 | if ($newsection =~ m/^description$/i) { | ||
| 1943 | $newsection = $section_default; | ||
| 1944 | } elsif ($newsection =~ m/^context$/i) { | ||
| 1945 | $newsection = $section_context; | ||
| 1946 | } elsif ($newsection =~ m/^returns?$/i) { | ||
| 1947 | $newsection = $section_return; | ||
| 1948 | } elsif ($newsection =~ m/^\@return$/) { | ||
| 1949 | # special: @return is a section, not a param description | ||
| 1950 | $newsection = $section_return; | ||
| 1951 | } | ||
| 1952 | |||
| 1953 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 1954 | if (!$in_doc_sect && $verbose) { | ||
| 1955 | print STDERR "${file}:$.: warning: contents before sections\n"; | ||
| 1956 | ++$warnings; | ||
| 1957 | } | ||
| 1958 | dump_section($file, $section, $contents); | ||
| 1959 | $section = $section_default; | ||
| 1960 | } | ||
| 1961 | |||
| 1962 | $in_doc_sect = 1; | ||
| 1963 | $state = STATE_BODY; | ||
| 1964 | $contents = $newcontents; | ||
| 1965 | $new_start_line = $.; | ||
| 1966 | while (substr($contents, 0, 1) eq " ") { | ||
| 1967 | $contents = substr($contents, 1); | ||
| 1968 | } | ||
| 1969 | if ($contents ne "") { | ||
| 1970 | $contents .= "\n"; | ||
| 1971 | } | ||
| 1972 | $section = $newsection; | ||
| 1973 | $leading_space = undef; | ||
| 1974 | } elsif (/$doc_end/) { | ||
| 1975 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 1976 | dump_section($file, $section, $contents); | ||
| 1977 | $section = $section_default; | ||
| 1978 | $contents = ""; | ||
| 1979 | } | ||
| 1980 | # look for doc_com + <text> + doc_end: | ||
| 1981 | if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { | ||
| 1982 | print STDERR "${file}:$.: warning: suspicious ending line: $_"; | ||
| 1983 | ++$warnings; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | $prototype = ""; | ||
| 1987 | $state = STATE_PROTO; | ||
| 1988 | $brcount = 0; | ||
| 1989 | } elsif (/$doc_content/) { | ||
| 1990 | # miguel-style comment kludge, look for blank lines after | ||
| 1991 | # @parameter line to signify start of description | ||
| 1992 | if ($1 eq "") { | ||
| 1993 | if ($section =~ m/^@/ || $section eq $section_context) { | ||
| 1994 | dump_section($file, $section, $contents); | ||
| 1995 | $section = $section_default; | ||
| 1996 | $contents = ""; | ||
| 1997 | $new_start_line = $.; | ||
| 1998 | } else { | ||
| 1999 | $contents .= "\n"; | ||
| 2000 | } | ||
| 2001 | $state = STATE_BODY; | ||
| 2002 | } elsif ($state == STATE_BODY_MAYBE) { | ||
| 2003 | # Continued declaration purpose | ||
| 2004 | chomp($declaration_purpose); | ||
| 2005 | $declaration_purpose .= " " . $1; | ||
| 2006 | $declaration_purpose =~ s/\s+/ /g; | ||
| 2007 | } else { | ||
| 2008 | my $cont = $1; | ||
| 2009 | if ($section =~ m/^@/ || $section eq $section_context) { | ||
| 2010 | if (!defined $leading_space) { | ||
| 2011 | if ($cont =~ m/^(\s+)/) { | ||
| 2012 | $leading_space = $1; | ||
| 2013 | } else { | ||
| 2014 | $leading_space = ""; | ||
| 2015 | } | ||
| 2016 | } | ||
| 2017 | $cont =~ s/^$leading_space//; | ||
| 2018 | } | ||
| 2019 | $contents .= $cont . "\n"; | ||
| 2020 | } | ||
| 2021 | } else { | ||
| 2022 | # i dont know - bad line? ignore. | ||
| 2023 | print STDERR "${file}:$.: warning: bad line: $_"; | ||
| 2024 | ++$warnings; | ||
| 2025 | } | ||
| 2026 | } | ||
| 2027 | |||
| 2028 | |||
| 2029 | # | ||
| 2030 | # STATE_PROTO: reading a function/whatever prototype. | ||
| 2031 | # | ||
| 2032 | sub process_proto($$) { | ||
| 2033 | my $file = shift; | ||
| 2034 | |||
| 2035 | if (/$doc_inline_oneline/) { | ||
| 2036 | $section = $1; | ||
| 2037 | $contents = $2; | ||
| 2038 | if ($contents ne "") { | ||
| 2039 | $contents .= "\n"; | ||
| 2040 | dump_section($file, $section, $contents); | ||
| 2041 | $section = $section_default; | ||
| 2042 | $contents = ""; | ||
| 2043 | } | ||
| 2044 | } elsif (/$doc_inline_start/) { | ||
| 2045 | $state = STATE_INLINE; | ||
| 2046 | $inline_doc_state = STATE_INLINE_NAME; | ||
| 2047 | } elsif ($decl_type eq 'function') { | ||
| 2048 | process_proto_function($_, $file); | ||
| 2049 | } else { | ||
| 2050 | process_proto_type($_, $file); | ||
| 2051 | } | ||
| 2052 | } | ||
| 2053 | |||
| 2054 | # | ||
| 2055 | # STATE_DOCBLOCK: within a DOC: block. | ||
| 2056 | # | ||
| 2057 | sub process_docblock($$) { | ||
| 2058 | my $file = shift; | ||
| 2059 | |||
| 2060 | if (/$doc_end/) { | ||
| 2061 | dump_doc_section($file, $section, $contents); | ||
| 2062 | $section = $section_default; | ||
| 2063 | $contents = ""; | ||
| 2064 | $function = ""; | ||
| 2065 | %parameterdescs = (); | ||
| 2066 | %parametertypes = (); | ||
| 2067 | @parameterlist = (); | ||
| 2068 | %sections = (); | ||
| 2069 | @sectionlist = (); | ||
| 2070 | $prototype = ""; | ||
| 2071 | $state = STATE_NORMAL; | ||
| 2072 | } elsif (/$doc_content/) { | ||
| 2073 | if ( $1 eq "" ) { | ||
| 2074 | $contents .= $blankline; | ||
| 2075 | } else { | ||
| 2076 | $contents .= $1 . "\n"; | ||
| 2077 | } | ||
| 2078 | } | ||
| 2079 | } | ||
| 2080 | |||
| 2081 | # | ||
| 2082 | # STATE_INLINE: docbook comments within a prototype. | ||
| 2083 | # | ||
| 2084 | sub process_inline($$) { | ||
| 2085 | my $file = shift; | ||
| 2086 | |||
| 2087 | # First line (state 1) needs to be a @parameter | ||
| 2088 | if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { | ||
| 2089 | $section = $1; | ||
| 2090 | $contents = $2; | ||
| 2091 | $new_start_line = $.; | ||
| 2092 | if ($contents ne "") { | ||
| 2093 | while (substr($contents, 0, 1) eq " ") { | ||
| 2094 | $contents = substr($contents, 1); | ||
| 2095 | } | ||
| 2096 | $contents .= "\n"; | ||
| 2097 | } | ||
| 2098 | $inline_doc_state = STATE_INLINE_TEXT; | ||
| 2099 | # Documentation block end */ | ||
| 2100 | } elsif (/$doc_inline_end/) { | ||
| 2101 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 2102 | dump_section($file, $section, $contents); | ||
| 2103 | $section = $section_default; | ||
| 2104 | $contents = ""; | ||
| 2105 | } | ||
| 2106 | $state = STATE_PROTO; | ||
| 2107 | $inline_doc_state = STATE_INLINE_NA; | ||
| 2108 | # Regular text | ||
| 2109 | } elsif (/$doc_content/) { | ||
| 2110 | if ($inline_doc_state == STATE_INLINE_TEXT) { | ||
| 2111 | $contents .= $1 . "\n"; | ||
| 2112 | # nuke leading blank lines | ||
| 2113 | if ($contents =~ /^\s*$/) { | ||
| 2114 | $contents = ""; | ||
| 2115 | } | ||
| 2116 | } elsif ($inline_doc_state == STATE_INLINE_NAME) { | ||
| 2117 | $inline_doc_state = STATE_INLINE_ERROR; | ||
| 2118 | print STDERR "${file}:$.: warning: "; | ||
| 2119 | print STDERR "Incorrect use of kernel-doc format: $_"; | ||
| 2120 | ++$warnings; | ||
| 2121 | } | ||
| 2122 | } | ||
| 2123 | } | ||
| 2124 | |||
| 2125 | |||
| 2126 | sub process_file($) { | ||
| 2127 | my $file; | ||
| 1835 | my $initial_section_counter = $section_counter; | 2128 | my $initial_section_counter = $section_counter; |
| 1836 | my ($orig_file) = @_; | 2129 | my ($orig_file) = @_; |
| 1837 | my $leading_space; | ||
| 1838 | 2130 | ||
| 1839 | $file = map_filename($orig_file); | 2131 | $file = map_filename($orig_file); |
| 1840 | 2132 | ||
| @@ -1853,250 +2145,23 @@ sub process_file($) { | |||
| 1853 | } | 2145 | } |
| 1854 | # Replace tabs by spaces | 2146 | # Replace tabs by spaces |
| 1855 | while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; | 2147 | while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}; |
| 2148 | # Hand this line to the appropriate state handler | ||
| 1856 | if ($state == STATE_NORMAL) { | 2149 | if ($state == STATE_NORMAL) { |
| 1857 | if (/$doc_start/o) { | 2150 | process_normal(); |
| 1858 | $state = STATE_NAME; # next line is always the function name | 2151 | } elsif ($state == STATE_NAME) { |
| 1859 | $in_doc_sect = 0; | 2152 | process_name($file, $_); |
| 1860 | $declaration_start_line = $. + 1; | 2153 | } elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) { |
| 1861 | } | 2154 | process_body($file, $_); |
| 1862 | } elsif ($state == STATE_NAME) {# this line is the function name (always) | ||
| 1863 | if (/$doc_block/o) { | ||
| 1864 | $state = STATE_DOCBLOCK; | ||
| 1865 | $contents = ""; | ||
| 1866 | $new_start_line = $. + 1; | ||
| 1867 | |||
| 1868 | if ( $1 eq "" ) { | ||
| 1869 | $section = $section_intro; | ||
| 1870 | } else { | ||
| 1871 | $section = $1; | ||
| 1872 | } | ||
| 1873 | } | ||
| 1874 | elsif (/$doc_decl/o) { | ||
| 1875 | $identifier = $1; | ||
| 1876 | if (/\s*([\w\s]+?)\s*-/) { | ||
| 1877 | $identifier = $1; | ||
| 1878 | } | ||
| 1879 | |||
| 1880 | $state = STATE_FIELD; | ||
| 1881 | # if there's no @param blocks need to set up default section | ||
| 1882 | # here | ||
| 1883 | $contents = ""; | ||
| 1884 | $section = $section_default; | ||
| 1885 | $new_start_line = $. + 1; | ||
| 1886 | if (/-(.*)/) { | ||
| 1887 | # strip leading/trailing/multiple spaces | ||
| 1888 | $descr= $1; | ||
| 1889 | $descr =~ s/^\s*//; | ||
| 1890 | $descr =~ s/\s*$//; | ||
| 1891 | $descr =~ s/\s+/ /g; | ||
| 1892 | $declaration_purpose = xml_escape($descr); | ||
| 1893 | $in_purpose = 1; | ||
| 1894 | } else { | ||
| 1895 | $declaration_purpose = ""; | ||
| 1896 | } | ||
| 1897 | |||
| 1898 | if (($declaration_purpose eq "") && $verbose) { | ||
| 1899 | print STDERR "${file}:$.: warning: missing initial short description on line:\n"; | ||
| 1900 | print STDERR $_; | ||
| 1901 | ++$warnings; | ||
| 1902 | } | ||
| 1903 | |||
| 1904 | if ($identifier =~ m/^struct/) { | ||
| 1905 | $decl_type = 'struct'; | ||
| 1906 | } elsif ($identifier =~ m/^union/) { | ||
| 1907 | $decl_type = 'union'; | ||
| 1908 | } elsif ($identifier =~ m/^enum/) { | ||
| 1909 | $decl_type = 'enum'; | ||
| 1910 | } elsif ($identifier =~ m/^typedef/) { | ||
| 1911 | $decl_type = 'typedef'; | ||
| 1912 | } else { | ||
| 1913 | $decl_type = 'function'; | ||
| 1914 | } | ||
| 1915 | |||
| 1916 | if ($verbose) { | ||
| 1917 | print STDERR "${file}:$.: info: Scanning doc for $identifier\n"; | ||
| 1918 | } | ||
| 1919 | } else { | ||
| 1920 | print STDERR "${file}:$.: warning: Cannot understand $_ on line $.", | ||
| 1921 | " - I thought it was a doc line\n"; | ||
| 1922 | ++$warnings; | ||
| 1923 | $state = STATE_NORMAL; | ||
| 1924 | } | ||
| 1925 | } elsif ($state == STATE_FIELD) { # look for head: lines, and include content | ||
| 1926 | if (/$doc_sect/i) { # case insensitive for supported section names | ||
| 1927 | $newsection = $1; | ||
| 1928 | $newcontents = $2; | ||
| 1929 | |||
| 1930 | # map the supported section names to the canonical names | ||
| 1931 | if ($newsection =~ m/^description$/i) { | ||
| 1932 | $newsection = $section_default; | ||
| 1933 | } elsif ($newsection =~ m/^context$/i) { | ||
| 1934 | $newsection = $section_context; | ||
| 1935 | } elsif ($newsection =~ m/^returns?$/i) { | ||
| 1936 | $newsection = $section_return; | ||
| 1937 | } elsif ($newsection =~ m/^\@return$/) { | ||
| 1938 | # special: @return is a section, not a param description | ||
| 1939 | $newsection = $section_return; | ||
| 1940 | } | ||
| 1941 | |||
| 1942 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 1943 | if (!$in_doc_sect && $verbose) { | ||
| 1944 | print STDERR "${file}:$.: warning: contents before sections\n"; | ||
| 1945 | ++$warnings; | ||
| 1946 | } | ||
| 1947 | dump_section($file, $section, xml_escape($contents)); | ||
| 1948 | $section = $section_default; | ||
| 1949 | } | ||
| 1950 | |||
| 1951 | $in_doc_sect = 1; | ||
| 1952 | $in_purpose = 0; | ||
| 1953 | $contents = $newcontents; | ||
| 1954 | $new_start_line = $.; | ||
| 1955 | while (substr($contents, 0, 1) eq " ") { | ||
| 1956 | $contents = substr($contents, 1); | ||
| 1957 | } | ||
| 1958 | if ($contents ne "") { | ||
| 1959 | $contents .= "\n"; | ||
| 1960 | } | ||
| 1961 | $section = $newsection; | ||
| 1962 | $leading_space = undef; | ||
| 1963 | } elsif (/$doc_end/) { | ||
| 1964 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 1965 | dump_section($file, $section, xml_escape($contents)); | ||
| 1966 | $section = $section_default; | ||
| 1967 | $contents = ""; | ||
| 1968 | } | ||
| 1969 | # look for doc_com + <text> + doc_end: | ||
| 1970 | if ($_ =~ m'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') { | ||
| 1971 | print STDERR "${file}:$.: warning: suspicious ending line: $_"; | ||
| 1972 | ++$warnings; | ||
| 1973 | } | ||
| 1974 | |||
| 1975 | $prototype = ""; | ||
| 1976 | $state = STATE_PROTO; | ||
| 1977 | $brcount = 0; | ||
| 1978 | # print STDERR "end of doc comment, looking for prototype\n"; | ||
| 1979 | } elsif (/$doc_content/) { | ||
| 1980 | # miguel-style comment kludge, look for blank lines after | ||
| 1981 | # @parameter line to signify start of description | ||
| 1982 | if ($1 eq "") { | ||
| 1983 | if ($section =~ m/^@/ || $section eq $section_context) { | ||
| 1984 | dump_section($file, $section, xml_escape($contents)); | ||
| 1985 | $section = $section_default; | ||
| 1986 | $contents = ""; | ||
| 1987 | $new_start_line = $.; | ||
| 1988 | } else { | ||
| 1989 | $contents .= "\n"; | ||
| 1990 | } | ||
| 1991 | $in_purpose = 0; | ||
| 1992 | } elsif ($in_purpose == 1) { | ||
| 1993 | # Continued declaration purpose | ||
| 1994 | chomp($declaration_purpose); | ||
| 1995 | $declaration_purpose .= " " . xml_escape($1); | ||
| 1996 | $declaration_purpose =~ s/\s+/ /g; | ||
| 1997 | } else { | ||
| 1998 | my $cont = $1; | ||
| 1999 | if ($section =~ m/^@/ || $section eq $section_context) { | ||
| 2000 | if (!defined $leading_space) { | ||
| 2001 | if ($cont =~ m/^(\s+)/) { | ||
| 2002 | $leading_space = $1; | ||
| 2003 | } else { | ||
| 2004 | $leading_space = ""; | ||
| 2005 | } | ||
| 2006 | } | ||
| 2007 | |||
| 2008 | $cont =~ s/^$leading_space//; | ||
| 2009 | } | ||
| 2010 | $contents .= $cont . "\n"; | ||
| 2011 | } | ||
| 2012 | } else { | ||
| 2013 | # i dont know - bad line? ignore. | ||
| 2014 | print STDERR "${file}:$.: warning: bad line: $_"; | ||
| 2015 | ++$warnings; | ||
| 2016 | } | ||
| 2017 | } elsif ($state == STATE_INLINE) { # scanning for inline parameters | 2155 | } elsif ($state == STATE_INLINE) { # scanning for inline parameters |
| 2018 | # First line (state 1) needs to be a @parameter | 2156 | process_inline($file, $_); |
| 2019 | if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) { | 2157 | } elsif ($state == STATE_PROTO) { |
| 2020 | $section = $1; | 2158 | process_proto($file, $_); |
| 2021 | $contents = $2; | ||
| 2022 | $new_start_line = $.; | ||
| 2023 | if ($contents ne "") { | ||
| 2024 | while (substr($contents, 0, 1) eq " ") { | ||
| 2025 | $contents = substr($contents, 1); | ||
| 2026 | } | ||
| 2027 | $contents .= "\n"; | ||
| 2028 | } | ||
| 2029 | $inline_doc_state = STATE_INLINE_TEXT; | ||
| 2030 | # Documentation block end */ | ||
| 2031 | } elsif (/$doc_inline_end/) { | ||
| 2032 | if (($contents ne "") && ($contents ne "\n")) { | ||
| 2033 | dump_section($file, $section, xml_escape($contents)); | ||
| 2034 | $section = $section_default; | ||
| 2035 | $contents = ""; | ||
| 2036 | } | ||
| 2037 | $state = STATE_PROTO; | ||
| 2038 | $inline_doc_state = STATE_INLINE_NA; | ||
| 2039 | # Regular text | ||
| 2040 | } elsif (/$doc_content/) { | ||
| 2041 | if ($inline_doc_state == STATE_INLINE_TEXT) { | ||
| 2042 | $contents .= $1 . "\n"; | ||
| 2043 | # nuke leading blank lines | ||
| 2044 | if ($contents =~ /^\s*$/) { | ||
| 2045 | $contents = ""; | ||
| 2046 | } | ||
| 2047 | } elsif ($inline_doc_state == STATE_INLINE_NAME) { | ||
| 2048 | $inline_doc_state = STATE_INLINE_ERROR; | ||
| 2049 | print STDERR "${file}:$.: warning: "; | ||
| 2050 | print STDERR "Incorrect use of kernel-doc format: $_"; | ||
| 2051 | ++$warnings; | ||
| 2052 | } | ||
| 2053 | } | ||
| 2054 | } elsif ($state == STATE_PROTO) { # scanning for function '{' (end of prototype) | ||
| 2055 | if (/$doc_inline_oneline/) { | ||
| 2056 | $section = $1; | ||
| 2057 | $contents = $2; | ||
| 2058 | if ($contents ne "") { | ||
| 2059 | $contents .= "\n"; | ||
| 2060 | dump_section($file, $section, xml_escape($contents)); | ||
| 2061 | $section = $section_default; | ||
| 2062 | $contents = ""; | ||
| 2063 | } | ||
| 2064 | } elsif (/$doc_inline_start/) { | ||
| 2065 | $state = STATE_INLINE; | ||
| 2066 | $inline_doc_state = STATE_INLINE_NAME; | ||
| 2067 | } elsif ($decl_type eq 'function') { | ||
| 2068 | process_proto_function($_, $file); | ||
| 2069 | } else { | ||
| 2070 | process_proto_type($_, $file); | ||
| 2071 | } | ||
| 2072 | } elsif ($state == STATE_DOCBLOCK) { | 2159 | } elsif ($state == STATE_DOCBLOCK) { |
| 2073 | if (/$doc_end/) | 2160 | process_docblock($file, $_); |
| 2074 | { | ||
| 2075 | dump_doc_section($file, $section, xml_escape($contents)); | ||
| 2076 | $section = $section_default; | ||
| 2077 | $contents = ""; | ||
| 2078 | $function = ""; | ||
| 2079 | %parameterdescs = (); | ||
| 2080 | %parametertypes = (); | ||
| 2081 | @parameterlist = (); | ||
| 2082 | %sections = (); | ||
| 2083 | @sectionlist = (); | ||
| 2084 | $prototype = ""; | ||
| 2085 | $state = STATE_NORMAL; | ||
| 2086 | } | ||
| 2087 | elsif (/$doc_content/) | ||
| 2088 | { | ||
| 2089 | if ( $1 eq "" ) | ||
| 2090 | { | ||
| 2091 | $contents .= $blankline; | ||
| 2092 | } | ||
| 2093 | else | ||
| 2094 | { | ||
| 2095 | $contents .= $1 . "\n"; | ||
| 2096 | } | ||
| 2097 | } | ||
| 2098 | } | 2161 | } |
| 2099 | } | 2162 | } |
| 2163 | |||
| 2164 | # Make sure we got something interesting. | ||
| 2100 | if ($initial_section_counter == $section_counter) { | 2165 | if ($initial_section_counter == $section_counter) { |
| 2101 | if ($output_mode ne "none") { | 2166 | if ($output_mode ne "none") { |
| 2102 | print STDERR "${file}:1: warning: no structured comments found\n"; | 2167 | print STDERR "${file}:1: warning: no structured comments found\n"; |
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index bc5788000018..6a897788f5a7 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl | |||
| @@ -3,15 +3,20 @@ | |||
| 3 | # (c) 2017 Tobin C. Harding <me@tobin.cc> | 3 | # (c) 2017 Tobin C. Harding <me@tobin.cc> |
| 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 | # leaking_addresses.pl: Scan 64 bit kernel for potential leaking addresses. | 6 | # leaking_addresses.pl: Scan the kernel for potential leaking addresses. |
| 7 | # - Scans dmesg output. | 7 | # - Scans dmesg output. |
| 8 | # - Walks directory tree and parses each file (for each directory in @DIRS). | 8 | # - Walks directory tree and parses each file (for each directory in @DIRS). |
| 9 | # | 9 | # |
| 10 | # Use --debug to output path before parsing, this is useful to find files that | 10 | # Use --debug to output path before parsing, this is useful to find files that |
| 11 | # cause the script to choke. | 11 | # cause the script to choke. |
| 12 | |||
| 12 | # | 13 | # |
| 13 | # You may like to set kptr_restrict=2 before running script | 14 | # When the system is idle it is likely that most files under /proc/PID will be |
| 14 | # (see Documentation/sysctl/kernel.txt). | 15 | # identical for various processes. Scanning _all_ the PIDs under /proc is |
| 16 | # unnecessary and implies that we are thoroughly scanning /proc. This is _not_ | ||
| 17 | # the case because there may be ways userspace can trigger creation of /proc | ||
| 18 | # files that leak addresses but were not present during a scan. For these two | ||
| 19 | # reasons we exclude all PID directories under /proc except '1/' | ||
| 15 | 20 | ||
| 16 | use warnings; | 21 | use warnings; |
| 17 | use strict; | 22 | use strict; |
| @@ -22,9 +27,10 @@ use Cwd 'abs_path'; | |||
| 22 | use Term::ANSIColor qw(:constants); | 27 | use Term::ANSIColor qw(:constants); |
| 23 | use Getopt::Long qw(:config no_auto_abbrev); | 28 | use Getopt::Long qw(:config no_auto_abbrev); |
| 24 | use Config; | 29 | use Config; |
| 30 | use bigint qw/hex/; | ||
| 31 | use feature 'state'; | ||
| 25 | 32 | ||
| 26 | my $P = $0; | 33 | my $P = $0; |
| 27 | my $V = '0.01'; | ||
| 28 | 34 | ||
| 29 | # Directories to scan. | 35 | # Directories to scan. |
| 30 | my @DIRS = ('/proc', '/sys'); | 36 | my @DIRS = ('/proc', '/sys'); |
| @@ -32,10 +38,9 @@ my @DIRS = ('/proc', '/sys'); | |||
| 32 | # Timer for parsing each file, in seconds. | 38 | # Timer for parsing each file, in seconds. |
| 33 | my $TIMEOUT = 10; | 39 | my $TIMEOUT = 10; |
| 34 | 40 | ||
| 35 | # Script can only grep for kernel addresses on the following architectures. If | 41 | # Kernel addresses vary by architecture. We can only auto-detect the following |
| 36 | # your architecture is not listed here and has a grep'able kernel address please | 42 | # architectures (using `uname -m`). (flag --32-bit overrides auto-detection.) |
| 37 | # consider submitting a patch. | 43 | my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64', 'x86'); |
| 38 | my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64'); | ||
| 39 | 44 | ||
| 40 | # Command line options. | 45 | # Command line options. |
| 41 | my $help = 0; | 46 | my $help = 0; |
| @@ -43,46 +48,34 @@ my $debug = 0; | |||
| 43 | my $raw = 0; | 48 | my $raw = 0; |
| 44 | my $output_raw = ""; # Write raw results to file. | 49 | my $output_raw = ""; # Write raw results to file. |
| 45 | my $input_raw = ""; # Read raw results from file instead of scanning. | 50 | my $input_raw = ""; # Read raw results from file instead of scanning. |
| 46 | |||
| 47 | my $suppress_dmesg = 0; # Don't show dmesg in output. | 51 | my $suppress_dmesg = 0; # Don't show dmesg in output. |
| 48 | my $squash_by_path = 0; # Summary report grouped by absolute path. | 52 | my $squash_by_path = 0; # Summary report grouped by absolute path. |
| 49 | my $squash_by_filename = 0; # Summary report grouped by filename. | 53 | my $squash_by_filename = 0; # Summary report grouped by filename. |
| 50 | 54 | my $kernel_config_file = ""; # Kernel configuration file. | |
| 51 | # Do not parse these files (absolute path). | 55 | my $opt_32bit = 0; # Scan 32-bit kernel. |
| 52 | my @skip_parse_files_abs = ('/proc/kmsg', | 56 | my $page_offset_32bit = 0; # Page offset for 32-bit kernel. |
| 53 | '/proc/kcore', | 57 | |
| 54 | '/proc/fs/ext4/sdb1/mb_groups', | 58 | # Skip these absolute paths. |
| 55 | '/proc/1/fd/3', | 59 | my @skip_abs = ( |
| 56 | '/sys/firmware/devicetree', | 60 | '/proc/kmsg', |
| 57 | '/proc/device-tree', | 61 | '/proc/device-tree', |
| 58 | '/sys/kernel/debug/tracing/trace_pipe', | 62 | '/proc/1/syscall', |
| 59 | '/sys/kernel/security/apparmor/revision'); | 63 | '/sys/firmware/devicetree', |
| 60 | 64 | '/sys/kernel/debug/tracing/trace_pipe', | |
| 61 | # Do not parse these files under any subdirectory. | 65 | '/sys/kernel/security/apparmor/revision'); |
| 62 | my @skip_parse_files_any = ('0', | 66 | |
| 63 | '1', | 67 | # Skip these under any subdirectory. |
| 64 | '2', | 68 | my @skip_any = ( |
| 65 | 'pagemap', | 69 | 'pagemap', |
| 66 | 'events', | 70 | 'events', |
| 67 | 'access', | 71 | 'access', |
| 68 | 'registers', | 72 | 'registers', |
| 69 | 'snapshot_raw', | 73 | 'snapshot_raw', |
| 70 | 'trace_pipe_raw', | 74 | 'trace_pipe_raw', |
| 71 | 'ptmx', | 75 | 'ptmx', |
| 72 | 'trace_pipe'); | 76 | 'trace_pipe', |
| 73 | 77 | 'fd', | |
| 74 | # Do not walk these directories (absolute path). | 78 | 'usbmon'); |
| 75 | my @skip_walk_dirs_abs = (); | ||
| 76 | |||
| 77 | # Do not walk these directories under any subdirectory. | ||
| 78 | my @skip_walk_dirs_any = ('self', | ||
| 79 | 'thread-self', | ||
| 80 | 'cwd', | ||
| 81 | 'fd', | ||
| 82 | 'usbmon', | ||
| 83 | 'stderr', | ||
| 84 | 'stdin', | ||
| 85 | 'stdout'); | ||
| 86 | 79 | ||
| 87 | sub help | 80 | sub help |
| 88 | { | 81 | { |
| @@ -91,31 +84,22 @@ sub help | |||
| 91 | print << "EOM"; | 84 | print << "EOM"; |
| 92 | 85 | ||
| 93 | Usage: $P [OPTIONS] | 86 | Usage: $P [OPTIONS] |
| 94 | Version: $V | ||
| 95 | 87 | ||
| 96 | Options: | 88 | Options: |
| 97 | 89 | ||
| 98 | -o, --output-raw=<file> Save results for future processing. | 90 | -o, --output-raw=<file> Save results for future processing. |
| 99 | -i, --input-raw=<file> Read results from file instead of scanning. | 91 | -i, --input-raw=<file> Read results from file instead of scanning. |
| 100 | --raw Show raw results (default). | 92 | --raw Show raw results (default). |
| 101 | --suppress-dmesg Do not show dmesg results. | 93 | --suppress-dmesg Do not show dmesg results. |
| 102 | --squash-by-path Show one result per unique path. | 94 | --squash-by-path Show one result per unique path. |
| 103 | --squash-by-filename Show one result per unique filename. | 95 | --squash-by-filename Show one result per unique filename. |
| 104 | -d, --debug Display debugging output. | 96 | --kernel-config-file=<file> Kernel configuration file (e.g /boot/config) |
| 105 | -h, --help, --version Display this help and exit. | 97 | --32-bit Scan 32-bit kernel. |
| 106 | 98 | --page-offset-32-bit=o Page offset (for 32-bit kernel 0xABCD1234). | |
| 107 | Examples: | 99 | -d, --debug Display debugging output. |
| 108 | 100 | -h, --help, --version Display this help and exit. | |
| 109 | # Scan kernel and dump raw results. | ||
| 110 | $0 | ||
| 111 | |||
| 112 | # Scan kernel and save results to file. | ||
| 113 | $0 --output-raw scan.out | ||
| 114 | 101 | ||
| 115 | # View summary report. | 102 | Scans the running kernel for potential leaking addresses. |
| 116 | $0 --input-raw scan.out --squash-by-filename | ||
| 117 | |||
| 118 | Scans the running (64 bit) kernel for potential leaking addresses. | ||
| 119 | 103 | ||
| 120 | EOM | 104 | EOM |
| 121 | exit($exitcode); | 105 | exit($exitcode); |
| @@ -131,6 +115,9 @@ GetOptions( | |||
| 131 | 'squash-by-path' => \$squash_by_path, | 115 | 'squash-by-path' => \$squash_by_path, |
| 132 | 'squash-by-filename' => \$squash_by_filename, | 116 | 'squash-by-filename' => \$squash_by_filename, |
| 133 | 'raw' => \$raw, | 117 | 'raw' => \$raw, |
| 118 | 'kernel-config-file=s' => \$kernel_config_file, | ||
| 119 | '32-bit' => \$opt_32bit, | ||
| 120 | 'page-offset-32-bit=o' => \$page_offset_32bit, | ||
| 134 | ) or help(1); | 121 | ) or help(1); |
| 135 | 122 | ||
| 136 | help(0) if ($help); | 123 | help(0) if ($help); |
| @@ -146,16 +133,19 @@ if (!$input_raw and ($squash_by_path or $squash_by_filename)) { | |||
| 146 | exit(128); | 133 | exit(128); |
| 147 | } | 134 | } |
| 148 | 135 | ||
| 149 | if (!is_supported_architecture()) { | 136 | if (!(is_supported_architecture() or $opt_32bit or $page_offset_32bit)) { |
| 150 | printf "\nScript does not support your architecture, sorry.\n"; | 137 | printf "\nScript does not support your architecture, sorry.\n"; |
| 151 | printf "\nCurrently we support: \n\n"; | 138 | printf "\nCurrently we support: \n\n"; |
| 152 | foreach(@SUPPORTED_ARCHITECTURES) { | 139 | foreach(@SUPPORTED_ARCHITECTURES) { |
| 153 | printf "\t%s\n", $_; | 140 | printf "\t%s\n", $_; |
| 154 | } | 141 | } |
| 142 | printf("\n"); | ||
| 143 | |||
| 144 | printf("If you are running a 32-bit architecture you may use:\n"); | ||
| 145 | printf("\n\t--32-bit or --page-offset-32-bit=<page offset>\n\n"); | ||
| 155 | 146 | ||
| 156 | my $archname = $Config{archname}; | 147 | my $archname = `uname -m`; |
| 157 | printf "\n\$ perl -MConfig -e \'print \"\$Config{archname}\\n\"\'\n"; | 148 | printf("Machine hardware name (`uname -m`): %s\n", $archname); |
| 158 | printf "%s\n", $archname; | ||
| 159 | 149 | ||
| 160 | exit(129); | 150 | exit(129); |
| 161 | } | 151 | } |
| @@ -177,49 +167,183 @@ sub dprint | |||
| 177 | 167 | ||
| 178 | sub is_supported_architecture | 168 | sub is_supported_architecture |
| 179 | { | 169 | { |
| 180 | return (is_x86_64() or is_ppc64()); | 170 | return (is_x86_64() or is_ppc64() or is_ix86_32()); |
| 181 | } | 171 | } |
| 182 | 172 | ||
| 183 | sub is_x86_64 | 173 | sub is_32bit |
| 184 | { | 174 | { |
| 185 | my $archname = $Config{archname}; | 175 | # Allow --32-bit or --page-offset-32-bit to override |
| 186 | 176 | if ($opt_32bit or $page_offset_32bit) { | |
| 187 | if ($archname =~ m/x86_64/) { | ||
| 188 | return 1; | 177 | return 1; |
| 189 | } | 178 | } |
| 190 | return 0; | 179 | |
| 180 | return is_ix86_32(); | ||
| 181 | } | ||
| 182 | |||
| 183 | sub is_ix86_32 | ||
| 184 | { | ||
| 185 | state $arch = `uname -m`; | ||
| 186 | |||
| 187 | chomp $arch; | ||
| 188 | if ($arch =~ m/i[3456]86/) { | ||
| 189 | return 1; | ||
| 190 | } | ||
| 191 | return 0; | ||
| 192 | } | ||
| 193 | |||
| 194 | sub is_arch | ||
| 195 | { | ||
| 196 | my ($desc) = @_; | ||
| 197 | my $arch = `uname -m`; | ||
| 198 | |||
| 199 | chomp $arch; | ||
| 200 | if ($arch eq $desc) { | ||
| 201 | return 1; | ||
| 202 | } | ||
| 203 | return 0; | ||
| 204 | } | ||
| 205 | |||
| 206 | sub is_x86_64 | ||
| 207 | { | ||
| 208 | state $is = is_arch('x86_64'); | ||
| 209 | return $is; | ||
| 191 | } | 210 | } |
| 192 | 211 | ||
| 193 | sub is_ppc64 | 212 | sub is_ppc64 |
| 194 | { | 213 | { |
| 195 | my $archname = $Config{archname}; | 214 | state $is = is_arch('ppc64'); |
| 215 | return $is; | ||
| 216 | } | ||
| 196 | 217 | ||
| 197 | if ($archname =~ m/powerpc/ and $archname =~ m/64/) { | 218 | # Gets config option value from kernel config file. |
| 198 | return 1; | 219 | # Returns "" on error or if config option not found. |
| 220 | sub get_kernel_config_option | ||
| 221 | { | ||
| 222 | my ($option) = @_; | ||
| 223 | my $value = ""; | ||
| 224 | my $tmp_file = ""; | ||
| 225 | my @config_files; | ||
| 226 | |||
| 227 | # Allow --kernel-config-file to override. | ||
| 228 | if ($kernel_config_file ne "") { | ||
| 229 | @config_files = ($kernel_config_file); | ||
| 230 | } elsif (-R "/proc/config.gz") { | ||
| 231 | my $tmp_file = "/tmp/tmpkconf"; | ||
| 232 | |||
| 233 | if (system("gunzip < /proc/config.gz > $tmp_file")) { | ||
| 234 | dprint "$0: system(gunzip < /proc/config.gz) failed\n"; | ||
| 235 | return ""; | ||
| 236 | } else { | ||
| 237 | @config_files = ($tmp_file); | ||
| 238 | } | ||
| 239 | } else { | ||
| 240 | my $file = '/boot/config-' . `uname -r`; | ||
| 241 | chomp $file; | ||
| 242 | @config_files = ($file, '/boot/config'); | ||
| 199 | } | 243 | } |
| 200 | return 0; | 244 | |
| 245 | foreach my $file (@config_files) { | ||
| 246 | dprint("parsing config file: %s\n", $file); | ||
| 247 | $value = option_from_file($option, $file); | ||
| 248 | if ($value ne "") { | ||
| 249 | last; | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | if ($tmp_file ne "") { | ||
| 254 | system("rm -f $tmp_file"); | ||
| 255 | } | ||
| 256 | |||
| 257 | return $value; | ||
| 258 | } | ||
| 259 | |||
| 260 | # Parses $file and returns kernel configuration option value. | ||
| 261 | sub option_from_file | ||
| 262 | { | ||
| 263 | my ($option, $file) = @_; | ||
| 264 | my $str = ""; | ||
| 265 | my $val = ""; | ||
| 266 | |||
| 267 | open(my $fh, "<", $file) or return ""; | ||
| 268 | while (my $line = <$fh> ) { | ||
| 269 | if ($line =~ /^$option/) { | ||
| 270 | ($str, $val) = split /=/, $line; | ||
| 271 | chomp $val; | ||
| 272 | last; | ||
| 273 | } | ||
| 274 | } | ||
| 275 | |||
| 276 | close $fh; | ||
| 277 | return $val; | ||
| 201 | } | 278 | } |
| 202 | 279 | ||
| 203 | sub is_false_positive | 280 | sub is_false_positive |
| 204 | { | 281 | { |
| 205 | my ($match) = @_; | 282 | my ($match) = @_; |
| 206 | 283 | ||
| 284 | if (is_32bit()) { | ||
| 285 | return is_false_positive_32bit($match); | ||
| 286 | } | ||
| 287 | |||
| 288 | # 64 bit false positives. | ||
| 289 | |||
| 207 | if ($match =~ '\b(0x)?(f|F){16}\b' or | 290 | if ($match =~ '\b(0x)?(f|F){16}\b' or |
| 208 | $match =~ '\b(0x)?0{16}\b') { | 291 | $match =~ '\b(0x)?0{16}\b') { |
| 209 | return 1; | 292 | return 1; |
| 210 | } | 293 | } |
| 211 | 294 | ||
| 212 | if (is_x86_64) { | 295 | if (is_x86_64() and is_in_vsyscall_memory_region($match)) { |
| 213 | # vsyscall memory region, we should probably check against a range here. | 296 | return 1; |
| 214 | if ($match =~ '\bf{10}600000\b' or | ||
| 215 | $match =~ '\bf{10}601000\b') { | ||
| 216 | return 1; | ||
| 217 | } | ||
| 218 | } | 297 | } |
| 219 | 298 | ||
| 220 | return 0; | 299 | return 0; |
| 221 | } | 300 | } |
| 222 | 301 | ||
| 302 | sub is_false_positive_32bit | ||
| 303 | { | ||
| 304 | my ($match) = @_; | ||
| 305 | state $page_offset = get_page_offset(); | ||
| 306 | |||
| 307 | if ($match =~ '\b(0x)?(f|F){8}\b') { | ||
| 308 | return 1; | ||
| 309 | } | ||
| 310 | |||
| 311 | if (hex($match) < $page_offset) { | ||
| 312 | return 1; | ||
| 313 | } | ||
| 314 | |||
| 315 | return 0; | ||
| 316 | } | ||
| 317 | |||
| 318 | # returns integer value | ||
| 319 | sub get_page_offset | ||
| 320 | { | ||
| 321 | my $page_offset; | ||
| 322 | my $default_offset = 0xc0000000; | ||
| 323 | |||
| 324 | # Allow --page-offset-32bit to override. | ||
| 325 | if ($page_offset_32bit != 0) { | ||
| 326 | return $page_offset_32bit; | ||
| 327 | } | ||
| 328 | |||
| 329 | $page_offset = get_kernel_config_option('CONFIG_PAGE_OFFSET'); | ||
| 330 | if (!$page_offset) { | ||
| 331 | return $default_offset; | ||
| 332 | } | ||
| 333 | return $page_offset; | ||
| 334 | } | ||
| 335 | |||
| 336 | sub is_in_vsyscall_memory_region | ||
| 337 | { | ||
| 338 | my ($match) = @_; | ||
| 339 | |||
| 340 | my $hex = hex($match); | ||
| 341 | my $region_min = hex("0xffffffffff600000"); | ||
| 342 | my $region_max = hex("0xffffffffff601000"); | ||
| 343 | |||
| 344 | return ($hex >= $region_min and $hex <= $region_max); | ||
| 345 | } | ||
| 346 | |||
| 223 | # True if argument potentially contains a kernel address. | 347 | # True if argument potentially contains a kernel address. |
| 224 | sub may_leak_address | 348 | sub may_leak_address |
| 225 | { | 349 | { |
| @@ -238,14 +362,8 @@ sub may_leak_address | |||
| 238 | return 0; | 362 | return 0; |
| 239 | } | 363 | } |
| 240 | 364 | ||
| 241 | # One of these is guaranteed to be true. | 365 | $address_re = get_address_re(); |
| 242 | if (is_x86_64()) { | 366 | while ($line =~ /($address_re)/g) { |
| 243 | $address_re = '\b(0x)?ffff[[:xdigit:]]{12}\b'; | ||
| 244 | } elsif (is_ppc64()) { | ||
| 245 | $address_re = '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b'; | ||
| 246 | } | ||
| 247 | |||
| 248 | while (/($address_re)/g) { | ||
| 249 | if (!is_false_positive($1)) { | 367 | if (!is_false_positive($1)) { |
| 250 | return 1; | 368 | return 1; |
| 251 | } | 369 | } |
| @@ -254,6 +372,31 @@ sub may_leak_address | |||
| 254 | return 0; | 372 | return 0; |
| 255 | } | 373 | } |
| 256 | 374 | ||
| 375 | sub get_address_re | ||
| 376 | { | ||
| 377 | if (is_ppc64()) { | ||
| 378 | return '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b'; | ||
| 379 | } elsif (is_32bit()) { | ||
| 380 | return '\b(0x)?[[:xdigit:]]{8}\b'; | ||
| 381 | } | ||
| 382 | |||
| 383 | return get_x86_64_re(); | ||
| 384 | } | ||
| 385 | |||
| 386 | sub get_x86_64_re | ||
| 387 | { | ||
| 388 | # We handle page table levels but only if explicitly configured using | ||
| 389 | # CONFIG_PGTABLE_LEVELS. If config file parsing fails or config option | ||
| 390 | # is not found we default to using address regular expression suitable | ||
| 391 | # for 4 page table levels. | ||
| 392 | state $ptl = get_kernel_config_option('CONFIG_PGTABLE_LEVELS'); | ||
| 393 | |||
| 394 | if ($ptl == 5) { | ||
| 395 | return '\b(0x)?ff[[:xdigit:]]{14}\b'; | ||
| 396 | } | ||
| 397 | return '\b(0x)?ffff[[:xdigit:]]{12}\b'; | ||
| 398 | } | ||
| 399 | |||
| 257 | sub parse_dmesg | 400 | sub parse_dmesg |
| 258 | { | 401 | { |
| 259 | open my $cmd, '-|', 'dmesg'; | 402 | open my $cmd, '-|', 'dmesg'; |
| @@ -268,26 +411,20 @@ sub parse_dmesg | |||
| 268 | # True if we should skip this path. | 411 | # True if we should skip this path. |
| 269 | sub skip | 412 | sub skip |
| 270 | { | 413 | { |
| 271 | my ($path, $paths_abs, $paths_any) = @_; | 414 | my ($path) = @_; |
| 272 | 415 | ||
| 273 | foreach (@$paths_abs) { | 416 | foreach (@skip_abs) { |
| 274 | return 1 if (/^$path$/); | 417 | return 1 if (/^$path$/); |
| 275 | } | 418 | } |
| 276 | 419 | ||
| 277 | my($filename, $dirs, $suffix) = fileparse($path); | 420 | my($filename, $dirs, $suffix) = fileparse($path); |
| 278 | foreach (@$paths_any) { | 421 | foreach (@skip_any) { |
| 279 | return 1 if (/^$filename$/); | 422 | return 1 if (/^$filename$/); |
| 280 | } | 423 | } |
| 281 | 424 | ||
| 282 | return 0; | 425 | return 0; |
| 283 | } | 426 | } |
| 284 | 427 | ||
| 285 | sub skip_parse | ||
| 286 | { | ||
| 287 | my ($path) = @_; | ||
| 288 | return skip($path, \@skip_parse_files_abs, \@skip_parse_files_any); | ||
| 289 | } | ||
| 290 | |||
| 291 | sub timed_parse_file | 428 | sub timed_parse_file |
| 292 | { | 429 | { |
| 293 | my ($file) = @_; | 430 | my ($file) = @_; |
| @@ -313,11 +450,9 @@ sub parse_file | |||
| 313 | return; | 450 | return; |
| 314 | } | 451 | } |
| 315 | 452 | ||
| 316 | if (skip_parse($file)) { | 453 | if (! -T $file) { |
| 317 | dprint "skipping file: $file\n"; | ||
| 318 | return; | 454 | return; |
| 319 | } | 455 | } |
| 320 | dprint "parsing: $file\n"; | ||
| 321 | 456 | ||
| 322 | open my $fh, "<", $file or return; | 457 | open my $fh, "<", $file or return; |
| 323 | while ( <$fh> ) { | 458 | while ( <$fh> ) { |
| @@ -328,12 +463,14 @@ sub parse_file | |||
| 328 | close $fh; | 463 | close $fh; |
| 329 | } | 464 | } |
| 330 | 465 | ||
| 331 | 466 | # Checks if the actual path name is leaking a kernel address. | |
| 332 | # True if we should skip walking this directory. | 467 | sub check_path_for_leaks |
| 333 | sub skip_walk | ||
| 334 | { | 468 | { |
| 335 | my ($path) = @_; | 469 | my ($path) = @_; |
| 336 | return skip($path, \@skip_walk_dirs_abs, \@skip_walk_dirs_any) | 470 | |
| 471 | if (may_leak_address($path)) { | ||
| 472 | printf("Path name may contain address: $path\n"); | ||
| 473 | } | ||
| 337 | } | 474 | } |
| 338 | 475 | ||
| 339 | # Recursively walk directory tree. | 476 | # Recursively walk directory tree. |
| @@ -342,7 +479,6 @@ sub walk | |||
| 342 | my @dirs = @_; | 479 | my @dirs = @_; |
| 343 | 480 | ||
| 344 | while (my $pwd = shift @dirs) { | 481 | while (my $pwd = shift @dirs) { |
| 345 | next if (skip_walk($pwd)); | ||
| 346 | next if (!opendir(DIR, $pwd)); | 482 | next if (!opendir(DIR, $pwd)); |
| 347 | my @files = readdir(DIR); | 483 | my @files = readdir(DIR); |
| 348 | closedir(DIR); | 484 | closedir(DIR); |
| @@ -353,11 +489,21 @@ sub walk | |||
| 353 | my $path = "$pwd/$file"; | 489 | my $path = "$pwd/$file"; |
| 354 | next if (-l $path); | 490 | next if (-l $path); |
| 355 | 491 | ||
| 492 | # skip /proc/PID except /proc/1 | ||
| 493 | next if (($path =~ /^\/proc\/[0-9]+$/) && | ||
| 494 | ($path !~ /^\/proc\/1$/)); | ||
| 495 | |||
| 496 | next if (skip($path)); | ||
| 497 | |||
| 498 | check_path_for_leaks($path); | ||
| 499 | |||
| 356 | if (-d $path) { | 500 | if (-d $path) { |
| 357 | push @dirs, $path; | 501 | push @dirs, $path; |
| 358 | } else { | 502 | next; |
| 359 | timed_parse_file($path); | ||
| 360 | } | 503 | } |
| 504 | |||
| 505 | dprint "parsing: $path\n"; | ||
| 506 | timed_parse_file($path); | ||
| 361 | } | 507 | } |
| 362 | } | 508 | } |
| 363 | } | 509 | } |
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index be56a1153014..9045823c7be7 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | # link vmlinux | 4 | # link vmlinux |
| 5 | # | 5 | # |
| 6 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and | 6 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and |
| 7 | # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.o files | 7 | # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files |
| 8 | # from top-level directories in the kernel tree, others are specified in | 8 | # from top-level directories in the kernel tree, others are specified in |
| 9 | # arch/$(ARCH)/Makefile. Ordering when linking is important, and | 9 | # arch/$(ARCH)/Makefile. Ordering when linking is important, and |
| 10 | # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives | 10 | # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives |
| @@ -18,7 +18,7 @@ | |||
| 18 | # | +--< init/version.o + more | 18 | # | +--< init/version.o + more |
| 19 | # | | 19 | # | |
| 20 | # +--< $(KBUILD_VMLINUX_MAIN) | 20 | # +--< $(KBUILD_VMLINUX_MAIN) |
| 21 | # | +--< drivers/built-in.o mm/built-in.o + more | 21 | # | +--< drivers/built-in.a mm/built-in.a + more |
| 22 | # | | 22 | # | |
| 23 | # +--< $(KBUILD_VMLINUX_LIBS) | 23 | # +--< $(KBUILD_VMLINUX_LIBS) |
| 24 | # | +--< lib/lib.a + more | 24 | # | +--< lib/lib.a + more |
| @@ -51,17 +51,15 @@ info() | |||
| 51 | # | 51 | # |
| 52 | # Traditional incremental style of link does not require this step | 52 | # Traditional incremental style of link does not require this step |
| 53 | # | 53 | # |
| 54 | # built-in.o output file | 54 | # built-in.a output file |
| 55 | # | 55 | # |
| 56 | archive_builtin() | 56 | archive_builtin() |
| 57 | { | 57 | { |
| 58 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 58 | info AR built-in.a |
| 59 | info AR built-in.o | 59 | rm -f built-in.a; |
| 60 | rm -f built-in.o; | 60 | ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \ |
| 61 | ${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \ | 61 | ${KBUILD_VMLINUX_INIT} \ |
| 62 | ${KBUILD_VMLINUX_INIT} \ | 62 | ${KBUILD_VMLINUX_MAIN} |
| 63 | ${KBUILD_VMLINUX_MAIN} | ||
| 64 | fi | ||
| 65 | } | 63 | } |
| 66 | 64 | ||
| 67 | # Link of vmlinux.o used for section mismatch analysis | 65 | # Link of vmlinux.o used for section mismatch analysis |
| @@ -70,20 +68,13 @@ modpost_link() | |||
| 70 | { | 68 | { |
| 71 | local objects | 69 | local objects |
| 72 | 70 | ||
| 73 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 71 | objects="--whole-archive \ |
| 74 | objects="--whole-archive \ | 72 | built-in.a \ |
| 75 | built-in.o \ | 73 | --no-whole-archive \ |
| 76 | --no-whole-archive \ | 74 | --start-group \ |
| 77 | --start-group \ | 75 | ${KBUILD_VMLINUX_LIBS} \ |
| 78 | ${KBUILD_VMLINUX_LIBS} \ | 76 | --end-group" |
| 79 | --end-group" | 77 | |
| 80 | else | ||
| 81 | objects="${KBUILD_VMLINUX_INIT} \ | ||
| 82 | --start-group \ | ||
| 83 | ${KBUILD_VMLINUX_MAIN} \ | ||
| 84 | ${KBUILD_VMLINUX_LIBS} \ | ||
| 85 | --end-group" | ||
| 86 | fi | ||
| 87 | ${LD} ${LDFLAGS} -r -o ${1} ${objects} | 78 | ${LD} ${LDFLAGS} -r -o ${1} ${objects} |
| 88 | } | 79 | } |
| 89 | 80 | ||
| @@ -96,46 +87,28 @@ vmlinux_link() | |||
| 96 | local objects | 87 | local objects |
| 97 | 88 | ||
| 98 | if [ "${SRCARCH}" != "um" ]; then | 89 | if [ "${SRCARCH}" != "um" ]; then |
| 99 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 90 | objects="--whole-archive \ |
| 100 | objects="--whole-archive \ | 91 | built-in.a \ |
| 101 | built-in.o \ | 92 | --no-whole-archive \ |
| 102 | --no-whole-archive \ | 93 | --start-group \ |
| 103 | --start-group \ | 94 | ${KBUILD_VMLINUX_LIBS} \ |
| 104 | ${KBUILD_VMLINUX_LIBS} \ | 95 | --end-group \ |
| 105 | --end-group \ | 96 | ${1}" |
| 106 | ${1}" | 97 | |
| 107 | else | 98 | ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \ |
| 108 | objects="${KBUILD_VMLINUX_INIT} \ | ||
| 109 | --start-group \ | ||
| 110 | ${KBUILD_VMLINUX_MAIN} \ | ||
| 111 | ${KBUILD_VMLINUX_LIBS} \ | ||
| 112 | --end-group \ | ||
| 113 | ${1}" | ||
| 114 | fi | ||
| 115 | |||
| 116 | ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \ | ||
| 117 | -T ${lds} ${objects} | 99 | -T ${lds} ${objects} |
| 118 | else | 100 | else |
| 119 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 101 | objects="-Wl,--whole-archive \ |
| 120 | objects="-Wl,--whole-archive \ | 102 | built-in.a \ |
| 121 | built-in.o \ | 103 | -Wl,--no-whole-archive \ |
| 122 | -Wl,--no-whole-archive \ | 104 | -Wl,--start-group \ |
| 123 | -Wl,--start-group \ | 105 | ${KBUILD_VMLINUX_LIBS} \ |
| 124 | ${KBUILD_VMLINUX_LIBS} \ | 106 | -Wl,--end-group \ |
| 125 | -Wl,--end-group \ | 107 | ${1}" |
| 126 | ${1}" | 108 | |
| 127 | else | 109 | ${CC} ${CFLAGS_vmlinux} -o ${2} \ |
| 128 | objects="${KBUILD_VMLINUX_INIT} \ | 110 | -Wl,-T,${lds} \ |
| 129 | -Wl,--start-group \ | 111 | ${objects} \ |
| 130 | ${KBUILD_VMLINUX_MAIN} \ | ||
| 131 | ${KBUILD_VMLINUX_LIBS} \ | ||
| 132 | -Wl,--end-group \ | ||
| 133 | ${1}" | ||
| 134 | fi | ||
| 135 | |||
| 136 | ${CC} ${CFLAGS_vmlinux} -o ${2} \ | ||
| 137 | -Wl,-T,${lds} \ | ||
| 138 | ${objects} \ | ||
| 139 | -lutil -lrt -lpthread | 112 | -lutil -lrt -lpthread |
| 140 | rm -f linux | 113 | rm -f linux |
| 141 | fi | 114 | fi |
| @@ -191,7 +164,7 @@ cleanup() | |||
| 191 | rm -f .tmp_System.map | 164 | rm -f .tmp_System.map |
| 192 | rm -f .tmp_kallsyms* | 165 | rm -f .tmp_kallsyms* |
| 193 | rm -f .tmp_vmlinux* | 166 | rm -f .tmp_vmlinux* |
| 194 | rm -f built-in.o | 167 | rm -f built-in.a |
| 195 | rm -f System.map | 168 | rm -f System.map |
| 196 | rm -f vmlinux | 169 | rm -f vmlinux |
| 197 | rm -f vmlinux.o | 170 | rm -f vmlinux.o |
| @@ -296,8 +269,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then | |||
| 296 | kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o | 269 | kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o |
| 297 | 270 | ||
| 298 | # step 3 | 271 | # step 3 |
| 299 | size1=$(stat -c "%s" .tmp_kallsyms1.o) | 272 | size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms1.o) |
| 300 | size2=$(stat -c "%s" .tmp_kallsyms2.o) | 273 | size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" .tmp_kallsyms2.o) |
| 301 | 274 | ||
| 302 | if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then | 275 | if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then |
| 303 | kallsymso=.tmp_kallsyms3.o | 276 | kallsymso=.tmp_kallsyms3.o |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9917f928d0fd..4ff08a0ef5d3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -840,8 +840,7 @@ static const char *const section_white_list[] = | |||
| 840 | ".debug*", | 840 | ".debug*", |
| 841 | ".cranges", /* sh64 */ | 841 | ".cranges", /* sh64 */ |
| 842 | ".zdebug*", /* Compressed debug sections. */ | 842 | ".zdebug*", /* Compressed debug sections. */ |
| 843 | ".GCC-command-line", /* mn10300 */ | 843 | ".GCC.command.line", /* record-gcc-switches */ |
| 844 | ".GCC.command.line", /* record-gcc-switches, non mn10300 */ | ||
| 845 | ".mdebug*", /* alpha, score, mips etc. */ | 844 | ".mdebug*", /* alpha, score, mips etc. */ |
| 846 | ".pdr", /* alpha, score, mips etc. */ | 845 | ".pdr", /* alpha, score, mips etc. */ |
| 847 | ".stab*", | 846 | ".stab*", |
| @@ -1104,8 +1103,8 @@ static const struct sectioncheck *section_mismatch( | |||
| 1104 | /* | 1103 | /* |
| 1105 | * The target section could be the SHT_NUL section when we're | 1104 | * The target section could be the SHT_NUL section when we're |
| 1106 | * handling relocations to un-resolved symbols, trying to match it | 1105 | * handling relocations to un-resolved symbols, trying to match it |
| 1107 | * doesn't make much sense and causes build failures on parisc and | 1106 | * doesn't make much sense and causes build failures on parisc |
| 1108 | * mn10300 architectures. | 1107 | * architectures. |
| 1109 | */ | 1108 | */ |
| 1110 | if (*tosec == '\0') | 1109 | if (*tosec == '\0') |
| 1111 | return NULL; | 1110 | return NULL; |
diff --git a/scripts/namespace.pl b/scripts/namespace.pl index 729c547fc9e1..6135574a6f39 100755 --- a/scripts/namespace.pl +++ b/scripts/namespace.pl | |||
| @@ -164,7 +164,7 @@ sub linux_objects | |||
| 164 | s:^\./::; | 164 | s:^\./::; |
| 165 | if (/.*\.o$/ && | 165 | if (/.*\.o$/ && |
| 166 | ! ( | 166 | ! ( |
| 167 | m:/built-in.o$: | 167 | m:/built-in.a$: |
| 168 | || m:arch/x86/vdso/: | 168 | || m:arch/x86/vdso/: |
| 169 | || m:arch/x86/boot/: | 169 | || m:arch/x86/boot/: |
| 170 | || m:arch/ia64/ia32/ia32.o$: | 170 | || m:arch/ia64/ia32/ia32.o$: |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 9fbcf5ed0ca7..73503ebce632 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | # Remove hyphens since they have special meaning in RPM filenames | 24 | # Remove hyphens since they have special meaning in RPM filenames |
| 25 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) | 25 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) |
| 26 | KDEB_SOURCENAME ?= linux-$(KERNELRELEASE) | 26 | KDEB_SOURCENAME ?= linux-$(KERNELRELEASE) |
| 27 | KBUILD_PKG_ROOTCMD ?="fakeroot -u" | ||
| 27 | export KDEB_SOURCENAME | 28 | export KDEB_SOURCENAME |
| 28 | # Include only those top-level files that are needed by make, plus the GPL copy | 29 | # Include only those top-level files that are needed by make, plus the GPL copy |
| 29 | TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \ | 30 | TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \ |
| @@ -66,35 +67,20 @@ binrpm-pkg: FORCE | |||
| 66 | 67 | ||
| 67 | clean-files += $(objtree)/*.spec | 68 | clean-files += $(objtree)/*.spec |
| 68 | 69 | ||
| 69 | # Deb target | ||
| 70 | # --------------------------------------------------------------------------- | ||
| 71 | quiet_cmd_builddeb = BUILDDEB | ||
| 72 | cmd_builddeb = set -e; \ | ||
| 73 | test `id -u` = 0 || \ | ||
| 74 | test -n "$(KBUILD_PKG_ROOTCMD)" || { \ | ||
| 75 | which fakeroot >/dev/null 2>&1 && \ | ||
| 76 | KBUILD_PKG_ROOTCMD="fakeroot -u"; \ | ||
| 77 | } || { \ | ||
| 78 | echo; \ | ||
| 79 | echo "builddeb must be run as root (or using fakeroot)."; \ | ||
| 80 | echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \ | ||
| 81 | echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \ | ||
| 82 | echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \ | ||
| 83 | false; \ | ||
| 84 | } && \ | ||
| 85 | \ | ||
| 86 | $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \ | ||
| 87 | $(srctree)/scripts/package/builddeb $@ | ||
| 88 | |||
| 89 | deb-pkg: FORCE | 70 | deb-pkg: FORCE |
| 90 | $(MAKE) clean | 71 | $(MAKE) clean |
| 72 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian | ||
| 91 | $(call cmd,src_tar,$(KDEB_SOURCENAME)) | 73 | $(call cmd,src_tar,$(KDEB_SOURCENAME)) |
| 92 | $(MAKE) KBUILD_SRC= | 74 | origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ |
| 93 | +$(call cmd,builddeb) | 75 | mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz |
| 76 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc | ||
| 94 | 77 | ||
| 95 | bindeb-pkg: FORCE | 78 | bindeb-pkg: FORCE |
| 96 | $(MAKE) KBUILD_SRC= | 79 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
| 97 | +$(call cmd,builddeb) | 80 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc |
| 81 | |||
| 82 | intdeb-pkg: FORCE | ||
| 83 | +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb | ||
| 98 | 84 | ||
| 99 | clean-dirs += $(objtree)/debian/ | 85 | clean-dirs += $(objtree)/debian/ |
| 100 | 86 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index b4f0f2b3f8d2..90c9a8ac7adb 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
| @@ -30,67 +30,11 @@ create_package() { | |||
| 30 | chmod -R a+rX "$pdir" | 30 | chmod -R a+rX "$pdir" |
| 31 | 31 | ||
| 32 | # Create the package | 32 | # Create the package |
| 33 | dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch}" -p$pname -P"$pdir" | 33 | dpkg-gencontrol -p$pname -P"$pdir" |
| 34 | dpkg --build "$pdir" .. | 34 | dpkg --build "$pdir" .. |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | set_debarch() { | ||
| 38 | # Attempt to find the correct Debian architecture | ||
| 39 | case "$UTS_MACHINE" in | ||
| 40 | i386|ia64|alpha) | ||
| 41 | debarch="$UTS_MACHINE" ;; | ||
| 42 | x86_64) | ||
| 43 | debarch=amd64 ;; | ||
| 44 | sparc*) | ||
| 45 | debarch=sparc ;; | ||
| 46 | s390*) | ||
| 47 | debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; | ||
| 48 | ppc*) | ||
| 49 | debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; | ||
| 50 | parisc*) | ||
| 51 | debarch=hppa ;; | ||
| 52 | mips*) | ||
| 53 | debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;; | ||
| 54 | aarch64|arm64) | ||
| 55 | debarch=arm64 ;; | ||
| 56 | arm*) | ||
| 57 | if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then | ||
| 58 | if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then | ||
| 59 | debarch=armhf | ||
| 60 | else | ||
| 61 | debarch=armel | ||
| 62 | fi | ||
| 63 | else | ||
| 64 | debarch=arm | ||
| 65 | fi | ||
| 66 | ;; | ||
| 67 | *) | ||
| 68 | debarch=$(dpkg --print-architecture) | ||
| 69 | echo "" >&2 | ||
| 70 | echo "** ** ** WARNING ** ** **" >&2 | ||
| 71 | echo "" >&2 | ||
| 72 | echo "Your architecture doesn't have its equivalent" >&2 | ||
| 73 | echo "Debian userspace architecture defined!" >&2 | ||
| 74 | echo "Falling back to using your current userspace instead!" >&2 | ||
| 75 | echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 | ||
| 76 | echo "" >&2 | ||
| 77 | esac | ||
| 78 | if [ -n "$KBUILD_DEBARCH" ] ; then | ||
| 79 | debarch="$KBUILD_DEBARCH" | ||
| 80 | fi | ||
| 81 | forcearch="-DArchitecture=$debarch" | ||
| 82 | |||
| 83 | } | ||
| 84 | |||
| 85 | # Some variables and settings used throughout the script | ||
| 86 | version=$KERNELRELEASE | 37 | version=$KERNELRELEASE |
| 87 | revision=$(cat .version) | ||
| 88 | if [ -n "$KDEB_PKGVERSION" ]; then | ||
| 89 | packageversion=$KDEB_PKGVERSION | ||
| 90 | else | ||
| 91 | packageversion=$version-$revision | ||
| 92 | fi | ||
| 93 | sourcename=$KDEB_SOURCENAME | ||
| 94 | tmpdir="$objtree/debian/tmp" | 38 | tmpdir="$objtree/debian/tmp" |
| 95 | kernel_headers_dir="$objtree/debian/hdrtmp" | 39 | kernel_headers_dir="$objtree/debian/hdrtmp" |
| 96 | libc_headers_dir="$objtree/debian/headertmp" | 40 | libc_headers_dir="$objtree/debian/headertmp" |
| @@ -99,9 +43,6 @@ packagename=linux-image-$version | |||
| 99 | kernel_headers_packagename=linux-headers-$version | 43 | kernel_headers_packagename=linux-headers-$version |
| 100 | libc_headers_packagename=linux-libc-dev | 44 | libc_headers_packagename=linux-libc-dev |
| 101 | dbg_packagename=$packagename-dbg | 45 | dbg_packagename=$packagename-dbg |
| 102 | debarch= | ||
| 103 | forcearch= | ||
| 104 | set_debarch | ||
| 105 | 46 | ||
| 106 | if [ "$ARCH" = "um" ] ; then | 47 | if [ "$ARCH" = "um" ] ; then |
| 107 | packagename=user-mode-linux-$version | 48 | packagename=user-mode-linux-$version |
| @@ -212,108 +153,9 @@ EOF | |||
| 212 | chmod 755 "$tmpdir/DEBIAN/$script" | 153 | chmod 755 "$tmpdir/DEBIAN/$script" |
| 213 | done | 154 | done |
| 214 | 155 | ||
| 215 | # Try to determine maintainer and email values | ||
| 216 | if [ -n "$DEBEMAIL" ]; then | ||
| 217 | email=$DEBEMAIL | ||
| 218 | elif [ -n "$EMAIL" ]; then | ||
| 219 | email=$EMAIL | ||
| 220 | else | ||
| 221 | email=$(id -nu)@$(hostname -f 2>/dev/null || hostname) | ||
| 222 | fi | ||
| 223 | if [ -n "$DEBFULLNAME" ]; then | ||
| 224 | name=$DEBFULLNAME | ||
| 225 | elif [ -n "$NAME" ]; then | ||
| 226 | name=$NAME | ||
| 227 | else | ||
| 228 | name="Anonymous" | ||
| 229 | fi | ||
| 230 | maintainer="$name <$email>" | ||
| 231 | |||
| 232 | # Try to determine distribution | ||
| 233 | if [ -n "$KDEB_CHANGELOG_DIST" ]; then | ||
| 234 | distribution=$KDEB_CHANGELOG_DIST | ||
| 235 | # In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog | ||
| 236 | elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then | ||
| 237 | : # nothing to do in this case | ||
| 238 | else | ||
| 239 | distribution="unstable" | ||
| 240 | echo >&2 "Using default distribution of 'unstable' in the changelog" | ||
| 241 | echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" | ||
| 242 | fi | ||
| 243 | |||
| 244 | # Generate a simple changelog template | ||
| 245 | cat <<EOF > debian/changelog | ||
| 246 | $sourcename ($packageversion) $distribution; urgency=low | ||
| 247 | |||
| 248 | * Custom built Linux kernel. | ||
| 249 | |||
| 250 | -- $maintainer $(date -R) | ||
| 251 | EOF | ||
| 252 | |||
| 253 | # Generate copyright file | ||
| 254 | cat <<EOF > debian/copyright | ||
| 255 | This is a packacked upstream version of the Linux kernel. | ||
| 256 | |||
| 257 | The sources may be found at most Linux archive sites, including: | ||
| 258 | https://www.kernel.org/pub/linux/kernel | ||
| 259 | |||
| 260 | Copyright: 1991 - 2017 Linus Torvalds and others. | ||
| 261 | |||
| 262 | The git repository for mainline kernel development is at: | ||
| 263 | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git | ||
| 264 | |||
| 265 | This program is free software; you can redistribute it and/or modify | ||
| 266 | it under the terms of the GNU General Public License as published by | ||
| 267 | the Free Software Foundation; version 2 dated June, 1991. | ||
| 268 | |||
| 269 | On Debian GNU/Linux systems, the complete text of the GNU General Public | ||
| 270 | License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. | ||
| 271 | EOF | ||
| 272 | |||
| 273 | |||
| 274 | build_depends="bc, kmod, cpio " | ||
| 275 | |||
| 276 | # Generate a control file | ||
| 277 | cat <<EOF > debian/control | ||
| 278 | Source: $sourcename | ||
| 279 | Section: kernel | ||
| 280 | Priority: optional | ||
| 281 | Maintainer: $maintainer | ||
| 282 | Build-Depends: $build_depends | ||
| 283 | Homepage: http://www.kernel.org/ | ||
| 284 | EOF | ||
| 285 | |||
| 286 | if [ "$ARCH" = "um" ]; then | ||
| 287 | cat <<EOF >> debian/control | ||
| 288 | |||
| 289 | Package: $packagename | ||
| 290 | Architecture: any | ||
| 291 | Description: User Mode Linux kernel, version $version | ||
| 292 | User-mode Linux is a port of the Linux kernel to its own system call | ||
| 293 | interface. It provides a kind of virtual machine, which runs Linux | ||
| 294 | as a user process under another Linux kernel. This is useful for | ||
| 295 | kernel development, sandboxes, jails, experimentation, and | ||
| 296 | many other things. | ||
| 297 | . | ||
| 298 | This package contains the Linux kernel, modules and corresponding other | ||
| 299 | files, version: $version. | ||
| 300 | EOF | ||
| 301 | |||
| 302 | else | ||
| 303 | cat <<EOF >> debian/control | ||
| 304 | |||
| 305 | Package: $packagename | ||
| 306 | Architecture: any | ||
| 307 | Description: Linux kernel, version $version | ||
| 308 | This package contains the Linux kernel, modules and corresponding other | ||
| 309 | files, version: $version. | ||
| 310 | EOF | ||
| 311 | |||
| 312 | fi | ||
| 313 | |||
| 314 | # Build kernel header package | 156 | # Build kernel header package |
| 315 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" | 157 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" |
| 316 | (cd $srctree; find arch/*/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles" | 158 | (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" |
| 317 | (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" | 159 | (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" |
| 318 | (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" | 160 | (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" |
| 319 | if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then | 161 | if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then |
| @@ -331,27 +173,6 @@ mkdir -p "$destdir" | |||
| 331 | ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" | 173 | ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" |
| 332 | rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" | 174 | rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" |
| 333 | 175 | ||
| 334 | cat <<EOF >> debian/control | ||
| 335 | |||
| 336 | Package: $kernel_headers_packagename | ||
| 337 | Architecture: any | ||
| 338 | Description: Linux kernel headers for $KERNELRELEASE on \${kernel:debarch} | ||
| 339 | This package provides kernel header files for $KERNELRELEASE on \${kernel:debarch} | ||
| 340 | . | ||
| 341 | This is useful for people who need to build external modules | ||
| 342 | EOF | ||
| 343 | |||
| 344 | cat <<EOF >> debian/control | ||
| 345 | |||
| 346 | Package: $libc_headers_packagename | ||
| 347 | Section: devel | ||
| 348 | Provides: linux-kernel-headers | ||
| 349 | Architecture: any | ||
| 350 | Description: Linux support headers for userspace development | ||
| 351 | This package provides userspaces headers from the Linux kernel. These headers | ||
| 352 | are used by the installed headers for GNU glibc and other system libraries. | ||
| 353 | EOF | ||
| 354 | |||
| 355 | if [ "$ARCH" != "um" ]; then | 176 | if [ "$ARCH" != "um" ]; then |
| 356 | create_package "$kernel_headers_packagename" "$kernel_headers_dir" | 177 | create_package "$kernel_headers_packagename" "$kernel_headers_dir" |
| 357 | create_package "$libc_headers_packagename" "$libc_headers_dir" | 178 | create_package "$libc_headers_packagename" "$libc_headers_dir" |
| @@ -370,47 +191,7 @@ if [ -n "$BUILD_DEBUG" ] ; then | |||
| 370 | ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version | 191 | ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version |
| 371 | # kdump-tools | 192 | # kdump-tools |
| 372 | ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version | 193 | ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version |
| 373 | |||
| 374 | cat <<EOF >> debian/control | ||
| 375 | |||
| 376 | Package: $dbg_packagename | ||
| 377 | Section: debug | ||
| 378 | Architecture: any | ||
| 379 | Description: Linux kernel debugging symbols for $version | ||
| 380 | This package will come in handy if you need to debug the kernel. It provides | ||
| 381 | all the necessary debug symbols for the kernel and its modules. | ||
| 382 | EOF | ||
| 383 | |||
| 384 | create_package "$dbg_packagename" "$dbg_dir" | 194 | create_package "$dbg_packagename" "$dbg_dir" |
| 385 | fi | 195 | fi |
| 386 | 196 | ||
| 387 | if [ "x$1" = "xdeb-pkg" ] | ||
| 388 | then | ||
| 389 | cat <<EOF > debian/rules | ||
| 390 | #!/usr/bin/make -f | ||
| 391 | |||
| 392 | build: | ||
| 393 | \$(MAKE) | ||
| 394 | |||
| 395 | binary-arch: | ||
| 396 | \$(MAKE) KDEB_SOURCENAME=${sourcename} KDEB_PKGVERSION=${packageversion} bindeb-pkg | ||
| 397 | |||
| 398 | clean: | ||
| 399 | rm -rf debian/*tmp debian/files | ||
| 400 | mv debian/ debian.backup # debian/ might be cleaned away | ||
| 401 | \$(MAKE) clean | ||
| 402 | mv debian.backup debian | ||
| 403 | |||
| 404 | binary: binary-arch | ||
| 405 | EOF | ||
| 406 | mv ${sourcename}.tar.gz ../${sourcename}_${version}.orig.tar.gz | ||
| 407 | tar caf ../${sourcename}_${packageversion}.debian.tar.gz debian/{copyright,rules,changelog,control} | ||
| 408 | dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ | ||
| 409 | -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz | ||
| 410 | mv ${sourcename}_${packageversion}*dsc .. | ||
| 411 | dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes | ||
| 412 | else | ||
| 413 | dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes | ||
| 414 | fi | ||
| 415 | |||
| 416 | exit 0 | 197 | exit 0 |
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian new file mode 100755 index 000000000000..6adb3a16ba3b --- /dev/null +++ b/scripts/package/mkdebian | |||
| @@ -0,0 +1,189 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Copyright 2003 Wichert Akkerman <wichert@wiggy.net> | ||
| 4 | # | ||
| 5 | # Simple script to generate a debian/ directory for a Linux kernel. | ||
| 6 | |||
| 7 | set -e | ||
| 8 | |||
| 9 | set_debarch() { | ||
| 10 | # Attempt to find the correct Debian architecture | ||
| 11 | case "$UTS_MACHINE" in | ||
| 12 | i386|ia64|alpha) | ||
| 13 | debarch="$UTS_MACHINE" ;; | ||
| 14 | x86_64) | ||
| 15 | debarch=amd64 ;; | ||
| 16 | sparc*) | ||
| 17 | debarch=sparc ;; | ||
| 18 | s390*) | ||
| 19 | debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; | ||
| 20 | ppc*) | ||
| 21 | debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; | ||
| 22 | parisc*) | ||
| 23 | debarch=hppa ;; | ||
| 24 | mips*) | ||
| 25 | debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;; | ||
| 26 | aarch64|arm64) | ||
| 27 | debarch=arm64 ;; | ||
| 28 | arm*) | ||
| 29 | if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then | ||
| 30 | if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then | ||
| 31 | debarch=armhf | ||
| 32 | else | ||
| 33 | debarch=armel | ||
| 34 | fi | ||
| 35 | else | ||
| 36 | debarch=arm | ||
| 37 | fi | ||
| 38 | ;; | ||
| 39 | *) | ||
| 40 | debarch=$(dpkg --print-architecture) | ||
| 41 | echo "" >&2 | ||
| 42 | echo "** ** ** WARNING ** ** **" >&2 | ||
| 43 | echo "" >&2 | ||
| 44 | echo "Your architecture doesn't have its equivalent" >&2 | ||
| 45 | echo "Debian userspace architecture defined!" >&2 | ||
| 46 | echo "Falling back to using your current userspace instead!" >&2 | ||
| 47 | echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 | ||
| 48 | echo "" >&2 | ||
| 49 | esac | ||
| 50 | if [ -n "$KBUILD_DEBARCH" ] ; then | ||
| 51 | debarch="$KBUILD_DEBARCH" | ||
| 52 | fi | ||
| 53 | } | ||
| 54 | |||
| 55 | # Some variables and settings used throughout the script | ||
| 56 | version=$KERNELRELEASE | ||
| 57 | if [ -n "$KDEB_PKGVERSION" ]; then | ||
| 58 | packageversion=$KDEB_PKGVERSION | ||
| 59 | else | ||
| 60 | revision=$(cat .version 2>/dev/null||echo 1) | ||
| 61 | packageversion=$version-$revision | ||
| 62 | fi | ||
| 63 | sourcename=$KDEB_SOURCENAME | ||
| 64 | packagename=linux-image-$version | ||
| 65 | kernel_headers_packagename=linux-headers-$version | ||
| 66 | dbg_packagename=$packagename-dbg | ||
| 67 | debarch= | ||
| 68 | set_debarch | ||
| 69 | |||
| 70 | if [ "$ARCH" = "um" ] ; then | ||
| 71 | packagename=user-mode-linux-$version | ||
| 72 | fi | ||
| 73 | |||
| 74 | # Try to determine maintainer and email values | ||
| 75 | if [ -n "$DEBEMAIL" ]; then | ||
| 76 | email=$DEBEMAIL | ||
| 77 | elif [ -n "$EMAIL" ]; then | ||
| 78 | email=$EMAIL | ||
| 79 | else | ||
| 80 | email=$(id -nu)@$(hostname -f 2>/dev/null || hostname) | ||
| 81 | fi | ||
| 82 | if [ -n "$DEBFULLNAME" ]; then | ||
| 83 | name=$DEBFULLNAME | ||
| 84 | elif [ -n "$NAME" ]; then | ||
| 85 | name=$NAME | ||
| 86 | else | ||
| 87 | name="Anonymous" | ||
| 88 | fi | ||
| 89 | maintainer="$name <$email>" | ||
| 90 | |||
| 91 | # Try to determine distribution | ||
| 92 | if [ -n "$KDEB_CHANGELOG_DIST" ]; then | ||
| 93 | distribution=$KDEB_CHANGELOG_DIST | ||
| 94 | # In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog | ||
| 95 | elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then | ||
| 96 | : # nothing to do in this case | ||
| 97 | else | ||
| 98 | distribution="unstable" | ||
| 99 | echo >&2 "Using default distribution of 'unstable' in the changelog" | ||
| 100 | echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" | ||
| 101 | fi | ||
| 102 | |||
| 103 | mkdir -p debian/ | ||
| 104 | echo $debarch > debian/arch | ||
| 105 | |||
| 106 | # Generate a simple changelog template | ||
| 107 | cat <<EOF > debian/changelog | ||
| 108 | $sourcename ($packageversion) $distribution; urgency=low | ||
| 109 | |||
| 110 | * Custom built Linux kernel. | ||
| 111 | |||
| 112 | -- $maintainer $(date -R) | ||
| 113 | EOF | ||
| 114 | |||
| 115 | # Generate copyright file | ||
| 116 | cat <<EOF > debian/copyright | ||
| 117 | This is a packacked upstream version of the Linux kernel. | ||
| 118 | |||
| 119 | The sources may be found at most Linux archive sites, including: | ||
| 120 | https://www.kernel.org/pub/linux/kernel | ||
| 121 | |||
| 122 | Copyright: 1991 - 2018 Linus Torvalds and others. | ||
| 123 | |||
| 124 | The git repository for mainline kernel development is at: | ||
| 125 | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git | ||
| 126 | |||
| 127 | This program is free software; you can redistribute it and/or modify | ||
| 128 | it under the terms of the GNU General Public License as published by | ||
| 129 | the Free Software Foundation; version 2 dated June, 1991. | ||
| 130 | |||
| 131 | On Debian GNU/Linux systems, the complete text of the GNU General Public | ||
| 132 | License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. | ||
| 133 | EOF | ||
| 134 | |||
| 135 | # Generate a control file | ||
| 136 | cat <<EOF > debian/control | ||
| 137 | Source: $sourcename | ||
| 138 | Section: kernel | ||
| 139 | Priority: optional | ||
| 140 | Maintainer: $maintainer | ||
| 141 | Build-Depends: bc, kmod, cpio | ||
| 142 | Homepage: http://www.kernel.org/ | ||
| 143 | |||
| 144 | Package: $packagename | ||
| 145 | Architecture: $debarch | ||
| 146 | Description: Linux kernel, version $version | ||
| 147 | This package contains the Linux kernel, modules and corresponding other | ||
| 148 | files, version: $version. | ||
| 149 | |||
| 150 | Package: $kernel_headers_packagename | ||
| 151 | Architecture: $debarch | ||
| 152 | Description: Linux kernel headers for $version on $debarch | ||
| 153 | This package provides kernel header files for $version on $debarch | ||
| 154 | . | ||
| 155 | This is useful for people who need to build external modules | ||
| 156 | |||
| 157 | Package: linux-libc-dev | ||
| 158 | Section: devel | ||
| 159 | Provides: linux-kernel-headers | ||
| 160 | Architecture: $debarch | ||
| 161 | Description: Linux support headers for userspace development | ||
| 162 | This package provides userspaces headers from the Linux kernel. These headers | ||
| 163 | are used by the installed headers for GNU glibc and other system libraries. | ||
| 164 | |||
| 165 | Package: $dbg_packagename | ||
| 166 | Section: debug | ||
| 167 | Architecture: $debarch | ||
| 168 | Description: Linux kernel debugging symbols for $version | ||
| 169 | This package will come in handy if you need to debug the kernel. It provides | ||
| 170 | all the necessary debug symbols for the kernel and its modules. | ||
| 171 | EOF | ||
| 172 | |||
| 173 | cat <<EOF > debian/rules | ||
| 174 | #!$(command -v $MAKE) -f | ||
| 175 | |||
| 176 | build: | ||
| 177 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC= | ||
| 178 | |||
| 179 | binary-arch: | ||
| 180 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} KBUILD_SRC= intdeb-pkg | ||
| 181 | |||
| 182 | clean: | ||
| 183 | rm -rf debian/*tmp debian/files | ||
| 184 | \$(MAKE) clean | ||
| 185 | |||
| 186 | binary: binary-arch | ||
| 187 | EOF | ||
| 188 | |||
| 189 | exit 0 | ||
diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 280027fad991..e05646dc24dc 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec | |||
| @@ -98,7 +98,7 @@ $M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_instal | |||
| 98 | $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build | 98 | $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build |
| 99 | $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source | 99 | $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source |
| 100 | $S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE | 100 | $S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE |
| 101 | $S$M tar cf - . $EXCLUDES | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE | 101 | $S$M tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE |
| 102 | $S$M cd %{buildroot}/lib/modules/$KERNELRELEASE | 102 | $S$M cd %{buildroot}/lib/modules/$KERNELRELEASE |
| 103 | $S$M ln -sf /usr/src/kernels/$KERNELRELEASE build | 103 | $S$M ln -sf /usr/src/kernels/$KERNELRELEASE build |
| 104 | $S$M ln -sf /usr/src/kernels/$KERNELRELEASE source | 104 | $S$M ln -sf /usr/src/kernels/$KERNELRELEASE source |
| @@ -118,6 +118,8 @@ $S$M ln -sf /usr/src/kernels/$KERNELRELEASE source | |||
| 118 | %preun | 118 | %preun |
| 119 | if [ -x /sbin/new-kernel-pkg ]; then | 119 | if [ -x /sbin/new-kernel-pkg ]; then |
| 120 | new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img | 120 | new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img |
| 121 | elif [ -x /usr/bin/kernel-install ]; then | ||
| 122 | kernel-install remove $KERNELRELEASE | ||
| 121 | fi | 123 | fi |
| 122 | 124 | ||
| 123 | %postun | 125 | %postun |
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index 16e086dcc567..8c9691c3329e 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c | |||
| @@ -33,20 +33,6 @@ | |||
| 33 | #include <string.h> | 33 | #include <string.h> |
| 34 | #include <unistd.h> | 34 | #include <unistd.h> |
| 35 | 35 | ||
| 36 | /* | ||
| 37 | * glibc synced up and added the metag number but didn't add the relocations. | ||
| 38 | * Work around this in a crude manner for now. | ||
| 39 | */ | ||
| 40 | #ifndef EM_METAG | ||
| 41 | #define EM_METAG 174 | ||
| 42 | #endif | ||
| 43 | #ifndef R_METAG_ADDR32 | ||
| 44 | #define R_METAG_ADDR32 2 | ||
| 45 | #endif | ||
| 46 | #ifndef R_METAG_NONE | ||
| 47 | #define R_METAG_NONE 3 | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #ifndef EM_AARCH64 | 36 | #ifndef EM_AARCH64 |
| 51 | #define EM_AARCH64 183 | 37 | #define EM_AARCH64 183 |
| 52 | #define R_AARCH64_NONE 0 | 38 | #define R_AARCH64_NONE 0 |
| @@ -538,12 +524,6 @@ do_file(char const *const fname) | |||
| 538 | gpfx = '_'; | 524 | gpfx = '_'; |
| 539 | break; | 525 | break; |
| 540 | case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; | 526 | case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; |
| 541 | case EM_METAG: reltype = R_METAG_ADDR32; | ||
| 542 | altmcount = "_mcount_wrapper"; | ||
| 543 | rel_type_nop = R_METAG_NONE; | ||
| 544 | /* We happen to have the same requirement as MIPS */ | ||
| 545 | is_fake_mcount32 = MIPS32_is_fake_mcount; | ||
| 546 | break; | ||
| 547 | case EM_MIPS: /* reltype: e_class */ gpfx = '_'; break; | 527 | case EM_MIPS: /* reltype: e_class */ gpfx = '_'; break; |
| 548 | case EM_PPC: reltype = R_PPC_ADDR32; gpfx = '_'; break; | 528 | case EM_PPC: reltype = R_PPC_ADDR32; gpfx = '_'; break; |
| 549 | case EM_PPC64: reltype = R_PPC64_ADDR64; gpfx = '_'; break; | 529 | case EM_PPC64: reltype = R_PPC64_ADDR64; gpfx = '_'; break; |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 2033af758173..191eb949d52c 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
| @@ -368,14 +368,11 @@ if ($arch eq "x86_64") { | |||
| 368 | } elsif ($arch eq "microblaze") { | 368 | } elsif ($arch eq "microblaze") { |
| 369 | # Microblaze calls '_mcount' instead of plain 'mcount'. | 369 | # Microblaze calls '_mcount' instead of plain 'mcount'. |
| 370 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; | 370 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; |
| 371 | } elsif ($arch eq "blackfin") { | 371 | } elsif ($arch eq "riscv") { |
| 372 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$"; | 372 | $function_regex = "^([0-9a-fA-F]+)\\s+<([^.0-9][0-9a-zA-Z_\\.]+)>:"; |
| 373 | $mcount_adjust = -4; | 373 | $mcount_regex = "^\\s*([0-9a-fA-F]+):\\sR_RISCV_CALL\\s_mcount\$"; |
| 374 | } elsif ($arch eq "tilegx" || $arch eq "tile") { | ||
| 375 | # Default to the newer TILE-Gx architecture if only "tile" is given. | ||
| 376 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$"; | ||
| 377 | $type = ".quad"; | 374 | $type = ".quad"; |
| 378 | $alignment = 8; | 375 | $alignment = 2; |
| 379 | } else { | 376 | } else { |
| 380 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 377 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
| 381 | } | 378 | } |
diff --git a/scripts/split-man.pl b/scripts/split-man.pl new file mode 100755 index 000000000000..bfe16cbe42df --- /dev/null +++ b/scripts/split-man.pl | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #!/usr/bin/perl | ||
| 2 | # SPDX-License-Identifier: GPL-2.0 | ||
| 3 | # | ||
| 4 | # Author: Mauro Carvalho Chehab <mchehab@s-opensource.com> | ||
| 5 | # | ||
| 6 | # Produce manpages from kernel-doc. | ||
| 7 | # See Documentation/doc-guide/kernel-doc.rst for instructions | ||
| 8 | |||
| 9 | if ($#ARGV < 0) { | ||
| 10 | die "where do I put the results?\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | mkdir $ARGV[0],0777; | ||
| 14 | $state = 0; | ||
| 15 | while (<STDIN>) { | ||
| 16 | if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) { | ||
| 17 | if ($state == 1) { close OUT } | ||
| 18 | $state = 1; | ||
| 19 | $fn = "$ARGV[0]/$1.9"; | ||
| 20 | print STDERR "Creating $fn\n"; | ||
| 21 | open OUT, ">$fn" or die "can't open $fn: $!\n"; | ||
| 22 | print OUT $_; | ||
| 23 | } elsif ($state != 0) { | ||
| 24 | print OUT $_; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | close OUT; | ||
