sockaddr.sh 928 B

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