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:]]'
23 header="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
24 if test -r "$header"; then
27 echo "$toolsdir/include/uapi/asm-generic/errno.h"
31 create_errno_lookup_func()
33 local arch=$(arch_string "$1")
36 printf "static const char *errno_to_name__%s(int err)\n{\n\tswitch (err) {\n" $arch
38 while read name nr; do
39 printf '\tcase %d: return "%s";\n' $nr $name
42 printf '\tdefault: return "(unknown)";\n\t}\n}\n'
48 local asm_errno=$(asm_errno_file "$arch")
50 $gcc $CFLAGS $include_path -E -dM -x c $asm_errno \
51 |grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
52 |awk '{ print $2","$3; }' \
54 |IFS=, create_errno_lookup_func "$arch"
57 create_arch_errno_table_func()
63 printf 'const char *arch_syscalls__strerrno(const char *arch, int err)\n'
65 for arch in $archlist; do
66 printf '\tif (!strcmp(arch, "%s"))\n' $(arch_string "$arch")
67 printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
69 printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
74 /* SPDX-License-Identifier: GPL-2.0 */
80 # Create list of architectures that have a specific errno.h.
82 for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do
83 test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch"
86 for arch in generic $archlist; do
89 create_arch_errno_table_func "$archlist" "generic"