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>
11 include_path
="-I$toolsdir/include/uapi"
15 echo "$1" |
sed -e 'y/- /__/' |
tr '[[:upper:]]' '[[:lower:]]'
22 header
="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
23 if test -r "$header"; then
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
40 printf '\tdefault: return "(unknown)";\n\t}\n}\n'
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; }' \
52 |IFS
=, create_errno_lookup_func
"$arch"
55 create_arch_errno_table_func
()
60 printf 'arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch)\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"
67 arch_str
=$
(arch_string
"$default")
68 printf '\treturn errno_to_name__%s;\n' "$arch_str"
73 /* SPDX-License-Identifier: GPL-2.0 */
79 # Create list of architectures that have a specific errno.h.
81 for f
in $toolsdir/arch
/*/include
/uapi
/asm
/errno.h
; do
82 d
=${f%/include/uapi/asm/errno.h}
84 test -f $toolsdir/arch
/$arch/include
/uapi
/asm
/errno.h
&& archlist
="$archlist $arch"
87 for arch
in generic
$archlist; do
90 create_arch_errno_table_func
"$archlist" "generic"