18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciprintf "static const char *fadvise_advices[] = {\n"
78c2ecf20Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+POSIX_FADV_(\w+)[[:space:]]+([[:digit:]]+)[[:space:]]+.*'
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciegrep $regex ${header_dir}/fadvise.h | \
108c2ecf20Sopenharmony_ci	sed -r "s/$regex/\2 \1/g"	| \
118c2ecf20Sopenharmony_ci	sort | xargs printf "\t[%s] = \"%s\",\n" | \
128c2ecf20Sopenharmony_ci	grep -v "[6].*DONTNEED" | grep -v "[7].*NOREUSE"
138c2ecf20Sopenharmony_ciprintf "};\n"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci# XXX Fix this properly:
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci# The grep 6/7 DONTNEED/NOREUSE are a hack to filter out the s/390 oddity See
188c2ecf20Sopenharmony_ci# tools/include/uapi/linux/fadvise.h for details.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci# Probably fix this when generating the string tables per arch so that We can
218c2ecf20Sopenharmony_ci# reliably process on arch FOO a perf.data file collected by 'perf trace
228c2ecf20Sopenharmony_ci# record' on arch BAR, e.g. collect on s/390 and process on x86.
23