VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200   1) #!/bin/bash
457c899653991 (Thomas Gleixner       2019-05-19 13:08:55 +0100   2) # SPDX-License-Identifier: GPL-2.0-only
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   3) # Generate tags or cscope files
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   4) # Usage tags.sh <mode>
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   5) #
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   6) # mode may be any of: tags, TAGS, cscope
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   7) #
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100   8) # Uses the following environment variables:
b3b3eb9dadfcb (Masahiro Yamada       2019-07-06 00:14:31 +0900   9) # SUBARCH, SRCARCH, srctree
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  10) 
a6ba0cb35da64 (Jiri Slaby            2008-12-10 13:48:38 +0100  11) if [ "$KBUILD_VERBOSE" = "1" ]; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  12) 	set -x
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  13) fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  14) 
ae63b2d7bdd9b (Prarit Bhargava       2014-02-06 07:51:42 -0500  15) # RCS_FIND_IGNORE has escaped ()s -- remove them.
ae63b2d7bdd9b (Prarit Bhargava       2014-02-06 07:51:42 -0500  16) ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )"
ae63b2d7bdd9b (Prarit Bhargava       2014-02-06 07:51:42 -0500  17) # tags and cscope files should also ignore MODVERSION *.mod.c files
ae63b2d7bdd9b (Prarit Bhargava       2014-02-06 07:51:42 -0500  18) ignore="$ignore ( -name *.mod.c ) -prune -o"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  19) 
95fd3f87bfbe8 (Masahiro Yamada       2019-07-06 12:07:13 +0900  20) # Use make KBUILD_ABS_SRCTREE=1 {tags|cscope}
e93bc1a0cab3e (Michal Marek          2010-03-08 10:26:22 +0100  21) # to force full paths for a non-O= build
c69ef1c87b8c3 (Masahiro Yamada       2019-04-29 13:06:43 +0900  22) if [ "${srctree}" = "." -o -z "${srctree}" ]; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  23) 	tree=
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  24) else
709cc372cad62 (Jiri Slaby            2008-12-10 13:10:13 +0100  25) 	tree=${srctree}/
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  26) fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  27) 
8c38a5328af80 (Konstantin Khlebnikov 2014-04-21 12:03:08 +0400  28) # ignore userspace tools
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  29) if [ -n "$COMPILED_SOURCE" ]; then
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  30) 	ignore="$ignore ( -path ./tools ) -prune -o"
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  31) else
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  32) 	ignore="$ignore ( -path ${tree}tools ) -prune -o"
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  33) fi
8c38a5328af80 (Konstantin Khlebnikov 2014-04-21 12:03:08 +0400  34) 
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  35) # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  36) if [ "${ALLSOURCE_ARCHS}" = "" ]; then
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  37) 	ALLSOURCE_ARCHS=${SRCARCH}
bc75cc6b5636e (John Kacur            2010-03-02 16:57:52 +0100  38) elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then
656c107770e37 (Joey Pabalinas        2018-05-21 23:16:06 -1000  39) 	ALLSOURCE_ARCHS=$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -printf '%f ')
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  40) fi
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  41) 
b3b3eb9dadfcb (Masahiro Yamada       2019-07-06 00:14:31 +0900  42) # find sources in arch/$1
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  43) find_arch_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  44) {
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  45) 	for i in $archincludedir; do
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  46) 		prune="$prune -wholename $i -prune -o"
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  47) 	done
d1db881d9bf16 (Masahiro Yamada       2019-07-06 00:14:30 +0900  48) 	find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  49) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  50) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  51) # find sources in arch/$1/include
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  52) find_arch_include_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  53) {
d1db881d9bf16 (Masahiro Yamada       2019-07-06 00:14:30 +0900  54) 	include=$(find ${tree}arch/$1/ -name include -type d -print);
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  55) 	if [ -n "$include" ]; then
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  56) 		archincludedir="$archincludedir $include"
9b24a15d81f4b (Yann Droneaud         2014-05-21 15:32:17 +0200  57) 		find $include $ignore -name "$2" -not -type l -print;
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  58) 	fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  59) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  60) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  61) # find sources in include/
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  62) find_include_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  63) {
9b24a15d81f4b (Yann Droneaud         2014-05-21 15:32:17 +0200  64) 	find ${tree}include $ignore -name config -prune -o -name "$1" \
9b24a15d81f4b (Yann Droneaud         2014-05-21 15:32:17 +0200  65) 		-not -type l -print;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  66) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  67) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  68) # find sources in rest of tree
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  69) # we could benefit from a list of dirs to search in here
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  70) find_other_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  71) {
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  72) 	find ${tree}* $ignore \
99443f811c452 (Arend van Spriel      2018-01-31 16:14:14 -0800  73) 	     \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \
9b24a15d81f4b (Yann Droneaud         2014-05-21 15:32:17 +0200  74) 	       -name "$1" -not -type l -print;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  75) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  76) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  77) find_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  78) {
709cc372cad62 (Jiri Slaby            2008-12-10 13:10:13 +0100  79) 	find_arch_sources $1 "$2"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  80) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  81) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  82) all_sources()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  83) {
a8bac511c8c18 (Michal Marek          2010-02-19 16:18:41 +0100  84) 	find_arch_include_sources ${SRCARCH} '*.[chS]'
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  85) 	if [ ! -z "$archinclude" ]; then
709cc372cad62 (Jiri Slaby            2008-12-10 13:10:13 +0100  86) 		find_arch_include_sources $archinclude '*.[chS]'
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  87) 	fi
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  88) 	find_include_sources '*.[chS]'
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  89) 	for arch in $ALLSOURCE_ARCHS
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  90) 	do
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  91) 		find_sources $arch '*.[chS]'
f81b1be40c44b (Guennadi Liakhovetski 2010-02-08 00:25:59 +0100  92) 	done
4f628248a5785 (Jike Song             2009-01-05 14:57:03 +0800  93) 	find_other_sources '*.[chS]'
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  94) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100  95) 
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900  96) all_compiled_sources()
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900  97) {
4f491bb6ea2ae (Jialu Xu              2020-08-06 23:17:29 -0700  98) 	realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) \
162343a876f14 (Rustam Kovhaev        2020-08-10 08:36:50 -0700  99) 		include/generated/autoconf.h $(find $ignore -name "*.cmd" -exec \
4f491bb6ea2ae (Jialu Xu              2020-08-06 23:17:29 -0700 100) 		grep -Poh '(?(?=^source_.* \K).*|(?=^  \K\S).*(?= \\))' {} \+ |
4f491bb6ea2ae (Jialu Xu              2020-08-06 23:17:29 -0700 101) 		awk '!a[$0]++') | sort -u
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 102) }
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 103) 
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 104) all_target_sources()
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 105) {
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 106) 	if [ -n "$COMPILED_SOURCE" ]; then
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 107) 		all_compiled_sources
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 108) 	else
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 109) 		all_sources
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 110) 	fi
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 111) }
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 112) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 113) all_kconfigs()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 114) {
7659c655beded (Hou Tao               2017-02-22 15:40:29 -0800 115) 	find ${tree}arch/ -maxdepth 1 $ignore \
7659c655beded (Hou Tao               2017-02-22 15:40:29 -0800 116) 	       -name "Kconfig*" -not -type l -print;
953fae66d1244 (Alexey Dobriyan       2009-02-11 13:24:09 -0800 117) 	for arch in $ALLSOURCE_ARCHS; do
953fae66d1244 (Alexey Dobriyan       2009-02-11 13:24:09 -0800 118) 		find_sources $arch 'Kconfig*'
953fae66d1244 (Alexey Dobriyan       2009-02-11 13:24:09 -0800 119) 	done
953fae66d1244 (Alexey Dobriyan       2009-02-11 13:24:09 -0800 120) 	find_other_sources 'Kconfig*'
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 121) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 122) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 123) docscope()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 124) {
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 125) 	(echo \-k; echo \-q; all_target_sources) > cscope.files
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 126) 	cscope -b -f cscope.out
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 127) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 128) 
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 129) dogtags()
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 130) {
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 131) 	all_target_sources | gtags -i -f -
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 132) }
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 133) 
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 134) # Basic regular expressions with an optional /kind-spec/ for ctags and
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 135) # the following limitations:
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 136) # - No regex modifiers
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 137) # - Use \{0,1\} instead of \?, because etags expects an unescaped ?
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 138) # - \s is not working with etags, use a space or [ \t]
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 139) # - \w works, but does not match underscores in etags
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 140) # - etags regular expressions have to match at the start of a line;
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 141) #   a ^[^#] is prepended by setup_regex unless an anchor is already present
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 142) regex_asm=(
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 143) 	'/^\(ENTRY\|_GLOBAL\)(\([[:alnum:]_\\]*\)).*/\2/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 144) )
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 145) regex_c=(
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 146) 	'/^SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/sys_\1/'
24d4e34f7a615 (Constantine Shulyupin 2018-07-12 08:28:46 +0300 147) 	'/^BPF_CALL_[0-9](\([[:alnum:]_]*\).*/\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 148) 	'/^COMPAT_SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/compat_sys_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 149) 	'/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 150) 	'/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 151) 	'/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 152) 	'/^DEFINE_EVENT([^,)]*, *\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
0a9e7da660b09 (Naveen N. Rao         2016-02-18 20:56:31 +0530 153) 	'/^DEFINE_INSN_CACHE_OPS(\([[:alnum:]_]*\).*/get_\1_slot/'
0a9e7da660b09 (Naveen N. Rao         2016-02-18 20:56:31 +0530 154) 	'/^DEFINE_INSN_CACHE_OPS(\([[:alnum:]_]*\).*/free_\1_slot/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 155) 	'/^PAGEFLAG(\([[:alnum:]_]*\).*/Page\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 156) 	'/^PAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 157) 	'/^PAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 158) 	'/^TESTSETFLAG(\([[:alnum:]_]*\).*/TestSetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 159) 	'/^TESTPAGEFLAG(\([[:alnum:]_]*\).*/Page\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 160) 	'/^SETPAGEFLAG(\([[:alnum:]_]*\).*/SetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 161) 	'/\<__SETPAGEFLAG(\([[:alnum:]_]*\).*/__SetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 162) 	'/\<TESTCLEARFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 163) 	'/\<__TESTCLEARFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 164) 	'/\<CLEARPAGEFLAG(\([[:alnum:]_]*\).*/ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 165) 	'/\<__CLEARPAGEFLAG(\([[:alnum:]_]*\).*/__ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 166) 	'/^__PAGEFLAG(\([[:alnum:]_]*\).*/__SetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 167) 	'/^__PAGEFLAG(\([[:alnum:]_]*\).*/__ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 168) 	'/^PAGEFLAG_FALSE(\([[:alnum:]_]*\).*/Page\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 169) 	'/\<TESTSCFLAG(\([[:alnum:]_]*\).*/TestSetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 170) 	'/\<TESTSCFLAG(\([[:alnum:]_]*\).*/TestClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 171) 	'/\<SETPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/SetPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 172) 	'/\<CLEARPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 173) 	'/\<__CLEARPAGEFLAG_NOOP(\([[:alnum:]_]*\).*/__ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 174) 	'/\<TESTCLEARFLAG_FALSE(\([[:alnum:]_]*\).*/TestClearPage\1/'
6e292b9be7f43 (Matthew Wilcox        2018-06-07 17:08:18 -0700 175) 	'/^PAGE_TYPE_OPS(\([[:alnum:]_]*\).*/Page\1/'
6e292b9be7f43 (Matthew Wilcox        2018-06-07 17:08:18 -0700 176) 	'/^PAGE_TYPE_OPS(\([[:alnum:]_]*\).*/__SetPage\1/'
6e292b9be7f43 (Matthew Wilcox        2018-06-07 17:08:18 -0700 177) 	'/^PAGE_TYPE_OPS(\([[:alnum:]_]*\).*/__ClearPage\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 178) 	'/^TASK_PFA_TEST([^,]*, *\([[:alnum:]_]*\))/task_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 179) 	'/^TASK_PFA_SET([^,]*, *\([[:alnum:]_]*\))/task_set_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 180) 	'/^TASK_PFA_CLEAR([^,]*, *\([[:alnum:]_]*\))/task_clear_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 181) 	'/^DEF_MMIO_\(IN\|OUT\)_[XD](\([[:alnum:]_]*\),[^)]*)/\2/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 182) 	'/^DEBUGGER_BOILERPLATE(\([[:alnum:]_]*\))/\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 183) 	'/^DEF_PCI_AC_\(\|NO\)RET(\([[:alnum:]_]*\).*/\2/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 184) 	'/^PCI_OP_READ(\(\w*\).*[1-4])/pci_bus_read_config_\1/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 185) 	'/^PCI_OP_WRITE(\(\w*\).*[1-4])/pci_bus_write_config_\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 186) 	'/\<DEFINE_\(RT_MUTEX\|MUTEX\|SEMAPHORE\|SPINLOCK\)(\([[:alnum:]_]*\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 187) 	'/\<DEFINE_\(RAW_SPINLOCK\|RWLOCK\|SEQLOCK\)(\([[:alnum:]_]*\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 188) 	'/\<DECLARE_\(RWSEM\|COMPLETION\)(\([[:alnum:]_]\+\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 189) 	'/\<DECLARE_BITMAP(\([[:alnum:]_]*\)/\1/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 190) 	'/\(^\|\s\)\(\|L\|H\)LIST_HEAD(\([[:alnum:]_]*\)/\3/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 191) 	'/\(^\|\s\)RADIX_TREE(\([[:alnum:]_]*\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 192) 	'/\<DEFINE_PER_CPU([^,]*, *\([[:alnum:]_]*\)/\1/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 193) 	'/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 194) 	'/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 195) 	'/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 196) 	'/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 197) 	'/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/'
1f6904f72937d (Kirill Tkhai          2018-10-26 15:02:38 -0700 198) 	'/\<\(DEFINE\|DECLARE\)_HASHTABLE(\([[:alnum:]_]*\)/\2/v/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 199) 	'/\<DEFINE_ID\(R\|A\)(\([[:alnum:]_]\+\)/\2/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 200) 	'/\<DEFINE_WD_CLASS(\([[:alnum:]_]\+\)/\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 201) 	'/\<ATOMIC_NOTIFIER_HEAD(\([[:alnum:]_]\+\)/\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 202) 	'/\<RAW_NOTIFIER_HEAD(\([[:alnum:]_]\+\)/\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 203) 	'/\<DECLARE_FAULT_ATTR(\([[:alnum:]_]\+\)/\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 204) 	'/\<BLOCKING_NOTIFIER_HEAD(\([[:alnum:]_]\+\)/\1/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 205) 	'/\<DEVICE_ATTR_\(RW\|RO\|WO\)(\([[:alnum:]_]\+\)/dev_attr_\2/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 206) 	'/\<DRIVER_ATTR_\(RW\|RO\|WO\)(\([[:alnum:]_]\+\)/driver_attr_\2/'
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 207) 	'/\<\(DEFINE\|DECLARE\)_STATIC_KEY_\(TRUE\|FALSE\)\(\|_RO\)(\([[:alnum:]_]\+\)/\4/'
6eb6d05958f32 (Peter Zijlstra        2020-07-29 20:12:32 +0200 208) 	'/^SEQCOUNT_LOCKTYPE(\([^,]*\),[[:space:]]*\([^,]*\),[^)]*)/seqcount_\2_t/'
6eb6d05958f32 (Peter Zijlstra        2020-07-29 20:12:32 +0200 209) 	'/^SEQCOUNT_LOCKTYPE(\([^,]*\),[[:space:]]*\([^,]*\),[^)]*)/seqcount_\2_init/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 210) )
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 211) regex_kconfig=(
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 212) 	'/^[[:blank:]]*\(menu\|\)config[[:blank:]]\+\([[:alnum:]_]\+\)/\2/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 213) 	'/^[[:blank:]]*\(menu\|\)config[[:blank:]]\+\([[:alnum:]_]\+\)/CONFIG_\2/'
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 214) )
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 215) setup_regex()
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 216) {
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 217) 	local mode=$1 lang tmp=() r
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 218) 	shift
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 219) 
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 220) 	regex=()
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 221) 	for lang; do
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 222) 		case "$lang" in
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 223) 		asm)       tmp=("${regex_asm[@]}") ;;
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 224) 		c)         tmp=("${regex_c[@]}") ;;
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 225) 		kconfig)   tmp=("${regex_kconfig[@]}") ;;
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 226) 		esac
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 227) 		for r in "${tmp[@]}"; do
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 228) 			if test "$mode" = "exuberant"; then
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 229) 				regex[${#regex[@]}]="--regex-$lang=${r}b"
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 230) 			else
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 231) 				# Remove ctags /kind-spec/
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 232) 				case "$r" in
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 233) 				/*/*/?/)
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 234) 					r=${r%?/}
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 235) 				esac
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 236) 				# Prepend ^[^#] unless already anchored
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 237) 				case "$r" in
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 238) 				/^*) ;;
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 239) 				*)
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 240) 					r="/^[^#]*${r#/}"
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 241) 				esac
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 242) 				regex[${#regex[@]}]="--regex=$r"
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 243) 			fi
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 244) 		done
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 245) 	done
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 246) }
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 247) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 248) exuberant()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 249) {
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 250) 	setup_regex exuberant asm c
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 251) 	all_target_sources | xargs $1 -a                        \
e23ba825db245 (Constantine Shulyupin 2018-07-11 21:36:42 +0300 252) 	-I __initdata,__exitdata,__initconst,__ro_after_init	\
22c1587adfed1 (Paul Gortmaker        2015-04-27 17:37:53 -0400 253) 	-I __initdata_memblock					\
f5a82137a53f4 (Kirill Tkhai          2013-10-23 15:08:44 +0200 254) 	-I __refdata,__attribute,__maybe_unused,__always_unused \
cd68a52533380 (Kirill Tkhai          2018-12-28 00:31:35 -0800 255) 	-I __acquires,__releases,__deprecated,__always_inline	\
1b2643f0d0938 (Kirill Tkhai          2013-02-21 16:42:42 -0800 256) 	-I __read_mostly,__aligned,____cacheline_aligned        \
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 257) 	-I ____cacheline_aligned_in_smp                         \
f5a82137a53f4 (Kirill Tkhai          2013-10-23 15:08:44 +0200 258) 	-I __cacheline_aligned,__cacheline_aligned_in_smp	\
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 259) 	-I ____cacheline_internodealigned_in_smp                \
1b2643f0d0938 (Kirill Tkhai          2013-02-21 16:42:42 -0800 260) 	-I __used,__packed,__packed2__,__must_check,__must_hold	\
f5a82137a53f4 (Kirill Tkhai          2013-10-23 15:08:44 +0200 261) 	-I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL,ACPI_EXPORT_SYMBOL   \
7db86dc97fb0c (Stefani Seibold       2009-09-18 12:49:24 -0700 262) 	-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
1b2643f0d0938 (Kirill Tkhai          2013-02-21 16:42:42 -0800 263) 	-I static,const						\
d0c75f33f065b (Mathieu Maret         2016-10-11 13:55:14 -0700 264) 	--extra=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \
d0c75f33f065b (Mathieu Maret         2016-10-11 13:55:14 -0700 265) 	"${regex[@]}"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 266) 
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 267) 	setup_regex exuberant kconfig
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 268) 	all_kconfigs | xargs $1 -a                              \
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 269) 	--langdef=kconfig --language-force=kconfig "${regex[@]}"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 270) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 271) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 272) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 273) emacs()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 274) {
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 275) 	setup_regex emacs asm c
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 276) 	all_target_sources | xargs $1 -a "${regex[@]}"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 277) 
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 278) 	setup_regex emacs kconfig
93209d65c1d38 (Michal Marek          2015-10-14 11:48:06 +0200 279) 	all_kconfigs | xargs $1 -a "${regex[@]}"
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 280) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 281) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 282) xtags()
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 283) {
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 284) 	if $1 --version 2>&1 | grep -iq exuberant; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 285) 		exuberant $1
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 286) 	elif $1 --version 2>&1 | grep -iq emacs; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 287) 		emacs $1
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 288) 	else
923e02ecf3f8d (Joonsoo Kim           2012-12-11 00:11:46 +0900 289) 		all_target_sources | xargs $1 -a
bb66fc67192bb (Masahiro Yamada       2014-06-10 19:08:13 +0900 290) 	fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 291) }
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 292) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 293) # Support um (which uses SUBARCH)
a6ba0cb35da64 (Jiri Slaby            2008-12-10 13:48:38 +0100 294) if [ "${ARCH}" = "um" ]; then
a6ba0cb35da64 (Jiri Slaby            2008-12-10 13:48:38 +0100 295) 	if [ "$SUBARCH" = "i386" ]; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 296) 		archinclude=x86
a6ba0cb35da64 (Jiri Slaby            2008-12-10 13:48:38 +0100 297) 	elif [ "$SUBARCH" = "x86_64" ]; then
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 298) 		archinclude=x86
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 299) 	else
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 300) 		archinclude=${SUBARCH}
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 301) 	fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 302) fi
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 303) 
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 304) remove_structs=
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 305) case "$1" in
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 306) 	"cscope")
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 307) 		docscope
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 308) 		;;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 309) 
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 310) 	"gtags")
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 311) 		dogtags
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 312) 		;;
f4ed1009fcea8 (Jianbin Kang          2011-01-14 20:07:05 +0800 313) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 314) 	"tags")
2e6cb8b0dc602 (Matt Kraai            2009-04-21 20:38:23 -0700 315) 		rm -f tags
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 316) 		xtags ctags
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 317) 		remove_structs=y
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 318) 		;;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 319) 
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 320) 	"TAGS")
2e6cb8b0dc602 (Matt Kraai            2009-04-21 20:38:23 -0700 321) 		rm -f TAGS
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 322) 		xtags etags
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 323) 		remove_structs=y
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 324) 		;;
a680eedc6c621 (Sam Ravnborg          2008-12-03 22:24:13 +0100 325) esac
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 326) 
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 327) # Remove structure forward declarations.
0eb043d0eec44 (Stephen Boyd          2012-03-31 23:41:07 -0700 328) if [ -n "$remove_structs" ]; then
77a88274dc1a2 (Masahiro Yamada       2021-04-30 10:56:27 +0900 329)     LC_ALL=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
66979224c0d28 (Yang Bai              2012-03-12 16:20:51 +0800 330) fi