aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build8
-rw-r--r--scripts/Makefile.extrawarn2
-rw-r--r--scripts/Makefile.lib13
-rw-r--r--scripts/Makefile.ubsan17
-rw-r--r--scripts/basic/fixdep.c2
-rwxr-xr-xscripts/bloat-o-meter8
-rwxr-xr-xscripts/checkkconfigsymbols.py234
-rwxr-xr-xscripts/checkpatch.pl82
-rw-r--r--scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci75
-rw-r--r--scripts/genksyms/genksyms.c6
-rwxr-xr-xscripts/get_maintainer.pl4
-rw-r--r--scripts/kconfig/conf.c7
-rw-r--r--scripts/kconfig/menu.c2
-rw-r--r--scripts/kconfig/qconf.cc2
-rwxr-xr-xscripts/kernel-doc7
-rwxr-xr-xscripts/ld-version.sh4
-rwxr-xr-xscripts/link-vmlinux.sh2
-rw-r--r--scripts/mod/file2alias.c5
-rw-r--r--scripts/mod/modpost.c3
-rw-r--r--scripts/package/Makefile4
-rw-r--r--scripts/recordmcount.c137
-rwxr-xr-xscripts/recordmcount.pl3
-rwxr-xr-xscripts/tags.sh217
23 files changed, 631 insertions, 213 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 01df30af4d4a..2c47f9c305aa 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -372,10 +372,14 @@ endif
372# <composite-object>-objs := <list of .o files> 372# <composite-object>-objs := <list of .o files>
373# or 373# or
374# <composite-object>-y := <list of .o files> 374# <composite-object>-y := <list of .o files>
375# or
376# <composite-object>-m := <list of .o files>
377# The -m syntax only works if <composite object> is a module
375link_multi_deps = \ 378link_multi_deps = \
376$(filter $(addprefix $(obj)/, \ 379$(filter $(addprefix $(obj)/, \
377$($(subst $(obj)/,,$(@:.o=-objs))) \ 380$($(subst $(obj)/,,$(@:.o=-objs))) \
378$($(subst $(obj)/,,$(@:.o=-y)))), $^) 381$($(subst $(obj)/,,$(@:.o=-y))) \
382$($(subst $(obj)/,,$(@:.o=-m)))), $^)
379 383
380quiet_cmd_link_multi-y = LD $@ 384quiet_cmd_link_multi-y = LD $@
381cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) 385cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
@@ -390,7 +394,7 @@ $(call multi_depend, $(multi-used-y), .o, -objs -y)
390$(multi-used-m): FORCE 394$(multi-used-m): FORCE
391 $(call if_changed,link_multi-m) 395 $(call if_changed,link_multi-m)
392 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) 396 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
393$(call multi_depend, $(multi-used-m), .o, -objs -y) 397$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
394 398
395targets += $(multi-used-y) $(multi-used-m) 399targets += $(multi-used-y) $(multi-used-m)
396 400
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 4efedcbe4165..f9e47a70509c 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -25,6 +25,7 @@ warning-1 += -Wold-style-definition
25warning-1 += $(call cc-option, -Wmissing-include-dirs) 25warning-1 += $(call cc-option, -Wmissing-include-dirs)
26warning-1 += $(call cc-option, -Wunused-but-set-variable) 26warning-1 += $(call cc-option, -Wunused-but-set-variable)
27warning-1 += $(call cc-disable-warning, missing-field-initializers) 27warning-1 += $(call cc-disable-warning, missing-field-initializers)
28warning-1 += $(call cc-disable-warning, sign-compare)
28 29
29warning-2 := -Waggregate-return 30warning-2 := -Waggregate-return
30warning-2 += -Wcast-align 31warning-2 += -Wcast-align
@@ -33,6 +34,7 @@ warning-2 += -Wnested-externs
33warning-2 += -Wshadow 34warning-2 += -Wshadow
34warning-2 += $(call cc-option, -Wlogical-op) 35warning-2 += $(call cc-option, -Wlogical-op)
35warning-2 += $(call cc-option, -Wmissing-field-initializers) 36warning-2 += $(call cc-option, -Wmissing-field-initializers)
37warning-2 += $(call cc-option, -Wsign-compare)
36 38
37warning-3 := -Wbad-function-cast 39warning-3 := -Wbad-function-cast
38warning-3 += -Wcast-qual 40warning-3 += -Wcast-qual
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 79e86613712f..2edbcadb3d7f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -48,7 +48,7 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m))
48 48
49# if $(foo-objs) exists, foo.o is a composite object 49# if $(foo-objs) exists, foo.o is a composite object
50multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 50multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
51multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 51multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
52multi-used := $(multi-used-y) $(multi-used-m) 52multi-used := $(multi-used-y) $(multi-used-m)
53single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) 53single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
54 54
@@ -67,7 +67,7 @@ obj-dirs := $(dir $(multi-objs) $(obj-y))
67 67
68# Replace multi-part objects by their individual parts, look at local dir only 68# Replace multi-part objects by their individual parts, look at local dir only
69real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) 69real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
70real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 70real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
71 71
72# Add subdir path 72# Add subdir path
73 73
@@ -104,8 +104,9 @@ modname_flags = $(if $(filter 1,$(words $(modname))),\
104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ 104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
105 $(ccflags-y) $(CFLAGS_$(basetarget).o) 105 $(ccflags-y) $(CFLAGS_$(basetarget).o)
106_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 106_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
107_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ 107orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
108 $(asflags-y) $(AFLAGS_$(basetarget).o) 108 $(asflags-y) $(AFLAGS_$(basetarget).o)
109_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
109_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) 110_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
110 111
111# 112#
@@ -129,6 +130,12 @@ _c_flags += $(if $(patsubst n%,, \
129 $(CFLAGS_KASAN)) 130 $(CFLAGS_KASAN))
130endif 131endif
131 132
133ifeq ($(CONFIG_UBSAN),y)
134_c_flags += $(if $(patsubst n%,, \
135 $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
136 $(CFLAGS_UBSAN))
137endif
138
132# If building the kernel in a separate objtree expand all occurrences 139# If building the kernel in a separate objtree expand all occurrences
133# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 140# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
134 141
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
new file mode 100644
index 000000000000..8ab68679cfb5
--- /dev/null
+++ b/scripts/Makefile.ubsan
@@ -0,0 +1,17 @@
1ifdef CONFIG_UBSAN
2 CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift)
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
4 CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
5 CFLAGS_UBSAN += $(call cc-option, -fsanitize=vla-bound)
6 CFLAGS_UBSAN += $(call cc-option, -fsanitize=null)
7 CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
8 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
9 CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
10 CFLAGS_UBSAN += $(call cc-option, -fsanitize=returns-nonnull-attribute)
11 CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
12 CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
13
14ifdef CONFIG_UBSAN_ALIGNMENT
15 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
16endif
17endif
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index c68fd61fdc42..5b327c67a828 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -251,7 +251,7 @@ static void parse_config_file(const char *map, size_t len)
251} 251}
252 252
253/* test is s ends in sub */ 253/* test is s ends in sub */
254static int strrcmp(char *s, char *sub) 254static int strrcmp(const char *s, const char *sub)
255{ 255{
256 int slen = strlen(s); 256 int slen = strlen(s);
257 int sublen = strlen(sub); 257 int sublen = strlen(sub);
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 23e78dcd12bf..38b64f487315 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -58,8 +58,8 @@ for name in common:
58delta.sort() 58delta.sort()
59delta.reverse() 59delta.reverse()
60 60
61print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ 61print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
62 (add, remove, grow, shrink, up, -down, up-down) 62 (add, remove, grow, shrink, up, -down, up-down))
63print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta") 63print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta"))
64for d, n in delta: 64for d, n in delta:
65 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d) 65 if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index 2f4b7ffd5570..d8f6c094cce5 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -8,11 +8,14 @@
8# Licensed under the terms of the GNU GPL License version 2 8# Licensed under the terms of the GNU GPL License version 2
9 9
10 10
11import difflib
11import os 12import os
12import re 13import re
14import signal
13import sys 15import sys
14from subprocess import Popen, PIPE, STDOUT 16from multiprocessing import Pool, cpu_count
15from optparse import OptionParser 17from optparse import OptionParser
18from subprocess import Popen, PIPE, STDOUT
16 19
17 20
18# regex expressions 21# regex expressions
@@ -26,7 +29,7 @@ SOURCE_FEATURE = r"(?:\W|\b)+[D]{,1}CONFIG_(" + FEATURE + r")"
26 29
27# regex objects 30# regex objects
28REGEX_FILE_KCONFIG = re.compile(r".*Kconfig[\.\w+\-]*$") 31REGEX_FILE_KCONFIG = re.compile(r".*Kconfig[\.\w+\-]*$")
29REGEX_FEATURE = re.compile(r'(?!\B"[^"]*)' + FEATURE + r'(?![^"]*"\B)') 32REGEX_FEATURE = re.compile(r'(?!\B)' + FEATURE + r'(?!\B)')
30REGEX_SOURCE_FEATURE = re.compile(SOURCE_FEATURE) 33REGEX_SOURCE_FEATURE = re.compile(SOURCE_FEATURE)
31REGEX_KCONFIG_DEF = re.compile(DEF) 34REGEX_KCONFIG_DEF = re.compile(DEF)
32REGEX_KCONFIG_EXPR = re.compile(EXPR) 35REGEX_KCONFIG_EXPR = re.compile(EXPR)
@@ -34,6 +37,7 @@ REGEX_KCONFIG_STMT = re.compile(STMT)
34REGEX_KCONFIG_HELP = re.compile(r"^\s+(help|---help---)\s*$") 37REGEX_KCONFIG_HELP = re.compile(r"^\s+(help|---help---)\s*$")
35REGEX_FILTER_FEATURES = re.compile(r"[A-Za-z0-9]$") 38REGEX_FILTER_FEATURES = re.compile(r"[A-Za-z0-9]$")
36REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+") 39REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+")
40REGEX_QUOTES = re.compile("(\"(.*?)\")")
37 41
38 42
39def parse_options(): 43def parse_options():
@@ -71,6 +75,9 @@ def parse_options():
71 "the pattern needs to be a Python regex. To " 75 "the pattern needs to be a Python regex. To "
72 "ignore defconfigs, specify -i '.*defconfig'.") 76 "ignore defconfigs, specify -i '.*defconfig'.")
73 77
78 parser.add_option('-s', '--sim', dest='sim', action='store', default="",
79 help="Print a list of maximum 10 string-similar symbols.")
80
74 parser.add_option('', '--force', dest='force', action='store_true', 81 parser.add_option('', '--force', dest='force', action='store_true',
75 default=False, 82 default=False,
76 help="Reset current Git tree even when it's dirty.") 83 help="Reset current Git tree even when it's dirty.")
@@ -109,6 +116,18 @@ def main():
109 """Main function of this module.""" 116 """Main function of this module."""
110 opts = parse_options() 117 opts = parse_options()
111 118
119 if opts.sim and not opts.commit and not opts.diff:
120 sims = find_sims(opts.sim, opts.ignore)
121 if sims:
122 print "%s: %s" % (yel("Similar symbols"), ', '.join(sims))
123 else:
124 print "%s: no similar symbols found" % yel("Similar symbols")
125 sys.exit(0)
126
127 # dictionary of (un)defined symbols
128 defined = {}
129 undefined = {}
130
112 if opts.commit or opts.diff: 131 if opts.commit or opts.diff:
113 head = get_head() 132 head = get_head()
114 133
@@ -127,40 +146,56 @@ def main():
127 146
128 # get undefined items before the commit 147 # get undefined items before the commit
129 execute("git reset --hard %s" % commit_a) 148 execute("git reset --hard %s" % commit_a)
130 undefined_a = check_symbols(opts.ignore) 149 undefined_a, _ = check_symbols(opts.ignore)
131 150
132 # get undefined items for the commit 151 # get undefined items for the commit
133 execute("git reset --hard %s" % commit_b) 152 execute("git reset --hard %s" % commit_b)
134 undefined_b = check_symbols(opts.ignore) 153 undefined_b, defined = check_symbols(opts.ignore)
135 154
136 # report cases that are present for the commit but not before 155 # report cases that are present for the commit but not before
137 for feature in sorted(undefined_b): 156 for feature in sorted(undefined_b):
138 # feature has not been undefined before 157 # feature has not been undefined before
139 if not feature in undefined_a: 158 if not feature in undefined_a:
140 files = sorted(undefined_b.get(feature)) 159 files = sorted(undefined_b.get(feature))
141 print "%s\t%s" % (yel(feature), ", ".join(files)) 160 undefined[feature] = files
142 if opts.find:
143 commits = find_commits(feature, opts.diff)
144 print red(commits)
145 # check if there are new files that reference the undefined feature 161 # check if there are new files that reference the undefined feature
146 else: 162 else:
147 files = sorted(undefined_b.get(feature) - 163 files = sorted(undefined_b.get(feature) -
148 undefined_a.get(feature)) 164 undefined_a.get(feature))
149 if files: 165 if files:
150 print "%s\t%s" % (yel(feature), ", ".join(files)) 166 undefined[feature] = files
151 if opts.find:
152 commits = find_commits(feature, opts.diff)
153 print red(commits)
154 167
155 # reset to head 168 # reset to head
156 execute("git reset --hard %s" % head) 169 execute("git reset --hard %s" % head)
157 170
158 # default to check the entire tree 171 # default to check the entire tree
159 else: 172 else:
160 undefined = check_symbols(opts.ignore) 173 undefined, defined = check_symbols(opts.ignore)
161 for feature in sorted(undefined): 174
162 files = sorted(undefined.get(feature)) 175 # now print the output
163 print "%s\t%s" % (yel(feature), ", ".join(files)) 176 for feature in sorted(undefined):
177 print red(feature)
178
179 files = sorted(undefined.get(feature))
180 print "%s: %s" % (yel("Referencing files"), ", ".join(files))
181
182 sims = find_sims(feature, opts.ignore, defined)
183 sims_out = yel("Similar symbols")
184 if sims:
185 print "%s: %s" % (sims_out, ', '.join(sims))
186 else:
187 print "%s: %s" % (sims_out, "no similar symbols found")
188
189 if opts.find:
190 print "%s:" % yel("Commits changing symbol")
191 commits = find_commits(feature, opts.diff)
192 if commits:
193 for commit in commits:
194 commit = commit.split(" ", 1)
195 print "\t- %s (\"%s\")" % (yel(commit[0]), commit[1])
196 else:
197 print "\t- no commit found"
198 print # new line
164 199
165 200
166def yel(string): 201def yel(string):
@@ -190,7 +225,7 @@ def find_commits(symbol, diff):
190 """Find commits changing %symbol in the given range of %diff.""" 225 """Find commits changing %symbol in the given range of %diff."""
191 commits = execute("git log --pretty=oneline --abbrev-commit -G %s %s" 226 commits = execute("git log --pretty=oneline --abbrev-commit -G %s %s"
192 % (symbol, diff)) 227 % (symbol, diff))
193 return commits 228 return [x for x in commits.split("\n") if x]
194 229
195 230
196def tree_is_dirty(): 231def tree_is_dirty():
@@ -209,43 +244,107 @@ def get_head():
209 return stdout.strip('\n') 244 return stdout.strip('\n')
210 245
211 246
212def check_symbols(ignore): 247def partition(lst, size):
213 """Find undefined Kconfig symbols and return a dict with the symbol as key 248 """Partition list @lst into eveni-sized lists of size @size."""
214 and a list of referencing files as value. Files matching %ignore are not 249 return [lst[i::size] for i in xrange(size)]
215 checked for undefined symbols.""" 250
216 source_files = [] 251
217 kconfig_files = [] 252def init_worker():
218 defined_features = set() 253 """Set signal handler to ignore SIGINT."""
219 referenced_features = dict() # {feature: [files]} 254 signal.signal(signal.SIGINT, signal.SIG_IGN)
255
256
257def find_sims(symbol, ignore, defined = []):
258 """Return a list of max. ten Kconfig symbols that are string-similar to
259 @symbol."""
260 if defined:
261 return sorted(difflib.get_close_matches(symbol, set(defined), 10))
262
263 pool = Pool(cpu_count(), init_worker)
264 kfiles = []
265 for gitfile in get_files():
266 if REGEX_FILE_KCONFIG.match(gitfile):
267 kfiles.append(gitfile)
220 268
269 arglist = []
270 for part in partition(kfiles, cpu_count()):
271 arglist.append((part, ignore))
272
273 for res in pool.map(parse_kconfig_files, arglist):
274 defined.extend(res[0])
275
276 return sorted(difflib.get_close_matches(symbol, set(defined), 10))
277
278
279def get_files():
280 """Return a list of all files in the current git directory."""
221 # use 'git ls-files' to get the worklist 281 # use 'git ls-files' to get the worklist
222 stdout = execute("git ls-files") 282 stdout = execute("git ls-files")
223 if len(stdout) > 0 and stdout[-1] == "\n": 283 if len(stdout) > 0 and stdout[-1] == "\n":
224 stdout = stdout[:-1] 284 stdout = stdout[:-1]
225 285
286 files = []
226 for gitfile in stdout.rsplit("\n"): 287 for gitfile in stdout.rsplit("\n"):
227 if ".git" in gitfile or "ChangeLog" in gitfile or \ 288 if ".git" in gitfile or "ChangeLog" in gitfile or \
228 ".log" in gitfile or os.path.isdir(gitfile) or \ 289 ".log" in gitfile or os.path.isdir(gitfile) or \
229 gitfile.startswith("tools/"): 290 gitfile.startswith("tools/"):
230 continue 291 continue
292 files.append(gitfile)
293 return files
294
295
296def check_symbols(ignore):
297 """Find undefined Kconfig symbols and return a dict with the symbol as key
298 and a list of referencing files as value. Files matching %ignore are not
299 checked for undefined symbols."""
300 pool = Pool(cpu_count(), init_worker)
301 try:
302 return check_symbols_helper(pool, ignore)
303 except KeyboardInterrupt:
304 pool.terminate()
305 pool.join()
306 sys.exit(1)
307
308
309def check_symbols_helper(pool, ignore):
310 """Helper method for check_symbols(). Used to catch keyboard interrupts in
311 check_symbols() in order to properly terminate running worker processes."""
312 source_files = []
313 kconfig_files = []
314 defined_features = []
315 referenced_features = dict() # {file: [features]}
316
317 for gitfile in get_files():
231 if REGEX_FILE_KCONFIG.match(gitfile): 318 if REGEX_FILE_KCONFIG.match(gitfile):
232 kconfig_files.append(gitfile) 319 kconfig_files.append(gitfile)
233 else: 320 else:
234 # all non-Kconfig files are checked for consistency 321 if ignore and not re.match(ignore, gitfile):
322 continue
323 # add source files that do not match the ignore pattern
235 source_files.append(gitfile) 324 source_files.append(gitfile)
236 325
237 for sfile in source_files: 326 # parse source files
238 if ignore and re.match(ignore, sfile): 327 arglist = partition(source_files, cpu_count())
239 # do not check files matching %ignore 328 for res in pool.map(parse_source_files, arglist):
240 continue 329 referenced_features.update(res)
241 parse_source_file(sfile, referenced_features)
242 330
243 for kfile in kconfig_files: 331
244 if ignore and re.match(ignore, kfile): 332 # parse kconfig files
245 # do not collect references for files matching %ignore 333 arglist = []
246 parse_kconfig_file(kfile, defined_features, dict()) 334 for part in partition(kconfig_files, cpu_count()):
247 else: 335 arglist.append((part, ignore))
248 parse_kconfig_file(kfile, defined_features, referenced_features) 336 for res in pool.map(parse_kconfig_files, arglist):
337 defined_features.extend(res[0])
338 referenced_features.update(res[1])
339 defined_features = set(defined_features)
340
341 # inverse mapping of referenced_features to dict(feature: [files])
342 inv_map = dict()
343 for _file, features in referenced_features.iteritems():
344 for feature in features:
345 inv_map[feature] = inv_map.get(feature, set())
346 inv_map[feature].add(_file)
347 referenced_features = inv_map
249 348
250 undefined = {} # {feature: [files]} 349 undefined = {} # {feature: [files]}
251 for feature in sorted(referenced_features): 350 for feature in sorted(referenced_features):
@@ -259,12 +358,26 @@ def check_symbols(ignore):
259 if feature[:-len("_MODULE")] in defined_features: 358 if feature[:-len("_MODULE")] in defined_features:
260 continue 359 continue
261 undefined[feature] = referenced_features.get(feature) 360 undefined[feature] = referenced_features.get(feature)
262 return undefined 361 return undefined, defined_features
263 362
264 363
265def parse_source_file(sfile, referenced_features): 364def parse_source_files(source_files):
266 """Parse @sfile for referenced Kconfig features.""" 365 """Parse each source file in @source_files and return dictionary with source
366 files as keys and lists of references Kconfig symbols as values."""
367 referenced_features = dict()
368 for sfile in source_files:
369 referenced_features[sfile] = parse_source_file(sfile)
370 return referenced_features
371
372
373def parse_source_file(sfile):
374 """Parse @sfile and return a list of referenced Kconfig features."""
267 lines = [] 375 lines = []
376 references = []
377
378 if not os.path.exists(sfile):
379 return references
380
268 with open(sfile, "r") as stream: 381 with open(sfile, "r") as stream:
269 lines = stream.readlines() 382 lines = stream.readlines()
270 383
@@ -275,9 +388,9 @@ def parse_source_file(sfile, referenced_features):
275 for feature in features: 388 for feature in features:
276 if not REGEX_FILTER_FEATURES.search(feature): 389 if not REGEX_FILTER_FEATURES.search(feature):
277 continue 390 continue
278 sfiles = referenced_features.get(feature, set()) 391 references.append(feature)
279 sfiles.add(sfile) 392
280 referenced_features[feature] = sfiles 393 return references
281 394
282 395
283def get_features_in_line(line): 396def get_features_in_line(line):
@@ -285,11 +398,35 @@ def get_features_in_line(line):
285 return REGEX_FEATURE.findall(line) 398 return REGEX_FEATURE.findall(line)
286 399
287 400
288def parse_kconfig_file(kfile, defined_features, referenced_features): 401def parse_kconfig_files(args):
402 """Parse kconfig files and return tuple of defined and references Kconfig
403 symbols. Note, @args is a tuple of a list of files and the @ignore
404 pattern."""
405 kconfig_files = args[0]
406 ignore = args[1]
407 defined_features = []
408 referenced_features = dict()
409
410 for kfile in kconfig_files:
411 defined, references = parse_kconfig_file(kfile)
412 defined_features.extend(defined)
413 if ignore and re.match(ignore, kfile):
414 # do not collect references for files that match the ignore pattern
415 continue
416 referenced_features[kfile] = references
417 return (defined_features, referenced_features)
418
419
420def parse_kconfig_file(kfile):
289 """Parse @kfile and update feature definitions and references.""" 421 """Parse @kfile and update feature definitions and references."""
290 lines = [] 422 lines = []
423 defined = []
424 references = []
291 skip = False 425 skip = False
292 426
427 if not os.path.exists(kfile):
428 return defined, references
429
293 with open(kfile, "r") as stream: 430 with open(kfile, "r") as stream:
294 lines = stream.readlines() 431 lines = stream.readlines()
295 432
@@ -300,7 +437,7 @@ def parse_kconfig_file(kfile, defined_features, referenced_features):
300 437
301 if REGEX_KCONFIG_DEF.match(line): 438 if REGEX_KCONFIG_DEF.match(line):
302 feature_def = REGEX_KCONFIG_DEF.findall(line) 439 feature_def = REGEX_KCONFIG_DEF.findall(line)
303 defined_features.add(feature_def[0]) 440 defined.append(feature_def[0])
304 skip = False 441 skip = False
305 elif REGEX_KCONFIG_HELP.match(line): 442 elif REGEX_KCONFIG_HELP.match(line):
306 skip = True 443 skip = True
@@ -308,6 +445,7 @@ def parse_kconfig_file(kfile, defined_features, referenced_features):
308 # ignore content of help messages 445 # ignore content of help messages
309 pass 446 pass
310 elif REGEX_KCONFIG_STMT.match(line): 447 elif REGEX_KCONFIG_STMT.match(line):
448 line = REGEX_QUOTES.sub("", line)
311 features = get_features_in_line(line) 449 features = get_features_in_line(line)
312 # multi-line statements 450 # multi-line statements
313 while line.endswith("\\"): 451 while line.endswith("\\"):
@@ -319,9 +457,9 @@ def parse_kconfig_file(kfile, defined_features, referenced_features):
319 if REGEX_NUMERIC.match(feature): 457 if REGEX_NUMERIC.match(feature):
320 # ignore numeric values 458 # ignore numeric values
321 continue 459 continue
322 paths = referenced_features.get(feature, set()) 460 references.append(feature)
323 paths.add(kfile) 461
324 referenced_features[feature] = paths 462 return defined, references
325 463
326 464
327if __name__ == "__main__": 465if __name__ == "__main__":
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b3c22808c3b..0147c91fa549 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -433,6 +433,28 @@ our @typeList = (
433 qr{${Ident}_handler_fn}, 433 qr{${Ident}_handler_fn},
434 @typeListMisordered, 434 @typeListMisordered,
435); 435);
436
437our $C90_int_types = qr{(?x:
438 long\s+long\s+int\s+(?:un)?signed|
439 long\s+long\s+(?:un)?signed\s+int|
440 long\s+long\s+(?:un)?signed|
441 (?:(?:un)?signed\s+)?long\s+long\s+int|
442 (?:(?:un)?signed\s+)?long\s+long|
443 int\s+long\s+long\s+(?:un)?signed|
444 int\s+(?:(?:un)?signed\s+)?long\s+long|
445
446 long\s+int\s+(?:un)?signed|
447 long\s+(?:un)?signed\s+int|
448 long\s+(?:un)?signed|
449 (?:(?:un)?signed\s+)?long\s+int|
450 (?:(?:un)?signed\s+)?long|
451 int\s+long\s+(?:un)?signed|
452 int\s+(?:(?:un)?signed\s+)?long|
453
454 int\s+(?:un)?signed|
455 (?:(?:un)?signed\s+)?int
456)};
457
436our @typeListFile = (); 458our @typeListFile = ();
437our @typeListWithAttr = ( 459our @typeListWithAttr = (
438 @typeList, 460 @typeList,
@@ -4517,7 +4539,7 @@ sub process {
4517 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; 4539 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
4518 4540
4519 $has_flow_statement = 1 if ($ctx =~ /\b(goto|return)\b/); 4541 $has_flow_statement = 1 if ($ctx =~ /\b(goto|return)\b/);
4520 $has_arg_concat = 1 if ($ctx =~ /\#\#/); 4542 $has_arg_concat = 1 if ($ctx =~ /\#\#/ && $ctx !~ /\#\#\s*(?:__VA_ARGS__|args)\b/);
4521 4543
4522 $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//; 4544 $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
4523 $dstat =~ s/$;//g; 4545 $dstat =~ s/$;//g;
@@ -4528,7 +4550,7 @@ sub process {
4528 # Flatten any parentheses and braces 4550 # Flatten any parentheses and braces
4529 while ($dstat =~ s/\([^\(\)]*\)/1/ || 4551 while ($dstat =~ s/\([^\(\)]*\)/1/ ||
4530 $dstat =~ s/\{[^\{\}]*\}/1/ || 4552 $dstat =~ s/\{[^\{\}]*\}/1/ ||
4531 $dstat =~ s/\[[^\[\]]*\]/1/) 4553 $dstat =~ s/.\[[^\[\]]*\]/1/)
4532 { 4554 {
4533 } 4555 }
4534 4556
@@ -4548,7 +4570,8 @@ sub process {
4548 union| 4570 union|
4549 struct| 4571 struct|
4550 \.$Ident\s*=\s*| 4572 \.$Ident\s*=\s*|
4551 ^\"|\"$ 4573 ^\"|\"$|
4574 ^\[
4552 }x; 4575 }x;
4553 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; 4576 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
4554 if ($dstat ne '' && 4577 if ($dstat ne '' &&
@@ -5116,13 +5139,44 @@ sub process {
5116 } 5139 }
5117 } 5140 }
5118# check for memory barriers without a comment. 5141# check for memory barriers without a comment.
5119 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { 5142
5143 my $barriers = qr{
5144 mb|
5145 rmb|
5146 wmb|
5147 read_barrier_depends
5148 }x;
5149 my $barrier_stems = qr{
5150 mb__before_atomic|
5151 mb__after_atomic|
5152 store_release|
5153 load_acquire|
5154 store_mb|
5155 (?:$barriers)
5156 }x;
5157 my $all_barriers = qr{
5158 (?:$barriers)|
5159 smp_(?:$barrier_stems)|
5160 virt_(?:$barrier_stems)
5161 }x;
5162
5163 if ($line =~ /\b(?:$all_barriers)\s*\(/) {
5120 if (!ctx_has_comment($first_line, $linenr)) { 5164 if (!ctx_has_comment($first_line, $linenr)) {
5121 WARN("MEMORY_BARRIER", 5165 WARN("MEMORY_BARRIER",
5122 "memory barrier without comment\n" . $herecurr); 5166 "memory barrier without comment\n" . $herecurr);
5123 } 5167 }
5124 } 5168 }
5125 5169
5170 my $underscore_smp_barriers = qr{__smp_(?:$barrier_stems)}x;
5171
5172 if ($realfile !~ m@^include/asm-generic/@ &&
5173 $realfile !~ m@/barrier\.h$@ &&
5174 $line =~ m/\b(?:$underscore_smp_barriers)\s*\(/ &&
5175 $line !~ m/^.\s*\#\s*define\s+(?:$underscore_smp_barriers)\s*\(/) {
5176 WARN("MEMORY_BARRIER",
5177 "__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr);
5178 }
5179
5126# check for waitqueue_active without a comment. 5180# check for waitqueue_active without a comment.
5127 if ($line =~ /\bwaitqueue_active\s*\(/) { 5181 if ($line =~ /\bwaitqueue_active\s*\(/) {
5128 if (!ctx_has_comment($first_line, $linenr)) { 5182 if (!ctx_has_comment($first_line, $linenr)) {
@@ -5241,6 +5295,26 @@ sub process {
5241 } 5295 }
5242 } 5296 }
5243 5297
5298# check for cast of C90 native int or longer types constants
5299 if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) {
5300 my $cast = $1;
5301 my $const = $2;
5302 if (WARN("TYPECAST_INT_CONSTANT",
5303 "Unnecessary typecast of c90 int constant\n" . $herecurr) &&
5304 $fix) {
5305 my $suffix = "";
5306 my $newconst = $const;
5307 $newconst =~ s/${Int_type}$//;
5308 $suffix .= 'U' if ($cast =~ /\bunsigned\b/);
5309 if ($cast =~ /\blong\s+long\b/) {
5310 $suffix .= 'LL';
5311 } elsif ($cast =~ /\blong\b/) {
5312 $suffix .= 'L';
5313 }
5314 $fixed[$fixlinenr] =~ s/\Q$cast\E$const\b/$newconst$suffix/;
5315 }
5316 }
5317
5244# check for sizeof(&) 5318# check for sizeof(&)
5245 if ($line =~ /\bsizeof\s*\(\s*\&/) { 5319 if ($line =~ /\bsizeof\s*\(\s*\&/) {
5246 WARN("SIZEOF_ADDRESS", 5320 WARN("SIZEOF_ADDRESS",
diff --git a/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci b/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
new file mode 100644
index 000000000000..8fa5a3c7b784
--- /dev/null
+++ b/scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
@@ -0,0 +1,75 @@
1/// Unsigned expressions cannot be lesser than zero. Presence of
2/// comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug,
3/// usually wrong type of variable.
4///
5/// To reduce number of false positives following tests have been added:
6/// - parts of range checks are skipped, eg. "if (u < 0 || u > 15) ...",
7/// developers prefer to keep such code,
8/// - comparisons "<= 0" and "> 0" are performed only on results of
9/// signed functions/macros,
10/// - hardcoded list of signed functions/macros with always non-negative
11/// result is used to avoid false positives difficult to detect by other ways
12///
13// Confidence: Average
14// Copyright: (C) 2015 Andrzej Hajda, Samsung Electronics Co., Ltd. GPLv2.
15// URL: http://coccinelle.lip6.fr/
16// Options: --all-includes
17
18virtual context
19virtual org
20virtual report
21
22@r_cmp@
23position p;
24typedef bool, u8, u16, u32, u64;
25{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long,
26 size_t, bool, u8, u16, u32, u64} v;
27expression e;
28@@
29
30 \( v = e \| &v \)
31 ...
32 (\( v@p < 0 \| v@p <= 0 \| v@p >= 0 \| v@p > 0 \))
33
34@r@
35position r_cmp.p;
36typedef s8, s16, s32, s64;
37{char, short, int, long, long long, ssize_t, s8, s16, s32, s64} vs;
38expression c, e, v;
39identifier f !~ "^(ata_id_queue_depth|btrfs_copy_from_user|dma_map_sg|dma_map_sg_attrs|fls|fls64|gameport_time|get_write_extents|nla_len|ntoh24|of_flat_dt_match|of_get_child_count|uart_circ_chars_pending|[A-Z0-9_]+)$";
40@@
41
42(
43 v = f(...)@vs;
44 ... when != v = e;
45* (\( v@p <=@e 0 \| v@p >@e 0 \))
46 ... when any
47|
48(
49 (\( v@p < 0 \| v@p <= 0 \)) || ... || (\( v >= c \| v > c \))
50|
51 (\( v >= c \| v > c \)) || ... || (\( v@p < 0 \| v@p <= 0 \))
52|
53 (\( v@p >= 0 \| v@p > 0 \)) && ... && (\( v < c \| v <= c \))
54|
55 ((\( v < c \| v <= c \) && ... && \( v@p >= 0 \| v@p > 0 \)))
56|
57* (\( v@p <@e 0 \| v@p >=@e 0 \))
58)
59)
60
61@script:python depends on org@
62p << r_cmp.p;
63e << r.e;
64@@
65
66msg = "WARNING: Unsigned expression compared with zero: %s" % (e)
67coccilib.org.print_todo(p[0], msg)
68
69@script:python depends on report@
70p << r_cmp.p;
71e << r.e;
72@@
73
74msg = "WARNING: Unsigned expression compared with zero: %s" % (e)
75coccilib.report.print_report(p[0], msg)
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 88632df4381b..dafaf96e0a34 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -423,13 +423,15 @@ static struct string_list *read_node(FILE *f)
423 struct string_list node = { 423 struct string_list node = {
424 .string = buffer, 424 .string = buffer,
425 .tag = SYM_NORMAL }; 425 .tag = SYM_NORMAL };
426 int c; 426 int c, in_string = 0;
427 427
428 while ((c = fgetc(f)) != EOF) { 428 while ((c = fgetc(f)) != EOF) {
429 if (c == ' ') { 429 if (!in_string && c == ' ') {
430 if (node.string == buffer) 430 if (node.string == buffer)
431 continue; 431 continue;
432 break; 432 break;
433 } else if (c == '"') {
434 in_string = !in_string;
433 } else if (c == '\n') { 435 } else if (c == '\n') {
434 if (node.string == buffer) 436 if (node.string == buffer)
435 return NULL; 437 return NULL;
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index cab641a12dd5..1873421f2305 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -16,7 +16,9 @@ my $P = $0;
16my $V = '0.26'; 16my $V = '0.26';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19use Cwd;
19 20
21my $cur_path = fastgetcwd() . '/';
20my $lk_path = "./"; 22my $lk_path = "./";
21my $email = 1; 23my $email = 1;
22my $email_usename = 1; 24my $email_usename = 1;
@@ -429,6 +431,8 @@ foreach my $file (@ARGV) {
429 } 431 }
430 } 432 }
431 if ($from_filename) { 433 if ($from_filename) {
434 $file =~ s/^\Q${cur_path}\E//; #strip any absolute path
435 $file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
432 push(@files, $file); 436 push(@files, $file);
433 if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) { 437 if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) {
434 open(my $f, '<', $file) 438 open(my $f, '<', $file)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 6c204318bc94..866369f10ff8 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -5,6 +5,7 @@
5 5
6#include <locale.h> 6#include <locale.h>
7#include <ctype.h> 7#include <ctype.h>
8#include <limits.h>
8#include <stdio.h> 9#include <stdio.h>
9#include <stdlib.h> 10#include <stdlib.h>
10#include <string.h> 11#include <string.h>
@@ -41,7 +42,7 @@ static int tty_stdio;
41static int valid_stdin = 1; 42static int valid_stdin = 1;
42static int sync_kconfig; 43static int sync_kconfig;
43static int conf_cnt; 44static int conf_cnt;
44static char line[128]; 45static char line[PATH_MAX];
45static struct menu *rootEntry; 46static struct menu *rootEntry;
46 47
47static void print_help(struct menu *menu) 48static void print_help(struct menu *menu)
@@ -109,7 +110,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
109 /* fall through */ 110 /* fall through */
110 case oldaskconfig: 111 case oldaskconfig:
111 fflush(stdout); 112 fflush(stdout);
112 xfgets(line, 128, stdin); 113 xfgets(line, sizeof(line), stdin);
113 if (!tty_stdio) 114 if (!tty_stdio)
114 printf("\n"); 115 printf("\n");
115 return 1; 116 return 1;
@@ -311,7 +312,7 @@ static int conf_choice(struct menu *menu)
311 /* fall through */ 312 /* fall through */
312 case oldaskconfig: 313 case oldaskconfig:
313 fflush(stdout); 314 fflush(stdout);
314 xfgets(line, 128, stdin); 315 xfgets(line, sizeof(line), stdin);
315 strip(line); 316 strip(line);
316 if (line[0] == '?') { 317 if (line[0] == '?') {
317 print_help(menu); 318 print_help(menu);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index b05cc3d4a9be..aed678e8a777 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -477,7 +477,7 @@ bool menu_is_visible(struct menu *menu)
477 477
478 if (menu->visibility) { 478 if (menu->visibility) {
479 if (expr_calc_value(menu->visibility) == no) 479 if (expr_calc_value(menu->visibility) == no)
480 return no; 480 return false;
481 } 481 }
482 482
483 sym = menu->sym; 483 sym = menu->sym;
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 91b7e6fbc364..fc5555992220 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1863,6 +1863,8 @@ int main(int ac, char** av)
1863 1863
1864 configSettings->endGroup(); 1864 configSettings->endGroup();
1865 delete configSettings; 1865 delete configSettings;
1866 delete v;
1867 delete configApp;
1866 1868
1867 return 0; 1869 return 0;
1868} 1870}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 125b906cd1d4..c37255bb620d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1816,6 +1816,8 @@ sub dump_struct($$) {
1816 $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i; 1816 $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
1817 $members =~ s/__aligned\s*\([^;]*\)//gos; 1817 $members =~ s/__aligned\s*\([^;]*\)//gos;
1818 $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos; 1818 $members =~ s/\s*CRYPTO_MINALIGN_ATTR//gos;
1819 # replace DECLARE_BITMAP
1820 $members =~ s/DECLARE_BITMAP\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
1819 1821
1820 create_parameterlist($members, ';', $file); 1822 create_parameterlist($members, ';', $file);
1821 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 1823 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1844,7 +1846,8 @@ sub dump_enum($$) {
1844 my $file = shift; 1846 my $file = shift;
1845 1847
1846 $x =~ s@/\*.*?\*/@@gos; # strip comments. 1848 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1847 $x =~ s/^#\s*define\s+.*$//; # strip #define macros inside enums 1849 # strip #define macros inside enums
1850 $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
1848 1851
1849 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { 1852 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1850 $declaration_name = $1; 1853 $declaration_name = $1;
@@ -2711,7 +2714,7 @@ $kernelversion = get_kernel_version();
2711 2714
2712# generate a sequence of code that will splice in highlighting information 2715# generate a sequence of code that will splice in highlighting information
2713# using the s// operator. 2716# using the s// operator.
2714foreach my $k (keys @highlights) { 2717for (my $k = 0; $k < @highlights; $k++) {
2715 my $pattern = $highlights[$k][0]; 2718 my $pattern = $highlights[$k][0];
2716 my $result = $highlights[$k][1]; 2719 my $result = $highlights[$k][1];
2717# print STDERR "scanning pattern:$pattern, highlight:($result)\n"; 2720# print STDERR "scanning pattern:$pattern, highlight:($result)\n";
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index 198580d245e0..d154f0877fd8 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -2,7 +2,9 @@
2# extract linker version number from stdin and turn into single number 2# extract linker version number from stdin and turn into single number
3 { 3 {
4 gsub(".*)", ""); 4 gsub(".*)", "");
5 gsub(".*version ", "");
6 gsub("-.*", "");
5 split($1,a, "."); 7 split($1,a, ".");
6 print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5]; 8 print a[1]*100000000 + a[2]*1000000 + a[3]*10000 + a[4]*100 + a[5];
7 exit 9 exit
8 } 10 }
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 1a10d8ac8162..ba6c34ea5429 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -62,7 +62,7 @@ vmlinux_link()
62 -Wl,--start-group \ 62 -Wl,--start-group \
63 ${KBUILD_VMLINUX_MAIN} \ 63 ${KBUILD_VMLINUX_MAIN} \
64 -Wl,--end-group \ 64 -Wl,--end-group \
65 -lutil ${1} 65 -lutil -lrt -lpthread ${1}
66 rm -f linux 66 rm -f linux
67 fi 67 fi
68} 68}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 5b96206e9aab..161dd0d67da8 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -125,7 +125,7 @@ do { \
125 sprintf(str + strlen(str), "*"); \ 125 sprintf(str + strlen(str), "*"); \
126} while(0) 126} while(0)
127 127
128/* Always end in a wildcard, for future extension */ 128/* End in a wildcard, for future extension */
129static inline void add_wildcard(char *str) 129static inline void add_wildcard(char *str)
130{ 130{
131 int len = strlen(str); 131 int len = strlen(str);
@@ -704,7 +704,6 @@ static int do_of_entry (const char *filename, void *symval, char *alias)
704 if (isspace (*tmp)) 704 if (isspace (*tmp))
705 *tmp = '_'; 705 *tmp = '_';
706 706
707 add_wildcard(alias);
708 return 1; 707 return 1;
709} 708}
710ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); 709ADD_TO_DEVTABLE("of", of_device_id, do_of_entry);
@@ -917,7 +916,7 @@ static int do_vmbus_entry(const char *filename, void *symval,
917 char guid_name[(sizeof(*guid) + 1) * 2]; 916 char guid_name[(sizeof(*guid) + 1) * 2];
918 917
919 for (i = 0; i < (sizeof(*guid) * 2); i += 2) 918 for (i = 0; i < (sizeof(*guid) * 2); i += 2)
920 sprintf(&guid_name[i], "%02x", TO_NATIVE((*guid)[i/2])); 919 sprintf(&guid_name[i], "%02x", TO_NATIVE((guid->b)[i/2]));
921 920
922 strcpy(alias, "vmbus:"); 921 strcpy(alias, "vmbus:");
923 strcat(alias, guid_name); 922 strcat(alias, guid_name);
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index e080746e1a6b..48958d3cec9e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -594,7 +594,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
594 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || 594 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 ||
595 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || 595 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 ||
596 strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || 596 strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 ||
597 strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) 597 strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 ||
598 strcmp(symname, ".TOC.") == 0)
598 return 1; 599 return 1;
599 /* Do not ignore this symbol */ 600 /* Do not ignore this symbol */
600 return 0; 601 return 0;
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 1aca224e8597..c2c7389bfbab 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -118,12 +118,12 @@ quiet_cmd_perf_tar = TAR
118 cmd_perf_tar = \ 118 cmd_perf_tar = \
119git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ 119git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
120 HEAD^{tree} $$(cd $(srctree); \ 120 HEAD^{tree} $$(cd $(srctree); \
121 echo $$(cat $(srctree)/tools/perf/MANIFEST)) \ 121 echo $$(cat tools/perf/MANIFEST)) \
122 -o $(perf-tar).tar; \ 122 -o $(perf-tar).tar; \
123mkdir -p $(perf-tar); \ 123mkdir -p $(perf-tar); \
124git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ 124git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
125(cd $(srctree)/tools/perf; \ 125(cd $(srctree)/tools/perf; \
126util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \ 126util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
127tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ 127tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
128rm -r $(perf-tar); \ 128rm -r $(perf-tar); \
129$(if $(findstring tar-src,$@),, \ 129$(if $(findstring tar-src,$@),, \
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 698768bdc581..e167592793a7 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -48,12 +48,17 @@
48 48
49static int fd_map; /* File descriptor for file being modified. */ 49static int fd_map; /* File descriptor for file being modified. */
50static int mmap_failed; /* Boolean flag. */ 50static int mmap_failed; /* Boolean flag. */
51static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
52static char gpfx; /* prefix for global symbol name (sometimes '_') */ 51static char gpfx; /* prefix for global symbol name (sometimes '_') */
53static struct stat sb; /* Remember .st_size, etc. */ 52static struct stat sb; /* Remember .st_size, etc. */
54static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ 53static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */
55static const char *altmcount; /* alternate mcount symbol name */ 54static const char *altmcount; /* alternate mcount symbol name */
56static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */ 55static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */
56static void *file_map; /* pointer of the mapped file */
57static void *file_end; /* pointer to the end of the mapped file */
58static int file_updated; /* flag to state file was changed */
59static void *file_ptr; /* current file pointer location */
60static void *file_append; /* added to the end of the file */
61static size_t file_append_size; /* how much is added to end of file */
57 62
58/* setjmp() return values */ 63/* setjmp() return values */
59enum { 64enum {
@@ -67,10 +72,14 @@ static void
67cleanup(void) 72cleanup(void)
68{ 73{
69 if (!mmap_failed) 74 if (!mmap_failed)
70 munmap(ehdr_curr, sb.st_size); 75 munmap(file_map, sb.st_size);
71 else 76 else
72 free(ehdr_curr); 77 free(file_map);
73 close(fd_map); 78 file_map = NULL;
79 free(file_append);
80 file_append = NULL;
81 file_append_size = 0;
82 file_updated = 0;
74} 83}
75 84
76static void __attribute__((noreturn)) 85static void __attribute__((noreturn))
@@ -92,12 +101,22 @@ succeed_file(void)
92static off_t 101static off_t
93ulseek(int const fd, off_t const offset, int const whence) 102ulseek(int const fd, off_t const offset, int const whence)
94{ 103{
95 off_t const w = lseek(fd, offset, whence); 104 switch (whence) {
96 if (w == (off_t)-1) { 105 case SEEK_SET:
97 perror("lseek"); 106 file_ptr = file_map + offset;
107 break;
108 case SEEK_CUR:
109 file_ptr += offset;
110 break;
111 case SEEK_END:
112 file_ptr = file_map + (sb.st_size - offset);
113 break;
114 }
115 if (file_ptr < file_map) {
116 fprintf(stderr, "lseek: seek before file\n");
98 fail_file(); 117 fail_file();
99 } 118 }
100 return w; 119 return file_ptr - file_map;
101} 120}
102 121
103static size_t 122static size_t
@@ -114,12 +133,38 @@ uread(int const fd, void *const buf, size_t const count)
114static size_t 133static size_t
115uwrite(int const fd, void const *const buf, size_t const count) 134uwrite(int const fd, void const *const buf, size_t const count)
116{ 135{
117 size_t const n = write(fd, buf, count); 136 size_t cnt = count;
118 if (n != count) { 137 off_t idx = 0;
119 perror("write"); 138
120 fail_file(); 139 file_updated = 1;
140
141 if (file_ptr + count >= file_end) {
142 off_t aoffset = (file_ptr + count) - file_end;
143
144 if (aoffset > file_append_size) {
145 file_append = realloc(file_append, aoffset);
146 file_append_size = aoffset;
147 }
148 if (!file_append) {
149 perror("write");
150 fail_file();
151 }
152 if (file_ptr < file_end) {
153 cnt = file_end - file_ptr;
154 } else {
155 cnt = 0;
156 idx = aoffset - count;
157 }
121 } 158 }
122 return n; 159
160 if (cnt)
161 memcpy(file_ptr, buf, cnt);
162
163 if (cnt < count)
164 memcpy(file_append + idx, buf + cnt, count - cnt);
165
166 file_ptr += count;
167 return count;
123} 168}
124 169
125static void * 170static void *
@@ -192,9 +237,7 @@ static int make_nop_arm64(void *map, size_t const offset)
192 */ 237 */
193static void *mmap_file(char const *fname) 238static void *mmap_file(char const *fname)
194{ 239{
195 void *addr; 240 fd_map = open(fname, O_RDONLY);
196
197 fd_map = open(fname, O_RDWR);
198 if (fd_map < 0 || fstat(fd_map, &sb) < 0) { 241 if (fd_map < 0 || fstat(fd_map, &sb) < 0) {
199 perror(fname); 242 perror(fname);
200 fail_file(); 243 fail_file();
@@ -203,15 +246,58 @@ static void *mmap_file(char const *fname)
203 fprintf(stderr, "not a regular file: %s\n", fname); 246 fprintf(stderr, "not a regular file: %s\n", fname);
204 fail_file(); 247 fail_file();
205 } 248 }
206 addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, 249 file_map = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
207 fd_map, 0); 250 fd_map, 0);
208 mmap_failed = 0; 251 mmap_failed = 0;
209 if (addr == MAP_FAILED) { 252 if (file_map == MAP_FAILED) {
210 mmap_failed = 1; 253 mmap_failed = 1;
211 addr = umalloc(sb.st_size); 254 file_map = umalloc(sb.st_size);
212 uread(fd_map, addr, sb.st_size); 255 uread(fd_map, file_map, sb.st_size);
256 }
257 close(fd_map);
258
259 file_end = file_map + sb.st_size;
260
261 return file_map;
262}
263
264static void write_file(const char *fname)
265{
266 char tmp_file[strlen(fname) + 4];
267 size_t n;
268
269 if (!file_updated)
270 return;
271
272 sprintf(tmp_file, "%s.rc", fname);
273
274 /*
275 * After reading the entire file into memory, delete it
276 * and write it back, to prevent weird side effects of modifying
277 * an object file in place.
278 */
279 fd_map = open(tmp_file, O_WRONLY | O_TRUNC | O_CREAT, sb.st_mode);
280 if (fd_map < 0) {
281 perror(fname);
282 fail_file();
283 }
284 n = write(fd_map, file_map, sb.st_size);
285 if (n != sb.st_size) {
286 perror("write");
287 fail_file();
288 }
289 if (file_append_size) {
290 n = write(fd_map, file_append, file_append_size);
291 if (n != file_append_size) {
292 perror("write");
293 fail_file();
294 }
295 }
296 close(fd_map);
297 if (rename(tmp_file, fname) < 0) {
298 perror(fname);
299 fail_file();
213 } 300 }
214 return addr;
215} 301}
216 302
217/* w8rev, w8nat, ...: Handle endianness. */ 303/* w8rev, w8nat, ...: Handle endianness. */
@@ -318,7 +404,6 @@ do_file(char const *const fname)
318 Elf32_Ehdr *const ehdr = mmap_file(fname); 404 Elf32_Ehdr *const ehdr = mmap_file(fname);
319 unsigned int reltype = 0; 405 unsigned int reltype = 0;
320 406
321 ehdr_curr = ehdr;
322 w = w4nat; 407 w = w4nat;
323 w2 = w2nat; 408 w2 = w2nat;
324 w8 = w8nat; 409 w8 = w8nat;
@@ -441,6 +526,7 @@ do_file(char const *const fname)
441 } 526 }
442 } /* end switch */ 527 } /* end switch */
443 528
529 write_file(fname);
444 cleanup(); 530 cleanup();
445} 531}
446 532
@@ -493,11 +579,14 @@ main(int argc, char *argv[])
493 case SJ_SETJMP: /* normal sequence */ 579 case SJ_SETJMP: /* normal sequence */
494 /* Avoid problems if early cleanup() */ 580 /* Avoid problems if early cleanup() */
495 fd_map = -1; 581 fd_map = -1;
496 ehdr_curr = NULL;
497 mmap_failed = 1; 582 mmap_failed = 1;
583 file_map = NULL;
584 file_ptr = NULL;
585 file_updated = 0;
498 do_file(file); 586 do_file(file);
499 break; 587 break;
500 case SJ_FAIL: /* error in do_file or below */ 588 case SJ_FAIL: /* error in do_file or below */
589 fprintf(stderr, "%s: failed\n", file);
501 ++n_error; 590 ++n_error;
502 break; 591 break;
503 case SJ_SUCCEED: /* premature success */ 592 case SJ_SUCCEED: /* premature success */
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 826470d7f000..96e2486a6fc4 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -263,7 +263,8 @@ if ($arch eq "x86_64") {
263 263
264} elsif ($arch eq "powerpc") { 264} elsif ($arch eq "powerpc") {
265 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; 265 $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
266 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:"; 266 # See comment in the sparc64 section for why we use '\w'.
267 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
267 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; 268 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
268 269
269 if ($bits == 64) { 270 if ($bits == 64) {
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 262889046703..23ba1c6a0a59 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -1,4 +1,4 @@
1#!/bin/sh 1#!/bin/bash
2# Generate tags or cscope files 2# Generate tags or cscope files
3# Usage tags.sh <mode> 3# Usage tags.sh <mode>
4# 4#
@@ -134,11 +134,6 @@ all_kconfigs()
134 find_other_sources 'Kconfig*' 134 find_other_sources 'Kconfig*'
135} 135}
136 136
137all_defconfigs()
138{
139 find_sources $ALLSOURCE_ARCHS "defconfig"
140}
141
142docscope() 137docscope()
143{ 138{
144 (echo \-k; echo \-q; all_target_sources) > cscope.files 139 (echo \-k; echo \-q; all_target_sources) > cscope.files
@@ -150,8 +145,107 @@ dogtags()
150 all_target_sources | gtags -i -f - 145 all_target_sources | gtags -i -f -
151} 146}
152 147
148# Basic regular expressions with an optional /kind-spec/ for ctags and
149# the following limitations:
150# - No regex modifiers
151# - Use \{0,1\} instead of \?, because etags expects an unescaped ?
152# - \s is not working with etags, use a space or [ \t]
153# - \w works, but does not match underscores in etags
154# - etags regular expressions have to match at the start of a line;
155# a ^[^#] is prepended by setup_regex unless an anchor is already present
156regex_asm=(
157 '/^\(ENTRY\|_GLOBAL\)(\([[:alnum:]_\\]*\)).*/\2/'
158)
159regex_c=(
160 '/^SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/sys_\1/'
161 '/^COMPAT_SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/compat_sys_\1/'
162 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1/'
163 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
164 '/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1/'
165 '/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
166 '/^PAGEFLAG(\([[:alnum:]_]*\).*/Page\1/'
167 '/^PAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/'
168 '/^PAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/'
169 '/^TESTSETFLAG(\([[:alnum:]_]*\).*/TestSetPage\1/'
170 '/^TESTPAGEFLAG(\([[:alnum:]_]*\).*/Page\1/'
171 '/^SETPAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/'
172 '/\<__SETPAGEFLAG(\([[:alnum:]_]*\).*/__SetPage\1/'
173 '/\<TESTCLEARFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
174 '/\<__TESTCLEARFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
175 '/\<CLEARPAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/'
176 '/\<__CLEARPAGEFLAG(\([[:alnum:]_]*\).*/__ClearPage\1/'
177 '/^__PAGEFLAG(\([[:alnum:]_]*\).*/__SetPage\1/'
178 '/^__PAGEFLAG(\([[:alnum:]_]*\).*/__ClearPage\1/'
179 '/^PAGEFLAG_FALSE(\([[:alnum:]_]*\).*/Page\1/'
180 '/\<TESTSCFLAG(\([[:alnum:]_]*\).*/TestSetPage\1/'
181 '/\<TESTSCFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
182 '/\<SETPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/SetPage\1/'
183 '/\<CLEARPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/ClearPage\1/'
184 '/\<__CLEARPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/__ClearPage\1/'
185 '/\<TESTCLEARFLAG_FALSE(\([[:alnum:]_]*\).*/TestClearPage\1/'
186 '/^TASK_PFA_TEST([^,]*, *\([[:alnum:]_]*\))/task_\1/'
187 '/^TASK_PFA_SET([^,]*, *\([[:alnum:]_]*\))/task_set_\1/'
188 '/^TASK_PFA_CLEAR([^,]*, *\([[:alnum:]_]*\))/task_clear_\1/'
189 '/^DEF_MMIO_\(IN\|OUT\)_[XD](\([[:alnum:]_]*\),[^)]*)/\2/'
190 '/^DEBUGGER_BOILERPLATE(\([[:alnum:]_]*\))/\1/'
191 '/^DEF_PCI_AC_\(\|NO\)RET(\([[:alnum:]_]*\).*/\2/'
192 '/^PCI_OP_READ(\(\w*\).*[1-4])/pci_bus_read_config_\1/'
193 '/^PCI_OP_WRITE(\(\w*\).*[1-4])/pci_bus_write_config_\1/'
194 '/\<DEFINE_\(MUTEX\|SEMAPHORE\|SPINLOCK\)(\([[:alnum:]_]*\)/\2/v/'
195 '/\<DEFINE_\(RAW_SPINLOCK\|RWLOCK\|SEQLOCK\)(\([[:alnum:]_]*\)/\2/v/'
196 '/\<DECLARE_\(RWSEM\|COMPLETION\)(\([[:alnum:]_]\+\)/\2/v/'
197 '/\<DECLARE_BITMAP(\([[:alnum:]_]*\)/\1/v/'
198 '/\(^\|\s\)\(\|L\|H\)LIST_HEAD(\([[:alnum:]_]*\)/\3/v/'
199 '/\(^\|\s\)RADIX_TREE(\([[:alnum:]_]*\)/\2/v/'
200 '/\<DEFINE_PER_CPU([^,]*, *\([[:alnum:]_]*\)/\1/v/'
201 '/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/'
202 '/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/'
203 '/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/'
204 '/\<DEFINE_PCI_DEVICE_TABLE(\([[:alnum:]_]*\)/\1/v/'
205 '/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/'
206 '/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/'
207 '/\<DEFINE_HASHTABLE(\([[:alnum:]_]*\)/\1/v/'
208)
209regex_kconfig=(
210 '/^[[:blank:]]*\(menu\|\)config[[:blank:]]\+\([[:alnum:]_]\+\)/\2/'
211 '/^[[:blank:]]*\(menu\|\)config[[:blank:]]\+\([[:alnum:]_]\+\)/CONFIG_\2/'
212)
213setup_regex()
214{
215 local mode=$1 lang tmp=() r
216 shift
217
218 regex=()
219 for lang; do
220 case "$lang" in
221 asm) tmp=("${regex_asm[@]}") ;;
222 c) tmp=("${regex_c[@]}") ;;
223 kconfig) tmp=("${regex_kconfig[@]}") ;;
224 esac
225 for r in "${tmp[@]}"; do
226 if test "$mode" = "exuberant"; then
227 regex[${#regex[@]}]="--regex-$lang=${r}b"
228 else
229 # Remove ctags /kind-spec/
230 case "$r" in
231 /*/*/?/)
232 r=${r%?/}
233 esac
234 # Prepend ^[^#] unless already anchored
235 case "$r" in
236 /^*) ;;
237 *)
238 r="/^[^#]*${r#/}"
239 esac
240 regex[${#regex[@]}]="--regex=$r"
241 fi
242 done
243 done
244}
245
153exuberant() 246exuberant()
154{ 247{
248 setup_regex exuberant asm c
155 all_target_sources | xargs $1 -a \ 249 all_target_sources | xargs $1 -a \
156 -I __initdata,__exitdata,__initconst, \ 250 -I __initdata,__exitdata,__initconst, \
157 -I __initdata_memblock \ 251 -I __initdata_memblock \
@@ -165,118 +259,21 @@ exuberant()
165 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL \ 259 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL \
166 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ 260 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
167 -I static,const \ 261 -I static,const \
168 --extra=+f --c-kinds=+px \ 262 --extra=+f --c-kinds=+px --langmap=c:+.h "${regex[@]}"
169 --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \
170 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \
171 --regex-c='/^COMPAT_SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/compat_sys_\1/' \
172 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \
173 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1_rcuidle/' \
174 --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \
175 --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1_rcuidle/' \
176 --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \
177 --regex-c++='/PAGEFLAG\(([^,)]*).*/SetPage\1/' \
178 --regex-c++='/PAGEFLAG\(([^,)]*).*/ClearPage\1/' \
179 --regex-c++='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/' \
180 --regex-c++='/TESTPAGEFLAG\(([^,)]*).*/Page\1/' \
181 --regex-c++='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/' \
182 --regex-c++='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/' \
183 --regex-c++='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \
184 --regex-c++='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \
185 --regex-c++='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/' \
186 --regex-c++='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/' \
187 --regex-c++='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/' \
188 --regex-c++='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/' \
189 --regex-c++='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/' \
190 --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/' \
191 --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/' \
192 --regex-c++='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/' \
193 --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \
194 --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
195 --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
196 --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
197 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \
198 --regex-c++='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \
199 --regex-c++='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \
200 --regex-c++='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\
201 --regex-c++='/DEF_MMIO_(IN|OUT)_(X|D)\(([^,]*),\s*[^)]*\)/\3/' \
202 --regex-c++='/DEBUGGER_BOILERPLATE\(([^,]*)\)/\1/' \
203 --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \
204 --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \
205 --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/' \
206 --regex-c='/DEFINE_(RAW_SPINLOCK|RWLOCK|SEQLOCK)\((\w*)/\2/v/' \
207 --regex-c='/DECLARE_(RWSEM|COMPLETION)\((\w*)/\2/v/' \
208 --regex-c='/DECLARE_BITMAP\((\w*)/\1/v/' \
209 --regex-c='/(^|\s)(|L|H)LIST_HEAD\((\w*)/\3/v/' \
210 --regex-c='/(^|\s)RADIX_TREE\((\w*)/\2/v/' \
211 --regex-c='/DEFINE_PER_CPU\(([^,]*,\s*)(\w*).*\)/\2/v/' \
212 --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \
213 --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \
214 --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \
215 --regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/' \
216 --regex-c='/(^\s)OFFSET\((\w*)/\2/v/' \
217 --regex-c='/(^\s)DEFINE\((\w*)/\2/v/' \
218 --regex-c='/DEFINE_HASHTABLE\((\w*)/\1/v/'
219 263
264 setup_regex exuberant kconfig
220 all_kconfigs | xargs $1 -a \ 265 all_kconfigs | xargs $1 -a \
221 --langdef=kconfig --language-force=kconfig \ 266 --langdef=kconfig --language-force=kconfig "${regex[@]}"
222 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
223 267
224 all_kconfigs | xargs $1 -a \
225 --langdef=kconfig --language-force=kconfig \
226 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
227
228 all_defconfigs | xargs -r $1 -a \
229 --langdef=dotconfig --language-force=dotconfig \
230 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
231} 268}
232 269
233emacs() 270emacs()
234{ 271{
235 all_target_sources | xargs $1 -a \ 272 setup_regex emacs asm c
236 --regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ 273 all_target_sources | xargs $1 -a "${regex[@]}"
237 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \
238 --regex='/^COMPAT_SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/compat_sys_\1/' \
239 --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \
240 --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1_rcuidle/' \
241 --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \
242 --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1_rcuidle/' \
243 --regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \
244 --regex='/PAGEFLAG(\([^,)]*\).*/SetPage\1/' \
245 --regex='/PAGEFLAG(\([^,)]*\).*/ClearPage\1/' \
246 --regex='/TESTSETFLAG(\([^,)]*\).*/TestSetPage\1/' \
247 --regex='/TESTPAGEFLAG(\([^,)]*\).*/Page\1/' \
248 --regex='/SETPAGEFLAG(\([^,)]*\).*/SetPage\1/' \
249 --regex='/__SETPAGEFLAG(\([^,)]*\).*/__SetPage\1/' \
250 --regex='/TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \
251 --regex='/__TESTCLEARFLAG(\([^,)]*\).*/TestClearPage\1/' \
252 --regex='/CLEARPAGEFLAG(\([^,)]*\).*/ClearPage\1/' \
253 --regex='/__CLEARPAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \
254 --regex='/__PAGEFLAG(\([^,)]*\).*/__SetPage\1/' \
255 --regex='/__PAGEFLAG(\([^,)]*\).*/__ClearPage\1/' \
256 --regex='/PAGEFLAG_FALSE(\([^,)]*\).*/Page\1/' \
257 --regex='/TESTSCFLAG(\([^,)]*\).*/TestSetPage\1/' \
258 --regex='/TESTSCFLAG(\([^,)]*\).*/TestClearPage\1/' \
259 --regex='/SETPAGEFLAG_NOOP(\([^,)]*\).*/SetPage\1/' \
260 --regex='/CLEARPAGEFLAG_NOOP(\([^,)]*\).*/ClearPage\1/' \
261 --regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \
262 --regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \
263 --regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \
264 --regex='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \
265 --regex='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \
266 --regex='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/' \
267 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \
268 --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \
269 --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'\
270 --regex='/[^#]*DEFINE_HASHTABLE(\([^,)]*\)/\1/'
271
272 all_kconfigs | xargs $1 -a \
273 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
274
275 all_kconfigs | xargs $1 -a \
276 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
277 274
278 all_defconfigs | xargs -r $1 -a \ 275 setup_regex emacs kconfig
279 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' 276 all_kconfigs | xargs $1 -a "${regex[@]}"
280} 277}
281 278
282xtags() 279xtags()