drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / tools / perf / trace / beauty / arch_errno_names.sh
blob30d3889b295771508917267db2daf5b2f8b317d8
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # Generate C file mapping errno codes to errno names.
6 # Copyright IBM Corp. 2018
7 # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
9 gcc="$1"
10 toolsdir="$2"
11 include_path="-I$toolsdir/include/uapi"
13 arch_string()
15 echo "$1" |sed -e 'y/- /__/' |tr '[[:upper:]]' '[[:lower:]]'
18 asm_errno_file()
20 arch="$1"
22 header="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
23 if test -r "$header"; then
24 echo "$header"
25 else
26 echo "$toolsdir/include/uapi/asm-generic/errno.h"
30 create_errno_lookup_func()
32 arch=$(arch_string "$1")
34 printf "static const char *errno_to_name__%s(int err)\n{\n\tswitch (err) {\n" $arch
36 while read name nr; do
37 printf '\tcase %d: return "%s";\n' $nr $name
38 done
40 printf '\tdefault: return "(unknown)";\n\t}\n}\n'
43 process_arch()
45 arch="$1"
46 asm_errno=$(asm_errno_file "$arch")
48 $gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
49 |grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
50 |awk '{ print $2","$3; }' \
51 |sort -t, -k2 -nu \
52 |IFS=, create_errno_lookup_func "$arch"
55 create_arch_errno_table_func()
57 archlist="$1"
58 default="$2"
60 printf 'arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch)\n'
61 printf '{\n'
62 for arch in $archlist; do
63 arch_str=$(arch_string "$arch")
64 printf '\tif (!strcmp(arch, "%s"))\n' "$arch_str"
65 printf '\t\treturn errno_to_name__%s;\n' "$arch_str"
66 done
67 arch_str=$(arch_string "$default")
68 printf '\treturn errno_to_name__%s;\n' "$arch_str"
69 printf '}\n'
72 cat <<EoHEADER
73 /* SPDX-License-Identifier: GPL-2.0 */
75 #include <string.h>
77 EoHEADER
79 # Create list of architectures that have a specific errno.h.
80 archlist=""
81 for f in $toolsdir/arch/*/include/uapi/asm/errno.h; do
82 d=${f%/include/uapi/asm/errno.h}
83 arch="${d##*/}"
84 test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
85 done
87 for arch in generic $archlist; do
88 process_arch "$arch"
89 done
90 create_arch_errno_table_func "$archlist" "generic"