diff options
Diffstat (limited to 'scripts')
49 files changed, 1257 insertions, 1475 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index be39cd1c74cf..d897278b1f97 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -21,6 +21,10 @@ depfile = $(subst $(comma),_,$(dot-target).d) basetarget = $(basename $(notdir $@)) ### +# filename of first prerequisite with directory and extension stripped +baseprereq = $(basename $(notdir $<)) + +### # Escape single quote for use in echo statements escsq = $(subst $(squote),'\$(squote)',$1) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 93b2b5938a2e..aeea84a24836 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -160,13 +160,51 @@ ld_flags = $(LDFLAGS) $(ldflags-y) modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) +ifdef REGENERATE_PARSERS + +# GPERF +# --------------------------------------------------------------------------- +quiet_cmd_gperf = GPERF $@ + cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< + +$(src)/%.hash.c_shipped: $(src)/%.gperf + $(call cmd,gperf) + +# LEX +# --------------------------------------------------------------------------- +LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) + +quiet_cmd_flex = LEX $@ + cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< + +$(src)/%.lex.c_shipped: $(src)/%.l + $(call cmd,flex) + +# YACC +# --------------------------------------------------------------------------- +YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) + +quiet_cmd_bison = YACC $@ + cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< + +$(src)/%.tab.c_shipped: $(src)/%.y + $(call cmd,bison) + +quiet_cmd_bison_h = YACC $@ + cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< + +$(src)/%.tab.h_shipped: $(src)/%.y + $(call cmd,bison_h) + +endif + # Shipped files # =========================================================================== quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -$(obj)/%:: $(src)/%_shipped +$(obj)/%: $(src)/%_shipped $(call cmd,shipped) # Commands useful for building a boot image diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 56dfafc73c1a..08dce14f2dc8 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -18,7 +18,7 @@ # Step 3 is used to place certain information in the module's ELF # section, including information such as: -# Version magic (see include/vermagic.h for full details) +# Version magic (see include/linux/vermagic.h for full details) # - Kernel release # - SMP is CONFIG_SMP # - PREEMPT is CONFIG_PREEMPT diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl index 12caa822a232..b78fca994a15 100644 --- a/scripts/bootgraph.pl +++ b/scripts/bootgraph.pl @@ -44,7 +44,7 @@ my %end; my %type; my $done = 0; my $maxtime = 0; -my $firsttime = 100; +my $firsttime = 99999; my $count = 0; my %pids; my %pidctr; diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b0aa2c680593..9d761c95eca2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -10,7 +10,7 @@ use strict; my $P = $0; $P =~ s@.*/@@g; -my $V = '0.31'; +my $V = '0.32'; use Getopt::Long qw(:config no_auto_abbrev); @@ -26,9 +26,13 @@ my $check = 0; my $summary = 1; my $mailback = 0; my $summary_file = 0; +my $show_types = 0; my $root; my %debug; +my %ignore_type = (); +my @ignore = (); my $help = 0; +my $configuration_file = ".checkpatch.conf"; sub help { my ($exitcode) = @_; @@ -46,6 +50,8 @@ Options: --terse one line per report -f, --file treat FILE as regular source file --subjective, --strict enable more subjective tests + --ignore TYPE(,TYPE2...) ignore various comma separated message types + --show-types show the message "types" in the output --root=PATH PATH to the kernel tree root --no-summary suppress the per-file summary --mailback only produce a report in case of warnings/errors @@ -63,6 +69,32 @@ EOM exit($exitcode); } +my $conf = which_conf($configuration_file); +if (-f $conf) { + my @conf_args; + open(my $conffile, '<', "$conf") + or warn "$P: Can't find a readable $configuration_file file $!\n"; + + while (<$conffile>) { + my $line = $_; + + $line =~ s/\s*\n?$//g; + $line =~ s/^\s*//g; + $line =~ s/\s+/ /g; + + next if ($line =~ m/^\s*#/); + next if ($line =~ m/^\s*$/); + + my @words = split(" ", $line); + foreach my $word (@words) { + last if ($word =~ m/^#/); + push (@conf_args, $word); + } + } + close($conffile); + unshift(@ARGV, @conf_args) if @conf_args; +} + GetOptions( 'q|quiet+' => \$quiet, 'tree!' => \$tree, @@ -73,6 +105,8 @@ GetOptions( 'f|file!' => \$file, 'subjective!' => \$check, 'strict!' => \$check, + 'ignore=s' => \@ignore, + 'show-types!' => \$show_types, 'root=s' => \$root, 'summary!' => \$summary, 'mailback!' => \$mailback, @@ -93,6 +127,19 @@ if ($#ARGV < 0) { exit(1); } +@ignore = split(/,/, join(',',@ignore)); +foreach my $word (@ignore) { + $word =~ s/\s*\n?$//g; + $word =~ s/^\s*//g; + $word =~ s/\s+/ /g; + $word =~ tr/[a-z]/[A-Z]/; + + next if ($word =~ m/^\s*#/); + next if ($word =~ m/^\s*$/); + + $ignore_type{$word}++; +} + my $dbg_values = 0; my $dbg_possible = 0; my $dbg_type = 0; @@ -145,7 +192,8 @@ our $Sparse = qr{ __must_check| __init_refok| __kprobes| - __ref + __ref| + __rcu }x; # Notes to $Attribute: @@ -209,13 +257,23 @@ our $typeTypedefs = qr{(?x: )}; our $logFunctions = qr{(?x: - printk| - [a-z]+_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)| - WARN| + printk(?:_ratelimited|_once|)| + [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| + WARN(?:_RATELIMIT|_ONCE|)| panic| MODULE_[A-Z_]+ )}; +our $signature_tags = qr{(?xi: + Signed-off-by:| + Acked-by:| + Tested-by:| + Reviewed-by:| + Reported-by:| + To:| + Cc: +)}; + our @typeList = ( qr{void}, qr{(?:unsigned\s+)?char}, @@ -268,6 +326,20 @@ sub build_types { } build_types(); +our $match_balanced_parentheses = qr/(\((?:[^\(\)]+|(-1))*\))/; + +our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; +our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*}; + +sub deparenthesize { + my ($string) = @_; + return "" if (!defined($string)); + $string =~ s@^\s*\(\s*@@g; + $string =~ s@\s*\)\s*$@@g; + $string =~ s@\s+@ @g; + return $string; +} + $chk_signoff = 0 if ($file); my @dep_includes = (); @@ -339,6 +411,88 @@ sub top_of_kernel_tree { } } return 1; + } + +sub parse_email { + my ($formatted_email) = @_; + + my $name = ""; + my $address = ""; + my $comment = ""; + + if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) { + $name = $1; + $address = $2; + $comment = $3 if defined $3; + } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) { + $address = $1; + $comment = $2 if defined $2; + } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) { + $address = $1; + $comment = $2 if defined $2; + $formatted_email =~ s/$address.*$//; + $name = $formatted_email; + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + # If there's a name left after stripping spaces and + # leading quotes, and the address doesn't have both + # leading and trailing angle brackets, the address + # is invalid. ie: + # "joe smith joe@smith.com" bad + # "joe smith <joe@smith.com" bad + if ($name ne "" && $address !~ /^<[^>]+>$/) { + $name = ""; + $address = ""; + $comment = ""; + } + } + + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + $address =~ s/^\s+|\s+$//g; + $address =~ s/^\<|\>$//g; + + if ($name =~ /[^\w \-]/i) { ##has "must quote" chars + $name =~ s/(?<!\\)"/\\"/g; ##escape quotes + $name = "\"$name\""; + } + + return ($name, $address, $comment); +} + +sub format_email { + my ($name, $address) = @_; + + my $formatted_email; + + $name =~ s/^\s+|\s+$//g; + $name =~ s/^\"|\"$//g; + $address =~ s/^\s+|\s+$//g; + + if ($name =~ /[^\w \-]/i) { ##has "must quote" chars + $name =~ s/(?<!\\)"/\\"/g; ##escape quotes + $name = "\"$name\""; + } + + if ("$name" eq "") { + $formatted_email = "$address"; + } else { + $formatted_email = "$name <$address>"; + } + + return $formatted_email; +} + +sub which_conf { + my ($conf) = @_; + + foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) { + if (-e "$path/$conf") { + return "$path/$conf"; + } + } + + return ""; } sub expand_tabs { @@ -1086,12 +1240,21 @@ sub possible { my $prefix = ''; +sub show_type { + return !defined $ignore_type{$_[0]}; +} + sub report { - if (defined $tst_only && $_[0] !~ /\Q$tst_only\E/) { + if (!show_type($_[1]) || + (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) { return 0; } - my $line = $prefix . $_[0]; - + my $line; + if ($show_types) { + $line = "$prefix$_[0]:$_[1]: $_[2]\n"; + } else { + $line = "$prefix$_[0]: $_[2]\n"; + } $line = (split('\n', $line))[0] . "\n" if ($terse); push(our @report, $line); @@ -1101,20 +1264,21 @@ sub report { sub report_dump { our @report; } + sub ERROR { - if (report("ERROR: $_[0]\n")) { + if (report("ERROR", $_[0], $_[1])) { our $clean = 0; our $cnt_error++; } } sub WARN { - if (report("WARNING: $_[0]\n")) { + if (report("WARNING", $_[0], $_[1])) { our $clean = 0; our $cnt_warn++; } } sub CHK { - if ($check && report("CHECK: $_[0]\n")) { + if ($check && report("CHECK", $_[0], $_[1])) { our $clean = 0; our $cnt_chk++; } @@ -1143,7 +1307,8 @@ sub check_absolute_file { ##print "prefix<$prefix>\n"; if ($prefix ne ".../") { - WARN("use relative pathname instead of absolute in changelog text\n" . $herecurr); + WARN("USE_RELATIVE_PATH", + "use relative pathname instead of absolute in changelog text\n" . $herecurr); } } @@ -1340,11 +1505,13 @@ sub process { $p1_prefix = $1; if (!$file && $tree && $p1_prefix ne '' && -e "$root/$p1_prefix") { - WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); + WARN("PATCH_PREFIX", + "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); } if ($realfile =~ m@^include/asm/@) { - ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); + ERROR("MODIFIED_INCLUDE_ASM", + "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); } next; } @@ -1361,27 +1528,61 @@ sub process { if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { my $permhere = $here . "FILE: $realfile\n"; if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) { - ERROR("do not set execute permissions for source files\n" . $permhere); + ERROR("EXECUTE_PERMISSIONS", + "do not set execute permissions for source files\n" . $permhere); } } -#check the patch for a signoff: +# Check the patch for a signoff: if ($line =~ /^\s*signed-off-by:/i) { - # This is a signoff, if ugly, so do not double report. $signoff++; - if (!($line =~ /^\s*Signed-off-by:/)) { - WARN("Signed-off-by: is the preferred form\n" . - $herecurr); + } + +# Check signature styles + if ($line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { + my $space_before = $1; + my $sign_off = $2; + my $space_after = $3; + my $email = $4; + my $ucfirst_sign_off = ucfirst(lc($sign_off)); + + if (defined $space_before && $space_before ne "") { + WARN("BAD_SIGN_OFF", + "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); } - if ($line =~ /^\s*signed-off-by:\S/i) { - WARN("space required after Signed-off-by:\n" . - $herecurr); + if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) { + WARN("BAD_SIGN_OFF", + "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr); + } + if (!defined $space_after || $space_after ne " ") { + WARN("BAD_SIGN_OFF", + "Use a single space after $ucfirst_sign_off\n" . $herecurr); + } + + my ($email_name, $email_address, $comment) = parse_email($email); + my $suggested_email = format_email(($email_name, $email_address)); + if ($suggested_email eq "") { + ERROR("BAD_SIGN_OFF", + "Unrecognized email address: '$email'\n" . $herecurr); + } else { + my $dequoted = $suggested_email; + $dequoted =~ s/^"//; + $dequoted =~ s/" </ </; + # Don't force email to have quotes + # Allow just an angle bracketed address + if ("$dequoted$comment" ne $email && + "<$email_address>$comment" ne $email && + "$suggested_email$comment" ne $email) { + WARN("BAD_SIGN_OFF", + "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr); + } } } # Check for wrappage within a valid hunk of the file if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { - ERROR("patch seems to be corrupt (line wrapped?)\n" . + ERROR("CORRUPTED_PATCH", + "patch seems to be corrupt (line wrapped?)\n" . $herecurr) if (!$emitted_corrupt++); } @@ -1408,7 +1609,8 @@ sub process { my $ptr = substr($blank, 0, length($utf8_prefix)) . "^"; my $hereptr = "$hereline$ptr\n"; - ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); + CHK("INVALID_UTF8", + "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); } # ignore non-hunk lines and lines being removed @@ -1417,11 +1619,13 @@ sub process { #trailing whitespace if ($line =~ /^\+.*\015/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - ERROR("DOS line endings\n" . $herevet); + ERROR("DOS_LINE_ENDINGS", + "DOS line endings\n" . $herevet); } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - ERROR("trailing whitespace\n" . $herevet); + ERROR("TRAILING_WHITESPACE", + "trailing whitespace\n" . $herevet); $rpt_cleaners = 1; } @@ -1452,7 +1656,8 @@ sub process { } $length++; } - WARN("please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_end && $length < 4); + WARN("CONFIG_DESCRIPTION", + "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_end && $length < 4); #print "is_end<$is_end> length<$length>\n"; } @@ -1466,28 +1671,33 @@ sub process { $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && $length > 80) { - WARN("line over 80 characters\n" . $herecurr); + WARN("LONG_LINE", + "line over 80 characters\n" . $herecurr); } # check for spaces before a quoted newline if ($rawline =~ /^.*\".*\s\\n/) { - WARN("unnecessary whitespace before a quoted newline\n" . $herecurr); + WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", + "unnecessary whitespace before a quoted newline\n" . $herecurr); } # check for adding lines without a newline. if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) { - WARN("adding a line without newline at end of file\n" . $herecurr); + WARN("MISSING_EOF_NEWLINE", + "adding a line without newline at end of file\n" . $herecurr); } # Blackfin: use hi/lo macros if ($realfile =~ m@arch/blackfin/.*\.S$@) { if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) { my $herevet = "$here\n" . cat_vet($line) . "\n"; - ERROR("use the LO() macro, not (... & 0xFFFF)\n" . $herevet); + ERROR("LO_MACRO", + "use the LO() macro, not (... & 0xFFFF)\n" . $herevet); } if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) { my $herevet = "$here\n" . cat_vet($line) . "\n"; - ERROR("use the HI() macro, not (... >> 16)\n" . $herevet); + ERROR("HI_MACRO", + "use the HI() macro, not (... >> 16)\n" . $herevet); } } @@ -1499,14 +1709,16 @@ sub process { if ($rawline =~ /^\+\s* \t\s*\S/ || $rawline =~ /^\+\s* \s*/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - ERROR("code indent should use tabs where possible\n" . $herevet); + ERROR("CODE_INDENT", + "code indent should use tabs where possible\n" . $herevet); $rpt_cleaners = 1; } # check for space before tabs. if ($rawline =~ /^\+/ && $rawline =~ / \t/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - WARN("please, no space before tabs\n" . $herevet); + WARN("SPACE_BEFORE_TAB", + "please, no space before tabs\n" . $herevet); } # check for spaces at the beginning of a line. @@ -1516,7 +1728,8 @@ sub process { # 3) hanging labels if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - WARN("please, no spaces at the start of a line\n" . $herevet); + WARN("LEADING_SPACE", + "please, no spaces at the start of a line\n" . $herevet); } # check we are in a valid C source file if not then ignore this hunk @@ -1524,17 +1737,20 @@ sub process { # check for RCS/CVS revision markers if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { - WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr); + WARN("CVS_KEYWORD", + "CVS style keyword markers, these will _not_ be updated\n". $herecurr); } # Blackfin: don't use __builtin_bfin_[cs]sync if ($line =~ /__builtin_bfin_csync/) { my $herevet = "$here\n" . cat_vet($line) . "\n"; - ERROR("use the CSYNC() macro in asm/blackfin.h\n" . $herevet); + ERROR("CSYNC", + "use the CSYNC() macro in asm/blackfin.h\n" . $herevet); } if ($line =~ /__builtin_bfin_ssync/) { my $herevet = "$here\n" . cat_vet($line) . "\n"; - ERROR("use the SSYNC() macro in asm/blackfin.h\n" . $herevet); + ERROR("SSYNC", + "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); } # Check for potential 'bare' types @@ -1623,7 +1839,8 @@ sub process { } } if ($err ne '') { - ERROR("switch and case should be at the same indent\n$hereline$err"); + ERROR("SWITCH_CASE_INDENT_LEVEL", + "switch and case should be at the same indent\n$hereline$err"); } } @@ -1651,7 +1868,8 @@ sub process { #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { - ERROR("that open brace { should be on the previous line\n" . + ERROR("OPEN_BRACE", + "that open brace { should be on the previous line\n" . "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); } if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ && @@ -1660,7 +1878,8 @@ sub process { { my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]); if ($nindent > $indent) { - WARN("trailing semicolon indicates no statements, indent implies otherwise\n" . + WARN("TRAILING_SEMICOLON", + "trailing semicolon indicates no statements, indent implies otherwise\n" . "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); } } @@ -1748,7 +1967,8 @@ sub process { if ($check && (($sindent % 8) != 0 || ($sindent <= $indent && $s ne ''))) { - WARN("suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n"); + WARN("SUSPECT_CODE_INDENT", + "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n"); } } @@ -1771,18 +1991,22 @@ sub process { # TEST: allow direct testing of the type matcher. if ($dbg_type) { if ($line =~ /^.\s*$Declare\s*$/) { - ERROR("TEST: is type\n" . $herecurr); + ERROR("TEST_TYPE", + "TEST: is type\n" . $herecurr); } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) { - ERROR("TEST: is not type ($1 is)\n". $herecurr); + ERROR("TEST_NOT_TYPE", + "TEST: is not type ($1 is)\n". $herecurr); } next; } # TEST: allow direct testing of the attribute matcher. if ($dbg_attr) { if ($line =~ /^.\s*$Modifier\s*$/) { - ERROR("TEST: is attr\n" . $herecurr); + ERROR("TEST_ATTR", + "TEST: is attr\n" . $herecurr); } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) { - ERROR("TEST: is not attr ($1 is)\n". $herecurr); + ERROR("TEST_NOT_ATTR", + "TEST: is not attr ($1 is)\n". $herecurr); } next; } @@ -1790,7 +2014,8 @@ sub process { # check for initialisation to aggregates open brace on the next line if ($line =~ /^.\s*{/ && $prevline =~ /(?:^|[^=])=\s*$/) { - ERROR("that open brace { should be on the previous line\n" . $hereprev); + ERROR("OPEN_BRACE", + "that open brace { should be on the previous line\n" . $hereprev); } # @@ -1801,14 +2026,16 @@ sub process { if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) { my $path = $1; if ($path =~ m{//}) { - ERROR("malformed #include filename\n" . + ERROR("MALFORMED_INCLUDE", + "malformed #include filename\n" . $herecurr); } } # no C99 // comments if ($line =~ m{//}) { - ERROR("do not use C99 // comments\n" . $herecurr); + ERROR("C99_COMMENTS", + "do not use C99 // comments\n" . $herecurr); } # Remove C99 comments. $line =~ s@//.*@@; @@ -1855,35 +2082,41 @@ sub process { } if (defined $suppress_export{$linenr} && $suppress_export{$linenr} == 2) { - WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); + WARN("EXPORT_SYMBOL", + "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); } # check for global initialisers. if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { - ERROR("do not initialise globals to 0 or NULL\n" . + ERROR("GLOBAL_INITIALISERS", + "do not initialise globals to 0 or NULL\n" . $herecurr); } # check for static initialisers. if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) { - ERROR("do not initialise statics to 0 or NULL\n" . + ERROR("INITIALISED_STATIC", + "do not initialise statics to 0 or NULL\n" . $herecurr); } # check for static const char * arrays. if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { - WARN("static const char * array should probably be static const char * const\n" . + WARN("STATIC_CONST_CHAR_ARRAY", + "static const char * array should probably be static const char * const\n" . $herecurr); } # check for static char foo[] = "bar" declarations. if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) { - WARN("static char array declaration should probably be static const char\n" . + WARN("STATIC_CONST_CHAR_ARRAY", + "static char array declaration should probably be static const char\n" . $herecurr); } # check for declarations of struct pci_device_id if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) { - WARN("Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr); + WARN("DEFINE_PCI_DEVICE_TABLE", + "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr); } # check for new typedefs, only function parameters and sparse annotations @@ -1893,7 +2126,8 @@ sub process { $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && $line !~ /\b$typeTypedefs\b/ && $line !~ /\b__bitwise(?:__|)\b/) { - WARN("do not add new typedefs\n" . $herecurr); + WARN("NEW_TYPEDEFS", + "do not add new typedefs\n" . $herecurr); } # * goes on variable not on type @@ -1911,7 +2145,8 @@ sub process { #print "from<$from> to<$to>\n"; if ($from ne $to) { - ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); + ERROR("POINTER_LOCATION", + "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); } } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) { my ($from, $to, $ident) = ($1, $1, $2); @@ -1928,7 +2163,8 @@ sub process { #print "from<$from> to<$to> ident<$ident>\n"; if ($from ne $to && $ident !~ /^$Modifier$/) { - ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); + ERROR("POINTER_LOCATION", + "\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); } } @@ -1940,12 +2176,14 @@ sub process { # } if ($line =~ /\bLINUX_VERSION_CODE\b/) { - WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); + WARN("LINUX_VERSION_CODE", + "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); } # check for uses of printk_ratelimit if ($line =~ /\bprintk_ratelimit\s*\(/) { - WARN("Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); + WARN("PRINTK_RATELIMITED", +"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); } # printk should use KERN_* levels. Note that follow on printk's on the @@ -1967,7 +2205,8 @@ sub process { } } if ($ok == 0) { - WARN("printk() should include KERN_ facility level\n" . $herecurr); + WARN("PRINTK_WITHOUT_KERN_LEVEL", + "printk() should include KERN_ facility level\n" . $herecurr); } } @@ -1975,18 +2214,21 @@ sub process { # or if closed on same line if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) { - ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr); + ERROR("OPEN_BRACE", + "open brace '{' following function declarations go on the next line\n" . $herecurr); } # open braces for enum, union and struct go on the same line. if ($line =~ /^.\s*{/ && $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { - ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); + ERROR("OPEN_BRACE", + "open brace '{' following $1 go on the same line\n" . $hereprev); } # missing space after union, struct or enum definition if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { - WARN("missing space after $1 definition\n" . $herecurr); + WARN("SPACING", + "missing space after $1 definition\n" . $herecurr); } # check for spacing round square brackets; allowed: @@ -1998,7 +2240,8 @@ sub process { if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && $prefix !~ /{\s+$/) { - ERROR("space prohibited before open square bracket '['\n" . $herecurr); + ERROR("BRACKET_SPACE", + "space prohibited before open square bracket '['\n" . $herecurr); } } @@ -2029,7 +2272,8 @@ sub process { } elsif ($ctx =~ /$Type$/) { } else { - WARN("space prohibited between function name and open parenthesis '('\n" . $herecurr); + WARN("SPACING", + "space prohibited between function name and open parenthesis '('\n" . $herecurr); } } # Check operator spacing. @@ -2103,7 +2347,8 @@ sub process { } elsif ($op eq ';') { if ($ctx !~ /.x[WEBC]/ && $cc !~ /^\\/ && $cc !~ /^;/) { - ERROR("space required after that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space required after that '$op' $at\n" . $hereptr); } # // is a comment @@ -2114,13 +2359,15 @@ sub process { # : when part of a bitfield } elsif ($op eq '->' || $opv eq ':B') { if ($ctx =~ /Wx.|.xW/) { - ERROR("spaces prohibited around that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "spaces prohibited around that '$op' $at\n" . $hereptr); } # , must have a space on the right. } elsif ($op eq ',') { if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { - ERROR("space required after that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space required after that '$op' $at\n" . $hereptr); } # '*' as part of a type definition -- reported already. @@ -2134,26 +2381,31 @@ sub process { $opv eq '*U' || $opv eq '-U' || $opv eq '&U' || $opv eq '&&U') { if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { - ERROR("space required before that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space required before that '$op' $at\n" . $hereptr); } if ($op eq '*' && $cc =~/\s*$Modifier\b/) { # A unary '*' may be const } elsif ($ctx =~ /.xW/) { - ERROR("space prohibited after that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space prohibited after that '$op' $at\n" . $hereptr); } # unary ++ and unary -- are allowed no space on one side. } elsif ($op eq '++' or $op eq '--') { if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) { - ERROR("space required one side of that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space required one side of that '$op' $at\n" . $hereptr); } if ($ctx =~ /Wx[BE]/ || ($ctx =~ /Wx./ && $cc =~ /^;/)) { - ERROR("space prohibited before that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space prohibited before that '$op' $at\n" . $hereptr); } if ($ctx =~ /ExW/) { - ERROR("space prohibited after that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space prohibited after that '$op' $at\n" . $hereptr); } @@ -2165,7 +2417,8 @@ sub process { $op eq '%') { if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { - ERROR("need consistent spacing around '$op' $at\n" . + ERROR("SPACING", + "need consistent spacing around '$op' $at\n" . $hereptr); } @@ -2173,7 +2426,8 @@ sub process { # terminating a case value or a label. } elsif ($opv eq ':C' || $opv eq ':L') { if ($ctx =~ /Wx./) { - ERROR("space prohibited before that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "space prohibited before that '$op' $at\n" . $hereptr); } # All the others need spaces both sides. @@ -2196,7 +2450,8 @@ sub process { } if ($ok == 0) { - ERROR("spaces required around that '$op' $at\n" . $hereptr); + ERROR("SPACING", + "spaces required around that '$op' $at\n" . $hereptr); } } $off += length($elements[$n + 1]); @@ -2205,7 +2460,8 @@ sub process { # check for multiple assignments if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) { - CHK("multiple assignments should be avoided\n" . $herecurr); + CHK("MULTIPLE_ASSIGNMENTS", + "multiple assignments should be avoided\n" . $herecurr); } ## # check for multiple declarations, allowing for a function declaration @@ -2219,45 +2475,53 @@ sub process { ## while ($ln =~ s/\([^\(\)]*\)//g) { ## } ## if ($ln =~ /,/) { -## WARN("declaring multiple variables together should be avoided\n" . $herecurr); +## WARN("MULTIPLE_DECLARATION", +## "declaring multiple variables together should be avoided\n" . $herecurr); ## } ## } #need space before brace following if, while, etc if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) || $line =~ /do{/) { - ERROR("space required before the open brace '{'\n" . $herecurr); + ERROR("SPACING", + "space required before the open brace '{'\n" . $herecurr); } # closing brace should have a space following it when it has anything # on the line if ($line =~ /}(?!(?:,|;|\)))\S/) { - ERROR("space required after that close brace '}'\n" . $herecurr); + ERROR("SPACING", + "space required after that close brace '}'\n" . $herecurr); } # check spacing on square brackets if ($line =~ /\[\s/ && $line !~ /\[\s*$/) { - ERROR("space prohibited after that open square bracket '['\n" . $herecurr); + ERROR("SPACING", + "space prohibited after that open square bracket '['\n" . $herecurr); } if ($line =~ /\s\]/) { - ERROR("space prohibited before that close square bracket ']'\n" . $herecurr); + ERROR("SPACING", + "space prohibited before that close square bracket ']'\n" . $herecurr); } # check spacing on parentheses if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ && $line !~ /for\s*\(\s+;/) { - ERROR("space prohibited after that open parenthesis '('\n" . $herecurr); + ERROR("SPACING", + "space prohibited after that open parenthesis '('\n" . $herecurr); } if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ && $line !~ /for\s*\(.*;\s+\)/ && $line !~ /:\s+\)/) { - ERROR("space prohibited before that close parenthesis ')'\n" . $herecurr); + ERROR("SPACING", + "space prohibited before that close parenthesis ')'\n" . $herecurr); } #goto labels aren't indented, allow a single space however if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { - WARN("labels should not be indented\n" . $herecurr); + WARN("INDENTED_LABEL", + "labels should not be indented\n" . $herecurr); } # Return is not a function. @@ -2276,23 +2540,47 @@ sub process { } #print "value<$value>\n"; if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) { - ERROR("return is not a function, parentheses are not required\n" . $herecurr); + ERROR("RETURN_PARENTHESES", + "return is not a function, parentheses are not required\n" . $herecurr); } elsif ($spacing !~ /\s+/) { - ERROR("space required before the open parenthesis '('\n" . $herecurr); + ERROR("SPACING", + "space required before the open parenthesis '('\n" . $herecurr); } } # Return of what appears to be an errno should normally be -'ve if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) { my $name = $1; if ($name ne 'EOF' && $name ne 'ERROR') { - WARN("return of an errno should typically be -ve (return -$1)\n" . $herecurr); + WARN("USE_NEGATIVE_ERRNO", + "return of an errno should typically be -ve (return -$1)\n" . $herecurr); + } + } + +# typecasts on min/max could be min_t/max_t + if ($line =~ /^\+(?:.*?)\b(min|max)\s*\($Typecast{0,1}($LvalOrFunc)\s*,\s*$Typecast{0,1}($LvalOrFunc)\s*\)/) { + if (defined $2 || defined $8) { + my $call = $1; + my $cast1 = deparenthesize($2); + my $arg1 = $3; + my $cast2 = deparenthesize($8); + my $arg2 = $9; + my $cast; + + if ($cast1 ne "" && $cast2 ne "") { + $cast = "$cast1 or $cast2"; + } elsif ($cast1 ne "") { + $cast = $cast1; + } else { + $cast = $cast2; + } + WARN("$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr); } } # Need a space before open parenthesis after if, while etc if ($line=~/\b(if|while|for|switch)\(/) { - ERROR("space required before the open parenthesis '('\n" . $herecurr); + ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); } # Check for illegal assignment in if conditional -- and check for trailing @@ -2320,7 +2608,8 @@ sub process { my ($s, $c) = ($stat, $cond); if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) { - ERROR("do not use assignment in if condition\n" . $herecurr); + ERROR("ASSIGN_IN_IF", + "do not use assignment in if condition\n" . $herecurr); } # Find out what is on the end of the line after the @@ -2342,7 +2631,8 @@ sub process { $stat_real = "[...]\n$stat_real"; } - ERROR("trailing statements should be on next line\n" . $herecurr . $stat_real); + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr . $stat_real); } } @@ -2358,7 +2648,8 @@ sub process { (?:\&\&|\|\||\)|\]) )/x) { - WARN("boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr); + WARN("HEXADECIMAL_BOOLEAN_TEST", + "boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr); } # if and else should not have general statements after it @@ -2366,12 +2657,14 @@ sub process { my $s = $1; $s =~ s/$;//g; # Remove any comments if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) { - ERROR("trailing statements should be on next line\n" . $herecurr); + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr); } } # if should not continue a brace if ($line =~ /}\s*if\b/) { - ERROR("trailing statements should be on next line\n" . + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr); } # case and default should not have general statements after them @@ -2381,14 +2674,16 @@ sub process { \s*return\s+ )/xg) { - ERROR("trailing statements should be on next line\n" . $herecurr); + ERROR("TRAILING_STATEMENTS", + "trailing statements should be on next line\n" . $herecurr); } # Check for }<nl>else {, these must be at the same # indent level to be relevant to each other. if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and $previndent == $indent) { - ERROR("else should follow close brace '}'\n" . $hereprev); + ERROR("ELSE_AFTER_BRACE", + "else should follow close brace '}'\n" . $hereprev); } if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and @@ -2401,7 +2696,8 @@ sub process { $s =~ s/\n.*//g; if ($s =~ /^\s*;/) { - ERROR("while should follow close brace '}'\n" . $hereprev); + ERROR("WHILE_AFTER_BRACE", + "while should follow close brace '}'\n" . $hereprev); } } @@ -2414,7 +2710,8 @@ sub process { #no spaces allowed after \ in define if ($line=~/\#\s*define.*\\\s$/) { - WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr); + WARN("WHITESPACE_AFTER_LINE_CONTINUATION", + "Whitepspace after \\ makes next lines useless\n" . $herecurr); } #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) @@ -2426,9 +2723,11 @@ sub process { $1 !~ /$allowed_asm_includes/) { if ($realfile =~ m{^arch/}) { - CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + CHK("ARCH_INCLUDE_LINUX", + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); } else { - WARN("Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + WARN("INCLUDE_LINUX", + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); } } } @@ -2512,7 +2811,8 @@ sub process { if ($rest !~ /while\s*\(/ && $dstat !~ /$exceptions/) { - ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); + ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", + "Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); } } elsif ($ctx !~ /;/) { @@ -2522,7 +2822,8 @@ sub process { $dstat !~ /^\.$Ident\s*=/ && $dstat =~ /$Operators/) { - ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); + ERROR("COMPLEX_MACRO", + "Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); } } } @@ -2533,7 +2834,8 @@ sub process { # ALIGN(...) # VMLINUX_SYMBOL(...) if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) { - WARN("vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr); + WARN("MISSING_VMLINUX_SYMBOL", + "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr); } # check for redundant bracing round if etc @@ -2581,7 +2883,8 @@ sub process { } } if ($seen && !$allowed) { - WARN("braces {} are not necessary for any arm of this statement\n" . $herectx); + WARN("BRACES", + "braces {} are not necessary for any arm of this statement\n" . $herectx); } } } @@ -2635,33 +2938,38 @@ sub process { $herectx .= raw_line($linenr, $n) . "\n";; } - WARN("braces {} are not necessary for single statement blocks\n" . $herectx); + WARN("BRACES", + "braces {} are not necessary for single statement blocks\n" . $herectx); } } # don't include deprecated include files (uses RAW line) for my $inc (@dep_includes) { if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) { - ERROR("Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr); + ERROR("DEPRECATED_INCLUDE", + "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr); } } # don't use deprecated functions for my $func (@dep_functions) { if ($line =~ /\b$func\b/) { - ERROR("Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr); + ERROR("DEPRECATED_FUNCTION", + "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr); } } # no volatiles please my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b}; if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) { - WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); + WARN("VOLATILE", + "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); } # warn about #if 0 if ($line =~ /^.\s*\#\s*if\s+0\b/) { - CHK("if this code is redundant consider removing it\n" . + CHK("REDUNDANT_CODE", + "if this code is redundant consider removing it\n" . $herecurr); } @@ -2669,14 +2977,16 @@ sub process { if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { my $expr = $1; if ($line =~ /\bkfree\(\Q$expr\E\);/) { - WARN("kfree(NULL) is safe this check is probably not required\n" . $hereprev); + WARN("NEEDLESS_KFREE", + "kfree(NULL) is safe this check is probably not required\n" . $hereprev); } } # check for needless usb_free_urb() checks if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { my $expr = $1; if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { - WARN("usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); + WARN("NEEDLESS_USB_FREE_URB", + "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); } } @@ -2684,14 +2994,16 @@ sub process { if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { # ignore udelay's < 10, however if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { - CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); + CHK("USLEEP_RANGE", + "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); } } # warn about unexpectedly long msleep's if ($line =~ /\bmsleep\s*\((\d+)\);/) { if ($1 < 20) { - WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line); + WARN("MSLEEP", + "msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line); } } @@ -2704,7 +3016,8 @@ sub process { # warn about spacing in #ifdefs if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) { - ERROR("exactly one space required after that #$1\n" . $herecurr); + ERROR("SPACING", + "exactly one space required after that #$1\n" . $herecurr); } # check for spinlock_t definitions without a comment. @@ -2712,50 +3025,65 @@ sub process { $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) { my $which = $1; if (!ctx_has_comment($first_line, $linenr)) { - CHK("$1 definition without comment\n" . $herecurr); + CHK("UNCOMMENTED_DEFINITION", + "$1 definition without comment\n" . $herecurr); } } # check for memory barriers without a comment. if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { if (!ctx_has_comment($first_line, $linenr)) { - CHK("memory barrier without comment\n" . $herecurr); + CHK("MEMORY_BARRIER", + "memory barrier without comment\n" . $herecurr); } } # check of hardware specific defines if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) { - CHK("architecture specific defines should be avoided\n" . $herecurr); + CHK("ARCH_DEFINES", + "architecture specific defines should be avoided\n" . $herecurr); } # Check that the storage class is at the beginning of a declaration if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) { - WARN("storage class should be at the beginning of the declaration\n" . $herecurr) + WARN("STORAGE_CLASS", + "storage class should be at the beginning of the declaration\n" . $herecurr) } # check the location of the inline attribute, that it is between # storage class and type. if ($line =~ /\b$Type\s+$Inline\b/ || $line =~ /\b$Inline\s+$Storage\b/) { - ERROR("inline keyword should sit between storage class and type\n" . $herecurr); + ERROR("INLINE_LOCATION", + "inline keyword should sit between storage class and type\n" . $herecurr); } # Check for __inline__ and __inline, prefer inline if ($line =~ /\b(__inline__|__inline)\b/) { - WARN("plain inline is preferred over $1\n" . $herecurr); + WARN("INLINE", + "plain inline is preferred over $1\n" . $herecurr); } # Check for __attribute__ packed, prefer __packed if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) { - WARN("__packed is preferred over __attribute__((packed))\n" . $herecurr); + WARN("PREFER_PACKED", + "__packed is preferred over __attribute__((packed))\n" . $herecurr); + } + +# Check for __attribute__ aligned, prefer __aligned + if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) { + WARN("PREFER_ALIGNED", + "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); } # check for sizeof(&) if ($line =~ /\bsizeof\s*\(\s*\&/) { - WARN("sizeof(& should be avoided\n" . $herecurr); + WARN("SIZEOF_ADDRESS", + "sizeof(& should be avoided\n" . $herecurr); } # check for line continuations in quoted strings with odd counts of " if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { - WARN("Avoid line continuations in quoted strings\n" . $herecurr); + WARN("LINE_CONTINUATIONS", + "Avoid line continuations in quoted strings\n" . $herecurr); } # check for new externs in .c files. @@ -2772,17 +3100,20 @@ sub process { if ($s =~ /^\s*;/ && $function_name ne 'uninitialized_var') { - WARN("externs should be avoided in .c files\n" . $herecurr); + WARN("AVOID_EXTERNS", + "externs should be avoided in .c files\n" . $herecurr); } if ($paren_space =~ /\n/) { - WARN("arguments for function declarations should follow identifier\n" . $herecurr); + WARN("FUNCTION_ARGUMENTS", + "arguments for function declarations should follow identifier\n" . $herecurr); } } elsif ($realfile =~ /\.c$/ && defined $stat && $stat =~ /^.\s*extern\s+/) { - WARN("externs should be avoided in .c files\n" . $herecurr); + WARN("AVOID_EXTERNS", + "externs should be avoided in .c files\n" . $herecurr); } # checks for new __setup's @@ -2790,37 +3121,44 @@ sub process { my $name = $1; if (!grep(/$name/, @setup_docs)) { - CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); + CHK("UNDOCUMENTED_SETUP", + "__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); } } # check for pointless casting of kmalloc return if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) { - WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); + WARN("UNNECESSARY_CASTS", + "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); } # check for multiple semicolons if ($line =~ /;\s*;\s*$/) { - WARN("Statements terminations use 1 semicolon\n" . $herecurr); + WARN("ONE_SEMICOLON", + "Statements terminations use 1 semicolon\n" . $herecurr); } # check for gcc specific __FUNCTION__ if ($line =~ /__FUNCTION__/) { - WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); + WARN("USE_FUNC", + "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); } # check for semaphores initialized locked if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { - WARN("consider using a completion\n" . $herecurr); + WARN("CONSIDER_COMPLETION", + "consider using a completion\n" . $herecurr); } # recommend kstrto* over simple_strto* if ($line =~ /\bsimple_(strto.*?)\s*\(/) { - WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr); + WARN("CONSIDER_KSTRTO", + "consider using kstrto* in preference to simple_$1\n" . $herecurr); } # check for __initcall(), use device_initcall() explicitly please if ($line =~ /^.\s*__initcall\s*\(/) { - WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); + WARN("USE_DEVICE_INITCALL", + "please use device_initcall() instead of __initcall()\n" . $herecurr); } # check for various ops structs, ensure they are const. my $struct_ops = qr{acpi_dock_ops| @@ -2862,7 +3200,8 @@ sub process { wd_ops}x; if ($line !~ /\bconst\b/ && $line =~ /\bstruct\s+($struct_ops)\b/) { - WARN("struct $1 should normally be const\n" . + WARN("CONST_STRUCT", + "struct $1 should normally be const\n" . $herecurr); } @@ -2875,7 +3214,8 @@ sub process { $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ && $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/) { - WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); + WARN("NR_CPUS", + "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); } # check for %L{u,d,i} in strings @@ -2884,7 +3224,8 @@ sub process { $string = substr($rawline, $-[1], $+[1] - $-[1]); $string =~ s/%%/__/g; if ($string =~ /(?<!%)%L[udi]/) { - WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr); + WARN("PRINTF_L", + "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr); last; } } @@ -2892,9 +3233,11 @@ sub process { # whine mightly about in_atomic if ($line =~ /\bin_atomic\s*\(/) { if ($realfile =~ m@^drivers/@) { - ERROR("do not use in_atomic in drivers\n" . $herecurr); + ERROR("IN_ATOMIC", + "do not use in_atomic in drivers\n" . $herecurr); } elsif ($realfile !~ m@^kernel/@) { - WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); + WARN("IN_ATOMIC", + "use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); } } @@ -2904,18 +3247,21 @@ sub process { if ($realfile !~ m@^kernel/lockdep@ && $realfile !~ m@^include/linux/lockdep@ && $realfile !~ m@^drivers/base/core@) { - ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); + ERROR("LOCKDEP", + "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr); } } if ($line =~ /debugfs_create_file.*S_IWUGO/ || $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { - WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); + WARN("EXPORTED_WORLD_WRITABLE", + "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); } # Check for memset with swapped arguments if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) { - ERROR("memset size is 3rd argument, not the second.\n" . $herecurr); + ERROR("MEMSET", + "memset size is 3rd argument, not the second.\n" . $herecurr); } } @@ -2938,10 +3284,12 @@ sub process { } if (!$is_patch) { - ERROR("Does not appear to be a unified-diff format patch\n"); + ERROR("NOT_UNIFIED_DIFF", + "Does not appear to be a unified-diff format patch\n"); } if ($is_patch && $chk_signoff && $signoff == 0) { - ERROR("Missing Signed-off-by: line(s)\n"); + ERROR("MISSING_SIGN_OFF", + "Missing Signed-off-by: line(s)\n"); } print report_dump(); @@ -2963,13 +3311,25 @@ sub process { } } + if (keys %ignore_type) { + print "NOTE: Ignored message types:"; + foreach my $ignore (sort keys %ignore_type) { + print " $ignore"; + } + print "\n"; + print "\n" if ($quiet == 0); + } + if ($clean == 1 && $quiet == 0) { print "$vname has no obvious style problems and is ready for submission.\n" } if ($clean == 0 && $quiet == 0) { - print "$vname has style problems, please review. If any of these errors\n"; - print "are false positives report them to the maintainer, see\n"; - print "CHECKPATCH in MAINTAINERS.\n"; + print << "EOM"; +$vname has style problems, please review. + +If any of these errors are false positives, please report +them to the maintainer, see CHECKPATCH in MAINTAINERS. +EOM } return $clean; diff --git a/scripts/docproc.c b/scripts/docproc.c index 98dec87974d0..4cfdc1797eb8 100644 --- a/scripts/docproc.c +++ b/scripts/docproc.c @@ -205,8 +205,7 @@ static void find_export_symbols(char * filename) PATH_MAX - strlen(real_filename)); sym = add_new_file(filename); fp = fopen(real_filename, "r"); - if (fp == NULL) - { + if (fp == NULL) { fprintf(stderr, "docproc: "); perror(real_filename); exit(1); @@ -487,8 +486,7 @@ static void parse_file(FILE *infile) default: defaultline(line); } - } - else { + } else { defaultline(line); } } @@ -519,8 +517,7 @@ int main(int argc, char *argv[]) exit(2); } - if (strcmp("doc", argv[1]) == 0) - { + if (strcmp("doc", argv[1]) == 0) { /* Need to do this in two passes. * First pass is used to collect all symbols exported * in the various files; @@ -556,9 +553,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Warning: didn't use docs for %s\n", all_list[i]); } - } - else if (strcmp("depend", argv[1]) == 0) - { + } else if (strcmp("depend", argv[1]) == 0) { /* Create first part of dependency chain * file.tmpl */ printf("%s\t", argv[2]); @@ -571,9 +566,7 @@ int main(int argc, char *argv[]) findall = adddep; parse_file(infile); printf("\n"); - } - else - { + } else { fprintf(stderr, "Unknown option: %s\n", argv[1]); exit(1); } diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 04a31c17639f..6d1c6bb9f224 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -25,31 +25,5 @@ HOSTCFLAGS_dtc-lexer.lex.o := $(HOSTCFLAGS_DTC) HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) # dependencies on generated files need to be listed explicitly -$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h -$(obj)/dtc-lexer.lex.o: $(obj)/dtc-lexer.lex.c $(obj)/dtc-parser.tab.h +$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h -targets += dtc-parser.tab.c dtc-lexer.lex.c - -clean-files += dtc-parser.tab.h - -# GENERATE_PARSER := 1 # Uncomment to rebuild flex/bison output - -ifdef GENERATE_PARSER - -BISON = bison -FLEX = flex - -quiet_cmd_bison = BISON $@ - cmd_bison = $(BISON) -o$@ -d $<; cp $@ $@_shipped -quiet_cmd_flex = FLEX $@ - cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped - -$(obj)/dtc-parser.tab.c: $(src)/dtc-parser.y FORCE - $(call if_changed,bison) - -$(obj)/dtc-parser.tab.h: $(obj)/dtc-parser.tab.c - -$(obj)/dtc-lexer.lex.c: $(src)/dtc-lexer.l FORCE - $(call if_changed,flex) - -endif diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped index 50c4420b4b2c..8bbe12817050 100644 --- a/scripts/dtc/dtc-lexer.lex.c_shipped +++ b/scripts/dtc/dtc-lexer.lex.c_shipped @@ -1,6 +1,5 @@ -#line 2 "dtc-lexer.lex.c" -#line 4 "dtc-lexer.lex.c" +#line 3 "scripts/dtc/dtc-lexer.lex.c_shipped" #define YY_INT_ALIGNED short int @@ -54,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -142,15 +140,7 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -550,7 +540,6 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "dtc-lexer.l" /* * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. * @@ -572,10 +561,6 @@ char *yytext; */ #define YY_NO_INPUT 1 - - - -#line 37 "dtc-lexer.l" #include "dtc.h" #include "srcpos.h" #include "dtc-parser.tab.h" @@ -603,7 +588,6 @@ static int dts_version = 1; static void push_input_file(const char *filename); static int pop_input_file(void); -#line 607 "dtc-lexer.lex.c" #define INITIAL 0 #define INCLUDE 1 @@ -686,12 +670,7 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -710,7 +689,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -792,10 +771,6 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 66 "dtc-lexer.l" - -#line 798 "dtc-lexer.lex.c" - if ( !(yy_init) ) { (yy_init) = 1; @@ -876,7 +851,6 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 67 "dtc-lexer.l" { char *name = strchr(yytext, '\"') + 1; yytext[yyleng-1] = '\0'; @@ -888,7 +862,6 @@ case YY_STATE_EOF(INCLUDE): case YY_STATE_EOF(BYTESTRING): case YY_STATE_EOF(PROPNODENAME): case YY_STATE_EOF(V1): -#line 73 "dtc-lexer.l" { if (!pop_input_file()) { yyterminate(); @@ -898,7 +871,6 @@ case YY_STATE_EOF(V1): case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 79 "dtc-lexer.l" { DPRINT("String: %s\n", yytext); yylval.data = data_copy_escape_string(yytext+1, @@ -908,7 +880,6 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 86 "dtc-lexer.l" { DPRINT("Keyword: /dts-v1/\n"); dts_version = 1; @@ -918,7 +889,6 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 93 "dtc-lexer.l" { DPRINT("Keyword: /memreserve/\n"); BEGIN_DEFAULT(); @@ -927,7 +897,6 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 99 "dtc-lexer.l" { DPRINT("Label: %s\n", yytext); yylval.labelref = xstrdup(yytext); @@ -937,7 +906,6 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 106 "dtc-lexer.l" { yylval.literal = xstrdup(yytext); DPRINT("Literal: '%s'\n", yylval.literal); @@ -946,7 +914,6 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 112 "dtc-lexer.l" { /* label reference */ DPRINT("Ref: %s\n", yytext+1); yylval.labelref = xstrdup(yytext+1); @@ -955,7 +922,6 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 118 "dtc-lexer.l" { /* new-style path reference */ yytext[yyleng-1] = '\0'; DPRINT("Ref: %s\n", yytext+2); @@ -965,7 +931,6 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 125 "dtc-lexer.l" { yylval.byte = strtol(yytext, NULL, 16); DPRINT("Byte: %02x\n", (int)yylval.byte); @@ -974,7 +939,6 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 131 "dtc-lexer.l" { DPRINT("/BYTESTRING\n"); BEGIN_DEFAULT(); @@ -983,7 +947,6 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 137 "dtc-lexer.l" { DPRINT("PropNodeName: %s\n", yytext); yylval.propnodename = xstrdup(yytext); @@ -993,7 +956,6 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 144 "dtc-lexer.l" { DPRINT("Binary Include\n"); return DT_INCBIN; @@ -1002,24 +964,20 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 149 "dtc-lexer.l" /* eat whitespace */ YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 150 "dtc-lexer.l" /* eat C-style comments */ YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 151 "dtc-lexer.l" /* eat C++-style comments */ YY_BREAK case 16: YY_RULE_SETUP -#line 153 "dtc-lexer.l" { DPRINT("Char: %c (\\x%02x)\n", yytext[0], (unsigned)yytext[0]); @@ -1037,10 +995,8 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 168 "dtc-lexer.l" ECHO; YY_BREAK -#line 1044 "dtc-lexer.lex.c" case YY_END_OF_BUFFER: { @@ -1756,8 +1712,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ @@ -1996,10 +1952,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 168 "dtc-lexer.l" - - - static void push_input_file(const char *filename) { assert(filename); @@ -2011,7 +1963,6 @@ static void push_input_file(const char *filename) yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE)); } - static int pop_input_file(void) { if (srcfile_pop() == 0) diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped index 9be2eea18a30..b05921e1e848 100644 --- a/scripts/dtc/dtc-parser.tab.c_shipped +++ b/scripts/dtc/dtc-parser.tab.c_shipped @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,8 +66,6 @@ /* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ -#line 21 "dtc-parser.y" #include <stdio.h> @@ -87,12 +84,10 @@ extern int treesource_error; static unsigned long long eval_literal(const char *s, int base, int bits); -/* Line 189 of yacc.c */ -#line 92 "dtc-parser.tab.c" /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG 0 +# define YYDEBUG 1 #endif /* Enabling verbose error messages. */ @@ -134,8 +129,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits); typedef union YYSTYPE { -/* Line 214 of yacc.c */ -#line 39 "dtc-parser.y" char *propnodename; char *literal; @@ -154,8 +147,6 @@ typedef union YYSTYPE -/* Line 214 of yacc.c */ -#line 159 "dtc-parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -166,8 +157,6 @@ typedef union YYSTYPE /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 171 "dtc-parser.tab.c" #ifdef short # undef short @@ -217,7 +206,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -607,9 +596,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -666,7 +664,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1405,8 +1403,6 @@ yyreduce: { case 2: -/* Line 1455 of yacc.c */ -#line 87 "dtc-parser.y" { the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), guess_boot_cpuid((yyvsp[(4) - (4)].node))); @@ -1415,8 +1411,6 @@ yyreduce: case 3: -/* Line 1455 of yacc.c */ -#line 95 "dtc-parser.y" { (yyval.re) = NULL; ;} @@ -1424,8 +1418,6 @@ yyreduce: case 4: -/* Line 1455 of yacc.c */ -#line 99 "dtc-parser.y" { (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); ;} @@ -1433,8 +1425,6 @@ yyreduce: case 5: -/* Line 1455 of yacc.c */ -#line 106 "dtc-parser.y" { (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].addr), (yyvsp[(3) - (4)].addr)); ;} @@ -1442,8 +1432,6 @@ yyreduce: case 6: -/* Line 1455 of yacc.c */ -#line 110 "dtc-parser.y" { add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); (yyval.re) = (yyvsp[(2) - (2)].re); @@ -1452,8 +1440,6 @@ yyreduce: case 7: -/* Line 1455 of yacc.c */ -#line 118 "dtc-parser.y" { (yyval.addr) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); ;} @@ -1461,8 +1447,6 @@ yyreduce: case 8: -/* Line 1455 of yacc.c */ -#line 125 "dtc-parser.y" { (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); ;} @@ -1470,8 +1454,6 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ -#line 129 "dtc-parser.y" { (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); ;} @@ -1479,8 +1461,6 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ -#line 133 "dtc-parser.y" { struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); @@ -1494,8 +1474,6 @@ yyreduce: case 11: -/* Line 1455 of yacc.c */ -#line 146 "dtc-parser.y" { (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); ;} @@ -1503,8 +1481,6 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ -#line 153 "dtc-parser.y" { (yyval.proplist) = NULL; ;} @@ -1512,8 +1488,6 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ -#line 157 "dtc-parser.y" { (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); ;} @@ -1521,8 +1495,6 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ -#line 164 "dtc-parser.y" { (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); ;} @@ -1530,8 +1502,6 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ -#line 168 "dtc-parser.y" { (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); ;} @@ -1539,8 +1509,6 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ -#line 172 "dtc-parser.y" { add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); (yyval.prop) = (yyvsp[(2) - (2)].prop); @@ -1549,8 +1517,6 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ -#line 180 "dtc-parser.y" { (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); ;} @@ -1558,8 +1524,6 @@ yyreduce: case 18: -/* Line 1455 of yacc.c */ -#line 184 "dtc-parser.y" { (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); ;} @@ -1567,8 +1531,6 @@ yyreduce: case 19: -/* Line 1455 of yacc.c */ -#line 188 "dtc-parser.y" { (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); ;} @@ -1576,8 +1538,6 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ -#line 192 "dtc-parser.y" { (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); ;} @@ -1585,8 +1545,6 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ -#line 196 "dtc-parser.y" { FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); struct data d; @@ -1607,8 +1565,6 @@ yyreduce: case 22: -/* Line 1455 of yacc.c */ -#line 213 "dtc-parser.y" { FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); struct data d = empty_data; @@ -1622,8 +1578,6 @@ yyreduce: case 23: -/* Line 1455 of yacc.c */ -#line 223 "dtc-parser.y" { (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); ;} @@ -1631,8 +1585,6 @@ yyreduce: case 24: -/* Line 1455 of yacc.c */ -#line 230 "dtc-parser.y" { (yyval.data) = empty_data; ;} @@ -1640,8 +1592,6 @@ yyreduce: case 25: -/* Line 1455 of yacc.c */ -#line 234 "dtc-parser.y" { (yyval.data) = (yyvsp[(1) - (2)].data); ;} @@ -1649,8 +1599,6 @@ yyreduce: case 26: -/* Line 1455 of yacc.c */ -#line 238 "dtc-parser.y" { (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); ;} @@ -1658,8 +1606,6 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ -#line 245 "dtc-parser.y" { (yyval.data) = empty_data; ;} @@ -1667,8 +1613,6 @@ yyreduce: case 28: -/* Line 1455 of yacc.c */ -#line 249 "dtc-parser.y" { (yyval.data) = data_append_cell((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].cell)); ;} @@ -1676,8 +1620,6 @@ yyreduce: case 29: -/* Line 1455 of yacc.c */ -#line 253 "dtc-parser.y" { (yyval.data) = data_append_cell(data_add_marker((yyvsp[(1) - (2)].data), REF_PHANDLE, (yyvsp[(2) - (2)].labelref)), -1); @@ -1686,8 +1628,6 @@ yyreduce: case 30: -/* Line 1455 of yacc.c */ -#line 258 "dtc-parser.y" { (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); ;} @@ -1695,8 +1635,6 @@ yyreduce: case 31: -/* Line 1455 of yacc.c */ -#line 265 "dtc-parser.y" { (yyval.cell) = eval_literal((yyvsp[(1) - (1)].literal), 0, 32); ;} @@ -1704,8 +1642,6 @@ yyreduce: case 32: -/* Line 1455 of yacc.c */ -#line 272 "dtc-parser.y" { (yyval.data) = empty_data; ;} @@ -1713,8 +1649,6 @@ yyreduce: case 33: -/* Line 1455 of yacc.c */ -#line 276 "dtc-parser.y" { (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); ;} @@ -1722,8 +1656,6 @@ yyreduce: case 34: -/* Line 1455 of yacc.c */ -#line 280 "dtc-parser.y" { (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); ;} @@ -1731,8 +1663,6 @@ yyreduce: case 35: -/* Line 1455 of yacc.c */ -#line 287 "dtc-parser.y" { (yyval.nodelist) = NULL; ;} @@ -1740,8 +1670,6 @@ yyreduce: case 36: -/* Line 1455 of yacc.c */ -#line 291 "dtc-parser.y" { (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); ;} @@ -1749,8 +1677,6 @@ yyreduce: case 37: -/* Line 1455 of yacc.c */ -#line 295 "dtc-parser.y" { print_error("syntax error: properties must precede subnodes"); YYERROR; @@ -1759,8 +1685,6 @@ yyreduce: case 38: -/* Line 1455 of yacc.c */ -#line 303 "dtc-parser.y" { (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); ;} @@ -1768,8 +1692,6 @@ yyreduce: case 39: -/* Line 1455 of yacc.c */ -#line 307 "dtc-parser.y" { add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); (yyval.node) = (yyvsp[(2) - (2)].node); @@ -1778,8 +1700,6 @@ yyreduce: -/* Line 1455 of yacc.c */ -#line 1783 "dtc-parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1990,8 +1910,6 @@ yyreturn: -/* Line 1675 of yacc.c */ -#line 313 "dtc-parser.y" void print_error(char const *fmt, ...) diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped index 95c9547adea5..4ee682bb7d33 100644 --- a/scripts/dtc/dtc-parser.tab.h_shipped +++ b/scripts/dtc/dtc-parser.tab.h_shipped @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -58,8 +57,6 @@ typedef union YYSTYPE { -/* Line 1676 of yacc.c */ -#line 39 "dtc-parser.y" char *propnodename; char *literal; @@ -78,8 +75,6 @@ typedef union YYSTYPE -/* Line 1676 of yacc.c */ -#line 83 "dtc-parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh index 520d16b1ffaf..98cffcb941ea 100644 --- a/scripts/gcc-goto.sh +++ b/scripts/gcc-goto.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Test for gcc 'asm goto' suport +# Test for gcc 'asm goto' support # Copyright (C) 2010, Jason Baron <jbaron@redhat.com> echo "int main(void) { entry: asm goto (\"\"::::entry); return 0; }" | $@ -x c - -c -o /dev/null >/dev/null 2>&1 && echo "y" diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore index be5cadb1b907..86dc07a01b43 100644 --- a/scripts/genksyms/.gitignore +++ b/scripts/genksyms/.gitignore @@ -1,4 +1,5 @@ -keywords.c -lex.c -parse.[ch] +*.hash.c +*.lex.c +*.tab.c +*.tab.h genksyms diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index 13d03cf05d95..a5510903e874 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -2,52 +2,12 @@ hostprogs-y := genksyms always := $(hostprogs-y) -genksyms-objs := genksyms.o parse.o lex.o +genksyms-objs := genksyms.o parse.tab.o lex.lex.o # -I needed for generated C source (shipped source) -HOSTCFLAGS_parse.o := -Wno-uninitialized -I$(src) +HOSTCFLAGS_parse.tab.o := -I$(src) +HOSTCFLAGS_lex.lex.o := -I$(src) # dependencies on generated files need to be listed explicitly -$(obj)/lex.o: $(obj)/parse.h $(obj)/keywords.c +$(obj)/lex.lex.o: $(obj)/keywords.hash.c $(obj)/parse.tab.h -# -I needed for generated C source (shipped source) -HOSTCFLAGS_lex.o := -I$(src) - -ifdef GENERATE_PARSER - -# gperf - -quiet_cmd_keywords.c = GPERF $@ - cmd_keywords.c = gperf -L ANSI-C -a -C -E -g -H is_reserved_hash \ - -k 1,3,$$ -N is_reserved_word -p -t $< > $@ - -$(obj)/keywords.c: $(obj)/keywords.gperf FORCE - $(call if_changed,keywords.c) - cp $@ $@_shipped - -# flex - -quiet_cmd_lex.c = FLEX $@ - cmd_lex.c = flex -o$@ -d $< - -$(obj)/lex.c: $(obj)/lex.l $(obj)/keywords.c FORCE - $(call if_changed,lex.c) - cp $@ $@_shipped - -# bison - -quiet_cmd_parse.c = BISON $@ - cmd_parse.c = bison -o$@ -dtv $(filter-out FORCE,$^) - -$(obj)/parse.c: $(obj)/parse.y FORCE - $(call if_changed,parse.c) - cp $@ $@_shipped - cp $(@:.c=.h) $(@:.c=.h)_shipped - -$(obj)/parse.h: $(obj)/parse.c ; - -clean-files += parse.output - -endif - -targets += keywords.c lex.c parse.c parse.h diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index f9e75531ea03..6d3fda0ce2ae 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -448,7 +448,7 @@ static struct string_list *read_node(FILE *f) node.string = buffer; if (node.string[1] == '#') { - int n; + size_t n; for (n = 0; n < ARRAY_SIZE(symbol_types); n++) { if (node.string[0] == symbol_types[n].n) { diff --git a/scripts/genksyms/keywords.gperf b/scripts/genksyms/keywords.gperf index e6349acb6f2f..3e77a943e7b7 100644 --- a/scripts/genksyms/keywords.gperf +++ b/scripts/genksyms/keywords.gperf @@ -1,3 +1,6 @@ +%language=ANSI-C +%define hash-function-name is_reserved_hash +%define lookup-function-name is_reserved_word %{ struct resword; static const struct resword *is_reserved_word(register const char *str, register unsigned int len); diff --git a/scripts/genksyms/keywords.c_shipped b/scripts/genksyms/keywords.hash.c_shipped index 8060e06798b3..82062607e8c0 100644 --- a/scripts/genksyms/keywords.c_shipped +++ b/scripts/genksyms/keywords.hash.c_shipped @@ -1,5 +1,5 @@ /* ANSI-C code produced by gperf version 3.0.4 */ -/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ +/* Command-line: gperf -t --output-file scripts/genksyms/keywords.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/genksyms/keywords.gperf */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -28,11 +28,11 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." #endif -#line 1 "scripts/genksyms/keywords.gperf" +#line 4 "scripts/genksyms/keywords.gperf" struct resword; static const struct resword *is_reserved_word(register const char *str, register unsigned int len); -#line 5 "scripts/genksyms/keywords.gperf" +#line 8 "scripts/genksyms/keywords.gperf" struct resword { const char *name; int token; }; /* maximum key range = 64, duplicates = 0 */ @@ -99,108 +99,108 @@ is_reserved_word (register const char *str, register unsigned int len) static const struct resword wordlist[] = { {""}, {""}, {""}, -#line 30 "scripts/genksyms/keywords.gperf" +#line 33 "scripts/genksyms/keywords.gperf" {"asm", ASM_KEYW}, {""}, -#line 12 "scripts/genksyms/keywords.gperf" +#line 15 "scripts/genksyms/keywords.gperf" {"__asm", ASM_KEYW}, {""}, -#line 13 "scripts/genksyms/keywords.gperf" +#line 16 "scripts/genksyms/keywords.gperf" {"__asm__", ASM_KEYW}, {""}, {""}, -#line 56 "scripts/genksyms/keywords.gperf" +#line 59 "scripts/genksyms/keywords.gperf" {"__typeof__", TYPEOF_KEYW}, {""}, -#line 16 "scripts/genksyms/keywords.gperf" +#line 19 "scripts/genksyms/keywords.gperf" {"__const", CONST_KEYW}, -#line 15 "scripts/genksyms/keywords.gperf" +#line 18 "scripts/genksyms/keywords.gperf" {"__attribute__", ATTRIBUTE_KEYW}, -#line 17 "scripts/genksyms/keywords.gperf" +#line 20 "scripts/genksyms/keywords.gperf" {"__const__", CONST_KEYW}, -#line 22 "scripts/genksyms/keywords.gperf" +#line 25 "scripts/genksyms/keywords.gperf" {"__signed__", SIGNED_KEYW}, -#line 48 "scripts/genksyms/keywords.gperf" +#line 51 "scripts/genksyms/keywords.gperf" {"static", STATIC_KEYW}, {""}, -#line 43 "scripts/genksyms/keywords.gperf" +#line 46 "scripts/genksyms/keywords.gperf" {"int", INT_KEYW}, -#line 36 "scripts/genksyms/keywords.gperf" +#line 39 "scripts/genksyms/keywords.gperf" {"char", CHAR_KEYW}, -#line 37 "scripts/genksyms/keywords.gperf" +#line 40 "scripts/genksyms/keywords.gperf" {"const", CONST_KEYW}, -#line 49 "scripts/genksyms/keywords.gperf" +#line 52 "scripts/genksyms/keywords.gperf" {"struct", STRUCT_KEYW}, -#line 28 "scripts/genksyms/keywords.gperf" +#line 31 "scripts/genksyms/keywords.gperf" {"__restrict__", RESTRICT_KEYW}, -#line 29 "scripts/genksyms/keywords.gperf" +#line 32 "scripts/genksyms/keywords.gperf" {"restrict", RESTRICT_KEYW}, -#line 9 "scripts/genksyms/keywords.gperf" +#line 12 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW}, -#line 20 "scripts/genksyms/keywords.gperf" +#line 23 "scripts/genksyms/keywords.gperf" {"__inline__", INLINE_KEYW}, {""}, -#line 24 "scripts/genksyms/keywords.gperf" +#line 27 "scripts/genksyms/keywords.gperf" {"__volatile__", VOLATILE_KEYW}, -#line 7 "scripts/genksyms/keywords.gperf" +#line 10 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, -#line 27 "scripts/genksyms/keywords.gperf" +#line 30 "scripts/genksyms/keywords.gperf" {"_restrict", RESTRICT_KEYW}, {""}, -#line 14 "scripts/genksyms/keywords.gperf" +#line 17 "scripts/genksyms/keywords.gperf" {"__attribute", ATTRIBUTE_KEYW}, -#line 8 "scripts/genksyms/keywords.gperf" +#line 11 "scripts/genksyms/keywords.gperf" {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, -#line 18 "scripts/genksyms/keywords.gperf" +#line 21 "scripts/genksyms/keywords.gperf" {"__extension__", EXTENSION_KEYW}, -#line 39 "scripts/genksyms/keywords.gperf" +#line 42 "scripts/genksyms/keywords.gperf" {"enum", ENUM_KEYW}, -#line 10 "scripts/genksyms/keywords.gperf" +#line 13 "scripts/genksyms/keywords.gperf" {"EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW}, -#line 40 "scripts/genksyms/keywords.gperf" +#line 43 "scripts/genksyms/keywords.gperf" {"extern", EXTERN_KEYW}, {""}, -#line 21 "scripts/genksyms/keywords.gperf" +#line 24 "scripts/genksyms/keywords.gperf" {"__signed", SIGNED_KEYW}, -#line 11 "scripts/genksyms/keywords.gperf" +#line 14 "scripts/genksyms/keywords.gperf" {"EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, -#line 51 "scripts/genksyms/keywords.gperf" +#line 54 "scripts/genksyms/keywords.gperf" {"union", UNION_KEYW}, -#line 55 "scripts/genksyms/keywords.gperf" +#line 58 "scripts/genksyms/keywords.gperf" {"typeof", TYPEOF_KEYW}, -#line 50 "scripts/genksyms/keywords.gperf" +#line 53 "scripts/genksyms/keywords.gperf" {"typedef", TYPEDEF_KEYW}, -#line 19 "scripts/genksyms/keywords.gperf" +#line 22 "scripts/genksyms/keywords.gperf" {"__inline", INLINE_KEYW}, -#line 35 "scripts/genksyms/keywords.gperf" +#line 38 "scripts/genksyms/keywords.gperf" {"auto", AUTO_KEYW}, -#line 23 "scripts/genksyms/keywords.gperf" +#line 26 "scripts/genksyms/keywords.gperf" {"__volatile", VOLATILE_KEYW}, {""}, {""}, -#line 52 "scripts/genksyms/keywords.gperf" +#line 55 "scripts/genksyms/keywords.gperf" {"unsigned", UNSIGNED_KEYW}, {""}, -#line 46 "scripts/genksyms/keywords.gperf" +#line 49 "scripts/genksyms/keywords.gperf" {"short", SHORT_KEYW}, -#line 42 "scripts/genksyms/keywords.gperf" +#line 45 "scripts/genksyms/keywords.gperf" {"inline", INLINE_KEYW}, {""}, -#line 54 "scripts/genksyms/keywords.gperf" +#line 57 "scripts/genksyms/keywords.gperf" {"volatile", VOLATILE_KEYW}, -#line 44 "scripts/genksyms/keywords.gperf" +#line 47 "scripts/genksyms/keywords.gperf" {"long", LONG_KEYW}, -#line 26 "scripts/genksyms/keywords.gperf" +#line 29 "scripts/genksyms/keywords.gperf" {"_Bool", BOOL_KEYW}, {""}, {""}, -#line 45 "scripts/genksyms/keywords.gperf" +#line 48 "scripts/genksyms/keywords.gperf" {"register", REGISTER_KEYW}, -#line 53 "scripts/genksyms/keywords.gperf" +#line 56 "scripts/genksyms/keywords.gperf" {"void", VOID_KEYW}, -#line 41 "scripts/genksyms/keywords.gperf" +#line 44 "scripts/genksyms/keywords.gperf" {"float", FLOAT_KEYW}, -#line 38 "scripts/genksyms/keywords.gperf" +#line 41 "scripts/genksyms/keywords.gperf" {"double", DOUBLE_KEYW}, {""}, {""}, {""}, {""}, -#line 47 "scripts/genksyms/keywords.gperf" +#line 50 "scripts/genksyms/keywords.gperf" {"signed", SIGNED_KEYW} }; diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l index e4ddd493fec3..400ae06a70df 100644 --- a/scripts/genksyms/lex.l +++ b/scripts/genksyms/lex.l @@ -29,7 +29,7 @@ #include <ctype.h> #include "genksyms.h" -#include "parse.h" +#include "parse.tab.h" /* We've got a two-level lexer here. We let flex do basic tokenization and then we categorize those basic tokens in the second stage. */ @@ -94,7 +94,7 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>) /* Bring in the keyword recognizer. */ -#include "keywords.c" +#include "keywords.hash.c" /* Macros to append to our phrase collection list. */ diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.lex.c_shipped index af4939041e4b..c83cf60410be 100644 --- a/scripts/genksyms/lex.c_shipped +++ b/scripts/genksyms/lex.lex.c_shipped @@ -1,20 +1,10 @@ -#line 2 "scripts/genksyms/lex.c" -#line 4 "scripts/genksyms/lex.c" +#line 3 "scripts/genksyms/lex.lex.c_shipped" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ -/* %not-for-header */ - -/* %if-c-only */ -/* %if-not-reentrant */ - -/* %endif */ -/* %endif */ -/* %ok-for-header */ - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 @@ -23,32 +13,16 @@ #define FLEX_BETA #endif -/* %if-c++-only */ -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -/* %if-c-only */ #include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h> -/* %endif */ -/* %if-tables-serialization */ -/* %endif */ /* end standard C headers. */ -/* %if-c-or-c++ */ /* flex integer type definitions */ #ifndef FLEXINT_H @@ -112,11 +86,6 @@ typedef unsigned int flex_uint32_t; #endif /* ! FLEXINT_H */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ @@ -138,13 +107,8 @@ typedef unsigned int flex_uint32_t; #define yyconst #endif -/* %not-for-header */ - /* Returned upon end-of-file. */ #define YY_NULL 0 -/* %ok-for-header */ - -/* %not-for-header */ /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, @@ -152,14 +116,6 @@ typedef unsigned int flex_uint32_t; * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) -/* %ok-for-header */ - -/* %if-reentrant */ -/* %endif */ - -/* %if-not-reentrant */ - -/* %endif */ /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less @@ -196,15 +152,9 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -/* %if-not-reentrant */ extern int yyleng; -/* %endif */ -/* %if-c-only */ -/* %if-not-reentrant */ extern FILE *yyin, *yyout; -/* %endif */ -/* %endif */ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 @@ -237,12 +187,7 @@ typedef size_t yy_size_t; #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -/* %if-c-only */ FILE *yy_input_file; -/* %endif */ - -/* %if-c++-only */ -/* %endif */ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -303,19 +248,10 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ - -/* %if-not-reentrant */ - /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ -/* %endif */ -/* %ok-for-header */ - -/* %endif */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -332,11 +268,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] -/* %if-c-only Standard (non-C++) definition */ - -/* %if-not-reentrant */ -/* %not-for-header */ - /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ @@ -351,9 +282,6 @@ static int yy_start = 0; /* start state number */ * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -/* %ok-for-header */ - -/* %endif */ void yyrestart (FILE *input_file ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); @@ -373,8 +301,6 @@ YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); -/* %endif */ - void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); @@ -403,14 +329,11 @@ void yyfree (void * ); #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ #define yywrap(n) 1 #define YY_SKIP_YYWRAP -#define FLEX_DEBUG - typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; @@ -424,28 +347,21 @@ int yylineno = 1; extern char *yytext; #define yytext_ptr yytext -/* %if-c-only Standard (non-C++) definition */ - static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); static void yy_fatal_error (yyconst char msg[] ); -/* %endif */ - /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ -/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; -/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 13 #define YY_END_OF_BUFFER 14 /* This struct is not used in this scanner, @@ -610,13 +526,7 @@ static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; extern int yy_flex_debug; -int yy_flex_debug = 1; - -static yyconst flex_int16_t yy_rule_linenum[13] = - { 0, - 67, 68, 69, 72, 75, 76, 77, 83, 84, 85, - 87, 90 - } ; +int yy_flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -626,7 +536,6 @@ static yyconst flex_int16_t yy_rule_linenum[13] = #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "scripts/genksyms/lex.l" /* Lexical analysis for genksyms. Copyright 1996, 1997 Linux International. @@ -648,7 +557,6 @@ char *yytext; You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#line 25 "scripts/genksyms/lex.l" #include <limits.h> #include <stdlib.h> @@ -656,7 +564,7 @@ char *yytext; #include <ctype.h> #include "genksyms.h" -#include "parse.h" +#include "parse.tab.h" /* We've got a two-level lexer here. We let flex do basic tokenization and then we categorize those basic tokens in the second stage. */ @@ -664,7 +572,6 @@ char *yytext; /* We don't do multiple input files. */ #define YY_NO_INPUT 1 -#line 668 "scripts/genksyms/lex.c" #define INITIAL 0 @@ -673,28 +580,15 @@ char *yytext; * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -/* %if-c-only */ #include <unistd.h> -/* %endif */ -/* %if-c++-only */ -/* %endif */ #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -/* %if-c-only Reentrant structure and macros (non-C++). */ -/* %if-reentrant */ -/* %if-c-only */ - static int yy_init_globals (void ); -/* %endif */ -/* %if-reentrant */ -/* %endif */ -/* %endif End reentrant structures and macros. */ - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -724,9 +618,6 @@ int yyget_lineno (void ); void yyset_lineno (int line_number ); -/* %if-bison-bridge */ -/* %endif */ - /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -739,14 +630,8 @@ extern int yywrap (void ); #endif #endif -/* %not-for-header */ - static void yyunput (int c,char *buf_ptr ); -/* %ok-for-header */ - -/* %endif */ - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif @@ -756,23 +641,15 @@ static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif -/* %ok-for-header */ -/* %endif */ #endif -/* %if-c-only */ - -/* %endif */ - /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 @@ -780,14 +657,10 @@ static int input (void ); /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO -/* %if-c-only Standard (non-C++) definition */ /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -795,11 +668,10 @@ static int input (void ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ -/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -824,8 +696,6 @@ static int input (void ); } \ }\ \ -/* %if-c++-only C++ definition \ */\ -/* %endif */ #endif @@ -844,39 +714,20 @@ static int input (void ); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -/* %if-c-only */ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ #endif -/* %if-tables-serialization structures and prototypes */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %not-for-header */ - -/* %tables-yydmap generated elements */ -/* %endif */ /* end tables serialization structures and prototypes */ -/* %ok-for-header */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -/* %if-c-only Standard (non-C++) definition */ extern int yylex (void); #define YY_DECL int yylex (void) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -891,15 +742,12 @@ extern int yylex (void); #define YY_BREAK break; #endif -/* %% [6.0] YY_RULE_SETUP definition goes here */ #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION -/* %not-for-header */ - /** The main scanner function which does all the work. */ YY_DECL @@ -908,13 +756,7 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -/* %% [7.0] user's declarations go here */ -#line 63 "scripts/genksyms/lex.l" - - - /* Keep track of our location in the original source files. */ -#line 918 "scripts/genksyms/lex.c" if ( !(yy_init) ) { @@ -928,18 +770,10 @@ YY_DECL (yy_start) = 1; /* first start state */ if ( ! yyin ) -/* %if-c-only */ yyin = stdin; -/* %endif */ -/* %if-c++-only */ -/* %endif */ if ( ! yyout ) -/* %if-c-only */ yyout = stdout; -/* %endif */ -/* %if-c++-only */ -/* %endif */ if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); @@ -952,7 +786,6 @@ YY_DECL while ( 1 ) /* loops until end-of-file is reached */ { -/* %% [8.0] yymore()-related code goes here */ yy_cp = (yy_c_buf_p); /* Support of yytext. */ @@ -963,7 +796,6 @@ YY_DECL */ yy_bp = yy_cp; -/* %% [9.0] code to set up and find next match goes here */ yy_current_state = (yy_start); yy_current_state += YY_AT_BOL(); yy_match: @@ -987,7 +819,6 @@ yy_match: while ( yy_base[yy_current_state] != 266 ); yy_find_action: -/* %% [10.0] code to find the action number goes here */ yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ @@ -998,30 +829,10 @@ yy_find_action: YY_DO_BEFORE_ACTION; -/* %% [11.0] code for yylineno update goes here */ - do_action: /* This label is used only to access EOF actions. */ -/* %% [12.0] debug code goes here */ - if ( yy_flex_debug ) - { - if ( yy_act == 0 ) - fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 13 ) - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 13 ) - fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); - else if ( yy_act == 14 ) - fprintf( stderr, "--(end of buffer or a NUL)\n" ); - else - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); - } - switch ( yy_act ) { /* beginning of action switch */ -/* %% [13.0] actions go here */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); @@ -1032,42 +843,35 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 67 "scripts/genksyms/lex.l" return FILENAME; YY_BREAK case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 68 "scripts/genksyms/lex.l" cur_line++; YY_BREAK case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 69 "scripts/genksyms/lex.l" cur_line++; YY_BREAK /* Ignore all other whitespace. */ case 4: YY_RULE_SETUP -#line 72 "scripts/genksyms/lex.l" ; YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 75 "scripts/genksyms/lex.l" return STRING; YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 76 "scripts/genksyms/lex.l" return CHAR; YY_BREAK case 7: YY_RULE_SETUP -#line 77 "scripts/genksyms/lex.l" return IDENT; YY_BREAK /* The Pedant requires that the other C multi-character tokens be @@ -1076,36 +880,29 @@ return IDENT; around them properly. */ case 8: YY_RULE_SETUP -#line 83 "scripts/genksyms/lex.l" return OTHER; YY_BREAK case 9: YY_RULE_SETUP -#line 84 "scripts/genksyms/lex.l" return INT; YY_BREAK case 10: YY_RULE_SETUP -#line 85 "scripts/genksyms/lex.l" return REAL; YY_BREAK case 11: YY_RULE_SETUP -#line 87 "scripts/genksyms/lex.l" return DOTS; YY_BREAK /* All other tokens are single characters. */ case 12: YY_RULE_SETUP -#line 90 "scripts/genksyms/lex.l" return yytext[0]; YY_BREAK case 13: YY_RULE_SETUP -#line 93 "scripts/genksyms/lex.l" ECHO; YY_BREAK -#line 1109 "scripts/genksyms/lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1172,7 +969,6 @@ case YY_STATE_EOF(INITIAL): else { -/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ yy_cp = (yy_c_buf_p); goto yy_find_action; } @@ -1238,14 +1034,6 @@ case YY_STATE_EOF(INITIAL): } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ -/* %ok-for-header */ - -/* %if-c++-only */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1254,11 +1042,7 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -/* %if-c-only */ static int yy_get_next_buffer (void) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); @@ -1392,24 +1176,16 @@ static int yy_get_next_buffer (void) /* yy_get_previous_state - get the state just before the EOB char was reached */ -/* %if-c-only */ -/* %not-for-header */ - static yy_state_type yy_get_previous_state (void) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register yy_state_type yy_current_state; register char *yy_cp; -/* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = (yy_start); yy_current_state += YY_AT_BOL(); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { -/* %% [16.0] code to find the next state goes here */ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { @@ -1433,15 +1209,10 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -/* %if-c-only */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register int yy_is_jam; - /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ - register char *yy_cp = (yy_c_buf_p); + register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) @@ -1461,12 +1232,7 @@ static int yy_get_next_buffer (void) return yy_is_jam ? 0 : yy_current_state; } -/* %if-c-only */ - static void yyunput (int c, register char * yy_bp ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register char *yy_cp; @@ -1498,17 +1264,11 @@ static int yy_get_next_buffer (void) *--yy_cp = (char) c; -/* %% [18.0] update yylineno here */ - (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } -/* %if-c-only */ - -/* %endif */ -/* %if-c-only */ #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1516,9 +1276,6 @@ static int yy_get_next_buffer (void) static int input (void) #endif -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int c; @@ -1582,25 +1339,18 @@ static int yy_get_next_buffer (void) *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); -/* %% [19.0] update BOL and yylineno */ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); return c; } -/* %if-c-only */ #endif /* ifndef YY_NO_INPUT */ -/* %endif */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ -/* %if-c-only */ void yyrestart (FILE * input_file ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { if ( ! YY_CURRENT_BUFFER ){ @@ -1617,11 +1367,7 @@ static int yy_get_next_buffer (void) * @param new_buffer The new input buffer. * */ -/* %if-c-only */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { /* TODO. We should be able to replace this entire function body @@ -1652,11 +1398,7 @@ static int yy_get_next_buffer (void) (yy_did_buffer_switch_on_eof) = 1; } -/* %if-c-only */ static void yy_load_buffer_state (void) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; @@ -1670,11 +1412,7 @@ static void yy_load_buffer_state (void) * * @return the allocated buffer state. */ -/* %if-c-only */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { YY_BUFFER_STATE b; @@ -1702,11 +1440,7 @@ static void yy_load_buffer_state (void) * @param b a buffer created with yy_create_buffer() * */ -/* %if-c-only */ void yy_delete_buffer (YY_BUFFER_STATE b ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { if ( ! b ) @@ -1721,26 +1455,15 @@ static void yy_load_buffer_state (void) yyfree((void *) b ); } -/* %if-c-only */ - #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ -/* %if-c-only */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int oerrno = errno; @@ -1759,13 +1482,8 @@ extern int isatty (int ); b->yy_bs_column = 0; } -/* %if-c-only */ - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -/* %endif */ -/* %if-c++-only */ -/* %endif */ errno = oerrno; } @@ -1773,11 +1491,7 @@ extern int isatty (int ); * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ -/* %if-c-only */ void yy_flush_buffer (YY_BUFFER_STATE b ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { if ( ! b ) return; @@ -1800,18 +1514,13 @@ extern int isatty (int ); yy_load_buffer_state( ); } -/* %if-c-or-c++ */ /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ -/* %if-c-only */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { if (new_buffer == NULL) return; @@ -1836,18 +1545,12 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } -/* %endif */ -/* %if-c-or-c++ */ /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ -/* %if-c-only */ void yypop_buffer_state (void) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { if (!YY_CURRENT_BUFFER) return; @@ -1862,17 +1565,11 @@ void yypop_buffer_state (void) (yy_did_buffer_switch_on_eof) = 1; } } -/* %endif */ -/* %if-c-or-c++ */ /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -/* %if-c-only */ static void yyensure_buffer_stack (void) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int num_to_alloc; @@ -1914,9 +1611,7 @@ static void yyensure_buffer_stack (void) (yy_buffer_stack_max) = num_to_alloc; } } -/* %endif */ -/* %if-c-only */ /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer @@ -1951,9 +1646,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) return b; } -/* %endif */ -/* %if-c-only */ /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan @@ -1967,9 +1660,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) return yy_scan_bytes(yystr,strlen(yystr) ); } -/* %endif */ -/* %if-c-only */ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan @@ -2006,21 +1697,16 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) return b; } -/* %endif */ #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif -/* %if-c-only */ static void yy_fatal_error (yyconst char* msg ) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } -/* %endif */ -/* %if-c++-only */ -/* %endif */ /* Redefine yyless() so it works in section 3 code. */ @@ -2041,10 +1727,6 @@ static void yy_fatal_error (yyconst char* msg ) /* Accessor methods (get/set functions) to struct members. */ -/* %if-c-only */ -/* %if-reentrant */ -/* %endif */ - /** Get the current line number. * */ @@ -2087,9 +1769,6 @@ char *yyget_text (void) return yytext; } -/* %if-reentrant */ -/* %endif */ - /** Set the current line number. * @param line_number * @@ -2126,14 +1805,6 @@ void yyset_debug (int bdebug ) yy_flex_debug = bdebug ; } -/* %endif */ - -/* %if-reentrant */ -/* %if-bison-bridge */ -/* %endif */ -/* %endif if-c-only */ - -/* %if-c-only */ static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. @@ -2161,9 +1832,7 @@ static int yy_init_globals (void) */ return 0; } -/* %endif */ -/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { @@ -2183,11 +1852,8 @@ int yylex_destroy (void) * yylex() is called, initialization will occur. */ yy_init_globals( ); -/* %if-reentrant */ -/* %endif */ return 0; } -/* %endif */ /* * Internal utility routines. @@ -2235,21 +1901,11 @@ void yyfree (void * ptr ) free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } -/* %if-tables-serialization definitions */ -/* %define-yytables The name for this specific scanner's tables. */ #define YYTABLES_NAME "yytables" -/* %endif */ - -/* %ok-for-header */ - -#line 93 "scripts/genksyms/lex.l" - - /* Bring in the keyword recognizer. */ -#include "keywords.c" - +#include "keywords.hash.c" /* Macros to append to our phrase collection list. */ @@ -2274,7 +1930,6 @@ void yyfree (void * ptr ) #define APP _APP(yytext, yyleng) - /* The second stage lexer. Here we incorporate knowledge of the state of the parser to tailor the tokens that are returned. */ diff --git a/scripts/genksyms/parse.c_shipped b/scripts/genksyms/parse.tab.c_shipped index 1a0b8607fb0e..61d4a5d09856 100644 --- a/scripts/genksyms/parse.c_shipped +++ b/scripts/genksyms/parse.tab.c_shipped @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,8 +66,6 @@ /* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ -#line 24 "scripts/genksyms/parse.y" #include <assert.h> @@ -101,8 +98,6 @@ remove_list(struct string_list **pb, struct string_list **pe) -/* Line 189 of yacc.c */ -#line 106 "scripts/genksyms/parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -186,8 +181,6 @@ typedef int YYSTYPE; /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 191 "scripts/genksyms/parse.c" #ifdef short # undef short @@ -237,7 +230,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -855,9 +848,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -914,7 +916,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1653,64 +1655,46 @@ yyreduce: { case 4: -/* Line 1455 of yacc.c */ -#line 109 "scripts/genksyms/parse.y" { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;} break; case 5: -/* Line 1455 of yacc.c */ -#line 111 "scripts/genksyms/parse.y" { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; ;} break; case 6: -/* Line 1455 of yacc.c */ -#line 115 "scripts/genksyms/parse.y" { is_typedef = 1; ;} break; case 7: -/* Line 1455 of yacc.c */ -#line 116 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 8: -/* Line 1455 of yacc.c */ -#line 117 "scripts/genksyms/parse.y" { is_typedef = 1; ;} break; case 9: -/* Line 1455 of yacc.c */ -#line 118 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 14: -/* Line 1455 of yacc.c */ -#line 123 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 15: -/* Line 1455 of yacc.c */ -#line 124 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 16: -/* Line 1455 of yacc.c */ -#line 129 "scripts/genksyms/parse.y" { if (current_name) { struct string_list *decl = (*(yyvsp[(3) - (3)]))->next; (*(yyvsp[(3) - (3)]))->next = NULL; @@ -1725,15 +1709,11 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ -#line 142 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 19: -/* Line 1455 of yacc.c */ -#line 148 "scripts/genksyms/parse.y" { struct string_list *decl = *(yyvsp[(1) - (1)]); *(yyvsp[(1) - (1)]) = NULL; add_symbol(current_name, @@ -1745,8 +1725,6 @@ yyreduce: case 20: -/* Line 1455 of yacc.c */ -#line 156 "scripts/genksyms/parse.y" { struct string_list *decl = *(yyvsp[(3) - (3)]); *(yyvsp[(3) - (3)]) = NULL; free_list(*(yyvsp[(2) - (3)]), NULL); @@ -1760,36 +1738,26 @@ yyreduce: case 21: -/* Line 1455 of yacc.c */ -#line 169 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); ;} break; case 22: -/* Line 1455 of yacc.c */ -#line 174 "scripts/genksyms/parse.y" { decl_spec = NULL; ;} break; case 24: -/* Line 1455 of yacc.c */ -#line 179 "scripts/genksyms/parse.y" { decl_spec = *(yyvsp[(1) - (1)]); ;} break; case 25: -/* Line 1455 of yacc.c */ -#line 180 "scripts/genksyms/parse.y" { decl_spec = *(yyvsp[(2) - (2)]); ;} break; case 26: -/* Line 1455 of yacc.c */ -#line 185 "scripts/genksyms/parse.y" { /* Version 2 checksumming ignores storage class, as that is really irrelevant to the linkage. */ remove_node((yyvsp[(1) - (1)])); @@ -1799,43 +1767,31 @@ yyreduce: case 31: -/* Line 1455 of yacc.c */ -#line 197 "scripts/genksyms/parse.y" { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); ;} break; case 32: -/* Line 1455 of yacc.c */ -#line 198 "scripts/genksyms/parse.y" { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); ;} break; case 37: -/* Line 1455 of yacc.c */ -#line 210 "scripts/genksyms/parse.y" { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); ;} break; case 38: -/* Line 1455 of yacc.c */ -#line 212 "scripts/genksyms/parse.y" { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); ;} break; case 39: -/* Line 1455 of yacc.c */ -#line 214 "scripts/genksyms/parse.y" { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); ;} break; case 40: -/* Line 1455 of yacc.c */ -#line 218 "scripts/genksyms/parse.y" { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; r = copy_node(i); r->tag = SYM_STRUCT; r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; @@ -1846,8 +1802,6 @@ yyreduce: case 41: -/* Line 1455 of yacc.c */ -#line 225 "scripts/genksyms/parse.y" { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; r = copy_node(i); r->tag = SYM_UNION; r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; @@ -1858,8 +1812,6 @@ yyreduce: case 42: -/* Line 1455 of yacc.c */ -#line 232 "scripts/genksyms/parse.y" { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; r = copy_node(i); r->tag = SYM_ENUM; r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; @@ -1870,57 +1822,41 @@ yyreduce: case 43: -/* Line 1455 of yacc.c */ -#line 242 "scripts/genksyms/parse.y" { add_symbol(NULL, SYM_ENUM, NULL, 0); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 44: -/* Line 1455 of yacc.c */ -#line 244 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 45: -/* Line 1455 of yacc.c */ -#line 245 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 56: -/* Line 1455 of yacc.c */ -#line 259 "scripts/genksyms/parse.y" { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); ;} break; case 57: -/* Line 1455 of yacc.c */ -#line 264 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} break; case 58: -/* Line 1455 of yacc.c */ -#line 268 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 61: -/* Line 1455 of yacc.c */ -#line 274 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 65: -/* Line 1455 of yacc.c */ -#line 280 "scripts/genksyms/parse.y" { /* restrict has no effect in prototypes so ignore it */ remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); @@ -1929,15 +1865,11 @@ yyreduce: case 66: -/* Line 1455 of yacc.c */ -#line 287 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 68: -/* Line 1455 of yacc.c */ -#line 293 "scripts/genksyms/parse.y" { if (current_name != NULL) { error_with_pos("unexpected second declaration name"); YYERROR; @@ -1950,134 +1882,96 @@ yyreduce: case 69: -/* Line 1455 of yacc.c */ -#line 302 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 70: -/* Line 1455 of yacc.c */ -#line 304 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 71: -/* Line 1455 of yacc.c */ -#line 306 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 72: -/* Line 1455 of yacc.c */ -#line 308 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 73: -/* Line 1455 of yacc.c */ -#line 310 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 74: -/* Line 1455 of yacc.c */ -#line 316 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 78: -/* Line 1455 of yacc.c */ -#line 324 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 79: -/* Line 1455 of yacc.c */ -#line 326 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 80: -/* Line 1455 of yacc.c */ -#line 328 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 81: -/* Line 1455 of yacc.c */ -#line 330 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 82: -/* Line 1455 of yacc.c */ -#line 332 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 83: -/* Line 1455 of yacc.c */ -#line 336 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 85: -/* Line 1455 of yacc.c */ -#line 338 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 86: -/* Line 1455 of yacc.c */ -#line 342 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 89: -/* Line 1455 of yacc.c */ -#line 349 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 90: -/* Line 1455 of yacc.c */ -#line 354 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} break; case 91: -/* Line 1455 of yacc.c */ -#line 359 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} break; case 93: -/* Line 1455 of yacc.c */ -#line 364 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 94: -/* Line 1455 of yacc.c */ -#line 366 "scripts/genksyms/parse.y" { /* For version 2 checksums, we don't want to remember private parameter names. */ remove_node((yyvsp[(1) - (1)])); @@ -2087,8 +1981,6 @@ yyreduce: case 95: -/* Line 1455 of yacc.c */ -#line 374 "scripts/genksyms/parse.y" { remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); ;} @@ -2096,43 +1988,31 @@ yyreduce: case 96: -/* Line 1455 of yacc.c */ -#line 378 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 97: -/* Line 1455 of yacc.c */ -#line 380 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 98: -/* Line 1455 of yacc.c */ -#line 382 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 99: -/* Line 1455 of yacc.c */ -#line 384 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 100: -/* Line 1455 of yacc.c */ -#line 386 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 101: -/* Line 1455 of yacc.c */ -#line 391 "scripts/genksyms/parse.y" { struct string_list *decl = *(yyvsp[(2) - (3)]); *(yyvsp[(2) - (3)]) = NULL; add_symbol(current_name, SYM_NORMAL, decl, is_extern); @@ -2142,120 +2022,86 @@ yyreduce: case 102: -/* Line 1455 of yacc.c */ -#line 399 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 104: -/* Line 1455 of yacc.c */ -#line 406 "scripts/genksyms/parse.y" { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); ;} break; case 105: -/* Line 1455 of yacc.c */ -#line 410 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 106: -/* Line 1455 of yacc.c */ -#line 411 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 107: -/* Line 1455 of yacc.c */ -#line 415 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 110: -/* Line 1455 of yacc.c */ -#line 421 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 111: -/* Line 1455 of yacc.c */ -#line 426 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 112: -/* Line 1455 of yacc.c */ -#line 428 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 113: -/* Line 1455 of yacc.c */ -#line 432 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 116: -/* Line 1455 of yacc.c */ -#line 438 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 117: -/* Line 1455 of yacc.c */ -#line 442 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} break; case 118: -/* Line 1455 of yacc.c */ -#line 443 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 120: -/* Line 1455 of yacc.c */ -#line 448 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 121: -/* Line 1455 of yacc.c */ -#line 452 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 123: -/* Line 1455 of yacc.c */ -#line 457 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(3) - (3)]); ;} break; case 124: -/* Line 1455 of yacc.c */ -#line 458 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(4) - (4)]); ;} break; case 127: -/* Line 1455 of yacc.c */ -#line 467 "scripts/genksyms/parse.y" { const char *name = strdup((*(yyvsp[(1) - (1)]))->string); add_symbol(name, SYM_ENUM_CONST, NULL, 0); @@ -2264,8 +2110,6 @@ yyreduce: case 128: -/* Line 1455 of yacc.c */ -#line 472 "scripts/genksyms/parse.y" { const char *name = strdup((*(yyvsp[(1) - (3)]))->string); struct string_list *expr = copy_list_range(*(yyvsp[(3) - (3)]), *(yyvsp[(2) - (3)])); @@ -2275,29 +2119,21 @@ yyreduce: case 129: -/* Line 1455 of yacc.c */ -#line 479 "scripts/genksyms/parse.y" { (yyval) = (yyvsp[(2) - (2)]); ;} break; case 130: -/* Line 1455 of yacc.c */ -#line 483 "scripts/genksyms/parse.y" { (yyval) = NULL; ;} break; case 132: -/* Line 1455 of yacc.c */ -#line 489 "scripts/genksyms/parse.y" { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); ;} break; -/* Line 1455 of yacc.c */ -#line 2301 "scripts/genksyms/parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2508,8 +2344,6 @@ yyreturn: -/* Line 1675 of yacc.c */ -#line 493 "scripts/genksyms/parse.y" static void diff --git a/scripts/genksyms/parse.h_shipped b/scripts/genksyms/parse.tab.h_shipped index 517523669251..350c2b403e21 100644 --- a/scripts/genksyms/parse.h_shipped +++ b/scripts/genksyms/parse.tab.h_shipped @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index d29a8d75cb22..eb2f1e64edf7 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -328,7 +328,8 @@ sub read_mailmap { # name1 <mail1> <mail2> # name1 <mail1> name2 <mail2> # (see man git-shortlog) - if (/^(.+)<(.+)>$/) { + + if (/^([^<]+)<([^>]+)>$/) { my $real_name = $1; my $address = $2; @@ -336,13 +337,13 @@ sub read_mailmap { ($real_name, $address) = parse_email("$real_name <$address>"); $mailmap->{names}->{$address} = $real_name; - } elsif (/^<([^\s]+)>\s*<([^\s]+)>$/) { + } elsif (/^<([^>]+)>\s*<([^>]+)>$/) { my $real_address = $1; my $wrong_address = $2; $mailmap->{addresses}->{$wrong_address} = $real_address; - } elsif (/^(.+)<([^\s]+)>\s*<([^\s]+)>$/) { + } elsif (/^(.+)<([^>]+)>\s*<([^>]+)>$/) { my $real_name = $1; my $real_address = $2; my $wrong_address = $3; @@ -353,7 +354,7 @@ sub read_mailmap { $mailmap->{names}->{$wrong_address} = $real_name; $mailmap->{addresses}->{$wrong_address} = $real_address; - } elsif (/^(.+)<([^\s]+)>\s*([^\s].*)<([^\s]+)>$/) { + } elsif (/^(.+)<([^>]+)>\s*(.+)\s*<([^>]+)>$/) { my $real_name = $1; my $real_address = $2; my $wrong_name = $3; diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index efb3be10d428..48462be328bb 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl @@ -35,6 +35,7 @@ foreach my $file (@files) { $line =~ s/([\s(])__iomem\s/$1/g; $line =~ s/\s__attribute_const__\s/ /g; $line =~ s/\s__attribute_const__$//g; + $line =~ s/\b__packed\b/__attribute__((packed))/g; $line =~ s/^#include <linux\/compiler.h>//; $line =~ s/(^|\s)(inline)\b/$1__$2__/g; $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 624f6502e03e..ee120d441565 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore @@ -2,7 +2,7 @@ # Generated files # config* -lex.*.c +*.lex.c *.tab.c *.tab.h zconf.hash.c diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index faa9a4701b6f..82d2eb285b70 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -170,8 +170,8 @@ mconf-objs := mconf.o zconf.tab.o $(lxdialog) nconf-objs := nconf.o zconf.tab.o nconf.gui.o kxgettext-objs := kxgettext.o zconf.tab.o qconf-cxxobjs := qconf.o -qconf-objs := kconfig_load.o zconf.tab.o -gconf-objs := gconf.o kconfig_load.o zconf.tab.o +qconf-objs := zconf.tab.o +gconf-objs := gconf.o zconf.tab.o hostprogs-y := conf @@ -203,8 +203,8 @@ ifeq ($(gconf-target),1) hostprogs-y += gconf endif -clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck -clean-files += zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h +clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck +clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h clean-files += mconf qconf gconf nconf clean-files += config.pot linux.pot @@ -220,15 +220,18 @@ always := dochecklxdialog HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) # generated files seem to need this to find local include files -HOSTCFLAGS_lex.zconf.o := -I$(src) +HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) -HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl -HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK +LEX_PREFIX_zconf := zconf +YACC_PREFIX_zconf := zconf -HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl +HOSTLOADLIBES_qconf = $(KC_QT_LIBS) +HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) + +HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ - -D LKC_DIRECT_LINK + -Wno-missing-prototypes HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) @@ -316,47 +319,15 @@ $(obj)/.tmp_gtkcheck: fi endif -$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c - -$(obj)/kconfig_load.o: $(obj)/lkc_defs.h - -$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h +$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c -$(obj)/gconf.o: $(obj)/lkc_defs.h +$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/%.moc: $(src)/%.h $(KC_QT_MOC) -i $< -o $@ -$(obj)/lkc_defs.h: $(src)/lkc_proto.h - $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' - # Extract gconf menu items for I18N support $(obj)/gconf.glade.h: $(obj)/gconf.glade $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ $(obj)/gconf.glade -### -# The following requires flex/bison/gperf -# By default we use the _shipped versions, uncomment the following line if -# you are modifying the flex/bison src. -# LKC_GENPARSER := 1 - -ifdef LKC_GENPARSER - -$(obj)/zconf.tab.c: $(src)/zconf.y -$(obj)/lex.zconf.c: $(src)/zconf.l -$(obj)/zconf.hash.c: $(src)/zconf.gperf - -%.tab.c: %.y - bison -l -b $* -p $(notdir $*) $< - cp $@ $@_shipped - -lex.%.c: %.l - flex -L -P$(notdir $*) -o$@ $< - cp $@ $@_shipped - -%.hash.c: %.gperf - gperf < $< > $@ - cp $@ $@_shipped - -endif diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 006ad817cd5f..f208f900ed3a 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -14,11 +14,11 @@ #include <sys/stat.h> #include <sys/time.h> -#define LKC_DIRECT_LINK #include "lkc.h" static void conf(struct menu *menu); static void check_conf(struct menu *menu); +static void xfgets(char *str, int size, FILE *in); enum input_mode { oldaskconfig, @@ -35,8 +35,6 @@ enum input_mode { oldnoconfig, } input_mode = oldaskconfig; -char *defconfig_file; - static int indent = 1; static int valid_stdin = 1; static int sync_kconfig; @@ -106,6 +104,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) return 0; } check_stdin(); + /* fall through */ case oldaskconfig: fflush(stdout); xfgets(line, 128, stdin); @@ -150,6 +149,7 @@ static int conf_string(struct menu *menu) def = NULL; break; } + /* fall through */ default: line[strlen(line)-1] = 0; def = line; @@ -304,6 +304,7 @@ static int conf_choice(struct menu *menu) break; } check_stdin(); + /* fall through */ case oldaskconfig: fflush(stdout); xfgets(line, 128, stdin); @@ -369,6 +370,7 @@ static void conf(struct menu *menu) check_conf(menu); return; } + /* fall through */ case P_COMMENT: prompt = menu_get_prompt(menu); if (prompt) @@ -456,10 +458,30 @@ static struct option long_opts[] = { {NULL, 0, NULL, 0} }; +static void conf_usage(const char *progname) +{ + + printf("Usage: %s [option] <kconfig-file>\n", progname); + printf("[option] is _one_ of the following:\n"); + printf(" --listnewconfig List new options\n"); + printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); + printf(" --oldconfig Update a configuration using a provided .config as base\n"); + printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); + printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n"); + printf(" --defconfig <file> New config with default defined in <file>\n"); + printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); + printf(" --allnoconfig New config where all options are answered with no\n"); + printf(" --allyesconfig New config where all options are answered with yes\n"); + printf(" --allmodconfig New config where all options are answered with mod\n"); + printf(" --alldefconfig New config with all symbols set to default\n"); + printf(" --randconfig New config with random answer to all options\n"); +} + int main(int ac, char **av) { + const char *progname = av[0]; int opt; - const char *name; + const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; setlocale(LC_ALL, ""); @@ -491,14 +513,24 @@ int main(int ac, char **av) srand(seed); break; } + case oldaskconfig: + case oldconfig: + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case listnewconfig: + case oldnoconfig: + break; case '?': - fprintf(stderr, _("See README for usage info\n")); + conf_usage(progname); exit(1); break; } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); + conf_usage(progname); exit(1); } name = av[optind]; @@ -641,13 +673,11 @@ int main(int ac, char **av) } return 0; } + /* * Helper function to facilitate fgets() by Jean Sacren. */ -void xfgets(str, size, in) - char *str; - int size; - FILE *in; +void xfgets(char *str, int size, FILE *in) { if (fgets(str, size, in) == NULL) fprintf(stderr, "\nError in reading or end of file.\n"); diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2bafd9a7c8da..59b667cae5f3 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -7,13 +7,13 @@ #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> -#define LKC_DIRECT_LINK #include "lkc.h" static void conf_warning(const char *fmt, ...) @@ -128,6 +128,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->flags |= def_flags; break; } + /* fall through */ case S_BOOLEAN: if (p[0] == 'y') { sym->def[def].tri = yes; @@ -140,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) break; } conf_warning("symbol value '%s' invalid for %s", p, sym->name); - break; + return 1; case S_OTHER: if (*p != '"') { for (p2 = p; *p2 && !isspace(*p2); p2++) @@ -148,6 +149,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->type = S_STRING; goto done; } + /* fall through */ case S_STRING: if (*p++ != '"') break; @@ -162,6 +164,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) conf_warning("invalid string found"); return 1; } + /* fall through */ case S_INT: case S_HEX: done: @@ -237,6 +240,7 @@ load: case S_STRING: if (sym->def[def].val) free(sym->def[def].val); + /* fall through */ default: sym->def[def].val = NULL; sym->def[def].tri = no; @@ -363,6 +367,7 @@ int conf_read(const char *name) break; if (!sym_is_choice(sym)) goto sym_ok; + /* fall through */ default: if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) goto sym_ok; @@ -417,64 +422,202 @@ int conf_read(const char *name) return 0; } -/* Write a S_STRING */ -static void conf_write_string(bool headerfile, const char *name, - const char *str, FILE *out) +/* + * Kconfig configuration printer + * + * This printer is used when generating the resulting configuration after + * kconfig invocation and `defconfig' files. Unset symbol might be omitted by + * passing a non-NULL argument to the printer. + * + */ +static void +kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) { - int l; - if (headerfile) - fprintf(out, "#define %s%s \"", CONFIG_, name); - else - fprintf(out, "%s%s=\"", CONFIG_, name); - - while (1) { - l = strcspn(str, "\"\\"); + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (*value == 'n') { + bool skip_unset = (arg != NULL); + + if (!skip_unset) + fprintf(fp, "# %s%s is not set\n", + CONFIG_, sym->name); + return; + } + break; + default: + break; + } + + fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value); +} + +static void +kconfig_print_comment(FILE *fp, const char *value, void *arg) +{ + const char *p = value; + size_t l; + + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, "#"); if (l) { - xfwrite(str, l, 1, out); - str += l; + fprintf(fp, " "); + fwrite(p, l, 1, fp); + p += l; } - if (!*str) + fprintf(fp, "\n"); + if (*p++ == '\0') break; - fprintf(out, "\\%c", *str++); } - fputs("\"\n", out); } -static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) +static struct conf_printer kconfig_printer_cb = +{ + .print_symbol = kconfig_print_symbol, + .print_comment = kconfig_print_comment, +}; + +/* + * Header printer + * + * This printer is used when generating the `include/generated/autoconf.h' file. + */ +static void +header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) { - const char *str; switch (sym->type) { case S_BOOLEAN: - case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - if (write_no) - fprintf(out, "# %s%s is not set\n", - CONFIG_, sym->name); - break; - case mod: - fprintf(out, "%s%s=m\n", CONFIG_, sym->name); - break; - case yes: - fprintf(out, "%s%s=y\n", CONFIG_, sym->name); + case S_TRISTATE: { + const char *suffix = ""; + + switch (*value) { + case 'n': break; + case 'm': + suffix = "_MODULE"; + /* fall through */ + default: + fprintf(fp, "#define %s%s%s 1\n", + CONFIG_, sym->name, suffix); } + /* + * Generate the __enabled_CONFIG_* and + * __enabled_CONFIG_*_MODULE macros for use by the + * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is + * generated even for booleans so that the IS_ENABLED() macro + * works. + */ + fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", + sym->name, (*value == 'y')); + fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", + sym->name, (*value == 'm')); break; - case S_STRING: - conf_write_string(false, sym->name, sym_get_string_value(sym), out); + } + case S_HEX: { + const char *prefix = ""; + + if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) + prefix = "0x"; + fprintf(fp, "#define %s%s %s%s\n", + CONFIG_, sym->name, prefix, value); break; - case S_HEX: + } + case S_STRING: case S_INT: - str = sym_get_string_value(sym); - fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str); + fprintf(fp, "#define %s%s %s\n", + CONFIG_, sym->name, value); + break; + default: break; + } + +} + +static void +header_print_comment(FILE *fp, const char *value, void *arg) +{ + const char *p = value; + size_t l; + + fprintf(fp, "/*\n"); + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, " *"); + if (l) { + fprintf(fp, " "); + fwrite(p, l, 1, fp); + p += l; + } + fprintf(fp, "\n"); + if (*p++ == '\0') + break; + } + fprintf(fp, " */\n"); +} + +static struct conf_printer header_printer_cb = +{ + .print_symbol = header_print_symbol, + .print_comment = header_print_comment, +}; + +/* + * Tristate printer + * + * This printer is used when generating the `include/config/tristate.conf' file. + */ +static void +tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + if (sym->type == S_TRISTATE && *value != 'n') + fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); +} + +static struct conf_printer tristate_printer_cb = +{ + .print_symbol = tristate_print_symbol, + .print_comment = kconfig_print_comment, +}; + +static void conf_write_symbol(FILE *fp, struct symbol *sym, + struct conf_printer *printer, void *printer_arg) +{ + const char *str; + + switch (sym->type) { case S_OTHER: case S_UNKNOWN: break; + case S_STRING: + str = sym_get_string_value(sym); + str = sym_escape_string_value(str); + printer->print_symbol(fp, sym, str, printer_arg); + free((void *)str); + break; + default: + str = sym_get_string_value(sym); + printer->print_symbol(fp, sym, str, printer_arg); } } +static void +conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg) +{ + char buf[256]; + + snprintf(buf, sizeof(buf), + "\n" + "Automatically generated file; DO NOT EDIT.\n" + "%s\n", + rootmenu.prompt->text); + + printer->print_comment(fp, buf, printer_arg); +} + /* * Write out a minimal config. * All values that has default values are skipped as this is redundant. @@ -531,7 +674,7 @@ int conf_write_defconfig(const char *filename) goto next_menu; } } - conf_write_symbol(sym, out, true); + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } next_menu: if (menu->list != NULL) { @@ -596,11 +739,7 @@ int conf_write(const char *name) if (!out) return 1; - fprintf(out, _("#\n" - "# Automatically generated make config: don't edit\n" - "# %s\n" - "#\n"), - rootmenu.prompt->text); + conf_write_heading(out, &kconfig_printer_cb, NULL); if (!conf_get_changed()) sym_clear_all_valid(); @@ -621,8 +760,8 @@ int conf_write(const char *name) if (!(sym->flags & SYMBOL_WRITE)) goto next; sym->flags &= ~SYMBOL_WRITE; - /* Write config symbol to file */ - conf_write_symbol(sym, out, true); + + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } next: @@ -771,7 +910,6 @@ out: int conf_write_autoconf(void) { struct symbol *sym; - const char *str; const char *name; FILE *out, *tristate, *out_h; int i; @@ -800,68 +938,23 @@ int conf_write_autoconf(void) return 1; } - fprintf(out, "#\n" - "# Automatically generated make config: don't edit\n" - "# %s\n" - "#\n", - rootmenu.prompt->text); - fprintf(tristate, "#\n" - "# Automatically generated - do not edit\n" - "\n"); - fprintf(out_h, "/*\n" - " * Automatically generated C config: don't edit\n" - " * %s\n" - " */\n", - rootmenu.prompt->text); + conf_write_heading(out, &kconfig_printer_cb, NULL); + + conf_write_heading(tristate, &tristate_printer_cb, NULL); + + conf_write_heading(out_h, &header_printer_cb, NULL); for_all_symbols(i, sym) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; - /* write symbol to config file */ - conf_write_symbol(sym, out, false); + /* write symbol to auto.conf, tristate and header files */ + conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); - /* update autoconf and tristate files */ - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - break; - case mod: - fprintf(tristate, "%s%s=M\n", - CONFIG_, sym->name); - fprintf(out_h, "#define %s%s_MODULE 1\n", - CONFIG_, sym->name); - break; - case yes: - if (sym->type == S_TRISTATE) - fprintf(tristate,"%s%s=Y\n", - CONFIG_, sym->name); - fprintf(out_h, "#define %s%s 1\n", - CONFIG_, sym->name); - break; - } - break; - case S_STRING: - conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); - break; - case S_HEX: - str = sym_get_string_value(sym); - if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out_h, "#define %s%s 0x%s\n", - CONFIG_, sym->name, str); - break; - } - case S_INT: - str = sym_get_string_value(sym); - fprintf(out_h, "#define %s%s %s\n", - CONFIG_, sym->name, str); - break; - default: - break; - } + conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); + + conf_write_symbol(out_h, sym, &header_printer_cb, NULL); } fclose(out); fclose(tristate); diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 001003452f68..290ce41f8ba4 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -7,15 +7,13 @@ #include <stdlib.h> #include <string.h> -#define LKC_DIRECT_LINK #include "lkc.h" #define DEBUG_EXPR 0 struct expr *expr_alloc_symbol(struct symbol *sym) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = E_SYMBOL; e->left.sym = sym; return e; @@ -23,8 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym) struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.expr = ce; return e; @@ -32,8 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.expr = e1; e->right.expr = e2; @@ -42,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.sym = s1; e->right.sym = s2; diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 16bfae2d3217..80fce57080cc 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -172,8 +172,6 @@ struct menu { #define MENU_CHANGED 0x0001 #define MENU_ROOT 0x0002 -#ifndef SWIG - extern struct file *file_list; extern struct file *current_file; struct file *lookup_file(const char *name); @@ -218,7 +216,6 @@ static inline int expr_is_no(struct expr *e) { return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); } -#endif #ifdef __cplusplus } diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index a11d5f7b9eeb..9f4438027df4 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -285,8 +285,6 @@ void init_left_tree(void) static void renderer_edited(GtkCellRendererText * cell, const gchar * path_string, const gchar * new_text, gpointer user_data); -static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle, - gchar * arg1, gpointer user_data); void init_right_tree(void) { @@ -320,8 +318,6 @@ void init_right_tree(void) "inconsistent", COL_BTNINC, "visible", COL_BTNVIS, "radio", COL_BTNRAD, NULL); - /*g_signal_connect(G_OBJECT(renderer), "toggled", - G_CALLBACK(renderer_toggled), NULL); */ renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), renderer, FALSE); @@ -888,35 +884,6 @@ static void toggle_sym_value(struct menu *menu) display_tree_part(); //fixme: keep exp/coll } -static void renderer_toggled(GtkCellRendererToggle * cell, - gchar * path_string, gpointer user_data) -{ - GtkTreePath *path, *sel_path = NULL; - GtkTreeIter iter, sel_iter; - GtkTreeSelection *sel; - struct menu *menu; - - path = gtk_tree_path_new_from_string(path_string); - if (!gtk_tree_model_get_iter(model2, &iter, path)) - return; - - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w)); - if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter)) - sel_path = gtk_tree_model_get_path(model2, &sel_iter); - if (!sel_path) - goto out1; - if (gtk_tree_path_compare(path, sel_path)) - goto out2; - - gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); - toggle_sym_value(menu); - - out2: - gtk_tree_path_free(sel_path); - out1: - gtk_tree_path_free(path); -} - static gint column2index(GtkTreeViewColumn * column) { gint i; @@ -1172,6 +1139,7 @@ static gchar **fill_row(struct menu *menu) row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); if (sym_is_choice(sym)) break; + /* fall through */ case S_TRISTATE: val = sym_get_tristate_value(sym); switch (val) { @@ -1506,10 +1474,6 @@ int main(int ac, char *av[]) char *env; gchar *glade_file; -#ifndef LKC_DIRECT_LINK - kconfig_load(); -#endif - bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c deleted file mode 100644 index dbdcaad82325..000000000000 --- a/scripts/kconfig/kconfig_load.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <dlfcn.h> -#include <stdio.h> -#include <stdlib.h> - -#include "lkc.h" - -#define P(name,type,arg) type (*name ## _p) arg -#include "lkc_proto.h" -#undef P - -void kconfig_load(void) -{ - void *handle; - char *error; - - handle = dlopen("./libkconfig.so", RTLD_LAZY); - if (!handle) { - handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY); - if (!handle) { - fprintf(stderr, "%s\n", dlerror()); - exit(1); - } - } - -#define P(name,type,arg) \ -{ \ - name ## _p = dlsym(handle, #name); \ - if ((error = dlerror())) { \ - fprintf(stderr, "%s\n", error); \ - exit(1); \ - } \ -} -#include "lkc_proto.h" -#undef P -} diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index e9d8e791bf0d..2858738b22d5 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c @@ -7,7 +7,6 @@ #include <stdlib.h> #include <string.h> -#define LKC_DIRECT_LINK #include "lkc.h" static char *escape(const char* text, char *bf, int len) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index febf0c94d558..b633bdb9f3d4 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -21,12 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; extern "C" { #endif -#ifdef LKC_DIRECT_LINK #define P(name,type,arg) extern type name arg -#else -#include "lkc_defs.h" -#define P(name,type,arg) extern type (*name ## _p) arg -#endif #include "lkc_proto.h" #undef P @@ -68,9 +63,7 @@ struct kconf_id { enum symbol_type stype; }; -#ifdef YYDEBUG extern int zconfdebug; -#endif int zconfparse(void); void zconfdump(FILE *out); @@ -81,9 +74,6 @@ void zconf_nextfile(const char *name); int zconf_lineno(void); const char *zconf_curname(void); -/* conf.c */ -void xfgets(char *str, int size, FILE *in); - /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); @@ -92,6 +82,11 @@ void sym_set_change_count(int count); void sym_add_change_count(int count); void conf_set_all_new_symbols(enum conf_def_mode mode); +struct conf_printer { + void (*print_symbol)(FILE *, struct symbol *, const char *, void *); + void (*print_comment)(FILE *, const char *, void *); +}; + /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) { @@ -99,9 +94,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) fprintf(stderr, "\nError in writing or end of file.\n"); } -/* kconfig_load.c */ -void kconfig_load(void); - /* menu.c */ void _menu_init(void); void menu_warn(struct menu *menu, const char *fmt, ...); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 17342fef38b9..47fe9c340f9a 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -31,6 +31,7 @@ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); P(sym_lookup,struct symbol *,(const char *name, int flags)); P(sym_find,struct symbol *,(const char *name)); P(sym_expand_string_value,const char *,(const char *in)); +P(sym_escape_string_value, const char *,(const char *in)); P(sym_re_search,struct symbol **,(const char *pattern)); P(sym_type_name,const char *,(enum symbol_type type)); P(sym_calc_value,void,(struct symbol *sym)); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d433c7a24745..820d2b6800fb 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -18,7 +18,6 @@ #include <unistd.h> #include <locale.h> -#define LKC_DIRECT_LINK #include "lkc.h" #include "lxdialog/dialog.h" @@ -845,6 +844,7 @@ int main(int ac, char **av) "\n\n")); return 1; } + /* fall through */ case -1: printf(_("\n\n" "*** End of the configuration.\n" diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5fdf10dc1d8a..d66008639a43 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -3,10 +3,11 @@ * Released under the terms of the GNU GPL v2.0. */ +#include <ctype.h> +#include <stdarg.h> #include <stdlib.h> #include <string.h> -#define LKC_DIRECT_LINK #include "lkc.h" static const char nohelp_text[] = N_( @@ -350,7 +351,7 @@ void menu_finalize(struct menu *parent) last_menu->next = NULL; } - sym->dir_dep.expr = parent->dep; + sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep); } for (menu = parent->list; menu; menu = menu->next) { if (sym && sym_is_choice(sym) && diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 488dd7410787..39ca1f1640ea 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -7,7 +7,7 @@ */ #define _GNU_SOURCE #include <string.h> -#define LKC_DIRECT_LINK + #include "lkc.h" #include "nconf.h" #include <ctype.h> @@ -1067,7 +1067,6 @@ static void conf(struct menu *menu) struct menu *submenu = 0; const char *prompt = menu_get_prompt(menu); struct symbol *sym; - struct menu *active_menu = NULL; int res; int current_index = 0; int last_top_row = 0; @@ -1152,13 +1151,9 @@ static void conf(struct menu *menu) continue; submenu = (struct menu *) item_data(); - active_menu = (struct menu *)item_data(); if (!submenu || !menu_is_visible(submenu)) continue; - if (submenu) - sym = submenu->sym; - else - sym = NULL; + sym = submenu->sym; switch (res) { case ' ': @@ -1222,20 +1217,13 @@ static void conf_message_callback(const char *fmt, va_list ap) static void show_help(struct menu *menu) { - struct gstr help = str_new(); - - if (menu && menu->sym && menu_has_help(menu)) { - if (menu->sym->name) { - str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name); - str_append(&help, _(menu_get_help(menu))); - str_append(&help, "\n"); - get_symbol_str(&help, menu->sym); - } else { - str_append(&help, _(menu_get_help(menu))); - } - } else { - str_append(&help, nohelp_text); - } + struct gstr help; + + if (!menu) + return; + + help = str_new(); + menu_get_ext_help(menu, &help); show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); str_free(&help); } diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index c2796b866f8f..df274febb3e5 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1478,10 +1478,13 @@ void ConfigMainWindow::loadConfig(void) ConfigView::updateListAll(); } -void ConfigMainWindow::saveConfig(void) +bool ConfigMainWindow::saveConfig(void) { - if (conf_write(NULL)) + if (conf_write(NULL)) { QMessageBox::information(this, "qconf", _("Unable to save configuration!")); + return false; + } + return true; } void ConfigMainWindow::saveConfigAs(void) @@ -1642,7 +1645,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); switch (mb.exec()) { case QMessageBox::Yes: - saveConfig(); + if (saveConfig()) + e->accept(); + else + e->ignore(); + break; case QMessageBox::No: e->accept(); break; @@ -1745,10 +1752,6 @@ int main(int ac, char** av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); -#ifndef LKC_DIRECT_LINK - kconfig_load(); -#endif - progname = av[0]; configApp = new QApplication(ac, av); if (ac > 1 && av[1][0] == '-') { diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 91677d900dbd..3715b3e7212c 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -311,7 +311,7 @@ public slots: void listFocusChanged(void); void goBack(void); void loadConfig(void); - void saveConfig(void); + bool saveConfig(void); void saveConfigAs(void); void searchConfig(void); void showSingleView(void); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a796c95fe8a0..071f00c3046e 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -9,7 +9,6 @@ #include <regex.h> #include <sys/utsname.h> -#define LKC_DIRECT_LINK #include "lkc.h" struct symbol symbol_yes = { @@ -751,7 +750,8 @@ const char *sym_get_string_value(struct symbol *sym) case no: return "n"; case mod: - return "m"; + sym_calc_value(modules_sym); + return (modules_sym->curr.tri == no) ? "n" : "m"; case yes: return "y"; } @@ -893,6 +893,49 @@ const char *sym_expand_string_value(const char *in) return res; } +const char *sym_escape_string_value(const char *in) +{ + const char *p; + size_t reslen; + char *res; + size_t l; + + reslen = strlen(in) + strlen("\"\"") + 1; + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + p += l; + + if (p[0] == '\0') + break; + + reslen++; + p++; + } + + res = malloc(reslen); + res[0] = '\0'; + + strcat(res, "\""); + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + strncat(res, p, l); + p += l; + + if (p[0] == '\0') + break; + + strcat(res, "\\"); + strncat(res, p++, 1); + } + + strcat(res, "\""); + return res; +} + struct symbol **sym_re_search(const char *pattern) { struct symbol *sym, **sym_arr = NULL; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 6330cc871a47..d0b8b2318e48 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -5,6 +5,8 @@ * Released under the terms of the GNU GPL v2.0. */ +#include <stdarg.h> +#include <stdlib.h> #include <string.h> #include "lkc.h" diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index c9e690eb7545..f14ab41154b6 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf @@ -9,7 +9,7 @@ struct kconf_id; -static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); +static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); %% mainmenu, T_MAINMENU, TF_COMMAND diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped index 4055d5de1750..40df0005daa9 100644 --- a/scripts/kconfig/zconf.hash.c_shipped +++ b/scripts/kconfig/zconf.hash.c_shipped @@ -1,6 +1,5 @@ -/* ANSI-C code produced by gperf version 3.0.3 */ -/* Command-line: gperf */ -/* Computed positions: -k'1,3' */ +/* ANSI-C code produced by gperf version 3.0.4 */ +/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -29,10 +28,11 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." #endif +#line 10 "scripts/kconfig/zconf.gperf" struct kconf_id; -static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); -/* maximum key range = 50, duplicates = 0 */ +static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); +/* maximum key range = 71, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -44,34 +44,34 @@ inline static unsigned int kconf_id_hash (register const char *str, register unsigned int len) { - static unsigned char asso_values[] = + static const unsigned char asso_values[] = { - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 40, 5, - 0, 0, 5, 52, 0, 20, 52, 52, 10, 20, - 5, 0, 35, 52, 0, 30, 0, 15, 0, 52, - 15, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52 + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 25, 25, + 0, 0, 0, 5, 0, 0, 73, 73, 5, 0, + 10, 5, 45, 73, 20, 20, 0, 15, 15, 73, + 20, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73 }; register int hval = len; @@ -85,87 +85,87 @@ kconf_id_hash (register const char *str, register unsigned int len) hval += asso_values[(unsigned char)str[0]]; break; } - return hval; + return hval + asso_values[(unsigned char)str[len - 1]]; } struct kconf_id_strings_t { - char kconf_id_strings_str2[sizeof("on")]; - char kconf_id_strings_str3[sizeof("env")]; + char kconf_id_strings_str2[sizeof("if")]; + char kconf_id_strings_str3[sizeof("int")]; char kconf_id_strings_str5[sizeof("endif")]; - char kconf_id_strings_str6[sizeof("option")]; - char kconf_id_strings_str7[sizeof("endmenu")]; - char kconf_id_strings_str8[sizeof("optional")]; + char kconf_id_strings_str7[sizeof("default")]; + char kconf_id_strings_str8[sizeof("tristate")]; char kconf_id_strings_str9[sizeof("endchoice")]; - char kconf_id_strings_str10[sizeof("range")]; - char kconf_id_strings_str11[sizeof("choice")]; - char kconf_id_strings_str12[sizeof("default")]; + char kconf_id_strings_str12[sizeof("def_tristate")]; char kconf_id_strings_str13[sizeof("def_bool")]; - char kconf_id_strings_str14[sizeof("help")]; - char kconf_id_strings_str16[sizeof("config")]; - char kconf_id_strings_str17[sizeof("def_tristate")]; - char kconf_id_strings_str18[sizeof("hex")]; - char kconf_id_strings_str19[sizeof("defconfig_list")]; - char kconf_id_strings_str22[sizeof("if")]; - char kconf_id_strings_str23[sizeof("int")]; + char kconf_id_strings_str14[sizeof("defconfig_list")]; + char kconf_id_strings_str17[sizeof("on")]; + char kconf_id_strings_str18[sizeof("optional")]; + char kconf_id_strings_str21[sizeof("option")]; + char kconf_id_strings_str22[sizeof("endmenu")]; + char kconf_id_strings_str23[sizeof("mainmenu")]; + char kconf_id_strings_str25[sizeof("menuconfig")]; char kconf_id_strings_str27[sizeof("modules")]; - char kconf_id_strings_str28[sizeof("tristate")]; char kconf_id_strings_str29[sizeof("menu")]; + char kconf_id_strings_str31[sizeof("select")]; char kconf_id_strings_str32[sizeof("comment")]; - char kconf_id_strings_str35[sizeof("menuconfig")]; - char kconf_id_strings_str36[sizeof("string")]; - char kconf_id_strings_str37[sizeof("visible")]; - char kconf_id_strings_str41[sizeof("prompt")]; - char kconf_id_strings_str42[sizeof("depends")]; - char kconf_id_strings_str44[sizeof("bool")]; - char kconf_id_strings_str46[sizeof("select")]; + char kconf_id_strings_str33[sizeof("env")]; + char kconf_id_strings_str35[sizeof("range")]; + char kconf_id_strings_str36[sizeof("choice")]; + char kconf_id_strings_str39[sizeof("bool")]; + char kconf_id_strings_str41[sizeof("source")]; + char kconf_id_strings_str42[sizeof("visible")]; + char kconf_id_strings_str43[sizeof("hex")]; + char kconf_id_strings_str46[sizeof("config")]; char kconf_id_strings_str47[sizeof("boolean")]; - char kconf_id_strings_str48[sizeof("mainmenu")]; - char kconf_id_strings_str51[sizeof("source")]; + char kconf_id_strings_str51[sizeof("string")]; + char kconf_id_strings_str54[sizeof("help")]; + char kconf_id_strings_str56[sizeof("prompt")]; + char kconf_id_strings_str72[sizeof("depends")]; }; -static struct kconf_id_strings_t kconf_id_strings_contents = +static const struct kconf_id_strings_t kconf_id_strings_contents = { - "on", - "env", + "if", + "int", "endif", - "option", - "endmenu", - "optional", - "endchoice", - "range", - "choice", "default", - "def_bool", - "help", - "config", + "tristate", + "endchoice", "def_tristate", - "hex", + "def_bool", "defconfig_list", - "if", - "int", + "on", + "optional", + "option", + "endmenu", + "mainmenu", + "menuconfig", "modules", - "tristate", "menu", + "select", "comment", - "menuconfig", - "string", - "visible", - "prompt", - "depends", + "env", + "range", + "choice", "bool", - "select", + "source", + "visible", + "hex", + "config", "boolean", - "mainmenu", - "source" + "string", + "help", + "prompt", + "depends" }; #define kconf_id_strings ((const char *) &kconf_id_strings_contents) #ifdef __GNUC__ __inline -#ifdef __GNUC_STDC_INLINE__ +#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif -struct kconf_id * +const struct kconf_id * kconf_id_lookup (register const char *str, register unsigned int len) { enum @@ -174,54 +174,94 @@ kconf_id_lookup (register const char *str, register unsigned int len) MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 14, MIN_HASH_VALUE = 2, - MAX_HASH_VALUE = 51 + MAX_HASH_VALUE = 72 }; - static struct kconf_id wordlist[] = + static const struct kconf_id wordlist[] = { {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_OPT_ENV, TF_OPTION}, +#line 25 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM}, +#line 36 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT}, {-1}, +#line 26 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_OPTIONAL, TF_COMMAND}, + {-1}, +#line 29 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, +#line 31 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE}, +#line 20 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_CHOICE, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, + {-1}, {-1}, +#line 32 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE}, +#line 35 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, - {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, +#line 45 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION}, {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, - {-1}, {-1}, {-1}, +#line 43 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM}, +#line 28 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND}, + {-1}, {-1}, +#line 42 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND}, +#line 17 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND}, +#line 15 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND}, + {-1}, +#line 23 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND}, + {-1}, +#line 44 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, + {-1}, +#line 16 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, - {-1}, {-1}, + {-1}, +#line 39 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND}, +#line 21 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, - {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND}, - {-1}, {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND}, +#line 46 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN}, +#line 40 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND}, +#line 19 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND}, + {-1}, {-1}, +#line 33 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND}, +#line 18 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND}, +#line 41 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND}, +#line 37 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX}, + {-1}, {-1}, +#line 22 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND}, +#line 34 "scripts/kconfig/zconf.gperf" {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}, + {-1}, {-1}, {-1}, +#line 38 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING}, {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND} +#line 24 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND}, + {-1}, +#line 30 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 27 "scripts/kconfig/zconf.gperf" + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) @@ -242,4 +282,5 @@ kconf_id_lookup (register const char *str, register unsigned int len) } return 0; } +#line 47 "scripts/kconfig/zconf.gperf" diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index b22f884f9022..00f9d3a9cf8b 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -1,5 +1,5 @@ -%option backup nostdinit noyywrap never-interactive full ecs -%option 8bit backup nodefault perf-report perf-report +%option nostdinit noyywrap never-interactive full ecs +%option 8bit nodefault perf-report perf-report %option noinput %x COMMAND HELP STRING PARAM %{ @@ -14,7 +14,6 @@ #include <string.h> #include <unistd.h> -#define LKC_DIRECT_LINK #include "lkc.h" #define START_STRSIZE 16 @@ -96,7 +95,7 @@ n [A-Za-z0-9_] <COMMAND>{ {n}+ { - struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); BEGIN(PARAM); current_pos.file = current_file; current_pos.lineno = current_file->lineno; @@ -132,7 +131,7 @@ n [A-Za-z0-9_] \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; --- /* ignore */ ({n}|[-/.])+ { - struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { zconflval.id = id; return id->token; diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/zconf.lex.c_shipped index d9182916f724..c32b1a49f5a3 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/zconf.lex.c_shipped @@ -1,5 +1,5 @@ -#line 3 "scripts/kconfig/lex.zconf.c" +#line 3 "scripts/kconfig/zconf.lex.c_shipped" #define YY_INT_ALIGNED short int @@ -72,6 +72,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -102,8 +103,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -160,15 +159,7 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -785,7 +776,6 @@ char *zconftext; #include <string.h> #include <unistd.h> -#define LKC_DIRECT_LINK #include "lkc.h" #define START_STRSIZE 16 @@ -922,12 +912,7 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1100,7 +1085,7 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP { - struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); BEGIN(PARAM); current_pos.file = current_file; current_pos.lineno = current_file->lineno; @@ -1175,7 +1160,7 @@ YY_RULE_SETUP case 19: YY_RULE_SETUP { - struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); + const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); if (id && id->flags & TF_PARAM) { zconflval.id = id; return id->token; @@ -2073,8 +2058,8 @@ YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to zconflex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index 4c5495ea205e..f636141e7bfd 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped @@ -1,10 +1,9 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -88,7 +87,6 @@ #include <string.h> #include <stdbool.h> -#define LKC_DIRECT_LINK #include "lkc.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) @@ -102,22 +100,18 @@ extern int zconflex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static void zconferror(const char *err); -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; -#define YYDEBUG 0 -#if YYDEBUG -#define YYERROR_VERBOSE -#endif /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG 0 +# define YYDEBUG 1 #endif /* Enabling verbose error messages. */ @@ -188,7 +182,7 @@ typedef union YYSTYPE struct symbol *symbol; struct expr *expr; struct menu *menu; - struct kconf_id *id; + const struct kconf_id *id; @@ -255,7 +249,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -535,18 +529,18 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 108, 108, 108, 110, 110, 112, 114, 115, 116, - 117, 118, 119, 123, 127, 127, 127, 127, 127, 127, - 127, 127, 131, 132, 133, 134, 135, 136, 140, 141, - 147, 155, 161, 169, 179, 181, 182, 183, 184, 185, - 186, 189, 197, 203, 213, 219, 225, 228, 230, 241, - 242, 247, 256, 261, 269, 272, 274, 275, 276, 277, - 278, 281, 287, 298, 304, 314, 316, 321, 329, 337, - 340, 342, 343, 344, 349, 356, 363, 368, 376, 379, - 381, 382, 383, 386, 394, 401, 408, 414, 421, 423, - 424, 425, 428, 436, 438, 439, 442, 449, 451, 456, - 457, 460, 461, 462, 466, 467, 470, 471, 474, 475, - 476, 477, 478, 479, 480, 483, 484, 487, 488 + 0, 104, 104, 104, 106, 106, 108, 110, 111, 112, + 113, 114, 115, 119, 123, 123, 123, 123, 123, 123, + 123, 123, 127, 128, 129, 130, 131, 132, 136, 137, + 143, 151, 157, 165, 175, 177, 178, 179, 180, 181, + 182, 185, 193, 199, 209, 215, 221, 224, 226, 237, + 238, 243, 252, 257, 265, 268, 270, 271, 272, 273, + 274, 277, 283, 294, 300, 310, 312, 317, 325, 333, + 336, 338, 339, 340, 345, 352, 359, 364, 372, 375, + 377, 378, 379, 382, 390, 397, 404, 410, 417, 419, + 420, 421, 424, 432, 434, 435, 438, 445, 447, 452, + 453, 456, 457, 458, 462, 463, 466, 467, 470, 471, + 472, 473, 474, 475, 476, 479, 480, 483, 484 }; #endif @@ -806,9 +800,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -865,7 +868,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1753,7 +1756,7 @@ yyreduce: case 48: { - struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); + const struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); if (id && id->flags & TF_OPTION) menu_add_option(id->token, (yyvsp[(3) - (3)].string)); else @@ -2258,10 +2261,8 @@ void conf_parse(const char *name) modules_sym->flags |= SYMBOL_AUTO; rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); -#if YYDEBUG if (getenv("ZCONF_DEBUG")) zconfdebug = 1; -#endif zconfparse(); if (zconfnerrs) exit(1); @@ -2300,7 +2301,7 @@ static const char *zconf_tokenname(int token) return "<token>"; } -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) { if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", @@ -2345,9 +2346,7 @@ static void zconf_error(const char *err, ...) static void zconferror(const char *err) { -#if YYDEBUG fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -#endif } static void print_quoted_string(FILE *out, const char *str) @@ -2496,7 +2495,7 @@ void zconfdump(FILE *out) } } -#include "lex.zconf.c" +#include "zconf.lex.c" #include "util.c" #include "confdata.c" #include "expr.c" diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 49fb4ab664c3..864da07ba4aa 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -11,7 +11,6 @@ #include <string.h> #include <stdbool.h> -#define LKC_DIRECT_LINK #include "lkc.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) @@ -25,16 +24,12 @@ extern int zconflex(void); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static void zconferror(const char *err); -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; -#define YYDEBUG 0 -#if YYDEBUG -#define YYERROR_VERBOSE -#endif %} %expect 30 @@ -45,7 +40,7 @@ static struct menu *current_menu, *current_entry; struct symbol *symbol; struct expr *expr; struct menu *menu; - struct kconf_id *id; + const struct kconf_id *id; } %token <id>T_MAINMENU @@ -229,7 +224,7 @@ symbol_option_list: /* empty */ | symbol_option_list T_WORD symbol_option_arg { - struct kconf_id *id = kconf_id_lookup($2, strlen($2)); + const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); if (id && id->flags & TF_OPTION) menu_add_option(id->token, $3); else @@ -503,10 +498,8 @@ void conf_parse(const char *name) modules_sym->flags |= SYMBOL_AUTO; rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); -#if YYDEBUG if (getenv("ZCONF_DEBUG")) zconfdebug = 1; -#endif zconfparse(); if (zconfnerrs) exit(1); @@ -545,7 +538,7 @@ static const char *zconf_tokenname(int token) return "<token>"; } -static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) +static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) { if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", @@ -590,9 +583,7 @@ static void zconf_error(const char *err, ...) static void zconferror(const char *err) { -#if YYDEBUG fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -#endif } static void print_quoted_string(FILE *out, const char *str) @@ -741,7 +732,7 @@ void zconfdump(FILE *out) } } -#include "lex.zconf.c" +#include "zconf.lex.c" #include "util.c" #include "confdata.c" #include "expr.c" diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 5325423ceab4..0cc044260744 100644 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -30,6 +30,13 @@ PATCHLEVEL = $4 lastword = \$(word \$(words \$(1)),\$(1)) makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) +ifeq ("\$(origin V)", "command line") +VERBOSE := \$(V) +endif +ifneq (\$(VERBOSE),1) +Q := @ +endif + MAKEARGS := -C $1 MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) @@ -40,7 +47,7 @@ MAKEFLAGS += --no-print-directory all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) all: - \$(MAKE) \$(MAKEARGS) \$(all) + \$(Q)\$(MAKE) \$(MAKEARGS) \$(all) Makefile:; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 413c53693e62..a509ff8f32fa 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -254,6 +254,28 @@ static enum export export_no(const char *s) return export_unknown; } +static const char *sec_name(struct elf_info *elf, int secindex); + +#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) + +static enum export export_from_secname(struct elf_info *elf, unsigned int sec) +{ + const char *secname = sec_name(elf, sec); + + if (strstarts(secname, "___ksymtab+")) + return export_plain; + else if (strstarts(secname, "___ksymtab_unused+")) + return export_unused; + else if (strstarts(secname, "___ksymtab_gpl+")) + return export_gpl; + else if (strstarts(secname, "___ksymtab_unused_gpl+")) + return export_unused_gpl; + else if (strstarts(secname, "___ksymtab_gpl_future+")) + return export_gpl_future; + else + return export_unknown; +} + static enum export export_from_sec(struct elf_info *elf, unsigned int sec) { if (sec == elf->export_sec) @@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) { unsigned int crc; - enum export export = export_from_sec(info, get_secindex(info, sym)); + enum export export; + + if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0) + export = export_from_secname(info, get_secindex(info, sym)); + else + export = export_from_sec(info, get_secindex(info, sym)); switch (sym->st_shndx) { case SHN_COMMON: diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 006960ebbce9..bc6aa003860e 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -118,10 +118,12 @@ perf-tar=perf-$(KERNELVERSION) quiet_cmd_perf_tar = TAR cmd_perf_tar = \ -git archive --prefix=$(perf-tar)/ HEAD^{tree} \ - $$(cat $(srctree)/tools/perf/MANIFEST) -o $(perf-tar).tar; \ +git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ + HEAD^{tree} $$(cd $(srctree); \ + echo $$(cat $(srctree)/tools/perf/MANIFEST)) \ + -o $(perf-tar).tar; \ mkdir -p $(perf-tar); \ -git rev-parse HEAD > $(perf-tar)/HEAD; \ +git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ tar rf $(perf-tar).tar $(perf-tar)/HEAD; \ rm -r $(perf-tar); \ $(if $(findstring tar-src,$@),, \ |