xref: /OK3568_Linux_fs/kernel/tools/perf/trace/beauty/fadvise.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/sh
2*4882a593Smuzhiyun# SPDX-License-Identifier: LGPL-2.1
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunprintf "static const char *fadvise_advices[] = {\n"
7*4882a593Smuzhiyunregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+POSIX_FADV_(\w+)[[:space:]]+([[:digit:]]+)[[:space:]]+.*'
8*4882a593Smuzhiyun
9*4882a593Smuzhiyunegrep $regex ${header_dir}/fadvise.h | \
10*4882a593Smuzhiyun	sed -r "s/$regex/\2 \1/g"	| \
11*4882a593Smuzhiyun	sort | xargs printf "\t[%s] = \"%s\",\n" | \
12*4882a593Smuzhiyun	grep -v "[6].*DONTNEED" | grep -v "[7].*NOREUSE"
13*4882a593Smuzhiyunprintf "};\n"
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun# XXX Fix this properly:
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun# The grep 6/7 DONTNEED/NOREUSE are a hack to filter out the s/390 oddity See
18*4882a593Smuzhiyun# tools/include/uapi/linux/fadvise.h for details.
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun# Probably fix this when generating the string tables per arch so that We can
21*4882a593Smuzhiyun# reliably process on arch FOO a perf.data file collected by 'perf trace
22*4882a593Smuzhiyun# record' on arch BAR, e.g. collect on s/390 and process on x86.
23