xref: /linux/tools/perf/trace/beauty/mremap_flags.sh (revision 75b1a8f9d62e50f05d0e4e9f3c8bcde32527ffc1)
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1
3
4if [ $# -ne 1 ] ; then
5	linux_header_dir=tools/include/uapi/linux
6else
7	linux_header_dir=$1
8fi
9
10linux_mman=${linux_header_dir}/mman.h
11
12printf "static const char *mremap_flags[] = {\n"
13regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MREMAP_([[:alnum:]_]+)[[:space:]]+((0x)?[[:xdigit:]]+)[[:space:]]*.*'
14egrep -q $regex ${linux_mman} && \
15(egrep $regex ${linux_mman} | \
16	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
17	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MREMAP_%s\n#define MREMAP_%s %s\n#endif\n")
18printf "};\n"
19