Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: LGPL-2.1
0003 
0004 # This one uses a copy from the kernel sources headers that is in a
0005 # place used just for these tools/perf/beauty/ usage, we shouldn't not
0006 # put it in tools/include/linux otherwise they would be used in the
0007 # normal compiler building process and would drag needless stuff from the
0008 # kernel.
0009 
0010 # When what these scripts need is already in tools/include/ then use it,
0011 # otherwise grab and check the copy from the kernel sources just for these
0012 # string table building scripts.
0013 
0014 [ $# -eq 1 ] && header_dir=$1 || header_dir=tools/perf/trace/beauty/include/linux/
0015 
0016 printf "static const char *socket_families[] = {\n"
0017 # #define AF_LOCAL      1       /* POSIX name for AF_UNIX       */
0018 regex='^#define[[:space:]]+AF_(\w+)[[:space:]]+([[:digit:]]+).*'
0019 
0020 egrep $regex ${header_dir}/socket.h | \
0021         sed -r "s/$regex/\2 \1/g"       | \
0022         xargs printf "\t[%s] = \"%s\",\n" | \
0023         egrep -v "\"(UNIX|MAX)\""
0024 printf "};\n"