9012e3dda2
It'll also conditionally generate the defines, so that if we don't have those when building a new tool tarball in an older systems, we get those, and we need them sometimes in the actual scnprintf routine, such as when checking if a flags means we have an extra arg, like with MREMAP_FIXED. $ tools/perf/trace/beauty/mremap_flags.sh static const char *mremap_flags[] = { [ilog2(1) + 1] = "MAYMOVE", #ifndef MREMAP_MAYMOVE #define MREMAP_MAYMOVE 1 #endif [ilog2(2) + 1] = "FIXED", #ifndef MREMAP_FIXED #define MREMAP_FIXED 2 #endif [ilog2(4) + 1] = "DONTUNMAP", #ifndef MREMAP_DONTUNMAP #define MREMAP_DONTUNMAP 4 #endif }; $ Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
19 lines
569 B
Bash
Executable File
19 lines
569 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: LGPL-2.1
|
|
|
|
if [ $# -ne 1 ] ; then
|
|
linux_header_dir=tools/include/uapi/linux
|
|
else
|
|
linux_header_dir=$1
|
|
fi
|
|
|
|
linux_mman=${linux_header_dir}/mman.h
|
|
|
|
printf "static const char *mremap_flags[] = {\n"
|
|
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MREMAP_([[:alnum:]_]+)[[:space:]]+((0x)?[[:xdigit:]]+)[[:space:]]*.*'
|
|
egrep -q $regex ${linux_mman} && \
|
|
(egrep $regex ${linux_mman} | \
|
|
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
|
|
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MREMAP_%s\n#define MREMAP_%s %s\n#endif\n")
|
|
printf "};\n"
|