^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: LGPL-2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # This one uses a copy from the kernel sources headers that is in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # place used just for these tools/perf/beauty/ usage, we shouldn't not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # put it in tools/include/linux otherwise they would be used in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # normal compiler building process and would drag needless stuff from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # When what these scripts need is already in tools/include/ then use it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # otherwise grab and check the copy from the kernel sources just for these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # string table building scripts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) [ $# -eq 1 ] && header_dir=$1 || header_dir=tools/perf/trace/beauty/include/linux/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) printf "static const char *socket_families[] = {\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # #define AF_LOCAL 1 /* POSIX name for AF_UNIX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) regex='^#define[[:space:]]+AF_(\w+)[[:space:]]+([[:digit:]]+).*'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) egrep $regex ${header_dir}/socket.h | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) sed -r "s/$regex/\2 \1/g" | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) xargs printf "\t[%s] = \"%s\",\n" | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) egrep -v "\"(UNIX|MAX)\""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) printf "};\n"